public static void onMenuClicked(ABaseFragment fragment, int menuId, StatusContent status) { switch (menuId) { case R.id.comment: BizFragment.getBizFragment(fragment).commentCreate(status); break; case R.id.repost: BizFragment.getBizFragment(fragment).statusRepost(status); break; case R.id.fav: BizFragment.getBizFragment(fragment).favorityCreate(status.getId() + "", null); break; case R.id.fav_destory: BizFragment.getBizFragment(fragment).favorityDestory(status.getId() + "", null); break; case R.id.copy: copyToClipboard(status.getText()); ViewUtils.showMessage(R.string.msg_text_copyed); break; case R.id.delete: deleteStatus(fragment, status); break; case R.id.weiguan: PublishActivity.publishStatusRepostAndWeiguan(fragment.getActivity(), null, status); break; case R.id.share: break; } }
public static void timelineMenuSelected( final ABaseFragment fragment, String selectedItem, final StatusContent status) { final String[] timelineMenuArr = GlobalContext.getInstance().getResources().getStringArray(R.array.timeline_menus); try { int position = 0; for (int i = 0; i < timelineMenuArr.length; i++) { if (timelineMenuArr[i].equals(selectedItem)) { position = i; break; } } switch (position) { // 原微博 case 0: TimelineCommentFragment.launch(fragment.getActivity(), status.getRetweeted_status()); break; // 复制 case 1: AisenUtils.copyToClipboard(status.getText()); ViewUtils.showMessage(R.string.msg_text_copyed); break; // 转发 case 2: BizFragment.getBizFragment(fragment).statusRepost(status); break; // 评论 case 3: BizFragment.getBizFragment(fragment).commentCreate(status); break; // 收藏 case 4: BizFragment.getBizFragment(fragment).favorityCreate(status.getId() + "", null); break; // 取消收藏 case 5: BizFragment.getBizFragment(fragment).favorityDestory(status.getId() + "", null); break; // 删除微博 case 6: deleteStatus(fragment, status); break; // 屏蔽微博 case 7: shieldStatus(fragment, status); break; // 围观 case 8: PublishActivity.publishStatusRepostAndWeiguan(fragment.getActivity(), null, status); break; } } catch (Exception e) { e.printStackTrace(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.as_ui_main); AdTokenUtils.loadIfExpired(); new GetTokenInfoTask(AppContext.getAccount()).execute(); BizFragment.getBizFragment(this); if (Build.VERSION.SDK_INT >= 19) { ViewGroup drawerRoot = (ViewGroup) findViewById(R.id.layDrawerRoot); drawerRoot.setPadding( drawerRoot.getPaddingLeft(), SystemBarUtils.getStatusBarHeight(this), drawerRoot.getPaddingRight(), drawerRoot.getBottom()); } if (Build.VERSION.SDK_INT == 19) { ViewGroup rootMain = (ViewGroup) findViewById(R.id.layMainRoot); rootMain.setPadding( rootMain.getPaddingLeft(), rootMain.getPaddingTop(), rootMain.getPaddingRight(), rootMain.getBottom() + SystemBarUtils.getNavigationBarHeight(this)); } mToolbar = getToolbar(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(false); mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, getToolbar(), R.string.draw_open, R.string.draw_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); if (isToolbarShown()) btnFab.show(true); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); btnFab.hide(true); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); lastSelectedMenu = savedInstanceState == null ? null : (MenuBean) savedInstanceState.getSerializable("menu"); if (ActivityHelper.getBooleanShareData("isFirstLaunch", true)) { ActivityHelper.putBooleanShareData("isFirstLaunch", false); mDrawerLayout.openDrawer(Gravity.LEFT); btnFab.hide(); getSupportActionBar().setTitle(R.string.draw_timeline); } else { if (lastSelectedMenu != null) getSupportActionBar().setTitle(lastSelectedMenu.getTitleRes()); else getSupportActionBar().setTitle(R.string.draw_timeline); } if (savedInstanceState == null) { String action = getIntent() != null ? getIntent().getAction() : null; String type = getActionType(getIntent(), action); menuFragment = MenuFragment.newInstance(type); getFragmentManager() .beginTransaction() .add(R.id.menu_frame, menuFragment, "MenuFragment") .commit(); // 添加右侧的抽屉 // GroupsMenuFragment groupsMenuFragment = GroupsMenuFragment.newInstance(); // getFragmentManager().beginTransaction().add(R.id.groups_frame, // groupsMenuFragment, "GroupsMenuFragment").commit(); } else { menuFragment = (MenuFragment) getFragmentManager().findFragmentByTag("MenuFragment"); // 2014-8-30 解决因为状态保存而导致的耗时阻塞 if (lastSelectedMenu.getType().equals("1")) onMenuSelected(lastSelectedMenu, true, null); } // 更新FAB的颜色 btnFab.setColorNormal(AisenUtils.getThemeColor(this)); btnFab.setColorPressed(AisenUtils.getThemeColor(this)); btnFab.setColorRipple(AisenUtils.getThemeColor(this)); btnFab.setOnLongClickListener(this); }
public static void commentMenuSelected( final ABaseFragment fragment, String selectedItem, final StatusComment comment) { final String[] commentMenuArr = GlobalContext.getInstance().getResources().getStringArray(R.array.cmt_menus); try { int position = 0; for (int i = 0; i < commentMenuArr.length; i++) { if (commentMenuArr[i].equals(selectedItem)) { position = i; break; } } switch (position) { // 复制 case 0: AisenUtils.copyToClipboard(comment.getText()); ViewUtils.showMessage(R.string.msg_text_copyed); break; // 转发 case 1: BizFragment.getBizFragment(fragment).commentRepost(comment); break; // 删除 case 2: new AlertDialogWrapper.Builder(fragment.getActivity()) .setMessage(R.string.msg_del_cmt_remind) .setNegativeButton(R.string.cancel, null) .setPositiveButton( R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BizFragment.getBizFragment(fragment) .commentDestory( comment, new BizFragment.OnCommentDestoryCallback() { @SuppressWarnings("unchecked") @Override public void onCommentDestory(StatusComment commnet) { if (fragment instanceof ARefreshFragment) { @SuppressWarnings("rawtypes") ARefreshFragment aRefreshFragment = ((ARefreshFragment) fragment); for (Object so : aRefreshFragment.getAdapterItems()) { StatusComment s = (StatusComment) so; if (s.getId().equals(commnet.getId())) { aRefreshFragment.getAdapterItems().remove(s); aRefreshFragment.notifyDataSetChanged(); break; } } } } }); } }) .show(); break; // 评论 case 3: BizFragment.getBizFragment(fragment).replyComment(comment.getStatus(), comment); break; } } catch (Exception e) { e.printStackTrace(); } }