List of usage examples for android.view Gravity END
int END
To view the source code for android.view Gravity END.
Click Source Link
From source file:org.wheelmap.android.activity.MainMultiPaneActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { ActionBar bar = getSupportActionBar(); if (bar == null) { return true; }// www . j a v a 2 s .c o m LayoutInflater inflater = LayoutInflater.from(this); View customView = inflater.inflate(R.layout.actionbar_tablet, null); bar.setCustomView(customView, new ActionBar.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.END)); boolean isPortraitMode = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; if (isPortraitMode) { ImageView addItem = (ImageView) customView.findViewById(R.id.menu_new_poi); addItem.setVisibility(View.VISIBLE); OnClickListener addClickListener = new OnClickListener() { @Override public void onClick(View v) { createNewPoi(); } }; addItem.setOnClickListener(addClickListener); LinearLayout l = (LinearLayout) findViewById(R.id.actionbar_bottom); for (int i = 0; i < l.getChildCount(); i++) { l.getChildAt(i).setOnTouchListener(new PressSelector()); } bar.setDisplayShowCustomEnabled(true); View v = findViewById(R.id.menu_filter); MapActivityUtils.setAccessFilterOptionDrawable(this, null, v); View filterWc = findViewById(R.id.menu_wc); MapActivityUtils.setWcFilterOptionsDrawable(this, null, filterWc); UserCredentials credentials = new UserCredentials(getApplicationContext()); ImageView image = (ImageView) findViewById(R.id.menu_login); image.setImageResource( credentials.isLoggedIn() ? R.drawable.start_icon_logged_in : R.drawable.start_icon_login); } else { MenuInflater inflaterMenu = getMenuInflater(); inflaterMenu.inflate(R.menu.ab_multi_activity, menu); MenuItem item = menu.findItem(R.id.menu_filter); MapActivityUtils.setAccessFilterOptionDrawable(this, item, null); item = menu.findItem(R.id.menu_wc); MapActivityUtils.setWcFilterOptionsDrawable(this, item, null); } if (mapModeType == MapModeType.MAP_MODE_ENGAGE) { MenuItem itemFilterWheelChairs = menu.findItem(R.id.menu_filter); itemFilterWheelChairs.setEnabled(false); //TODO Disable it - doesn't work yet } ImageView listMapToggle = (ImageView) findViewById(R.id.switch_view); if (listMapToggle != null) { listMapToggle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleMovableResize(); } }); } return true; }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
public DrawerForm(Context context, Context unstyledContext, Callback callback, WatcherService.Client watcherServiceClient) { this.context = context; this.unstyledContext = unstyledContext; this.callback = callback; this.watcherServiceClient = watcherServiceClient; float density = ResourceUtils.obtainDensity(context); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new SortableListView.LayoutParams(SortableListView.LayoutParams.MATCH_PARENT, SortableListView.LayoutParams.WRAP_CONTENT)); LinearLayout editTextContainer = new LinearLayout(context); editTextContainer.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView(editTextContainer); searchEdit = new SafePasteEditText(context); searchEdit.setOnKeyListener((v, keyCode, event) -> { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { v.clearFocus();//from www.jav a2 s . c o m } return false; }); searchEdit.setHint(context.getString(R.string.text_code_number_address)); searchEdit.setOnEditorActionListener(this); searchEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); searchEdit.setImeOptions(EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NO_EXTRACT_UI); ImageView searchIcon = new ImageView(context, null, android.R.attr.buttonBarButtonStyle); searchIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonForward, 0)); searchIcon.setScaleType(ImageView.ScaleType.CENTER); searchIcon.setOnClickListener(this); editTextContainer.addView(searchEdit, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); editTextContainer.addView(searchIcon, (int) (40f * density), (int) (40f * density)); if (C.API_LOLLIPOP) { editTextContainer.setPadding((int) (12f * density), (int) (8f * density), (int) (8f * density), 0); } else { editTextContainer.setPadding(0, (int) (2f * density), (int) (4f * density), (int) (2f * density)); } LinearLayout selectorContainer = new LinearLayout(context); selectorContainer.setBackgroundResource( ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0)); selectorContainer.setOrientation(LinearLayout.HORIZONTAL); selectorContainer.setGravity(Gravity.CENTER_VERTICAL); selectorContainer.setOnClickListener(v -> { hideKeyboard(); setChanSelectMode(!chanSelectMode); }); linearLayout.addView(selectorContainer); selectorContainer.setMinimumHeight((int) (40f * density)); if (C.API_LOLLIPOP) { selectorContainer.setPadding((int) (16f * density), 0, (int) (16f * density), 0); ((LinearLayout.LayoutParams) selectorContainer.getLayoutParams()).topMargin = (int) (4f * density); } else { selectorContainer.setPadding((int) (8f * density), 0, (int) (12f * density), 0); } chanNameView = new TextView(context, null, android.R.attr.textAppearanceListItem); chanNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f); if (C.API_LOLLIPOP) { chanNameView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM); } else { chanNameView.setFilters(new InputFilter[] { new InputFilter.AllCaps() }); } selectorContainer.addView(chanNameView, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); chanSelectorIcon = new ImageView(context); chanSelectorIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDownDrawer, 0)); selectorContainer.addView(chanSelectorIcon, (int) (24f * density), (int) (24f * density)); ((LinearLayout.LayoutParams) chanSelectorIcon.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL | Gravity.END; headerView = linearLayout; inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); chans.add(new ListItem(ListItem.ITEM_DIVIDER, 0, 0, null)); int color = ResourceUtils.getColor(context, R.attr.drawerIconColor); ChanManager manager = ChanManager.getInstance(); Collection<String> availableChans = manager.getAvailableChanNames(); for (String chanName : availableChans) { ChanConfiguration configuration = ChanConfiguration.get(chanName); if (configuration.getOption(ChanConfiguration.OPTION_READ_POSTS_COUNT)) { watcherSupportSet.add(chanName); } Drawable drawable = manager.getIcon(chanName, color); chanIcons.put(chanName, drawable); chans.add( new ListItem(ListItem.ITEM_CHAN, chanName, null, null, configuration.getTitle(), 0, drawable)); } if (availableChans.size() == 1) { selectorContainer.setVisibility(View.GONE); } }
From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java
private void configContentView() { if (mContentView instanceof TextView) { TextView tv = (TextView) mContentView; tv.setText(mText);// www.jav a 2s . c o m } else { TextView tv = (TextView) mContentView.findViewById(mTextViewId); if (tv != null) tv.setText(mText); } mContentView.setPadding(mPadding, mPadding, mPadding, mPadding); if (mShowArrow) { mArrowView = new ImageView(mContext); mArrowView.setImageDrawable(mArrowDrawable); LinearLayoutCompat.LayoutParams arrowLayoutParams; if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowWidth, (int) mArrowHeight, 0); } else { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowHeight, (int) mArrowWidth, 0); } mArrowView.setLayoutParams(arrowLayoutParams); LinearLayoutCompat linearLayout = new LinearLayoutCompat(mContext); linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation( mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayoutCompat.HORIZONTAL : LinearLayoutCompat.VERTICAL); int padding = mAnimated ? mAnimationPadding : (int) SimpleTooltipUtils.pxFromDp(4); linearLayout.setPadding(padding, padding, padding, padding); if (mGravity == Gravity.TOP || mGravity == Gravity.START) { linearLayout.addView(mContentView); linearLayout.addView(mArrowView); } else { linearLayout.addView(mArrowView); linearLayout.addView(mContentView); } LinearLayoutCompat.LayoutParams contentViewParams = new LinearLayoutCompat.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); contentViewParams.gravity = Gravity.CENTER; mContentView.setLayoutParams(contentViewParams); mContentLayout = linearLayout; } else { mContentLayout = mContentView; mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } mContentLayout.setVisibility(View.INVISIBLE); mPopupWindow.setContentView(mContentLayout); }
From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java
private void configContentView() { if (mContentView instanceof TextView) { TextView tv = (TextView) mContentView; tv.setText(mText);/*from w w w . java 2 s. co m*/ } else { TextView tv = (TextView) mContentView.findViewById(mTextViewId); if (tv != null) tv.setText(mText); } mContentView.setPadding((int) mPadding, (int) mPadding, (int) mPadding, (int) mPadding); if (mShowArrow) { mArrowView = new ImageView(mContext); mArrowView.setImageDrawable(mArrowDrawable); LinearLayoutCompat.LayoutParams arrowLayoutParams; if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowWidth, (int) mArrowHeight, 0); } else { arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowHeight, (int) mArrowWidth, 0); } mArrowView.setLayoutParams(arrowLayoutParams); LinearLayoutCompat linearLayout = new LinearLayoutCompat(mContext); linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.setOrientation( mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayoutCompat.HORIZONTAL : LinearLayoutCompat.VERTICAL); int padding = mAnimated ? mAnimationPadding : (int) SimpleTooltipUtils.pxFromDp(4); linearLayout.setPadding(padding, padding, padding, padding); if (mGravity == Gravity.TOP || mGravity == Gravity.START) { linearLayout.addView(mContentView); linearLayout.addView(mArrowView); } else { linearLayout.addView(mArrowView); linearLayout.addView(mContentView); } LinearLayoutCompat.LayoutParams contentViewParams = new LinearLayoutCompat.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); contentViewParams.gravity = Gravity.CENTER; mContentView.setLayoutParams(contentViewParams); mContentLayout = linearLayout; } else { mContentLayout = mContentView; mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } mContentLayout.setVisibility(View.INVISIBLE); mPopupWindow.setContentView(mContentLayout); }
From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java
/** * Called by Constructor to provide fragment transitions. The default implementation assigns * transitions based on {@link #getUiStyle()}: * <ul>//from w w w . jav a2 s . c o m * <li> {@link #UI_STYLE_REPLACE} Slide from/to end(right) for enter transition, slide from/to * start(left) for exit transition, shared element enter transition is set to ChangeBounds. * <li> {@link #UI_STYLE_ENTRANCE} Enter transition is set to slide from both sides, exit * transition is same as {@link #UI_STYLE_REPLACE}, no shared element enter transition. * <li> {@link #UI_STYLE_ACTIVITY_ROOT} Enter transition is set to null and app should rely on * activity transition, exit transition is same as {@link #UI_STYLE_REPLACE}, no shared element * enter transition. * </ul> * <p/> * The default implementation heavily relies on {@link GuidedActionsStylist} and * {@link GuidanceStylist} layout, app may override this method when modifying the default * layout of {@link GuidedActionsStylist} or {@link GuidanceStylist}. * <p/> * TIP: because the fragment view is removed during fragment transition, in general app cannot * use two Visibility transition together. Workaround is to create your own Visibility * transition that controls multiple animators (e.g. slide and fade animation in one Transition * class). */ protected void onProvideFragmentTransitions() { if (Build.VERSION.SDK_INT >= 21) { final int uiStyle = getUiStyle(); if (uiStyle == UI_STYLE_REPLACE) { Object enterTransition = TransitionHelper.createFadeAndShortSlide(Gravity.END); TransitionHelper.exclude(enterTransition, android.support.v17.leanback.R.id.guidedstep_background, true); TransitionHelper.exclude(enterTransition, android.support.v17.leanback.R.id.guidedactions_sub_list_background, true); TransitionHelper.setEnterTransition(this, enterTransition); Object fade = TransitionHelper .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT); TransitionHelper.include(fade, android.support.v17.leanback.R.id.guidedactions_sub_list_background); Object changeBounds = TransitionHelper.createChangeBounds(false); Object sharedElementTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(sharedElementTransition, fade); TransitionHelper.addTransition(sharedElementTransition, changeBounds); TransitionHelper.setSharedElementEnterTransition(this, sharedElementTransition); } else if (uiStyle == UI_STYLE_ENTRANCE) { if (entranceTransitionType == SLIDE_FROM_SIDE) { Object fade = TransitionHelper .createFadeTransition(TransitionHelper.FADE_IN | TransitionHelper.FADE_OUT); TransitionHelper.include(fade, android.support.v17.leanback.R.id.guidedstep_background); Object slideFromSide = TransitionHelper.createFadeAndShortSlide(Gravity.END | Gravity.START); //TransitionHelper.include(slideFromSide, android.support.v17.leanback.R.id.content_fragment); TransitionHelper.include(slideFromSide, android.support.v17.leanback.R.id.action_fragment_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, fade); TransitionHelper.addTransition(enterTransition, slideFromSide); TransitionHelper.setEnterTransition(this, enterTransition); } else { Object slideFromBottom = TransitionHelper.createFadeAndShortSlide(Gravity.BOTTOM); TransitionHelper.include(slideFromBottom, android.support.v17.leanback.R.id.guidedstep_background_view_root); Object enterTransition = TransitionHelper.createTransitionSet(false); TransitionHelper.addTransition(enterTransition, slideFromBottom); TransitionHelper.setEnterTransition(this, enterTransition); } // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } else if (uiStyle == UI_STYLE_ACTIVITY_ROOT) { // for Activity root, we don't need enter transition, use activity transition TransitionHelper.setEnterTransition(this, null); // No shared element transition TransitionHelper.setSharedElementEnterTransition(this, null); } // exitTransition is same for all style Object exitTransition = TransitionHelper.createFadeAndShortSlide(Gravity.START); TransitionHelper.exclude(exitTransition, android.support.v17.leanback.R.id.guidedstep_background, true); TransitionHelper.exclude(exitTransition, android.support.v17.leanback.R.id.guidedactions_sub_list_background, true); TransitionHelper.setExitTransition(this, exitTransition); } }
From source file:ca.mymenuapp.ui.debug.DebugAppContainer.java
@Override public ViewGroup get(final Activity activity, MyMenuApp app) { this.app = app; this.activity = activity; drawerContext = activity;/*from w ww. jav a2 s. c o m*/ activity.setContentView(R.layout.debug_activity_frame); // Manually find the debug drawer and inflate the drawer layout inside of it. ViewGroup drawer = findById(activity, R.id.debug_drawer); LayoutInflater.from(drawerContext).inflate(R.layout.debug_drawer_content, drawer); // Inject after inflating the drawer layout so its views are available to inject. ButterKnife.inject(this, activity); // Set up the contextual actions to watch views coming in and out of the content area. Set<ContextualDebugActions.DebugAction<?>> debugActions = Collections.emptySet(); ContextualDebugActions contextualActions = new ContextualDebugActions(this, debugActions); content.setOnHierarchyChangeListener(HierarchyTreeChangeListener.wrap(contextualActions)); drawerLayout.setDrawerShadow(R.drawable.debug_drawer_shadow, Gravity.END); drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() { @Override public void onDrawerOpened(View drawerView) { refreshPicassoStats(); } }); // If you have not seen the debug drawer before, show it with a message if (!seenDebugDrawer.get()) { drawerLayout.postDelayed(new Runnable() { @Override public void run() { drawerLayout.openDrawer(Gravity.END); Toast.makeText(activity, R.string.debug_drawer_welcome, Toast.LENGTH_LONG).show(); } }, 1000); seenDebugDrawer.set(true); } setupNetworkSection(); setupUserInterfaceSection(); setupBuildSection(); setupDeviceSection(); setupPicassoSection(); return content; }
From source file:im.vector.fragments.GroupsFragment.java
@SuppressLint("NewApi") private void displayGroupPopupMenu(final Group group, final View actionView) { final Context context = getActivity(); final PopupMenu popup; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { popup = new PopupMenu(context, actionView, Gravity.END); } else {/* w w w. j a v a 2s .c o m*/ popup = new PopupMenu(context, actionView); } popup.getMenuInflater().inflate(R.menu.vector_home_group_settings, popup.getMenu()); CommonActivityUtils.tintMenuIcons(popup.getMenu(), ThemeUtils.getColor(context, R.attr.settings_icon_tint_color)); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.ic_action_select_remove_group: { leaveOrReject(group.getGroupId()); break; } } return false; } }); // force to display the icon try { Field[] fields = popup.getClass().getDeclaredFields(); for (Field field : fields) { if ("mPopup".equals(field.getName())) { field.setAccessible(true); Object menuPopupHelper = field.get(popup); Class<?> classPopupHelper = Class.forName(menuPopupHelper.getClass().getName()); Method setForceIcons = classPopupHelper.getMethod("setForceShowIcon", boolean.class); setForceIcons.invoke(menuPopupHelper, true); break; } } } catch (Exception e) { Log.e(LOG_TAG, "## displayGroupPopupMenu() : failed " + e.getMessage()); } popup.show(); }
From source file:email.schaal.ocreader.ListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* ww w . j a v a2s. c o m*/ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setColorSchemeResources(R.color.primary); swipeRefreshLayout.setOnRefreshListener(this); profileDrawerItem = new ProfileDrawerItem() .withName(preferences.getString(Preferences.USERNAME.getKey(), getString(R.string.app_name))) .withEmail(Preferences.URL.getString(preferences)); updateUserProfile(); IProfile profileSettingsItem = new ProfileSettingDrawerItem().withName(getString(R.string.account_settings)) .withIconTinted(true).withIcon(R.drawable.ic_settings).withTag(new Runnable() { @Override public void run() { Intent loginIntent = new Intent(ListActivity.this, LoginActivity.class); startActivityForResult(loginIntent, LoginActivity.REQUEST_CODE); } }); accountHeader = new AccountHeaderBuilder().withActivity(this) .withHeaderBackground(R.drawable.header_background) .addProfiles(profileDrawerItem, profileSettingsItem).withCurrentProfileHiddenInList(true) .withProfileImagesClickable(false).withSavedInstance(savedInstanceState) .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { @Override public boolean onProfileChanged(View view, IProfile profile, boolean current) { if (profile instanceof Tagable) { Tagable tagable = (Tagable) profile; if (tagable.getTag() instanceof Runnable) { ((Runnable) tagable.getTag()).run(); return false; } } return true; } }).build(); refreshDrawerItem = new PrimaryDrawerItem().withName(getString(R.string.action_sync)).withSelectable(false) .withIconTintingEnabled(true).withIcon(R.drawable.ic_refresh).withIdentifier(REFRESH_DRAWER_ITEM_ID) .withTag(new Runnable() { @Override public void run() { SyncService.startSync(ListActivity.this); } }); DrawerBuilder startDrawerBuilder = new DrawerBuilder().withActivity(this).withAccountHeader(accountHeader) .addStickyDrawerItems(refreshDrawerItem).withOnDrawerListener(new Drawer.OnDrawerListener() { @Override public void onDrawerOpened(View drawerView) { drawerManager.getStartAdapter().updateUnreadCount(getRealm(), isShowOnlyUnread()); } @Override public void onDrawerClosed(View drawerView) { } @Override public void onDrawerSlide(View drawerView, float slideOffset) { } }).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem.getTag() instanceof TreeItem) { TreeItem item = (TreeItem) drawerItem.getTag(); onStartDrawerItemClicked(item); return false; } else if (drawerItem.getTag() instanceof Runnable) { ((Runnable) drawerItem.getTag()).run(); } return true; } }).withSavedInstance(savedInstanceState); DrawerBuilder endDrawerBuilder = new DrawerBuilder().withActivity(this).withDrawerGravity(Gravity.END) .withSavedInstance(savedInstanceState).withShowDrawerOnFirstLaunch(true) .withOnDrawerListener(new Drawer.OnDrawerListener() { @Override public void onDrawerOpened(View drawerView) { drawerManager.getEndAdapter().updateUnreadCount(getRealm(), isShowOnlyUnread()); } @Override public void onDrawerClosed(View drawerView) { } @Override public void onDrawerSlide(View drawerView, float slideOffset) { } }).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem.getTag() instanceof Feed) { Feed feed = (Feed) drawerItem.getTag(); onEndDrawerItemClicked(feed); return false; } return true; } }); startDrawerBuilder.withToolbar(toolbar); startDrawer = startDrawerBuilder.build(); drawerManager = new DrawerManager(this, startDrawer, endDrawerBuilder.append(startDrawer), isShowOnlyUnread(), this); RecyclerView itemsRecyclerView = (RecyclerView) findViewById(R.id.items_recyclerview); layoutManager = new LinearLayoutManager(this); adapter = new SelectableItemsAdapter(getRealm(), drawerManager.getState(), this, Preferences.ORDER.getOrder(preferences), Preferences.SORT_FIELD.getString(preferences), this); fab_mark_all_read = (FloatingActionButton) findViewById(R.id.fab_mark_all_as_read); fab_mark_all_read.setOnClickListener(new View.OnClickListener() { private void onCompletion(View view) { adapter.updateItems(false); view.setEnabled(true); } @Override public void onClick(final View v) { Queries.markTemporaryFeedAsRead(getRealm(), new Realm.Transaction.OnSuccess() { @Override public void onSuccess() { onCompletion(v); } }, new Realm.Transaction.OnError() { @Override public void onError(Throwable error) { error.printStackTrace(); onCompletion(v); } }); } }); fab_mark_all_read.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(ListActivity.this, R.string.mark_all_as_read, Toast.LENGTH_SHORT).show(); return true; } }); itemsRecyclerView.setAdapter(adapter); itemsRecyclerView.setLayoutManager(layoutManager); if (savedInstanceState != null) layoutManager.onRestoreInstanceState(savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE)); itemsRecyclerView.addItemDecoration(new DividerItemDecoration(this, 40)); itemsRecyclerView.setItemAnimator(new DefaultItemAnimator()); drawerManager.getState().restoreInstanceState(getRealm(), PreferenceManager.getDefaultSharedPreferences(this)); adapter.updateItems(false); drawerManager.reloadAdapters(getRealm(), isShowOnlyUnread()); //noinspection ConstantConditions getSupportActionBar().setTitle(drawerManager.getState().getTreeItem().getName()); }
From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_stats); mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation); mScrollView = (ObservableScrollView) findViewById(R.id.game_scroll_view); mScrollView.addCallbacks(this); ViewTreeObserver vto = mScrollView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(mGlobalLayoutListener); }/* w w w . ja v a 2 s . co m*/ mScrollViewChild = findViewById(R.id.game_scroll_view_child); mDetailsContainer = findViewById(R.id.game_details_container); mDetailsContainer.setAlpha(0); mDetailsContainer.setY(1200); mHeaderBox = findViewById(R.id.header_game); mGameViewContainer = findViewById(R.id.game_photo_container); mGameImageView = (ImageView) findViewById(R.id.game_photo); mGameTimeView = (TextView) findViewById(R.id.game_time_view); mGameScoreViewLeft = (TextView) findViewById(R.id.game_score_view_left); mGameScoreViewRight = (TextView) findViewById(R.id.game_score_view_right); tickerLayout = (LinearLayout) findViewById(R.id.sidedrawer); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mTitle = (TextView) findViewById(R.id.header_title); mSubtitle = (TextView) findViewById(R.id.header_subtitle); mUpdateProgressBar = (ProgressBar) findViewById(R.id.header_progressbar); mapView = (ImageView) findViewById(R.id.game_map_view); mHasPhoto = true; mGameImageView.setColorFilter(Color.rgb(123, 123, 123), android.graphics.PorterDuff.Mode.MULTIPLY); DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); Picasso.with(this).load(R.drawable.drawable_dota_bg_dire_ancient).config(Bitmap.Config.ARGB_8888) .resize(Math.round(displayMetrics.widthPixels * PHOTO_ASPECT_RATIO * 2 / 3), displayMetrics.widthPixels * 2 / 3) .transform(new CropImageTransform(displayMetrics.heightPixels, displayMetrics.widthPixels)) .into(mGameImageView); setBundleContents(); initMapView(); mPresenter = new LiveStatsPresenter(this); mLiveTickerAdapter = new LiveTickerAdapter(this, R.layout.sidedrawer_list_item); if (savedInstanceState != null) { mLiveTickerAdapter.onRestoreInstanceState(savedInstanceState); gameCompleted = savedInstanceState.getBoolean(KEY_GAME_COMPLETE, false); } mDrawerListView = (ListView) findViewById(R.id.sidedrawer_items_list); mDrawerListView.setAdapter(mLiveTickerAdapter); mUpdateProgressAnim = new ProgressBarAnimation(mUpdateProgressBar, 2000, 0); mUpdateProgressAnim.setDuration(GAME_UPDATE_INTERVAL); mUpdateProgressAnim.setInterpolator(new LinearInterpolator()); if (!PrefUtils.hasLiveDrawerBeenShown(this)) { mDrawerLayout.openDrawer(Gravity.END); Toast.makeText(this, "Match events are shown in the right drawer", Toast.LENGTH_SHORT).show(); PrefUtils.setLiveDrawerShown(this); } }
From source file:edu.ptu.navpattern.tooltip.Tooltip.java
private PointF calculateLocation() { PointF location = new PointF(); final RectF anchorRect = calculateRectInWindow(mAnchorView); final PointF anchorCenter = new PointF(anchorRect.centerX(), anchorRect.centerY()); switch (mGravity) { case Gravity.START: location.x = anchorRect.left - mContentView.getWidth() - mMargin; location.y = anchorCenter.y - mContentView.getHeight() / 2f; break;/*from w w w. jav a 2s . c om*/ case Gravity.END: location.x = anchorRect.right + mMargin; location.y = anchorCenter.y - mContentView.getHeight() / 2f; break; case Gravity.TOP: location.x = anchorCenter.x - mContentView.getWidth() / 2f; location.y = anchorRect.top - mContentView.getHeight() - mMargin; break; case Gravity.BOTTOM: location.x = anchorCenter.x - mContentView.getWidth() / 2f; location.y = anchorRect.bottom + mMargin; break; } return location; }