コード例 #1
0
 private void updateItems() {
   if (mItems == null) return;
   Item[] items = null;
   final Collection<CachedBluetoothDevice> devices = mController.getDevices();
   if (devices != null) {
     items = new Item[getBondedCount(devices)];
     int i = 0;
     for (CachedBluetoothDevice device : devices) {
       if (device.getBondState() == BluetoothDevice.BOND_NONE) continue;
       final Item item = new Item();
       item.icon = R.drawable.ic_qs_bluetooth_on;
       item.line1 = device.getName();
       int state = device.getMaxConnectionState();
       if (state == BluetoothProfile.STATE_CONNECTED) {
         item.icon = R.drawable.ic_qs_bluetooth_connected;
         item.line2 = mContext.getString(R.string.quick_settings_connected);
         item.canDisconnect = true;
       } else if (state == BluetoothProfile.STATE_CONNECTING) {
         item.icon = R.drawable.ic_qs_bluetooth_connecting;
         item.line2 = mContext.getString(R.string.quick_settings_connecting);
       }
       item.tag = device;
       items[i++] = item;
     }
   }
   mItems.setItems(items);
 }
コード例 #2
0
 private void updateItems() {
   if (mItems == null) return;
   Item[] items = null;
   if (mAccessPoints != null) {
     items = new Item[mAccessPoints.length];
     for (int i = 0; i < mAccessPoints.length; i++) {
       final AccessPoint ap = mAccessPoints[i];
       final Item item = new Item();
       item.tag = ap;
       item.icon = mWifiController.getIcon(ap);
       item.line1 = ap.getSsid();
       item.line2 = ap.isActive() ? ap.getSummary() : null;
       item.overlay =
           ap.getSecurity() != AccessPoint.SECURITY_NONE
               ? mContext.getDrawable(R.drawable.qs_ic_wifi_lock)
               : null;
       items[i] = item;
     }
   }
   mItems.setItems(items);
 }