コード例 #1
0
  private void dismissInternal() {
    // Remove any attached window decor for recycling
    boolean hadDecor = mDecor != null;
    if (hadDecor) {
      mWindowManager.removeView(mDecor);
      mWindowRecycled++;
      mDecor.getViewTreeObserver().removeGlobalOnLayoutListener(this);
      mDecor = null;
      mWindow.closeAllPanels();
    }
    mShowing = false;
    mDismissed = true;

    // Cancel any pending queries
    mHandler.cancelOperation(TOKEN_DATA);
    mQuerying = false;

    // Completely hide header and reset track
    mHeader.setVisibility(View.GONE);
    resetTrack();
  }
コード例 #2
0
  /**
   * Start showing a dialog for the given {@link Contacts#_ID} pointing towards the given location.
   */
  public synchronized void show(Uri lookupUri, Rect anchor, int mode, String[] excludeMimes) {
    if (mQuerying || mShowing) {
      Log.w(TAG, "dismissing before showing");
      dismissInternal();
    }

    if (TRACE_LAUNCH && false /*!android.os.Debug.isMethodTracingActive()*/) {
      android.os.Debug.startMethodTracing(TRACE_TAG);
    }

    // Prepare header view for requested mode
    mLookupUri = lookupUri;
    mAnchor = new Rect(anchor);
    mMode = mode;
    mExcludeMimes = excludeMimes;

    mHeader = getHeaderView(mode);

    setHeaderText(R.id.name, R.string.quickcontact_missing_name);

    setHeaderText(R.id.status, null);
    setHeaderText(R.id.timestamp, null);

    setHeaderImage(R.id.presence, null);

    resetTrack();

    mHasValidSocial = false;
    mDismissed = false;
    mQuerying = true;

    // Start background query for data, but only select photo rows when they
    // directly match the super-primary PHOTO_ID.
    final Uri dataUri = getDataUri(lookupUri);
    mHandler.cancelOperation(TOKEN_DATA);

    // Only request photo data when required by mode
    if (mMode == QuickContact.MODE_LARGE) {
      // Select photos, but only super-primary
      mHandler.startQuery(
          TOKEN_DATA,
          lookupUri,
          dataUri,
          DataQuery.PROJECTION,
          Data.MIMETYPE
              + "!=? OR ("
              + Data.MIMETYPE
              + "=? AND "
              + Data._ID
              + "="
              + Contacts.PHOTO_ID
              + ")",
          new String[] {Photo.CONTENT_ITEM_TYPE, Photo.CONTENT_ITEM_TYPE},
          null);
    } else {
      // Exclude all photos from cursor
      mHandler.startQuery(
          TOKEN_DATA,
          lookupUri,
          dataUri,
          DataQuery.PROJECTION,
          Data.MIMETYPE + "!=?",
          new String[] {Photo.CONTENT_ITEM_TYPE},
          null);
    }
  }