Exemple #1
0
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.detail, menu);
   MenuItem menuItem = menu.findItem(R.id.action_share);
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   if (mVideos != null) mShareActionProvider.setShareIntent(createShareIntent());
 }
Exemple #2
0
  public static void setStatusShareMenu(MenuItem shareItem, StatusContent status) {
    String url = null;

    if (status.getPic_urls() != null && status.getPic_urls().length > 0) {
      url = status.getPic_urls()[0].getThumbnail_pic();
    } else if (!TextUtils.isEmpty(status.getThumbnail_pic())) {
      url = status.getThumbnail_pic();
    }
    if (!TextUtils.isEmpty(url)) {
      File file = BitmapLoader.getInstance().getCacheFile(url.replace("thumbnail", "large"));
      if (file.exists()) {
        url = url.replace("thumbnail", "large");
      } else {
        file = BitmapLoader.getInstance().getCacheFile(url.replace("thumbnail", "bmiddle"));
        if (file.exists()) {
          url = url.replace("thumbnail", "bmiddle");
        }
      }
    }

    Intent shareIntent = Utils.getShareIntent(status.getText(), status.getText(), url);

    ShareActionProvider shareProvider =
        (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    shareProvider.setShareHistoryFileName("channe_share.xml");
    shareProvider.setShareIntent(shareIntent);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // And implement a share action
    // Fetch/store provider
    // But only if there is data to share
    MenuItem item = menu.findItem(R.id.menu_item_share);

    if (mbShowShare == true) {

      ShareActionProvider shareAction =
          (ShareActionProvider) MenuItemCompat.getActionProvider(item);

      if (shareAction != null) {
        shareAction.setShareIntent(createShareIntent());
      }
    } else {
      // hide the share
      item.setVisible(false);
    }

    return true;
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (mMovie != null) {
      inflater.inflate(R.menu.menu_fragment_detail, menu);

      final MenuItem action_favorite = menu.findItem(R.id.action_favorite);
      MenuItem action_share = menu.findItem(R.id.action_share);
      /*
      action_favorite.setIcon(Utility.isFavorited(getActivity(), mMovie.getId()) == 1 ?
              R.drawable.abc_btn_rating_star_on_mtrl_alpha :
              R.drawable.abc_btn_rating_star_off_mtrl_alpha);
      */
      new AsyncTask<Void, Void, Integer>() {
        @Override
        protected Integer doInBackground(Void... params) {
          return Utility.isFavorited(getActivity(), mMovie.getId());
        }

        @Override
        protected void onPostExecute(Integer isFavorited) {
          action_favorite.setIcon(
              isFavorited == 1
                  ? R.drawable.ic_favorite_white_18dp
                  : R.drawable.ic_favorite_border_white_18dp);
        }
      }.execute();

      mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(action_share);

      if (mTrailer != null) {
        mShareActionProvider.setShareIntent(createShareMovieIntent());
      }
    }
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_imageviewer, menu);

    if (getIntent() != null && getIntent().getDataString() != null) {
      Intent intent =
          new Intent(
              Intent.ACTION_SEND,
              Uri.parse(
                  getIntent()
                      .getDataString()
                      .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
      intent.setType("text/plain");
      intent.putExtra(
          Intent.EXTRA_TEXT,
          getIntent()
              .getDataString()
              .replace(getResources().getString(R.string.IMAGE_SCHEME), "http"));
      intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName());
      intent.putExtra(
          ShareCompat.EXTRA_CALLING_ACTIVITY,
          getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent());
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK);

      MenuItem shareItem = menu.findItem(R.id.action_share);
      ShareActionProviderHax share =
          (ShareActionProviderHax) MenuItemCompat.getActionProvider(shareItem);
      share.onShareActionProviderSubVisibilityChangedListener = this;
      share.setShareIntent(intent);
    }
    return true;
  }
Exemple #6
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.book_detail, menu);

    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
  }
  /**
   * Overridden method to display the share action button in the options menu
   *
   * @param menu the options menu
   * @return boolean - if options were created for the menu
   */
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_detail, menu);

    Movie selectedMovie = getIntent().getParcelableExtra(DetailActivity.EXTRASCURRENTMOVIE);
    if (selectedMovie.getFavorite() != null && !selectedMovie.getFavorite().isEmpty()) {
      // Locate MenuItem for Favorite/Bookmark button
      MenuItem favItem = menu.findItem(R.id.menu_item_bookmark);
      favItem.setIcon(R.drawable.bookmark_plus);
      favItem.setChecked(true);
    }

    // Locate MenuItem with ShareActionProvider
    MenuItem shareItem = menu.findItem(R.id.menu_item_share);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

    if (mShareActionProvider != null) {
      mShareActionProvider.setShareIntent(getDefaultShareIntent());
    } else {
      Log.d(LOG_TAG, "ShareActionProvider is null");
      return false;
    }
    return true;
  }
Exemple #8
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   Fragment fragment = fm.findFragmentById(R.id.fragment_container);
   MenuInflater menuInflater = getMenuInflater();
   // ListView Menu - edit list, get new list, about
   if (fragment instanceof TkkListViewFragment) {
     menuInflater.inflate(R.menu.menu_tkk, menu);
     listEditEnabled = false;
     ((TkkListViewFragment) fragment).getListView().setRearrangeEnabled(false);
   } else if (fragment instanceof TkkWebViewFragment) {
     // WebView Menu - share button
     menuInflater.inflate(R.menu.menu_webview, menu);
     MenuItem item = menu.findItem(R.id.menu_item_share);
     ShareActionProvider mShareActionProvider =
         (ShareActionProvider) MenuItemCompat.getActionProvider(item);
     Intent shareIntent = new Intent(Intent.ACTION_SEND);
     shareIntent.setType("text/plain");
     shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(getString(R.string.app_icon_url)));
     shareIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.app_name));
     shareIntent.putExtra(
         Intent.EXTRA_TEXT,
         getString(R.string.share_message)
             + " "
             + getString(R.string.subtitle)
             + '\n'
             + fragment.getArguments().getString("name")
             + '\n'
             + getString(R.string.get_message)
             + '\n'
             + getString(R.string.download_url));
     mShareActionProvider.setShareIntent(shareIntent);
   }
   return true;
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.detailfragment, menu);
    MenuItem menuItem = menu.findItem(R.id.action_share_first_trailer);

    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
    updateShareIntent();
  }
 public void setIsFavorite(MenuItem item, boolean isFavorite) {
   if (MenuItemCompat.getActionProvider(item) != this) throw new IllegalArgumentException();
   final Drawable icon = item.getIcon();
   if (icon instanceof LikeAnimationDrawable) {
     icon.mutate();
     icon.setColorFilter(isFavorite ? mActivatedColor : mDefaultColor, PorterDuff.Mode.SRC_ATOP);
   }
 }
 public static void initialize(final MenuItem menuItem, final Geocache cache) {
   final ActionProvider actionProvider = MenuItemCompat.getActionProvider(menuItem);
   if (actionProvider instanceof NavigationSelectionActionProvider) {
     final NavigationSelectionActionProvider navigateAction =
         (NavigationSelectionActionProvider) actionProvider;
     navigateAction.setTarget(cache);
   }
 }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_fragment_details, menu);
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
  }
Exemple #13
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.menu_image_picker, menu);
   shareMenu = menu.findItem(R.id.menu_item_share);
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenu);
   return true;
 }
 public void invokeItem(MenuItem item, LikeAnimationDrawable.OnLikedListener listener) {
   if (MenuItemCompat.getActionProvider(item) != this) throw new IllegalArgumentException();
   final Drawable icon = item.getIcon();
   if (icon instanceof LikeAnimationDrawable) {
     ((LikeAnimationDrawable) icon).setOnLikedListener(listener);
     ((LikeAnimationDrawable) icon).start();
   }
 }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.menu_movie_detail, menu);
   // Locate MenuItem with ShareActionProvider
   shareMenuItem = menu.findItem(R.id.menu_share);
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem);
   setShareIntent();
   super.onCreateOptionsMenu(menu, inflater);
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_activity_player, menu);

    MenuItem shareItem = menu.findItem(R.id.ss_action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    mShareActionProvider.setShareIntent(getDefaultIntent());
    return super.onCreateOptionsMenu(menu);
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    inflater.inflate(R.menu.menu_detail, menu);
    MenuItem item = menu.findItem(R.id.menu_item_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    setShareIntent();
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.menu_web, menu);
   ShareActionProvider shareActionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(menu.findItem(R.id.menu_share));
   shareActionProvider.setShareIntent(
       AppUtils.makeShareIntent(
           getString(R.string.share_format, mItem.getDisplayedTitle(), mItem.getUrl())));
   return super.onCreateOptionsMenu(menu);
 }
Exemple #19
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_article, menu);

    MenuItem item = menu.findItem(R.id.action_share);
    actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    actionProvider.setShareIntent(shareIntent);
    return true;
  }
 public void init(final ActionMenuView menuBar, MenuItem item) {
   if (MenuItemCompat.getActionProvider(item) != this) throw new IllegalArgumentException();
   final Drawable icon = ContextCompat.getDrawable(getContext(), mIcon);
   final LikeAnimationDrawable drawable =
       new LikeAnimationDrawable(
           icon, mDefaultColor, mActivatedColor, mUseStar ? Style.FAVORITE : Style.LIKE);
   drawable.mutate();
   drawable.setCallback(new ViewCallback(menuBar));
   item.setIcon(drawable);
 }
Exemple #21
0
  // SHARE CPU INFO VIA ACTION_SEND
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_share, menu);

    MenuItem item = menu.findItem(R.id.menu_item_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    setShareIntent(createShareIntent());
    return true;
  }
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    MenuItem shareItem = menu.findItem(R.id.action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

    if (mForecast != null) {
      mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
  }
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu items for use in the action bar
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.product_detail, menu);
   // Get the menu item.
   MenuItem menuItem = menu.findItem(R.id.action_share);
   // Get the provider and hold onto it to set/change the share intent.
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   mShareActionProvider.setShareIntent(getDefaultIntent());
   return super.onCreateOptionsMenu(menu);
 }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   // Inflate the menu; this adds items to the action bar if it is present.
   inflater.inflate(R.menu.menu_detail, menu);
   // Retrieve the share menu item
   MenuItem menuItem = menu.findItem(R.id.action_share);
   // Get the provider and hold onto it to set/change the share intent.
   mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   //        mShareActionProvider.setShareIntent(createShareVideoIntent(null));
   super.onCreateOptionsMenu(menu, inflater);
 }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.detail_fragment, menu);
   MenuItem menuItem = menu.findItem(R.id.action_share);
   ShareActionProvider mShareActionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareIntent(createShareIntent());
   } else {
     Log.d(TAG, "Share action provider is null?");
   }
 }
Exemple #26
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.menu_main, menu);
   MenuItem miShare = menu.findItem(R.id.action_share);
   shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(miShare);
   Intent intent = new Intent(Intent.ACTION_SEND);
   intent.setType("text/plain");
   intent.putExtra(Intent.EXTRA_TEXT, "this is an test text");
   shareActionProvider.setShareIntent(intent);
   return super.onCreateOptionsMenu(menu);
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.about_menu, menu);

    // 定位使用ShareActionProvider的菜单项
    MenuItem item = menu.findItem(R.id.shareMenuItem);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    shareActionProvider.setShareIntent(shareIntent);

    return super.onCreateOptionsMenu(menu);
  }
Exemple #28
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.book_detail, menu);

    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
    if (shareActionProvider != null) {
      shareActionProvider.setShareIntent(createShareIntent(null));
    } else {
      Log.e(LOG_TAG, "Share Action Provider is null?");
    }
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main, menu);

    MenuItem menuItem = menu.findItem(R.id.action_share);

    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    if (textView.getText().toString() != null) {

      shareActionProvider.setShareIntent(createShareConstitutionIntent());
    }
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.image, menu);
   MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
   if (ActionBarUtil.hasSB()) {
     MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_NEVER);
   }
   ShareActionProvider actionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(actionItem);
   actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
   actionProvider.setShareIntent(createShareIntent());
   return super.onCreateOptionsMenu(menu);
 }