コード例 #1
0
 public void onPrepareSubMenu(SubMenu subMenu) {
   int i;
   subMenu.clear();
   ActivityChooserModel dataModel =
       ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName);
   PackageManager packageManager = this.mContext.getPackageManager();
   int expandedActivityCount = dataModel.getActivityCount();
   int collapsedActivityCount = Math.min(expandedActivityCount, this.mMaxShownActivityCount);
   for (i = 0; i < collapsedActivityCount; i++) {
     ResolveInfo activity = dataModel.getActivity(i);
     subMenu
         .add(0, i, i, activity.loadLabel(packageManager))
         .setIcon(activity.loadIcon(packageManager))
         .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
   }
   if (collapsedActivityCount < expandedActivityCount) {
     SubMenu expandedSubMenu =
         subMenu.addSubMenu(
             0,
             collapsedActivityCount,
             collapsedActivityCount,
             this.mContext.getString(C0103R.string.abc_activity_chooser_view_see_all));
     for (i = 0; i < expandedActivityCount; i++) {
       activity = dataModel.getActivity(i);
       expandedSubMenu
           .add(0, i, i, activity.loadLabel(packageManager))
           .setIcon(activity.loadIcon(packageManager))
           .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
     }
   }
 }
コード例 #2
0
  /** {@inheritDoc} */
  @DSSafe(DSCat.SAFE_LIST)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2014-09-18 21:46:52.211 -0400",
      hash_original_method = "5458A50E7CC261A43D8FD66D69514BF7",
      hash_generated_method = "9C9DCF571226F099D8D0DA86C844CB03")
  @Override
  public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);

    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
      ResolveInfo activity = dataModel.getActivity(i);
      subMenu
          .add(0, i, i, activity.loadLabel(packageManager))
          .setIcon(activity.loadIcon(packageManager))
          .setOnMenuItemClickListener(mOnMenuItemClickListener);
    }

    if (collapsedActivityCount < expandedActivityCount) {
      // Add a sub-menu for showing all activities as a list item.
      SubMenu expandedSubMenu =
          subMenu.addSubMenu(
              Menu.NONE,
              collapsedActivityCount,
              collapsedActivityCount,
              mContext.getString(R.string.abc_activity_chooser_view_see_all));
      for (int i = 0; i < expandedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        expandedSubMenu
            .add(0, i, i, activity.loadLabel(packageManager))
            .setIcon(activity.loadIcon(packageManager))
            .setOnMenuItemClickListener(mOnMenuItemClickListener);
      }
    }
  }