use of android.view.MenuItem 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.view.MenuItem in project weiciyuan by qii.
the class BrowserWebFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.actionbar_menu_browserwebfragment, menu);
MenuItem item = menu.findItem(R.id.menu_share);
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
refreshItem = menu.findItem(R.id.menu_refresh);
super.onCreateOptionsMenu(menu, inflater);
if (Utility.isWeiboAccountDomainLink(mUrl)) {
String result = Utility.getDomainFromWeiboAccountLink(mUrl);
Intent intent = new Intent(getActivity(), UserInfoActivity.class);
intent.putExtra("domain", result);
getActivity().startActivity(intent);
getActivity().finish();
} else if (Utility.isWeiboMid(mUrl)) {
String mid = Utility.getMidFromUrl(mUrl);
RedirectLinkToWeiboIdTask task = new RedirectLinkToWeiboIdTask(BrowserWebFragment.this, mUrl, mid);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
mWebView.loadUrl(mUrl);
}
}
use of android.view.MenuItem in project weiciyuan by qii.
the class BrowserWeiboMsgActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (msg == null) {
return super.onCreateOptionsMenu(menu);
}
getMenuInflater().inflate(R.menu.actionbar_menu_browserweibomsgactivity, menu);
if (msg.getUser() != null && msg.getUser().getId().equals(GlobalContext.getInstance().getCurrentAccountId())) {
menu.findItem(R.id.menu_delete).setVisible(true);
}
MenuItem item = menu.findItem(R.id.menu_share);
shareActionProvider = (ShareActionProvider) item.getActionProvider();
return super.onCreateOptionsMenu(menu);
}
use of android.view.MenuItem in project weiciyuan by qii.
the class BrowserCommentFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.actionbar_menu_browserweibocommentactivity, menu);
MenuItem item = menu.findItem(R.id.menu_share);
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
buildShareActionMenu();
super.onCreateOptionsMenu(menu, inflater);
}
use of android.view.MenuItem in project weiciyuan by qii.
the class WriteWeiboActivity method buildInterface.
private void buildInterface() {
setContentView(R.layout.writeweiboactivity_layout);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setTitle(R.string.write_weibo);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
int avatarWidth = getResources().getDimensionPixelSize(R.dimen.timeline_avatar_width);
int avatarHeight = getResources().getDimensionPixelSize(R.dimen.timeline_avatar_height);
Bitmap bitmap = ImageUtility.getWriteWeiboRoundedCornerPic(GlobalContext.getInstance().getAccountBean().getInfo().getAvatar_large(), avatarWidth, avatarHeight, FileLocationMethod.avatar_large);
if (bitmap == null) {
bitmap = ImageUtility.getWriteWeiboRoundedCornerPic(GlobalContext.getInstance().getAccountBean().getInfo().getProfile_image_url(), avatarWidth, avatarHeight, FileLocationMethod.avatar_small);
}
if (bitmap != null) {
actionBar.setIcon(new BitmapDrawable(getResources(), bitmap));
}
View title = getLayoutInflater().inflate(R.layout.writeweiboactivity_title_layout, null);
TextView contentNumber = (TextView) title.findViewById(R.id.content_number);
contentNumber.setVisibility(View.GONE);
haveGPS = (ImageView) title.findViewById(R.id.have_gps);
final PopupMenu popupMenu = new PopupMenu(this, haveGPS);
popupMenu.inflate(R.menu.popmenu_gps);
haveGPS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupMenu.show();
}
});
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_view:
StringBuilder geoUriString = new StringBuilder().append("geo:" + geoBean.getLat() + "," + geoBean.getLon());
if (!TextUtils.isEmpty(location)) {
geoUriString.append("?q=").append(location);
}
Uri geoUri = Uri.parse(geoUriString.toString());
Intent mapCall = new Intent(Intent.ACTION_VIEW, geoUri);
if (Utility.isIntentSafe(WriteWeiboActivity.this, mapCall)) {
startActivity(mapCall);
} else {
Toast.makeText(WriteWeiboActivity.this, R.string.your_device_dont_have_any_map_app_to_open_gps_info, Toast.LENGTH_SHORT).show();
}
break;
case R.id.menu_delete:
haveGPS.setVisibility(View.GONE);
geoBean = null;
break;
}
return true;
}
});
actionBar.setCustomView(title, new ActionBar.LayoutParams(Gravity.RIGHT));
actionBar.setDisplayShowCustomEnabled(true);
content = ((KeyboardControlEditText) findViewById(R.id.status_new_content));
content.addTextChangedListener(new TextNumLimitWatcher((TextView) findViewById(R.id.menu_send), content, this));
content.setDrawingCacheEnabled(true);
AutoCompleteAdapter adapter = new AutoCompleteAdapter(this, content, (ProgressBar) title.findViewById(R.id.have_suggest_progressbar));
content.setAdapter(adapter);
preview = ViewUtility.findViewById(this, R.id.status_image_preview);
View.OnClickListener onClickListener = new BottomButtonClickListener();
findViewById(R.id.menu_at).setOnClickListener(onClickListener);
findViewById(R.id.menu_emoticon).setOnClickListener(onClickListener);
findViewById(R.id.menu_add_pic).setOnClickListener(onClickListener);
findViewById(R.id.menu_send).setOnClickListener(onClickListener);
CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_at), R.string.at_other);
CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_emoticon), R.string.add_emoticon);
CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_add_pic), R.string.add_pic);
CheatSheet.setup(WriteWeiboActivity.this, findViewById(R.id.menu_send), R.string.send);
smiley = (SmileyPicker) findViewById(R.id.smiley_picker);
smiley.setEditText(WriteWeiboActivity.this, ((LinearLayout) findViewById(R.id.root_layout)), content);
container = (RelativeLayout) findViewById(R.id.container);
content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideSmileyPicker(true);
}
});
}
Aggregations