Java Code Examples for android.view.Window#clearFlags()
The following examples show how to use
android.view.Window#clearFlags() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusBarUtils.java From MNProgressHUD with Apache License 2.0 | 6 votes |
/** * Flag只有在使用了FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS * 并且没有使用 FLAG_TRANSLUCENT_STATUS 的时候才有效,也就是只有在状态栏全透明的时候才有效。 * * @param window * @param bDark bDark为true时是黑色的字,为false时是白色的字 */ private static void setStatusBarModeDefault(Window window, boolean bDark) { //6.0以上 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (window == null) { return; } window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(ColorUtils.blendARGB(Color.TRANSPARENT, Color.BLACK, 0.0f)); View decorView = window.getDecorView(); if (decorView != null) { int vis = decorView.getSystemUiVisibility(); vis |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; if (bDark) { vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } else { vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } decorView.setSystemUiVisibility(vis); } } }
Example 2
Source File: ScreenUtils.java From FamilyChat with Apache License 2.0 | 6 votes |
/** * 将状态栏变为透明的 */ public static void changStatusbarTransparent(Activity activity) { //5.0以上改变状态栏颜色的方法 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //5.0以上将状态栏变为全透明 Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //改变状态栏颜色 activity.getWindow().setStatusBarColor(Color.TRANSPARENT); } //4.4改变状态栏颜色的方法 else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }
Example 3
Source File: BaseActivity.java From shinny-futures-android with GNU General Public License v3.0 | 6 votes |
protected void changeStatusBarColor(boolean isFirm) { Window window = getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); int statusBarHeight = getStatusBarHeight(this); View view = new View(this); view.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); view.getLayoutParams().height = statusBarHeight; ((ViewGroup) window.getDecorView()).addView(view); if (isFirm) view.setBackground(getResources().getDrawable(R.color.colorPrimaryDark)); else view.setBackground(getResources().getDrawable(R.color.login_simulation_hint)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (isFirm) window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)); else window.setStatusBarColor(ContextCompat.getColor(this, R.color.login_simulation_hint)); } }
Example 4
Source File: BaseActivity.java From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); Utils.DARK_THEME = Themes.isDarkTheme(this); Themes.Theme theme = Themes.getTheme(this, Utils.DARK_THEME); if (Utils.DARK_THEME) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); } setTheme(theme.getStyle()); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(statusBarColor()); } }
Example 5
Source File: StatusBarCompat.java From GalleryLayoutManager with Apache License 2.0 | 6 votes |
/** * 全屏布局模式,透明状态栏和导航栏 * @param activity */ public static void layoutFullScreen(Activity activity) { Window window = activity.getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //控制状态栏在屏幕上层,不占据屏幕布局空间 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE //保持整个View稳定,使View不会因为SystemUI的变化而做layou | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); //控制导航栏浮在屏幕上层,不占据屏幕布局空间 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); window.setNavigationBarColor(Color.TRANSPARENT); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } }
Example 6
Source File: MainActivity.java From Elephant with Apache License 2.0 | 5 votes |
/** * 切换状态栏颜色值 * @param colorValue 颜色值 */ private void changeStatusColor(int colorValue) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(ContextCompat.getColor(this, colorValue)); } }
Example 7
Source File: MainActivity.java From MultiTypeRecyclerViewAdapter with Apache License 2.0 | 5 votes |
private void handleTranslucent() { Window window = getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.setNavigationBarColor(Color.WHITE); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }
Example 8
Source File: BaseActivity.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
/** * 将状态栏背景颜色设置为透明 */ protected void setStatusBarTransparent() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } }
Example 9
Source File: StatusBarUtils.java From CloudReader with Apache License 2.0 | 5 votes |
public static void setFullScreen(Activity activity){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN| View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // 设置透明状态栏,这样才能让 ContentView 向上 activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }
Example 10
Source File: Utility.java From stockita-point-of-sale with MIT License | 5 votes |
/** * This method to will set the color of the statusbar to */ public static void changeTheStatusbarColor(Activity activity, int colorResource) { /** * Change the color of the status bar */ Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (Build.VERSION.SDK_INT >= 23) { window.setStatusBarColor(ContextCompat.getColor(activity, colorResource)); } else { window.setStatusBarColor(activity.getResources().getColor(colorResource)); } }
Example 11
Source File: SystemBarUtils.java From MarkdownEditors with Apache License 2.0 | 5 votes |
/** android 6.0设置字体颜色 */ @TargetApi(Build.VERSION_CODES.M) public static void setStatusBarDarkModeForM(Window window) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; window.getDecorView().setSystemUiVisibility(systemUiVisibility); }
Example 12
Source File: Utils.java From Musicoco with Apache License 2.0 | 5 votes |
public static void transitionStatusBar(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //该参数指布局能延伸到navigationbar,我们场景中不应加这个参数 // | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } }
Example 13
Source File: BaseActivity.java From RecyclerViewAdapter with Apache License 2.0 | 5 votes |
public void setStatusBarHide() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } }
Example 14
Source File: OtherUtils.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * 切换状态栏颜色 */ public static void changeStatusBarColor(Activity activity, int color) { //5.0以上改变状态栏颜色的方法 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //5.0以上将状态栏变为全透明 Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //改变状态栏颜色 activity.getWindow().setStatusBarColor(color); } //4.4改变状态栏颜色的方法 else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //向根布局中添加一个和状态栏一样高度的View ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView(); View statusBarView = new View(activity); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity)); statusBarView.setBackgroundColor(color); decorView.addView(statusBarView, lp); } }
Example 15
Source File: ScreenLocker.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
public void hide() { setVisibility(GONE); if(activity != null) { Window win = activity.getWindow(); win.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } clearLockTasks(); reset(); }
Example 16
Source File: StatusBarUtil.java From StatusBarUtil with Apache License 2.0 | 5 votes |
/** * 设置纯色状态栏(自定义颜色,alpha) * * @param activity 目标activity * @param color 状态栏颜色值 * @param alpha 状态栏透明度 */ public static void setColor(@NonNull Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int alpha) { WeakReference<Activity> activityWeakReference = new WeakReference<>(activity); Window window = activityWeakReference.get().getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(cipherColor(color, alpha)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); setTranslucentView((ViewGroup) window.getDecorView(), color, alpha); setRootView(activityWeakReference.get(), true); } }
Example 17
Source File: StatusBarHelper.java From monero-wallet-android-app with MIT License | 4 votes |
@TargetApi(19) public static void translucent(Window window, @ColorInt int colorOn5x) { if (!supportTranslucent()) { // 版本小于4.4,绝对不考虑沉浸式 return; } // 小米和魅族4.4 以上版本支持沉浸式 if (DeviceHelper.isMeizu() || DeviceHelper.isMIUI()) { window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); return; } if (NotchHelper.isNotchOfficialSupport()) { handleDisplayCutoutMode(window); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && supportTransclentStatusBar6()) { // android 6以后可以改状态栏字体颜色,因此可以自行设置为透明 // ZUK Z1是个另类,自家应用可以实现字体颜色变色,但没开放接口 window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } else { // android 5不能修改状态栏字体颜色,因此直接用FLAG_TRANSLUCENT_STATUS,nexus表现为半透明 // 魅族和小米的表现如何? // update: 部分手机运用FLAG_TRANSLUCENT_STATUS时背景不是半透明而是没有背景了。。。。。 // window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // 采取setStatusBarColor的方式,部分机型不支持,那就纯黑了,保证状态栏图标可见 window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(colorOn5x); } // } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // // android4.4的默认是从上到下黑到透明,我们的背景是白色,很难看,因此只做魅族和小米的 // } else if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1){ // // 如果app 为白色,需要更改状态栏颜色,因此不能让19一下支持透明状态栏 // Window window = activity.getWindow(); // Integer transparentValue = getStatusBarAPITransparentValue(activity); // if(transparentValue != null) { // window.getDecorView().setSystemUiVisibility(transparentValue); // } } }
Example 18
Source File: EBrowserActivity.java From appcan-android with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(null); if (!EResources.init(this)) { loadResError(); return; } if (!AppCan.ACTION_APPCAN_SDK.equals(getIntent().getAction())) { startMaskActivity(); } else { startCustomMaskActivity(getIntent()); } mVisable = true; Window activityWindow = getWindow(); ESystemInfo.getIntence().init(this); mBrowser = new EBrowser(this); mEHandler = new EHandler(Looper.getMainLooper()); initEngineUI(); mBrowserAround = new EBrowserAround(this); setContentView(mEBrwMainFrame); initInternalBranch(); //启动图超时关闭处理。特殊的:有config.xml中的removeloading为true时,则认为启动图由JS代码控制关闭,引擎不做超时了 Message loadDelayMsg = mEHandler .obtainMessage(EHandler.F_MSG_LOAD_TIMEOUT_HIDE_SH); long delay = 3 * 1000L; if (mSipBranch) { delay = 1000L; } mEHandler.sendMessageDelayed(loadDelayMsg, delay); WWidgetData wWidgetData=getIntent().getParcelableExtra(KET_WIDGET_DATE); getIntent().removeExtra(KET_WIDGET_DATE);//删除intent中的数据,避免传递给网页 // maybe start by other app if (wWidgetData == null || TextUtils.isEmpty(wWidgetData.m_indexUrl)) { wWidgetData = AppCan.getInstance().getRootWidgetData(); } initEngine(wWidgetData); EUtil.printeBackup(savedInstanceState, "onCreate"); // EUtil.checkAndroidProxy(getBaseContext()); handleIntent(getIntent()); PushRecieveMsgReceiver.setContext(this); globalSlidingMenu = new SlidingMenu(this); globalSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); // globalSlidingMenu.setShadowWidthRes(EUExUtil.getResDimenID("shadow_width")); // globalSlidingMenu.setShadowDrawable(EUExUtil.getResDrawableID("shadow")); // globalSlidingMenu.setShadowWidthRes(R.dimen.shadow_width); // globalSlidingMenu.setShadowDrawable(R.drawable.shadow); // globalSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); // globalSlidingMenu.setFadeDegree(0.35f); // globalSlidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); // globalSlidingMenu.setMenu(R.layout.menu_frame); // globalSlidingMenu.setMode(SlidingMenu.LEFT_RIGHT); // // globalSlidingMenu.setSecondaryMenu(R.layout.menu_frame_two); // globalSlidingMenu.setSecondaryShadowDrawable(R.drawable.shadowright); // globalSlidingMenu.setBehindWidthRes(R.dimen.slidingmenu_width); // globalSlidingMenu.setBehindWidthRes(0); reflectionPluginMethod("onActivityCreate"); try { activityWindow.clearFlags( WindowManager.LayoutParams.class.getField( "FLAG_NEEDS_MENU_KEY").getInt(null)); } catch (Exception e) { } //TODO 新的更精准的前后台监听,待完善 ActivityActionRecorder.getInstance().registerTriggerListener(new ActivityActionRecorder.AppBackgroundStatusListener() { @Override public void onEnterBackground() { isForground = false; if (null != mBrowser) { mBrowser.onAppPause(); } if (null != mBrowserAround) { mBrowserAround.onPause(); } } @Override public void onEnterForground() { if (null != mBrowser) { mBrowser.onAppResume(); } if (null != mBrowserAround) { mBrowserAround.onResume(); } isForground = true; } }); }
Example 19
Source File: VaultManagerActivity.java From braintree-android-drop-in with MIT License | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bt_vault_management_activity); mLoadingViewSwitcher = findViewById(R.id.bt_loading_view_switcher); RecyclerView vaultManagerView = findViewById(R.id.bt_vault_manager_list); View closeButton = findViewById(R.id.bt_vault_manager_close); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); try { mBraintreeFragment = getBraintreeFragment(); } catch (InvalidArgumentException e) { finish(e); } ArrayList<PaymentMethodNonce> nonces; if (savedInstanceState == null) { nonces = getIntent().getParcelableArrayListExtra(EXTRA_PAYMENT_METHOD_NONCES); } else { nonces = savedInstanceState.getParcelableArrayList(EXTRA_PAYMENT_METHOD_NONCES); } mAdapter.setPaymentMethodNonces(nonces); vaultManagerView.setLayoutManager(new LinearLayoutManager( this, RecyclerView.VERTICAL, false)); vaultManagerView.setAdapter(mAdapter); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(Color.TRANSPARENT); } }
Example 20
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Defaults.setupInitialValues(getApplicationContext(), getIntent()); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(main_layout_id); isMultipleSelection = (1 != Defaults.MAX_IMAGE_SELECTION); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImagePickerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(container); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(adapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image // Get gallery photos in a new UI thread like AsyncTask to update UI changes properly new FetchImages().execute(); }