@Override
 public void removeCustomTile(StatusBarPanelCustomTile customTile) {
   if (mCustomTileListenerService != null) {
     mCustomTileListenerService.removeCustomTile(
         customTile.getPackage(), customTile.getTag(), customTile.getId());
   }
 }
 void addCustomTile(StatusBarPanelCustomTile sbc) {
   synchronized (mTiles) {
     if (!mTiles.containsKey(sbc.getKey())) {
       mCustomTileData.add(new CustomTileData.Entry(sbc));
       mTiles.put(sbc.getKey(), new CustomQSTile(this, sbc));
       if (mCallback != null) {
         mCallback.onTilesChanged();
       }
     }
   }
 }
 void updateCustomTile(StatusBarPanelCustomTile sbc) {
   synchronized (mTiles) {
     if (mTiles.containsKey(sbc.getKey())) {
       QSTile<?> tile = mTiles.get(sbc.getKey());
       if (tile instanceof CustomQSTile) {
         CustomQSTile qsTile = (CustomQSTile) tile;
         qsTile.update(sbc);
       }
     }
   }
 }
  private void handleShowDetailImpl(Record r, boolean show, int x, int y) {
    if ((mDetailRecord != null) == show) return; // already in right state
    DetailAdapter detailAdapter = null;
    AnimatorListener listener = null;
    if (show) {
      detailAdapter = r.detailAdapter;
      r.detailView = detailAdapter.createDetailView(mContext, r.detailView, mDetailContent);
      if (r.detailView == null) throw new IllegalStateException("Must return detail view");

      final Intent settingsIntent = detailAdapter.getSettingsIntent();
      mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE);
      mDetailSettingsButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              mHost.startSettingsActivity(settingsIntent);
            }
          });

      // Do not display remove tile button for dynamic tiles
      final StatusBarPanelCustomTile customTile = detailAdapter.getCustomTile();
      mDetailRemoveButton.setVisibility(
          customTile != null
                  && !(customTile.getPackage().equals(mContext.getPackageName())
                      || customTile.getUid() == Process.SYSTEM_UID)
              ? VISIBLE
              : GONE);
      mDetailRemoveButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              mHost.collapsePanels();
              mHost.removeCustomTile(customTile);
            }
          });

      mDetailContent.removeAllViews();
      mDetail.bringToFront();
      mDetailContent.addView(r.detailView);
      setDetailRecord(r);
      listener = mHideGridContentWhenDone;
    } else {
      mClosingDetail = true;
      setGridContentVisibility(true);
      listener = mTeardownDetailWhenDone;
      fireScanStateChanged(false);
    }
    sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    fireShowingDetail(show ? detailAdapter : null);
    mClipper.animateCircularClip(x, y, show, listener);
  }