android.view.Window#setFlags ( )源码实例Demo

下面列出了android.view.Window#setFlags ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: smart-farmer-android   文件: SignIn2Activity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.setFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    setContentView(R.layout.activity_sign_in2);

    btn_login = (Button) findViewById(R.id.btn_to_login);
    btn_register = (Button) findViewById(R.id.btn_to_register);

    btn_login.setOnClickListener(this);
    btn_register.setOnClickListener(this);

}
 
源代码2 项目: BaseAndroidApp   文件: AdjustStatusbar.java
@TargetApi (Build.VERSION_CODES.KITKAT)
public static void addColorAndHeight(@NonNull Activity activity) {
   if (!activity.getResources()
         .getBoolean(R.bool.should_color_status_bar)) {
      return;
   }
   View statusBar = activity.findViewById(R.id.statusBarBackground);
   if (statusBar == null) {
      return;
   }
   Window window = activity.getWindow();
   window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
         WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
   int statusBarHeight = getStatusBarHeight(activity);
   if (statusBarHeight != 0) {
      final int color = ContextCompat.getColor(activity, R.color.primary_dark);
      statusBar.getLayoutParams().height = +statusBarHeight;
      statusBar.setBackgroundColor(color);
      statusBar.setVisibility(View.VISIBLE);
   } else {
      statusBar.setVisibility(View.GONE);
   }
}
 
源代码3 项目: android_maplibui   文件: StyledDialogFragment.java
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html

    Dialog dialog = new Dialog(mContext);

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;
}
 
源代码4 项目: monolog-android   文件: SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Window window = getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    setContentView(R.layout.activity_splash);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            //显示广告
            runAd();
        }
    }, 500);
}
 
源代码5 项目: libsoftwaresync   文件: MainActivity.java
private void createUi() {
  Window appWindow = getWindow();
  appWindow.setFlags(
      WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  // Disable sleep / screen off.
  appWindow.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

  // Create the SurfaceView.
  surfaceView = findViewById(R.id.viewfinder_surface_view);

  // TextViews.
  statusTextView = findViewById(R.id.status_text);
  softwaresyncStatusTextView = findViewById(R.id.softwaresync_text);
  sensorExposureTextView = findViewById(R.id.sensor_exposure);
  sensorSensitivityTextView = findViewById(R.id.sensor_sensitivity);
  phaseTextView = findViewById(R.id.phase);

  // Controls.
  captureStillButton = findViewById(R.id.capture_still_button);
  phaseAlignButton = findViewById(R.id.phase_align_button);
  exposureSeekBar = findViewById(R.id.exposure_seekbar);
  sensitivitySeekBar = findViewById(R.id.sensitivity_seekbar);
  sensorExposureTextView.setText("Exposure: " + prettyExposureValue(currentSensorExposureTimeNs));
  sensorSensitivityTextView.setText("Sensitivity: " + currentSensorSensitivity);
}
 
源代码6 项目: smart-farmer-android   文件: SignInActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.setFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    setContentView(R.layout.activity_sign_in);

    mImgLoginRegisterClose = (ImageView) findViewById(R.id.img_login_register_close);
    mIndicatorLoginRegister = (ViewPagerIndicator) findViewById(R.id.indicator_login_register);
    mViewpagerLoginRegister = (ViewPager) findViewById(R.id.viewpager_login_register);

    mImgLoginRegisterClose.setOnClickListener(this);

    LoginRegisterAdapter adapter = new LoginRegisterAdapter(getSupportFragmentManager());
    mViewpagerLoginRegister.setAdapter(adapter);
    mIndicatorLoginRegister.setViewPager(mViewpagerLoginRegister, 0);
}
 
源代码7 项目: HayaiLauncher   文件: StatusBarColorHelper.java
public static void setStatusBarColor(final Resources resources, final Activity activity,
                                     final int color) {
    //There's no support for colored status bar in versions below KITKAT
    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;

    final Window window = activity.getWindow();
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        //LOLLIPOP+ path
        window.setStatusBarColor(color);
    } else {
        //KITKAT path
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        final int statusBarHeight = getStatusBarHeight(resources);
        final View statusBarDummy = activity.findViewById(R.id.statusBarDummyView);
        statusBarDummy.getLayoutParams().height=statusBarHeight;
        statusBarDummy.setBackgroundColor(color);
    }
}
 
源代码8 项目: shinny-futures-android   文件: BaseActivity.java
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));
    }
}
 
源代码9 项目: Twire   文件: Service.java
public static void isTranslucentActionbar(String LOG_TAG, Context context, Toolbar toolbar, Activity activity) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        Log.d(LOG_TAG, "Settings translucent status bar");

        double statusBarHeight = Math.ceil(25 * context.getResources().getDisplayMetrics().density);

        Window w = activity.getWindow(); // in Activity's onCreate() for instance
        //w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        toolbar.getLayoutParams().height = (int) (context.getResources().getDimension((R.dimen.main_toolbar_height)) + statusBarHeight);
    }
}
 
源代码10 项目: NBAPlus   文件: LollipopUtils.java
public static void hideStatusbar(Activity activity) {

    //对于Lollipop的设备,只需要在style.xml中设置colorPrimaryDark即可

    //对于4.4的设备,如下即可
    Window w = activity.getWindow();

    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
      w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
          WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      return;
    }
  }
 
源代码11 项目: CatchPiggy   文件: BaseActivity.java
private void mode2() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            Window window = getWindow();
            // Translucent status bar
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            // Translucent navigation bar
//            window.setFlags(
//                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
//                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
//                            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                            | View.SYSTEM_UI_FLAG_IMMERSIVE
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                window.setStatusBarColor(Color.TRANSPARENT);
                window.setNavigationBarColor(Color.TRANSPARENT);
            }
        }
    }
 
源代码12 项目: react-native-navigation   文件: Presenter.java
private void mergeTranslucent(StatusBarOptions options) {
    Window window = activity.getWindow();
    if (options.translucent.isTrue()) {
        window.setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
    } else if (options.translucent.isFalse() && StatusBarUtils.isTranslucent(window)) {
        window.clearFlags(FLAG_TRANSLUCENT_STATUS);
    }
}
 
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    setContentView(R.layout.activity_material_intro);

    overScrollLayout = (OverScrollViewPager) findViewById(R.id.view_pager_slides);
    viewPager = overScrollLayout.getOverScrollView();
    pageIndicator = (InkPageIndicator) findViewById(R.id.indicator);
    backButton = (ImageButton) findViewById(R.id.button_back);
    nextButton = (ImageButton) findViewById(R.id.button_next);
    skipButton = (ImageButton) findViewById(R.id.button_skip);
    messageButton = (Button) findViewById(R.id.button_message);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout_slide);
    navigationView = (LinearLayout) findViewById(R.id.navigation_view);

    adapter = new SlidesAdapter(getSupportFragmentManager());

    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(2);
    pageIndicator.setViewPager(viewPager);

    nextButtonTranslationWrapper = new NextButtonTranslationWrapper(nextButton);
    initOnPageChangeListeners();

    permissionNotGrantedClickListener = new PermissionNotGrantedClickListener(this, nextButtonTranslationWrapper);
    finishScreenClickListener = new FinishScreenClickListener();

    setBackButtonVisible();

    viewPager.post(new Runnable() {
        @Override
        public void run() {
            if (adapter.getCount() == 0) {
                finish();
            } else {
                int currentItem = viewPager.getCurrentItem();
                messageButtonBehaviourOnPageSelected.pageSelected(currentItem);
                nextButtonBehaviour(currentItem, adapter.getItem(currentItem));
            }
        }
    });
}
 
源代码14 项目: ProjectX   文件: AMWindowCompat.java
@Override
public void setTranslucentNavigation(Window window) {
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
 
源代码15 项目: Matisse-Kotlin   文件: CropImmersiveManage.java
/**
 * @param baseActivity
 * @param statusBarColor     状态栏的颜色
 * @param navigationBarColor 导航栏的颜色
 */
public static void immersiveAboveAPI23(AppCompatActivity baseActivity, boolean isMarginStatusBar
        , boolean isMarginNavigationBar, int statusBarColor, int navigationBarColor, boolean isDarkStatusBarIcon) {
    try {
        Window window = baseActivity.getWindow();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            //4.4版本及以上 5.0版本及以下
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (isMarginStatusBar && isMarginNavigationBar) {
                //5.0版本及以上
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            } else if (!isMarginStatusBar && !isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else if (!isMarginStatusBar && isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else {
                //留出来状态栏 不留出来导航栏 没找到办法。。
                return;
            }

            window.setStatusBarColor(statusBarColor);
            window.setNavigationBarColor(navigationBarColor);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码16 项目: Infinity-For-Reddit   文件: RulesActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_rules);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);

            int navBarHeight = getNavBarHeight();
            if (navBarHeight > 0) {
                recyclerView.setPadding(0, 0, 0, navBarHeight);
            }
        }
    }

    appBarLayout.setBackgroundColor(mCustomThemeWrapper.getColorPrimary());
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mSubredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);

    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper);
    recyclerView.setAdapter(mAdapter);

    //fetchRules();

    FetchRules.fetchRules(mRetrofit, mSubredditName, new FetchRules.FetchRulesListener() {
        @Override
        public void success(ArrayList<Rule> rules) {
            progressBar.setVisibility(View.GONE);
            if (rules == null || rules.size() == 0) {
                errorTextView.setVisibility(View.VISIBLE);
                errorTextView.setText(R.string.no_rule);
                errorTextView.setOnClickListener(view -> {
                });
            }
            mAdapter.changeDataset(rules);
        }

        @Override
        public void failed() {
            displayError();
        }
    });
}
 
源代码17 项目: ripple   文件: CountDownActivity.java
@TargetApi(11)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mTestRun = getIntent().getBooleanExtra(PanicActivity.EXTRA_TEST_RUN, false);

    Window window = getWindow();
    window.setBackgroundDrawable(null);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_count_down);

    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    int scale;
    if (displayMetrics.heightPixels > displayMetrics.widthPixels) {
        scale = displayMetrics.heightPixels;
    } else {
        scale = displayMetrics.widthPixels;
    }
    mCountDownNumber = (TextView) findViewById(R.id.countDownNumber);
    mCountDownNumber.setTextSize(((float) scale) * 0.45f / getResources().getDisplayMetrics().scaledDensity);

    mTouchToCancel = (TextView) findViewById(R.id.tap_anywhere_to_cancel);
    mCancelButton = (ImageView) findViewById(R.id.cancelButton);

    mCountDownAsyncTask = new CountDownAsyncTask();

    if (savedInstanceState != null && savedInstanceState.getBoolean(KEY_COUNT_DOWN_DONE, false)) {
        showDoneScreen();
    } else {
        mCountDownAsyncTask.execute();
    }

    ConstraintLayout frameRoot = findViewById(R.id.frameRoot);
    frameRoot.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            cancel();
            return true;
        }
    });

    if (Build.VERSION.SDK_INT >= 16) {
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
    } else if (Build.VERSION.SDK_INT >= 14) {
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    }

    if (Build.VERSION.SDK_INT >= 11) {
        frameRoot.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                /* If the nav bar comes back while the countdown is active,
                   that means the user clicked on the screen. Showing the
                   test dialog also triggers this, so filter on countdown */
                if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 && mCountDown > 0) {
                    cancel();
                }
            }
        });
    }
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_filtered_thing);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);
        }
    }

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setToolbarGoToTop(toolbar);

    params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();

    name = getIntent().getStringExtra(EXTRA_NAME);
    postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
    int filter = getIntent().getIntExtra(EXTRA_FILTER, Post.TEXT_TYPE);

    if (postType == PostDataSource.TYPE_USER) {
        userWhere = getIntent().getStringExtra(EXTRA_USER_WHERE);
        if (userWhere != null && !PostDataSource.USER_WHERE_SUBMITTED.equals(userWhere) && mMenu != null) {
            mMenu.findItem(R.id.action_sort_filtered_thing_activity).setVisible(false);
        }
    }

    if (savedInstanceState != null) {
        isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);

        mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit();

        if (!mNullAccessToken && mAccessToken == null) {
            getCurrentAccountAndBindView(filter);
        } else {
            bindView(filter, false);
        }
    } else {
        getCurrentAccountAndBindView(filter);
    }

    postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
}
 
源代码19 项目: PictureSelector   文件: CropImmersiveManage.java
/**
 * @param baseActivity
 * @param statusBarColor     状态栏的颜色
 * @param navigationBarColor 导航栏的颜色
 */
public static void immersiveAboveAPI23(AppCompatActivity baseActivity, boolean isMarginStatusBar
        , boolean isMarginNavigationBar, int statusBarColor, int navigationBarColor, boolean isDarkStatusBarIcon) {
    try {
        Window window = baseActivity.getWindow();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            //4.4版本及以上 5.0版本及以下
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (isMarginStatusBar && isMarginNavigationBar) {
                //5.0版本及以上
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            } else if (!isMarginStatusBar && !isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else if (!isMarginStatusBar && isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else {
                //留出来状态栏 不留出来导航栏 没找到办法。。
                return;
            }

            window.setStatusBarColor(statusBarColor);
            window.setNavigationBarColor(navigationBarColor);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码20 项目: ImmersionBar   文件: ImmersionBar.java
/**
 * 隐藏状态栏
 * Hide status bar.
 *
 * @param window the window
 */
public static void hideStatusBar(@NonNull Window window) {
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
}