@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getListView().setDivider(null); writeDMToolbar = (Toolbar) ((MainTimeLineActivity) getActivity()).findViewById(R.id.mainTimeLineToolBar); writeDMToolbar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem arg0) { switch (arg0.getItemId()) { case R.id.menu_write_dm: Intent intent = new Intent(getActivity(), DMSelectUserActivity.class); startActivityForResult(intent, 0); break; } return false; } }); }
/** * Initializes the SelectionToolbar. * * @param toolbarLayoutId The resource id of the toolbar layout. This will be inflated into * a ViewStub. * @param delegate The SelectionDelegate that will inform the toolbar of selection changes. * @param titleResId The resource id of the title string. May be 0 if this class shouldn't set * set a title when the selection is cleared. * @param drawerLayout The DrawerLayout whose navigation icon is displayed in this toolbar. * @param normalGroupResId The resource id of the menu group to show when a selection isn't * established. * @param selectedGroupResId The resource id of the menu item to show when a selection is * established. * @param normalBackgroundColorResId The resource id of the color to use as the background color * when selection is not enabled. If null the default appbar * background color will be used. * @param listener The OnMenuItemClickListener to set on the toolbar. * @return The initialized SelectionToolbar. */ public SelectableListToolbar<E> initializeToolbar(int toolbarLayoutId, SelectionDelegate<E> delegate, int titleResId, @Nullable DrawerLayout drawerLayout, int normalGroupResId, int selectedGroupResId, @Nullable Integer normalBackgroundColorResId, @Nullable OnMenuItemClickListener listener) { mToolbarStub.setLayoutResource(toolbarLayoutId); @SuppressWarnings("unchecked") SelectableListToolbar<E> toolbar = (SelectableListToolbar<E>) mToolbarStub.inflate(); mToolbar = toolbar; mToolbar.initialize(delegate, titleResId, drawerLayout, normalGroupResId, selectedGroupResId, normalBackgroundColorResId); if (listener != null) { mToolbar.setOnMenuItemClickListener(listener); } mToolbarShadow = (FadingShadowView) findViewById(R.id.shadow); mToolbarShadow.init( ApiCompatibilityUtils.getColor(getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); delegate.addObserver(this); setToolbarShadowVisibility(); return mToolbar; }
/** * Prepares the toolbar for use. * * Many of the things that would ideally be set as attributes don't work and need to be set * programmatically. This is likely due to how we compile the support libraries. */ private void prepareToolbar() { EditorDialogToolbar toolbar = (EditorDialogToolbar) mLayout.findViewById(R.id.action_bar); toolbar.setTitle(mEditorModel.getTitle()); toolbar.setTitleTextColor(Color.WHITE); toolbar.setShowDeleteMenuItem(false); // Show the help article when the user asks. toolbar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { launchAutofillHelpPage(mContext); return true; } }); // Cancel editing when the user hits the back arrow. toolbar.setNavigationContentDescription(R.string.cancel); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancelEdit(); } }); // Make it appear that the toolbar is floating by adding a shadow. FadingShadowView shadow = (FadingShadowView) mLayout.findViewById(R.id.shadow); shadow.init(ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); // The top shadow is handled by the toolbar, so hide the one used in the field editor. FadingEdgeScrollView scrollView = (FadingEdgeScrollView) mLayout.findViewById(R.id.scroll_view); scrollView.setShadowVisibility(false, true); }
/** * Creates and returns a listener, which allows to observe, when an item of the tab switcher's * toolbar has been clicked. * * @return The listener, which has been created, as an instance of the type {@link * OnMenuItemClickListener}. The listener may not be null */ @NonNull private OnMenuItemClickListener createToolbarMenuListener() { return new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.add_tab_menu_item: int index = tabSwitcher.getCount(); Tab tab = createTab(index); if (tabSwitcher.isSwitcherShown()) { tabSwitcher.addTab(tab, 0, createRevealAnimation()); } else { tabSwitcher.addTab(tab, 0, createPeekAnimation()); } return true; case R.id.clear_tabs_menu_item: tabSwitcher.clear(); return true; case R.id.settings_menu_item: Intent intent = new Intent(MainActivity.this, SettingsActivity.class); startActivity(intent); default: return false; } } }; }
@Override public final void inflateToolbarMenu(@MenuRes final int resourceId, @Nullable final OnMenuItemClickListener listener) { this.toolbarMenuId = resourceId; this.toolbarMenuItemListener = listener; notifyOnToolbarMenuInflated(resourceId, listener); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.editmyprofileactivity_layout); mEditToolBar = (Toolbar) findViewById(R.id.editMyProFileToolbar); initLayout(); userBean = (UserBean) getIntent().getParcelableExtra(Constants.USERBEAN); initValue(savedInstanceState); mEditToolBar.inflateMenu(R.menu.actionbar_menu_editmyprofileactivity); save = mEditToolBar.getMenu().findItem(R.id.menu_save); mEditToolBar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { // TODO Auto-generated method stub Intent intent; switch (item.getItemId()) { case android.R.id.home: intent = MainTimeLineActivity.newIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return true; case R.id.menu_save: save(); return true; } return false; } }); }
/** * Prepares the toolbar for use. * * Many of the things that would ideally be set as attributes don't work and need to be set * programmatically. This is likely due to how we compile the support libraries. */ private void prepareToolbar() { EditorDialogToolbar toolbar = (EditorDialogToolbar) mLayout.findViewById(R.id.action_bar); toolbar.setTitle(mEditorModel.getTitle()); toolbar.setTitleTextColor(Color.WHITE); toolbar.setShowDeleteMenuItem(false); // Show the help article when the user asks. toolbar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { launchAutofillHelpPage(mContext); return true; } }); // Cancel editing when the user hits the back arrow. toolbar.setNavigationContentDescription(R.string.cancel); toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissDialog(); } }); // Make it appear that the toolbar is floating by adding a shadow. FadingShadowView shadow = (FadingShadowView) mLayout.findViewById(R.id.shadow); shadow.init(ApiCompatibilityUtils.getColor( mContext.getResources(), R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP); // The top shadow is handled by the toolbar, so hide the one used in the field editor. FadingEdgeScrollView scrollView = (FadingEdgeScrollView) mLayout.findViewById(R.id.scroll_view); scrollView.setEdgeVisibility( FadingEdgeScrollView.DRAW_NO_EDGE, FadingEdgeScrollView.DRAW_FADING_EDGE); }
@Override public final void inflateToolbarMenu(@MenuRes final int resourceId, @Nullable final OnMenuItemClickListener listener) { model.inflateToolbarMenu(resourceId, listener); }
@Override public final void onToolbarMenuInflated(@MenuRes final int resourceId, @Nullable final OnMenuItemClickListener listener) { inflateToolbarMenu(); }
@Override public final void onToolbarMenuInflated(@MenuRes final int resourceId, @Nullable final OnMenuItemClickListener listener) { }
@Override public void onCreate(Bundle savedInstanceState) { MobclickAgent.setDebugMode(false); MobclickAgent.openActivityDurationTrack(false); MobclickAgent.updateOnlineConfig(this); // CookieManager manager = CookieManager.getInstance(); // manager.removeAllCookie(); String action = getIntent() != null ? getIntent().getAction() : null; if (ACTION_OPEN_FROM_APP_INNER.equals(action)) { // empty } else if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) { // empty } else { // finish current Activity jumpToMainTimeLineActivity(); } super.onCreate(savedInstanceState); setContentView(R.layout.accountactivity_layout); mToolBar = (Toolbar) findViewById(R.id.accountToolBar); mToolBar.inflateMenu(R.menu.actionbar_menu_accountactivity); mToolBar.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem arg0) { switch (arg0.getItemId()) { case R.id.menu_add_account:{ showAddAccountDialog(); break; } default: break; } return false; } }); // getActionBar().setTitle(getString(R.string.app_name)); listAdapter = new AccountAdapter(); listView = (ListView) findViewById(R.id.listView); listView.setOnItemClickListener(new AccountListItemClickListener()); listView.setAdapter(listAdapter); listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new AccountMultiChoiceModeListener()); getLoaderManager().initLoader(LOADER_ID, null, this); if (SettingUtils.firstStart()) { showChangeLogDialog(); } if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) { showAddAccountDialog(); AccountBean accountBean = getIntent().getParcelableExtra(REFRESH_ACTION_EXTRA); Toast.makeText(this, String.format(getString(R.string.account_token_has_expired), accountBean.getUsernick()), Toast.LENGTH_SHORT).show(); } }
/** * Initializes the SelectionToolbar. * * @param toolbarLayoutId The resource id of the toolbar layout. This will be inflated into * a ViewStub. * @param delegate The SelectionDelegate that will inform the toolbar of selection changes. * @param titleResId The resource id of the title string. May be 0 if this class shouldn't set * set a title when the selection is cleared. * @param drawerLayout The DrawerLayout whose navigation icon is displayed in this toolbar. * @param normalGroupResId The resource id of the menu group to show when a selection isn't * established. * @param selectedGroupResId The resource id of the menu item to show when a selection is * established. * @param listener The OnMenuItemClickListener to set on the toolbar. * @return The initialized SelectionToolbar. */ public <E> SelectionToolbar<E> initializeToolbar(int toolbarLayoutId, SelectionDelegate<E> delegate, int titleResId, @Nullable DrawerLayout drawerLayout, int normalGroupResId, int selectedGroupResId, OnMenuItemClickListener listener) { mToolbarStub.setLayoutResource(toolbarLayoutId); @SuppressWarnings("unchecked") SelectionToolbar<E> toolbar = (SelectionToolbar<E>) mToolbarStub.inflate(); toolbar.initialize(delegate, titleResId, drawerLayout, normalGroupResId, selectedGroupResId); toolbar.setOnMenuItemClickListener(listener); return toolbar; }
/** * Notifies the listeners, that the menu of the toolbar, which is shown, when the tab switcher * is shown, has been inflated. * * @param resourceId * The resource id of the menu, which has been inflated, as an {@link Integer} value. * The resource id must correspond to a valid menu resource * @param menuItemClickListener * The listener, which has been registered to be notified, when an item of the menu has * been clicked, as an instance of the type OnMenuItemClickListener or null, if no * listener should be notified */ private void notifyOnToolbarMenuInflated(@MenuRes final int resourceId, @Nullable final OnMenuItemClickListener menuItemClickListener) { for (Listener listener : listeners) { listener.onToolbarMenuInflated(resourceId, menuItemClickListener); } }
/** * The method, which is invoked, when the menu of the toolbar, which is shown, when the tab * switcher is shown, has been inflated. * * @param resourceId * The resource id of the menu, which has been inflated, as an {@link Integer} * value. The resource id must correspond to a valid menu resource * @param listener * The listener, which has been registered to be notified, when an item of the menu * has been clicked, as an instance of the type OnMenuItemClickListener or null, if * no listener should be notified */ void onToolbarMenuInflated(@MenuRes int resourceId, @Nullable OnMenuItemClickListener listener);
/** * Inflates the menu of the toolbar, which is shown, when the tab switcher is shown. When using * the tablet layout, the menu is inflated into the secondary toolbar. If another menu has * already been inflated, its items will be removed. * * @param resourceId * The resource id of the menu, which should be inflated, as an {@link Integer} value. * The resource id must correspond to a valid menu resource * @param listener * The listener, which should be notified, when an menu item has been clicked, as an * instance of the type OnMenuItemClickListener or null, if no listener should be * notified */ void inflateToolbarMenu(@MenuRes int resourceId, @Nullable OnMenuItemClickListener listener);
/** * Returns the listener, which is notified, when an item of the menu of the toolbar, which is * shown, when the tab switcher is shown, has been clicked. * * @return The listener, which is notified, when an item of the menu of the toolbar, which is * shown, when the tab switcher is shown, has been clicked as an instance of the type * OnMenuItemClickListener or null, if no listener should be notified */ @Nullable public final OnMenuItemClickListener getToolbarMenuItemListener() { return toolbarMenuItemListener; }
/** * Inflates the menu of the toolbar, which is shown, when the tab switcher is shown. When using * the tablet layout, the menu is inflated into the secondary toolbar. * * @param resourceId * The resource id of the menu, which should be inflated, as an {@link Integer} value. * The resource id must correspond to a valid menu resource * @param listener * The listener, which should be notified, when an menu item has been clicked, as an * instance of the type OnMenuItemClickListener or null, if no listener should be * notified */ void inflateToolbarMenu(@MenuRes int resourceId, @Nullable OnMenuItemClickListener listener);