private View buildQSTile(String tileType) {
    QSTileHolder item = QSTileHolder.from(getActivity(), tileType);
    if (item == null) {
      return null;
    }
    ColoringCardView qsTile =
        (ColoringCardView) getLayoutInflater(null).inflate(R.layout.qs_item, null);
    int defaultColor = getResources().getColor(R.color.qs_tile_default_background_color);
    qsTile.setColor(defaultColor);
    if (item.name != null) {
      ImageView icon = (ImageView) qsTile.findViewById(android.R.id.icon);
      Drawable d = Utils.getNamedDrawable(getSystemUIContext(getActivity()), item.resourceName);
      d.setColorFilter(
          getResources().getColor(R.color.qs_tile_tint_color), PorterDuff.Mode.SRC_ATOP);
      icon.setImageDrawable(d);
      TextView title = (TextView) qsTile.findViewById(android.R.id.title);
      title.setText(item.name);

      ImageView type = (ImageView) qsTile.findViewById(R.id.type);
      d =
          getActivity()
              .getDrawable(
                  QSUtils.isDynamicQsTile(tileType)
                      ? R.drawable.ic_qs_tile_dynamic_type
                      : R.drawable.ic_qs_tile_static_type);
      type.setImageDrawable(d);
    }
    qsTile.setTag(tileType);

    return qsTile;
  }
  private QSTile<?> createTile(String tileSpec) {
    // Ensure tile is supported on this device
    if (!QSUtils.getAvailableTiles(mContext).contains(tileSpec)) {
      return null;
    }
    if (QSUtils.isDynamicQsTile(tileSpec)) {
      return null;
    }

    switch (tileSpec) {
      case QSConstants.TILE_WIFI:
        return new WifiTile(this);
      case QSConstants.TILE_BLUETOOTH:
        return new BluetoothTile(this);
      case QSConstants.TILE_INVERSION:
        return new ColorInversionTile(this);
      case QSConstants.TILE_CELLULAR:
        return new CellularTile(this);
      case QSConstants.TILE_AIRPLANE:
        return new AirplaneModeTile(this);
      case QSConstants.TILE_ROTATION:
        return new RotationLockTile(this);
      case QSConstants.TILE_FLASHLIGHT:
        return new FlashlightTile(this);
      case QSConstants.TILE_LOCATION:
        return new LocationTile(this);
      case QSConstants.TILE_CAST:
        return new CastTile(this);
      case QSConstants.TILE_HOTSPOT:
        return new HotspotTile(this);
      case QSConstants.TILE_NOTIFICATIONS:
        return new NotificationsTile(this);
      case QSConstants.TILE_DATA:
        return new DataTile(this);
      case QSConstants.TILE_ROAMING:
        return new RoamingTile(this);
      case QSConstants.TILE_DDS:
        return new DdsTile(this);
      case QSConstants.TILE_COMPASS:
        return new CompassTile(this);
      case QSConstants.TILE_APN:
        return new ApnTile(this);
      case QSConstants.TILE_PROFILES:
        return new ProfilesTile(this);
      case QSConstants.TILE_PERFORMANCE:
        return new PerfProfileTile(this);
      case QSConstants.TILE_ADB_NETWORK:
        return new AdbOverNetworkTile(this);
      case QSConstants.TILE_NFC:
        return new NfcTile(this);
      case QSConstants.TILE_LOCKSCREEN:
        return new LockscreenToggleTile(this);
      case QSConstants.TILE_LTE:
        return new LteTile(this);
      case QSConstants.TILE_VISUALIZER:
        return new VisualizerTile(this);
      case QSConstants.TILE_SCREEN_TIMEOUT:
        return new ScreenTimeoutTile(this);
      case QSConstants.TILE_LIVE_DISPLAY:
        return new LiveDisplayTile(this);
      case QSConstants.TILE_USB_TETHER:
        return new UsbTetherTile(this);
      case QSConstants.TILE_HEADS_UP:
        return new HeadsUpTile(this);
      case QSConstants.TILE_AMBIENT_DISPLAY:
        return new AmbientDisplayTile(this);
      case QSConstants.TILE_SYNC:
        return new SyncTile(this);
      default:
        throw new IllegalArgumentException("Bad tile spec: " + tileSpec);
    }
  }