コード例 #1
0
  /**
   * Switch to an item's view when it is touched
   *
   * @param ownerId the PersonItem.INTERNAL_ID of the person whose media should be shown
   */
  private void onView(String ownerId) {
    PersonItem person = PersonManager.findPersonByInternalId(getContentResolver(), ownerId);
    Intent browseMediaIntent = new Intent(PeopleBrowserActivity.this, MediaBrowserActivity.class);
    browseMediaIntent.putExtra(getString(R.string.extra_parent_id), ownerId);

    // not really the best place to manage person re-locking, but never mind...
    if (!person.isLocked()) {
      if (person.lockExpired()) {
        person.setLockStatus(PersonItem.PERSON_LOCKED);
        PersonManager.updatePerson(getContentResolver(), person);
      } else {
        browseMediaIntent.putExtra(
            getString(R.string.extra_media_visibility), MediaItem.MEDIA_PRIVATE);
      }
    } else {
      UIUtilities.showToast(PeopleBrowserActivity.this, R.string.message_view_locked_person, true);
    }

    startActivityForResult(browseMediaIntent, R.id.intent_media_browser);
  }
コード例 #2
0
  // setBackgroundDrawable is deprecated from API 16+ (Jelly Bean), but we still want to target
  // earlier versions;
  // since this is purely a name change, there's no real reason to do anything platform-independent
  @SuppressWarnings("deprecation")
  private void updatePeopleIcons(boolean fadeIn) {
    mPendingIconsUpdate = false;

    final GridView grid = mGrid;
    final FastBitmapDrawable icon = mDefaultIcon;
    final int count = grid.getChildCount();

    for (int i = 0; i < count; i++) {
      final View view = grid.getChildAt(i);
      final PersonViewHolder holder = (PersonViewHolder) view.getTag();
      if (holder.queryIcon) {
        // if the icon has gone missing (recently imported or cache deletion), regenerate it
        String personCacheId = PersonItem.getCacheId(holder.personInternalId);
        FastBitmapDrawable cachedIcon =
            ImageCacheUtilities.getCachedIcon(
                MediaTablet.DIRECTORY_THUMBS, personCacheId, ImageCacheUtilities.NULL_DRAWABLE);
        if (ImageCacheUtilities.NULL_DRAWABLE.equals(cachedIcon)) {
          PersonManager.reloadPersonIcon(
              getResources(), getContentResolver(), holder.personInternalId);
          cachedIcon =
              ImageCacheUtilities.getCachedIcon(MediaTablet.DIRECTORY_THUMBS, personCacheId, icon);
        }

        if (fadeIn) {
          CrossFadeDrawable d = holder.transition;
          d.setEnd(cachedIcon.getBitmap());
          holder.display.setBackgroundDrawable(d);
          d.startTransition(MediaTablet.ANIMATION_FADE_TRANSITION_DURATION);
        } else {
          holder.display.setBackgroundDrawable(cachedIcon);
        }

        holder.loader.setVisibility(View.GONE);
        holder.queryIcon = false;

        if (holder.selected) {
          holder.overlay.setBackgroundResource(R.drawable.item_public);
          holder.overlay.setPadding(0, 0, 0, 0);
        } else {
          holder.overlay.setBackgroundDrawable(null);
        }
      }
    }

    grid.invalidate();
  }