List of usage examples for android.app Activity findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.lixplor.fastutil.utils.control.KeyboardUtil.java
public static void setOnKeyboardVisibilityChangedListener(@NonNull Activity activity, @NonNull final OnKeyboardVisibilityChangedListener onKeyboardVisibilityChangedListener) { View rootLayout = activity.findViewById(android.R.id.content); sMyOnGlobalLayoutListener = new MyOnGlobalLayoutListener(activity, onKeyboardVisibilityChangedListener); rootLayout.getViewTreeObserver().addOnGlobalLayoutListener(sMyOnGlobalLayoutListener); }
From source file:com.andryr.musicplayer.utils.NavigationUtils.java
public static void showMainActivity(Activity activity) { Intent i = new Intent(activity, MainActivity.class); ActivityCompat.startActivity(activity, i, ActivityOptionsCompat .makeSceneTransitionAnimation(activity, activity.findViewById(R.id.artwork), "artwork").toBundle()); }
From source file:com.google.android.apps.forscience.whistlepunk.TransitionUtils.java
public static Pair<View, String>[] getTransitionPairs(Activity activity, View v, String transitionName) { ArrayList<Pair<View, String>> list = new ArrayList<>(); list.add(Pair.create(v, transitionName)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { View statusBar = activity.findViewById(android.R.id.statusBarBackground); if (statusBar != null) { list.add(Pair.create(statusBar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME)); }//from w w w.j av a2 s . c om View navigationBar = activity.findViewById(android.R.id.navigationBarBackground); if (navigationBar != null) { list.add(Pair.create(navigationBar, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME)); } } return list.toArray(new Pair[list.size()]); }
From source file:com.hybris.mobile.app.commerce.utils.UIUtils.java
/** * Show/Hide the keyboard/* w w w . ja v a 2 s. c o m*/ * * @param activity */ public static void hideKeyboard(Activity activity) { if (activity != null) { InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(activity.findViewById(android.R.id.content).getWindowToken(), 0); } }
From source file:com.raza.betternts.activities.MainActivity.java
public static void showSnackBar(String text, Activity a) { CoordinatorLayout cL = (CoordinatorLayout) a.findViewById(R.id.main_layout); Snackbar snackbar = Snackbar.make(cL, text, Snackbar.LENGTH_LONG); snackbar.show();/*from w w w .j a v a 2 s .c o m*/ }
From source file:com.andryr.musicplayer.utils.NavigationUtils.java
public static void showPlaybackActivity(Activity activity) { Intent i = new Intent(activity, PlaybackActivity.class); ActivityCompat.startActivity(activity, i, ActivityOptionsCompat/*from ww w. j ava 2s . c o m*/ .makeSceneTransitionAnimation(activity, activity.findViewById(R.id.artwork_min), "artwork") .toBundle()); }
From source file:com.hybris.mobile.app.commerce.helper.OrderHelper.java
public static void createDeliverySummary(Activity activity, Order order) { TextView mOrderConfirmDeliveryAddress; TextView mOrderConfirmDeliveryMode;/*w w w . j a va 2s . c o m*/ mOrderConfirmDeliveryAddress = (TextView) activity.findViewById(R.id.order_delivery_address_text); mOrderConfirmDeliveryMode = (TextView) activity.findViewById(R.id.order_delivery_method_text); if (order != null) { if (order.getDeliveryAddress() != null && StringUtils.isNotBlank(order.getDeliveryAddress().getFormattedAddress())) { mOrderConfirmDeliveryAddress.setText(order.getDeliveryAddress().getFormattedAddress()); } // Display delivery method if (order.getDeliveryMode() != null) { mOrderConfirmDeliveryMode.setText( order.getDeliveryMode().getName() + " - " + order.getDeliveryMode().getDescription() + " - " + order.getDeliveryMode().getDeliveryCost().getFormattedValue()); } } }
From source file:org.proninyaroslav.libretorrent.core.utils.Utils.java
public static void showColoredStatusBar_KitKat(Activity activity) { RelativeLayout statusBar = (RelativeLayout) activity.findViewById(R.id.statusBarKitKat); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { statusBar.setVisibility(View.VISIBLE); }//from ww w .jav a2 s. com }
From source file:com.micabyte.android.app.BaseActivity.java
/** * Removes the reference to the activity from every view in a view hierarchy (listeners, images * etc.) in order to limit/eliminate memory leaks. This is a "fix" for memory problems on older * versions of Android; it may not be necessary on newer versions. * <p/>//from w w w .jav a2s . c om * see http://code.google.com/p/android/issues/detail?id=8488 * <p/> * If used, this method should be called in the onDestroy() method of each activity. * * @param viewID normally the id of the root layout */ protected static void unbindReferences(Activity activity, int viewID) { try { final View view = activity.findViewById(viewID); if (view != null) { unbindViewReferences(view); if (view instanceof ViewGroup) unbindViewGroupReferences((ViewGroup) view); } } catch (Throwable e) { // whatever exception is thrown just ignore it because a crash is // likely to be worse than this method not doing what it's supposed to do // e.printStackTrace(); } System.gc(); }
From source file:Main.java
public static void prepare(Activity activity, int id, int width) { if (sCoverBitmap != null) { sCoverBitmap.recycle();/*from w w w.j a v a 2 s.c o m*/ } Rect rectgle = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectgle); int statusBarHeight = rectgle.top; ViewGroup v1 = (ViewGroup) activity.findViewById(id).getRootView(); v1.setDrawingCacheEnabled(true); Bitmap source = Bitmap.createBitmap(v1.getDrawingCache()); v1.setDrawingCacheEnabled(false); if (statusBarHeight != 0) { sCoverBitmap = Bitmap.createBitmap(source, 0, statusBarHeight, source.getWidth(), source.getHeight() - statusBarHeight); source.recycle(); } else { sCoverBitmap = source; } sWidth = width; }