Example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE

List of usage examples for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE

Introduction

In this page you can find the example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE.

Prototype

int SYSTEM_UI_FLAG_LAYOUT_STABLE

To view the source code for android.view View SYSTEM_UI_FLAG_LAYOUT_STABLE.

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : When using other layout flags, we would like a stable view of the content insets given to #fitSystemWindows(Rect) .

Usage

From source file:gl.iglou.scenegraph.MatModeInterface.java

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        decorView.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
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    }//from   ww  w.jav  a2  s  .  c om
}

From source file:org.uoyabause.android.YabauseHandler.java

/** Called when the activity is first created. */
@Override/* www . ja  va 2  s .c  o m*/
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(Yabause.this);
    boolean lock_landscape = sharedPref.getBoolean("pref_landscape", false);
    if (lock_landscape == true) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }

    super.onCreate(savedInstanceState);
    System.gc();

    YabauseApplication application = (YabauseApplication) getApplication();
    mTracker = application.getDefaultTracker();

    setContentView(R.layout.main);
    getWindow().setSustainedPerformanceMode(true);
    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.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
                    | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
    if (sharedPref.getBoolean("pref_analog_pad", false) == true) {
        mNavigationView.setCheckedItem(R.id.pad_mode);
    }

    DrawerLayout.DrawerListener drawerListener = new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View view, float v) {

        }

        @Override
        public void onDrawerOpened(View view) {
            if (menu_showing == false) {
                menu_showing = true;
                YabauseRunnable.pause();
                audio.mute(audio.SYSTEM);
                String name = YabauseRunnable.getGameTitle();
                TextView tx = (TextView) findViewById(R.id.menu_title);
                if (tx != null) {
                    tx.setText(name);
                }

                if (adView != null) {
                    LinearLayout lp = (LinearLayout) findViewById(R.id.navilayer);
                    if (lp != null) {
                        final int mCount = lp.getChildCount();
                        boolean find = false;
                        for (int i = 0; i < mCount; ++i) {
                            final View mChild = lp.getChildAt(i);
                            if (mChild == adView) {
                                find = true;
                            }
                        }
                        if (find == false) {
                            lp.addView(adView);
                        }
                        AdRequest adRequest = new AdRequest.Builder()
                                .addTestDevice("303A789B146C169D4BDB5652D928FF8E").build();
                        adView.loadAd(adRequest);
                    }
                }

            }
        }

        @Override
        public void onDrawerClosed(View view) {

            if (waiting_reault == false && menu_showing == true) {
                menu_showing = false;
                YabauseRunnable.resume();
                audio.unmute(audio.SYSTEM);
            }

        }

        @Override
        public void onDrawerStateChanged(int i) {
        }
    };
    this.mDrawerLayout.setDrawerListener(drawerListener);

    audio = new YabauseAudio(this);

    Intent intent = getIntent();
    String game = intent.getStringExtra("org.uoyabause.android.FileName");
    if (game != null && game.length() > 0) {
        YabauseStorage storage = YabauseStorage.getStorage();
        gamepath = storage.getGamePath(game);
    } else
        gamepath = "";

    String exgame = intent.getStringExtra("org.uoyabause.android.FileNameEx");
    if (exgame != null) {
        gamepath = exgame;
    }

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    readPreferences();

    padm = PadManager.getPadManager();
    padm.loadSettings();
    waiting_reault = false;

    handler = new YabauseHandler(this);
    yabauseThread = new YabauseRunnable(this);

    UiModeManager uiModeManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() != Configuration.UI_MODE_TYPE_TELEVISION) {
        SharedPreferences prefs = getSharedPreferences("private", Context.MODE_PRIVATE);
        Boolean hasDonated = prefs.getBoolean("donated", false);
        if (hasDonated) {
            adView = null;
        } else {
            adView = new AdView(this);
            adView.setAdUnitId(getString(R.string.banner_ad_unit_id2));
            adView.setAdSize(AdSize.BANNER);
            AdRequest adRequest = new AdRequest.Builder().build();
            adView.loadAd(adRequest);
            adView.setAdListener(new AdListener() {
                @Override
                public void onAdOpened() {
                    // Save app state before going to the ad overlay.
                }
            });
        }
    } else {
        adView = null;
    }

}

From source file:com.fastbootmobile.encore.app.ArtistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_artist);

    mHandler = new Handler();

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT);

    if (savedInstanceState == null) {
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = getIntent().getExtras();
    } else {/* ww  w.ja  v a  2s  .c om*/
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new ArtistFragment();
        fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit();
    }

    mActiveFragment.setArguments(mHero, mInitialIntent);

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View fab = mActiveFragment.findViewById(R.id.fabPlay);
                fab.setVisibility(View.VISIBLE);

                // get the center for the clipping circle
                int cx = fab.getMeasuredWidth() / 2;
                int cy = fab.getMeasuredHeight() / 2;

                // get the final radius for the clipping circle
                final int finalRadius = fab.getWidth();

                // create and start the animator for this view
                // (the start radius is zero)
                Animator anim;
                if (mIsEntering) {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius);
                } else {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0);
                }
                anim.setInterpolator(new DecelerateInterpolator());
                anim.start();

                fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f);
                fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f);
                fab.animate().translationX(0.0f).translationY(0.0f)
                        .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime))
                        .setInterpolator(new DecelerateInterpolator()).start();

                final View artistName = mActiveFragment.findViewById(R.id.tvArtist);
                if (artistName != null) {
                    cx = artistName.getMeasuredWidth() / 4;
                    cy = artistName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy);

                    if (mIsEntering) {
                        artistName.setVisibility(View.INVISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300);
                    } else {
                        artistName.setVisibility(View.VISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0);
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

From source file:com.gigathinking.simpleapplock.Welcome.java

@TargetApi(19)
private void startImmersiveMode(View view) {
    view.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_STICKY);
}

From source file:com.example.android.immersive.ImmersiveDrawerActivity.java

private void showSystemUI() {
    mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

From source file:io.v.android.apps.syncslides.PresentationActivity.java

/**
 * Set the system UI to be immersive or not.
 *//* www  .  j  a  va  2s.c  o  m*/
public void setUiImmersive(boolean immersive) {
    if (immersive) {
        getSupportActionBar().hide();
        getWindow().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
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    } else {
        getSupportActionBar().show();
        // See the comment at the top of fragment_slide_list.xml for why we don't simply
        // use View.SYSTEM_UI_FLAG_VISIBLE.
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
}

From source file:com.oceansky.yellow.app.ArtistActivity.java

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_artist);

    mHandler = new Handler();

    FragmentManager fm = getSupportFragmentManager();
    mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT);

    if (savedInstanceState == null) {
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = getIntent().getExtras();
    } else {/*  w  w w  .  j a  v a  2 s . co m*/
        mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO);
        mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT);
    }

    if (mActiveFragment == null) {
        mActiveFragment = new ArtistFragment();
        fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit();
    }

    try {
        mActiveFragment.setArguments(mHero, mInitialIntent);
    } catch (IllegalStateException e) {
        Log.e(TAG, "Invalid artist!", e);
    }

    // Remove the activity title as we don't want it here
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle("");
    }

    mIsEntering = true;

    if (Utils.hasLollipop()) {
        setEnterSharedElementCallback(new SharedElementCallback() {
            @Override
            public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                View fab = mActiveFragment.findViewById(R.id.fabPlay);
                fab.setVisibility(View.VISIBLE);

                // get the center for the clipping circle
                int cx = fab.getMeasuredWidth() / 2;
                int cy = fab.getMeasuredHeight() / 2;

                // get the final radius for the clipping circle
                final int finalRadius = fab.getWidth();

                // create and start the animator for this view
                // (the start radius is zero)
                Animator anim;
                if (mIsEntering) {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius);
                } else {
                    anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0);
                }
                anim.setInterpolator(new DecelerateInterpolator());
                anim.start();

                fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f);
                fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f);
                fab.animate().translationX(0.0f).translationY(0.0f)
                        .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime))
                        .setInterpolator(new DecelerateInterpolator()).start();

                final View artistName = mActiveFragment.findViewById(R.id.tvArtist);
                if (artistName != null) {
                    cx = artistName.getMeasuredWidth() / 4;
                    cy = artistName.getMeasuredHeight() / 2;
                    final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
                    final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy);

                    if (mIsEntering) {
                        artistName.setVisibility(View.INVISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300);
                    } else {
                        artistName.setVisibility(View.VISIBLE);
                        Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0);
                    }
                }
            }
        });
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

From source file:com.google.android.apps.muzei.MainFragment.java

@Override
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
    // Set up the action bar
    final View actionBarContainer = view.findViewById(R.id.action_bar_container);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        actionBarContainer.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x44000000, 8, Gravity.TOP));
    }//w  ww. j av a  2s .c  o m
    final Toolbar toolbar = view.findViewById(R.id.toolbar);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity != null) {
        activity.setSupportActionBar(toolbar);
        activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    // Set up the container for the child fragments
    final View container = view.findViewById(R.id.container);
    if (savedInstanceState == null) {
        FirebaseAnalytics.getInstance(getActivity()).setCurrentScreen(getActivity(), "ArtDetail",
                ArtDetailFragment.class.getSimpleName());
        getChildFragmentManager().beginTransaction().replace(R.id.container, new ArtDetailFragment()).commit();
    }

    // Set up the bottom nav
    final BottomNavigationView bottomNavigationView = view.findViewById(R.id.bottom_nav);
    bottomNavigationView
            .setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
                    if (getChildFragmentManager().isStateSaved()) {
                        // Can't navigate after the state is saved
                        return false;
                    }
                    switch (item.getItemId()) {
                    case R.id.main_art_details:
                        FirebaseAnalytics.getInstance(getContext()).setCurrentScreen(getActivity(), "ArtDetail",
                                ArtDetailFragment.class.getSimpleName());
                        getChildFragmentManager().beginTransaction()
                                .replace(R.id.container, new ArtDetailFragment())
                                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
                        return true;
                    case R.id.main_choose_source:
                        FirebaseAnalytics.getInstance(getContext()).setCurrentScreen(getActivity(),
                                "ChooseSource", ChooseSourceFragment.class.getSimpleName());
                        getChildFragmentManager().popBackStack("main",
                                FragmentManager.POP_BACK_STACK_INCLUSIVE);
                        getChildFragmentManager().beginTransaction()
                                .replace(R.id.container, new ChooseSourceFragment()).addToBackStack("main")
                                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
                        return true;
                    case R.id.main_effects:
                        FirebaseAnalytics.getInstance(getContext()).setCurrentScreen(getActivity(), "Effects",
                                EffectsFragment.class.getSimpleName());
                        getChildFragmentManager().popBackStack("main",
                                FragmentManager.POP_BACK_STACK_INCLUSIVE);
                        getChildFragmentManager().beginTransaction()
                                .replace(R.id.container, new EffectsFragment()).addToBackStack("main")
                                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit();
                        return true;
                    default:
                        return false;
                    }
                }
            });
    bottomNavigationView.setOnNavigationItemReselectedListener(
            new BottomNavigationView.OnNavigationItemReselectedListener() {
                @Override
                public void onNavigationItemReselected(@NonNull final MenuItem item) {
                    if (item.getItemId() == R.id.main_art_details) {
                        getActivity().getWindow().getDecorView()
                                .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
                                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
                                        | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
                    }
                }
            });

    // Send the correct window insets to each view
    ViewCompat.setOnApplyWindowInsetsListener(view, new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat insets) {
            // Ensure the action bar container gets the appropriate insets
            ViewCompat.dispatchApplyWindowInsets(actionBarContainer,
                    insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(),
                            insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0));
            ViewCompat.dispatchApplyWindowInsets(container, insets.replaceSystemWindowInsets(
                    insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0));
            ViewCompat.dispatchApplyWindowInsets(bottomNavigationView,
                    insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), 0,
                            insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()));
            return insets;
        }
    });

    // Listen for visibility changes to know when to hide our views
    view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int vis) {
            final boolean visible = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) == 0;

            actionBarContainer.setVisibility(View.VISIBLE);
            actionBarContainer.animate().alpha(visible ? 1f : 0f).setDuration(200)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            if (!visible) {
                                actionBarContainer.setVisibility(View.GONE);
                            }
                        }
                    });

            bottomNavigationView.setVisibility(View.VISIBLE);
            bottomNavigationView.animate().alpha(visible ? 1f : 0f).setDuration(200)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            if (!visible) {
                                bottomNavigationView.setVisibility(View.GONE);
                            }
                        }
                    });
        }
    });

}

From source file:com.example.maxuan.photoutils.ViewPagerActivity.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.selectCancel) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("").setPositiveButton("", new DialogInterface.OnClickListener() {
            @Override//from  w w w  .ja  v a2 s  . co m
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        }).setNegativeButton("?", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
                    return;
                getWindow().getDecorView()
                        .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN
                                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            }
        }).create().show();
    } else if (v.getId() == R.id.checkbox) {
        Photo photo = photos.get(mViewPager.getCurrentItem());
        int pos = selectedPhotoArray.indexOfKey(photo.id);
        if (selectCheckBox.isChecked() && pos < 0) {
            if (selectedPhotoArray.size() < 9) {
                selectedPhotoArray.append(photo.id, photo);
                selectedPhotoAdapter.notifyDataSetChanged();
                recyclerView.scrollToPosition(selectedPhotoArray.indexOfKey(photo.id));
            } else {
                Toast.makeText(this, "??", Toast.LENGTH_SHORT).show();
                selectCheckBox.setChecked(false);
            }
        } else if (!selectCheckBox.isChecked() && pos >= 0) {
            selectedPhotoArray.remove(photo.id);
            selectedPhotoAdapter.notifyItemRemoved(pos);
            //                recyclerView.scrollToPosition(pos>0?pos-1:0);
        }
        completeBtn.setText(String.format(format, selectedPhotoArray.size()));
        handleSelectedPhotoView(selectedPhotoArray.size() != 0);
    } else if (v.getId() == R.id.completeBtn) {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putSparseParcelableArray("selectedPhotos", selectedPhotoArray);
        intent.putExtra("data", bundle);
        setResult(RESULT_OK, intent);
        finish();
    }
}

From source file:com.imagine.BaseActivity.java

void setUIVisibility(int mode) {
    if (setSystemUiVisibility == null) {
        return;/*from  www .j a  v a 2s.  c  o m*/
    }
    try {
        int flags = mode | commonUILayoutFlags;
        if ((android.os.Build.VERSION.SDK_INT == 16 || android.os.Build.VERSION.SDK_INT == 17)
                && (mode & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
            // if not hiding navigation, use a "stable" layout so Android 4.1 & 4.2 don't return all 0 view insets
            //Log.i(logTag, "using stable layout");
            flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        }
        setSystemUiVisibility.invoke(getWindow().getDecorView(), flags);
    } catch (IllegalAccessException ie) {
        //Log.i(logTag, "IllegalAccessException calling setSystemUiVisibility");
    } catch (InvocationTargetException ite) {
        //Log.i(logTag, "InvocationTargetException calling setSystemUiVisibility");
    }
}