use of android.widget.ShareActionProvider in project android-support-v4-googlemaps by petedoyle.
the class ShareCompatICS method configureMenuItem.
public static void configureMenuItem(MenuItem item, Activity callingActivity, Intent intent) {
ActionProvider itemProvider = item.getActionProvider();
ShareActionProvider provider = null;
if (!(itemProvider instanceof ShareActionProvider)) {
provider = new ShareActionProvider(callingActivity);
} else {
provider = (ShareActionProvider) itemProvider;
}
provider.setShareHistoryFileName(HISTORY_FILENAME_PREFIX + callingActivity.getClass().getName());
provider.setShareIntent(intent);
item.setActionProvider(provider);
}
use of android.widget.ShareActionProvider in project weiciyuan by qii.
the class StatusSingleChoiceModeListener method onActionItemClicked.
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (listView.getCheckedItemCount() == 0) {
return true;
}
Intent intent;
long[] ids = listView.getCheckedItemIds();
switch(item.getItemId()) {
case R.id.menu_repost:
intent = new Intent(getActivity(), WriteRepostActivity.class);
intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
intent.putExtra("id", String.valueOf(ids[0]));
intent.putExtra("msg", bean);
getActivity().startActivity(intent);
listView.clearChoices();
mode.finish();
break;
case R.id.menu_comment:
intent = new Intent(getActivity(), WriteCommentActivity.class);
intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
intent.putExtra("id", String.valueOf(ids[0]));
intent.putExtra("msg", bean);
getActivity().startActivity(intent);
listView.clearChoices();
mode.finish();
break;
case R.id.menu_fav:
if (Utility.isTaskStopped(favTask) && Utility.isTaskStopped(unFavTask)) {
favTask = new FavAsyncTask(GlobalContext.getInstance().getSpecialToken(), bean.getId());
favTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
}
listView.clearChoices();
mode.finish();
break;
case R.id.menu_unfav:
if (Utility.isTaskStopped(favTask) && Utility.isTaskStopped(unFavTask)) {
unFavTask = new UnFavAsyncTask(GlobalContext.getInstance().getSpecialToken(), bean.getId());
unFavTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
}
listView.clearChoices();
mode.finish();
break;
case R.id.menu_remove:
int position = listView.getCheckedItemPosition() - listView.getHeaderViewsCount();
RemoveDialog dialog = new RemoveDialog(position);
dialog.setTargetFragment(fragment, 0);
dialog.show(fragment.getFragmentManager(), "");
break;
case R.id.menu_share:
if (fragment.getActivity() != null) {
Utility.setShareIntent(fragment.getActivity(), mShareActionProvider, bean);
}
mShareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
@Override
public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
finish();
return false;
}
});
break;
case R.id.menu_copy:
ClipboardManager cm = (ClipboardManager) fragment.getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(ClipData.newPlainText("sinaweibo", bean.getText()));
Toast.makeText(fragment.getActivity(), fragment.getString(R.string.copy_successfully), Toast.LENGTH_SHORT).show();
mode.finish();
break;
}
return true;
}
use of android.widget.ShareActionProvider in project weiciyuan by qii.
the class StatusSingleChoiceModeListener method onPrepareActionMode.
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
menu.clear();
if (bean.getUser().getId().equals(GlobalContext.getInstance().getCurrentAccountId())) {
inflater.inflate(R.menu.contextual_menu_fragment_status_listview_myself, menu);
} else {
inflater.inflate(R.menu.contextual_menu_fragment_status_listview, menu);
}
mode.setTitle(bean.getUser().getScreen_name());
//fuck sina weibo
// MenuItem favItem = menu.findItem(R.id.menu_fav);
// MenuItem unFavItem = menu.findItem(R.id.menu_unfav);
// if (bean.isFavorited()) {
// favItem.setVisible(false);
// unFavItem.setVisible(true);
// } else {
// favItem.setVisible(true);
// unFavItem.setVisible(false);
// }
MenuItem item = menu.findItem(R.id.menu_share);
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
if (fragment.getActivity() != null) {
Utility.setShareIntent(fragment.getActivity(), mShareActionProvider, bean);
}
mShareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
@Override
public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
finish();
return false;
}
});
return true;
}
use of android.widget.ShareActionProvider in project weiciyuan by qii.
the class CommentSingleChoiceModeListener method onActionItemClicked.
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
Intent intent;
switch(item.getItemId()) {
case R.id.menu_view:
intent = new Intent(getActivity(), BrowserCommentActivity.class);
intent.putExtra("comment", bean);
intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
getActivity().startActivity(intent);
listView.clearChoices();
mode.finish();
break;
case R.id.menu_comment:
intent = new Intent(getActivity(), WriteReplyToCommentActivity.class);
intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
intent.putExtra("msg", bean);
getActivity().startActivity(intent);
listView.clearChoices();
mode.finish();
break;
case R.id.menu_share:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_TEXT, bean.getText());
PackageManager packageManager = getActivity().getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(sharingIntent, 0);
boolean isIntentSafe = activities.size() > 0;
if (isIntentSafe && mShareActionProvider != null) {
mShareActionProvider.setShareIntent(sharingIntent);
}
mShareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
@Override
public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
finish();
return false;
}
});
break;
case R.id.menu_copy:
ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
cm.setPrimaryClip(ClipData.newPlainText("sinaweibo", bean.getText()));
Toast.makeText(getActivity(), getActivity().getString(R.string.copy_successfully), Toast.LENGTH_SHORT).show();
listView.clearChoices();
mode.finish();
break;
case R.id.menu_remove:
int position = listView.getCheckedItemPosition() - listView.getHeaderViewsCount();
RemoveDialog dialog = new RemoveDialog(position);
dialog.setTargetFragment(fragment, 0);
dialog.show(fragment.getFragmentManager(), "");
break;
}
return true;
}
use of android.widget.ShareActionProvider in project glimmr by brk3.
the class PhotoViewerFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (BuildConfig.DEBUG)
Log.d(getLogTag(), "onCreateOptionsMenu");
inflater.inflate(R.menu.photoviewer_menu, menu);
mFavoriteButton = menu.findItem(R.id.menu_favorite);
mWallpaperButton = menu.findItem(R.id.menu_set_wallpaper);
/* The task could return before this has inflated, so make sure it's up
* to date */
if (mPhotoExtendedInfo != null) {
updateFavoriteButtonIcon(mPhotoExtendedInfo.isFavorite());
}
/* Set file with share history to the provider and set the share
* intent. */
MenuItem shareActionItem = menu.findItem(R.id.menu_share);
ShareActionProvider shareActionProvider = (ShareActionProvider) shareActionItem.getActionProvider();
shareActionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
shareActionProvider.setShareIntent(createShareIntent());
}
Aggregations