Java Code Examples for android.app.ActionBar#hide()

The following examples show how to use android.app.ActionBar#hide() . 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: DashBoardActivity.java    From AndrOBD with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	// set to full screen
	getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

	// keep main display on?
	if(MainActivity.prefs.getBoolean("keep_screen_on", false))
	{
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	}
	// hide the action bar
	ActionBar actionBar = getActionBar();
	if (actionBar != null) actionBar.hide();

	// prevent activity from falling asleep
	PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
	wakeLock = Objects.requireNonNull(powerManager).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
		getString(R.string.app_name));
	wakeLock.acquire();

	/* get PIDs to be shown */
	positions = getIntent().getIntArrayExtra(POSITIONS);
}
 
Example 2
Source File: UIHelper.java    From coolreader with MIT License 6 votes vote down vote up
@SuppressLint("NewApi")
public static void ToggleFullscreen(Activity activity, boolean fullscreen) {
	if (fullscreen) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			ActionBar actionBar = activity.getActionBar();
			if (actionBar != null)
				actionBar.hide();
		} else {
			activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
		}

		activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
	} else {
		activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
		activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}
}
 
Example 3
Source File: DetailActivity.java    From Meizi with Apache License 2.0 6 votes vote down vote up
private void hideStatusBar() {
    if (Build.VERSION.SDK_INT < 16) { // old method
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else { // Jellybean and up, new hotness
        View decorView = getWindow().getDecorView();
        // Hide the status bar.
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
        // Remember that you should never show the action bar if the
        // status bar is hidden, so hide that too if necessary.
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
    }
}
 
Example 4
Source File: PermissionReceiverActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.hide();
    }
}
 
Example 5
Source File: BaseActivity.java    From iMoney with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutId());
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.hide();
    }
    ButterKnife.bind(this);
    // 将当前的Activity添加到ActivityManager中
    ActivityManager.getInstance().add(this);
    initData();
}
 
Example 6
Source File: MvpBaseActivity.java    From iMoney with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPresenter = createPresenter();
    mPresenter.attachView((V) this);
    setContentView(getLayoutId());
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.hide();
    }
    ButterKnife.bind(this);
    ActivityManager.getInstance().add(this);
    initData();
}
 
Example 7
Source File: XulDemoBaseActivity.java    From starcor.xul with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	initLayout();

	if (!TextUtils.isEmpty(mXulPageBehavior)) {
		mXulBehavior = XulActivityBehavior.createBehavior(mXulPageBehavior);
	}

	if (mXulBehavior == null) {
		initXulRender();
	} else {
		mXulBehavior.initLayout(this, mLayout);
		initXulRender();
		mXulBehavior.initXulRender(mXulPageRender);
	}

	Window window = getWindow();
	window.addFlags(Window.FEATURE_NO_TITLE|WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
	ActionBar actionBar = getActionBar();
	if (actionBar != null) {
		actionBar.hide();
	}
	mLayout.setSystemUiVisibility(
		View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
			View.SYSTEM_UI_FLAG_FULLSCREEN |
			View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
			View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
			View.SYSTEM_UI_FLAG_LOW_PROFILE |
			View.SYSTEM_UI_FLAG_LAYOUT_STABLE
	);

	setContentView(mLayout);
}
 
Example 8
Source File: HoneycombThemeHelper.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public boolean setActionBarVisible(boolean visible) {
  ActionBar actionBar = activity.getActionBar();
  if (actionBar == null) {
    if (activity instanceof Form) {
      ((Form) activity).dispatchErrorOccurredEvent((Form) activity, "ActionBar", ErrorMessages.ERROR_ACTIONBAR_NOT_SUPPORTED);
    }
    return false;
  } else if (visible) {
    actionBar.show();
  } else {
    actionBar.hide();
  }
  return true;
}
 
Example 9
Source File: UIHelper.java    From coolreader with MIT License 5 votes vote down vote up
@SuppressLint("NewApi")
public static void ToggleActionBar(Activity activity, boolean show) {
	if (!show) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			ActionBar actionBar = activity.getActionBar();
			if (actionBar != null)
				actionBar.hide();
		} else {
			activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
		}
	}
}
 
Example 10
Source File: CompatibilityImpl.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static boolean hideActionBar(Activity activity) {
    ActionBar actionBar = activity.getActionBar();
    if (actionBar == null || !actionBar.isShowing()) return false;
    actionBar.hide();
    return true;
}
 
Example 11
Source File: FolderActivity.java    From filemanager with MIT License 5 votes vote down vote up
public void setActionbarVisible(boolean visible)
{
       ActionBar actionBar = getActionBar();
       if (actionBar == null) return;
	if (visible)
	{
		actionBar.show();
           setSystemBarTranslucency(false);
	}
	else
	{
		actionBar.hide();
           setSystemBarTranslucency(true);
	}
}
 
Example 12
Source File: CoreMaterialActivity.java    From MaterialDesignSupport with MIT License 5 votes vote down vote up
private void setupActionBarVisibility() {
    final ActionBar actionBar = getActionBar();
    if (actionBar == null) {
        return;
    }

    final Intent intent = getIntent();
    if (intent == null) {
        mActionBarShowing = true;
        actionBar.show();
        return;
    }

    final Bundle bundle = intent.getExtras();
    if (bundle == null) {
        mActionBarShowing = true;
        actionBar.show();
        return;
    }

    mActionBarShowing = bundle.getBoolean(ACTION_BAR_SHOWING);
    if (mActionBarShowing == null || mActionBarShowing) {
        mActionBarShowing = true;
        actionBar.show();
        return;
    }

    mActionBarShowing = false;
    actionBar.hide();
}
 
Example 13
Source File: SystemUiHelperImplJB.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onSystemUiHidden() {
    if (mLevel == SystemUiHelper.LEVEL_LOW_PROFILE) {
        // Manually hide the action bar when in low profile mode.
        ActionBar ab = mActivity.getActionBar();
        if (ab != null) {
            ab.hide();
        }
    }

    setIsShowing(false);
}
 
Example 14
Source File: ContentFragment.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
/** Toggle whether the system UI (status bar / system bar) is visible.
 *  This also toggles the action bar visibility.
 * @param show True to show the system UI, false to hide it.
 */
void setSystemUiVisible(boolean show) {
    mSystemUiVisible = show;

    Window window = getActivity().getWindow();
    WindowManager.LayoutParams winParams = window.getAttributes();
    View view = getView();
    ActionBar actionBar = getActivity().getActionBar();

    if (show) {
        // Show status bar (remove fullscreen flag)
        window.setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Show system bar
        view.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
        // Show action bar
        actionBar.show();
    } else {
        // Add fullscreen flag (hide status bar)
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Hide system bar
        view.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
        // Hide action bar
        actionBar.hide();
    }
    window.setAttributes(winParams);
}
 
Example 15
Source File: AndroidMediaController.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void setSupportActionBar(@Nullable ActionBar actionBar) {
    this.mActionBar = actionBar;
    if (isShowing()) {
        actionBar.show();
    } else {
        actionBar.hide();
    }
}
 
Example 16
Source File: CameraActivity.java    From Eye-blink-detector with MIT License 4 votes vote down vote up
private void showCameraScannerOverlay() {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        View decorView = getWindow().getDecorView();
        // Hide the status bar.
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
        // Remember that you should never show the action bar if the
        // status bar is hidden, so hide that too if necessary.
        ActionBar actionBar = getActionBar();
        if (null != actionBar) {
            actionBar.hide();
        }
    }

    try {
        mGuideFrame = new Rect();

        mFrameOrientation = ORIENTATION_PORTRAIT;

        if (getIntent().getBooleanExtra(PRIVATE_EXTRA_CAMERA_BYPASS_TEST_MODE, false)) {
            if (!this.getPackageName().contentEquals("io.card.development")) {
                throw new IllegalStateException("Illegal access of private extra");
            }
            // use reflection here so that the tester can be safely stripped for release
            // builds.
            Class<?> testScannerClass = Class.forName("io.card.payment.CardScannerTester");
            Constructor<?> cons = testScannerClass.getConstructor(this.getClass(),
                    Integer.TYPE);
            mCardScanner = (FaceScanner) cons.newInstance(new Object[] { this,
                    mFrameOrientation });
        } else {
            mCardScanner = new FaceScanner(this, mFrameOrientation);
        }

        mCardScanner.prepareScanner();

        setPreviewLayout();

        orientationListener = new OrientationEventListener(this,
                SensorManager.SENSOR_DELAY_UI) {
            @Override
            public void onOrientationChanged(int orientation) {
                doOrientationChange(orientation);
            }
        };

    } catch (Exception e) {
        handleGeneralExceptionError(e);
    }
}
 
Example 17
Source File: StatusBarUtil.java    From V2EX with GNU General Public License v3.0 4 votes vote down vote up
public static void hideActionBar(Activity activity){
    ActionBar actionBar = activity.getActionBar();
    if (actionBar != null)
        actionBar.hide();
}
 
Example 18
Source File: LoginActivity.java    From Abelana-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mUserInfoStore = new UserInfoStore(this);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) actionBar.hide();

    // Step 1: Create a GitkitClient.
    // The configurations are set in the AndroidManifest.xml. You can also set or overwrite them
    // by calling the corresponding setters on the GitkitClient builder.
    //

    mGitkitClient = GitkitClient.newBuilder(this, new GitkitClient.SignInCallbacks() {
        // Implement the onSignIn method of GitkitClient.SignInCallbacks interface.
        // This method is called when the sign-in process succeeds. A Gitkit IdToken and the signed
        // in account information are passed to the callback.
        @Override
        public void onSignIn(IdToken idToken, GitkitUser user) {
            mUserInfoStore.saveIdTokenAndGitkitUser(idToken, user);
            showProfilePage(idToken, user);
        }

        // Implement the onSignInFailed method of GitkitClient.SignInCallbacks interface.
        // This method is called when the sign-in process fails.
        @Override
        public void onSignInFailed() {
            Toast.makeText(LoginActivity.this, "Sign in failed", Toast.LENGTH_LONG).show();
        }
    }).build();


    // Step 2: Check if there is an already signed in user.
    // If there is an already signed in user, show the ic_profile page and welcome message.
    // Otherwise, show a sign in button.
    //
    if (mUserInfoStore.isUserLoggedIn()) {
        showProfilePage(mUserInfoStore.getSavedIdToken(), mUserInfoStore.getSavedGitkitUser());
    } else {
        showSignInPage();
    }

}
 
Example 19
Source File: ListPreferenceEx.java    From VIA-AI with MIT License 4 votes vote down vote up
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
    ActionBar bar = ((Activity)mContext).getActionBar();
    if(bar != null) bar.hide();
    super.onPrepareDialogBuilder(builder);
}
 
Example 20
Source File: ImageDetailActivity.java    From android-DisplayingBitmaps with Apache License 2.0 4 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB)
@Override
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail_pager);

    // Fetch screen height and width, to use as our max size when loading images as this
    // activity runs full screen
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    // For this sample we'll use half of the longest width to resize our images. As the
    // image scaling ensures the image is larger than this, we should be left with a
    // resolution that is appropriate for both portrait and landscape. For best image quality
    // we shouldn't divide by 2, but this will use more memory and require a larger memory
    // cache.
    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams =
            new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of app memory

    // The ImageFetcher takes care of loading images into our ImageView children asynchronously
    mImageFetcher = new ImageFetcher(this, longest);
    mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), Images.imageUrls.length);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.horizontal_page_margin));
    mPager.setOffscreenPageLimit(2);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to create a more
    // immersive photo viewing experience
    if (Utils.hasHoneycomb()) {
        final ActionBar actionBar = getActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(
                new View.OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int vis) {
                        if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                            actionBar.hide();
                        } else {
                            actionBar.show();
                        }
                    }
                });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity
    final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1);
    if (extraCurrentItem != -1) {
        mPager.setCurrentItem(extraCurrentItem);
    }
}