List of usage examples for android.app Activity getWindow
public Window getWindow()
From source file:enterprayz.megatools.Tools.java
@TargetApi(19) private static void setTranslucentStatus(Activity activity, boolean on) { Window win = activity.getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) {/*from ww w . j a va 2 s. c o m*/ winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }
From source file:com.lincoln.www.transition.TransitionHelper.java
/** * Create the transition participants required during a activity transition while * avoiding glitches with the system UI. * * @param activity The activity used as start for the transition. * @param includeStatusBar If false, the status bar will not be added as the transition * participant./*from w w w . j a va2 s .co m*/ * @return All transition participants. */ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // Avoid system UI glitches as described here: // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = null; View navBar = null; if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); navBar = decor.findViewById(android.R.id.navigationBarBackground); } // Create pair of transition participants. List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } return participants.toArray(new Pair[participants.size()]); }
From source file:utills.TransitionHelper.java
/** * Create the transition participants required during a activity transition while * avoiding glitches with the system UI. * * @param activity The activity used as start for the transition. * @param includeStatusBar If false, the status bar will not be added as the transition * participant./*w ww .j a va 2 s. com*/ * @return All transition participants. */ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // Avoid system UI glitches as described here: // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = null; if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); // Create pair of transition participants. List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } return participants.toArray(new Pair[participants.size()]); }
From source file:com.bobomee.android.common.util.ScreenUtil.java
/** * get the height of title */*from ww w. j av a2 s. com*/ */ public static int getTitleH(Activity ctx) { int contentTop = ctx.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop(); return contentTop - getStatusH(ctx); }
From source file:ng.kingsley.android.util.TransitionUtils.java
/** * Create the transition participants required during a activity transition while * avoiding glitches with the system UI. * * @param activity The activity used as start for the transition. * @param includeStatusBar If false, the status bar will not be added as the transition * participant.//from ww w . ja va 2s .c o m * @return All transition participants. */ public static Pair[] createSafePairs(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // Avoid system UI glitches as described here: // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = null; if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); // Create pair of transition participants. List<Pair> participants = new ArrayList<>(3); addNonNullViewToPairs(statusBar, participants); addNonNullViewToPairs(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } return participants.toArray(new Pair[participants.size()]); }
From source file:Main.java
public static int getSystemUiStatusBarHeight(Activity activity) { final int statusBarResId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (statusBarResId > 0) { return activity.getResources().getDimensionPixelSize(statusBarResId); } else {/*from w ww .j a va 2 s.c o m*/ final Rect rect = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); return rect.top; } }
From source file:com.azizbekian.spyur.utils.TransitionUtils.java
/** * Create the transition participants required during a activity transition while * avoiding glitches with the system UI. * * @param activity The activity used as start for the transition. * @param includeStatusBar If false, the status bar will not be added as the transition * participant.//from ww w . j a va 2 s . c o m * @return All transition participants. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) { // Avoid system UI glitches as described here: // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb View decor = activity.getWindow().getDecorView(); View statusBar = null; if (includeStatusBar) { statusBar = decor.findViewById(android.R.id.statusBarBackground); } View navBar = decor.findViewById(android.R.id.navigationBarBackground); // Create pair of transition participants. List<Pair> participants = new ArrayList<>(3); addNonNullViewToTransitionParticipants(statusBar, participants); addNonNullViewToTransitionParticipants(navBar, participants); // only add transition participants if there's at least one none-null element if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) { participants.addAll(Arrays.asList(otherParticipants)); } //noinspection unchecked return participants.toArray(new Pair[participants.size()]); }
From source file:com.bobomee.android.common.util.ScreenUtil.java
/** * shot the current screen ,with the status but the status is trans * * * @param ctx current activity/*from w w w . ja va 2 s.c o m*/ */ public static Bitmap shotActivity(Activity ctx) { View view = ctx.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bp = Bitmap.createBitmap(view.getDrawingCache(), 0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); view.setDrawingCacheEnabled(false); view.destroyDrawingCache(); return bp; }
From source file:menion.android.whereyougo.gui.extension.activity.CustomActivity.java
public static void setScreenFullscreen(Activity activity) { try {/* w w w. ja v a2s . co m*/ if (Preferences.APPEARANCE_FULLSCREEN) { activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } catch (Exception e) { // Logger.e(TAG, "setFullScreen(" + activity + ")", e); } }
From source file:com.bobomee.android.common.util.ScreenUtil.java
/** * get the height of status *//w ww. ja va 2 s . c om */ public static int getStatusH(Activity ctx) { Rect s = new Rect(); ctx.getWindow().getDecorView().getWindowVisibleDisplayFrame(s); return s.top; }