List of usage examples for android.app ActionBar isShowing
public abstract boolean isShowing();
From source file:com.pickr.fragments.PhotoFragment.java
@Override public void onClick(View view) { if (view.getId() == R.id.photoImageView) { ActionBar actionBar = getActivity().getActionBar(); if (actionBar.isShowing()) { actionBar.hide();//from ww w .ja v a 2 s . c o m } else { actionBar.show(); } } }
From source file:com.hkm.oc.wv.supportwebview.webviewSupports.java
protected void toolbartoggle() { ActionBar ab = getActionBar(); if (ab.isShowing()) ab.hide();/* w w w . j av a2 s.c om*/ else ab.show(); }
From source file:com.dycode.jepretstory.mediachooser.fragment.VideoFragment.java
@Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { // TODO Auto-generated method stub ActionBar ab = getActivity().getActionBar(); if (scrollState == ScrollState.UP) { if (ab.isShowing()) { ab.hide();/*from w ww. j ava2 s . co m*/ } } else if (scrollState == ScrollState.DOWN) { if (!ab.isShowing()) { ab.show(); } } }
From source file:com.dycode.jepretstory.mediachooser.fragment.ImageFragment.java
@Override public void onUpOrCancelMotionEvent(ScrollState scrollState) { ActionBar ab = getActivity().getActionBar(); if (scrollState == ScrollState.UP) { if (ab.isShowing()) { ab.hide();/* www . j a va 2 s .c om*/ } } else if (scrollState == ScrollState.DOWN) { if (!ab.isShowing()) { ab.show(); } } }
From source file:org.kegbot.app.HomeActivity.java
@Override protected void onStart() { super.onStart(); mCore = KegbotCore.getInstance(this); mConfig = mCore.getConfiguration();/*from w ww. j ava 2 s. c o m*/ maybeShowTapWarnings(); //for dummy pour status final Pair<String, String> qty = Units.localizeWithoutScaling(mCore.getConfiguration(), 0.0); mPourVolumeBadge.setBadgeValue(qty.first); mPourVolumeBadge.setBadgeCaption("Current " + Units.capitalizeUnits(qty.second) + " Poured"); mImageView0.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final ActionBar actionBar = getActionBar(); if (actionBar.isShowing()) { actionBar.hide(); mConfig.setShowActionBar(false); } else { actionBar.show(); mConfig.setShowActionBar(true); } } }); //for start button final Context thisContext = this; mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mConfig.useAccounts()) { final Intent intent = KegtabCommon.getAuthDrinkerActivityIntent(thisContext); startActivityForResult(intent, REQUEST_AUTHENTICATE); } else { mCore.getFlowManager().activateUserAmbiguousTap(""); } } }); mNewDrinkerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Intent intent = KegtabCommon.getCreateDrinkerActivityIntent(thisContext); startActivityForResult(intent, REQUEST_CREATE_DRINKER); } }); mTapStatusPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { //for progress bar if (mTaps.size() > 0) { final KegTap tap = mTaps.get(position); if (tap.hasCurrentKeg()) { final Models.Keg keg = tap.getCurrentKeg(); double remainml = keg.getRemainingVolumeMl(); double totalml = keg.getFullVolumeMl(); double percent = (remainml) / (totalml) * 100; final ProgressBar mTapProgress = (ProgressBar) findViewById(R.id.tapProgress); mTapProgress.setMax((int) totalml); mTapProgress.setProgress((int) remainml); final TextView mTapPercentage = (TextView) findViewById(R.id.tapPercentage); mTapPercentage.setText(String.format("%.2f", percent) + "%"); } } //for backgrounds switch (position) { case 0: mImageView0.setImageResource(R.drawable.e1); mImageView1.setBackgroundResource(R.drawable.e2); break; case 1: mImageView0.setImageResource(R.drawable.a1); mImageView1.setBackgroundResource(R.drawable.a2); break; case 2: mImageView0.setImageResource(R.drawable.b1); mImageView1.setBackgroundResource(R.drawable.b2); break; case 3: mImageView0.setImageResource(R.drawable.c1); mImageView1.setBackgroundResource(R.drawable.c2); break; case 4: mImageView0.setImageResource(R.drawable.d1); mImageView1.setBackgroundResource(R.drawable.d2); break; default: mImageView0.setImageResource(R.drawable.e1); mImageView1.setBackgroundResource(R.drawable.e2); break; } } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.gmail.charleszq.picorner.ui.ImageDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate and locate the main ImageView final View v = inflater.inflate(R.layout.image_detail_fragment, container, false); mImageView = (ImageView) v.findViewById(R.id.imageView); // photo title and author name mUserInfoContainer = v.findViewById(R.id.photo_detail_user_info); ActionBar bar = getActivity().getActionBar(); mUserInfoContainer.setVisibility(bar.isShowing() ? View.VISIBLE : View.INVISIBLE); mPhotoTitle = (TextView) v.findViewById(R.id.photo_detail_photo_title); String photoTitle = mPhoto.getTitle(); if (photoTitle == null) { photoTitle = ""; //$NON-NLS-1$ } else {/* ww w.j a v a 2 s . c om*/ if (photoTitle.length() > IConstants.MAX_PHOTO_TITLE_LEN) { photoTitle = photoTitle.substring(0, IConstants.MAX_PHOTO_TITLE_LEN) + "..."; //$NON-NLS-1$ } } StringBuilder pt = new StringBuilder(); if (mPhoto.getMediaSource() == MediaSourceType.PX500) { pt.append(getString(R.string.px500_rating)).append(" ").append(mPhoto.getRating()).append("\n"); //$NON-NLS-1$//$NON-NLS-2$ } pt.append(photoTitle); mPhotoTitle.setText(pt.toString()); mUserName = (TextView) v.findViewById(R.id.photo_detail_author_name); StringBuilder sb = new StringBuilder(); sb.append(getString(R.string.msg_by_author_name)); sb.append(" "); //$NON-NLS-1$ Author a = mPhoto.getAuthor(); if (a != null) { sb.append(mPhoto.getAuthor().getUserName() == null ? mPhoto.getAuthor().getUserId() : mPhoto.getAuthor().getUserName()); mUserName.setText(sb.toString()); } return v; }
From source file:com.polychrom.cordova.ActionBarPlugin.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { if (!plugin_actions.contains(action)) { return false; }/* w ww. java 2 s.c o m*/ final Activity ctx = (Activity) cordova; if ("isAvailable".equals(action)) { JSONObject result = new JSONObject(); result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR)); callbackContext.success(result); return true; } final ActionBar bar = ctx.getActionBar(); if (bar == null) { Window window = ctx.getWindow(); if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) { callbackContext .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!"); } else { callbackContext.error("Failed to get ActionBar"); } return true; } if (menu == null) { callbackContext.error("Options menu not initialised"); return true; } final StringBuffer error = new StringBuffer(); JSONObject result = new JSONObject(); if ("isShowing".equals(action)) { result.put("value", bar.isShowing()); } else if ("getHeight".equals(action)) { result.put("value", bar.getHeight()); } else if ("getDisplayOptions".equals(action)) { result.put("value", bar.getDisplayOptions()); } else if ("getNavigationMode".equals(action)) { result.put("value", bar.getNavigationMode()); } else if ("getSelectedNavigationItem".equals(action)) { result.put("value", bar.getSelectedNavigationIndex()); } else if ("getSubtitle".equals(action)) { result.put("value", bar.getSubtitle()); } else if ("getTitle".equals(action)) { result.put("value", bar.getTitle()); } else { try { JSONException exception = new Runnable() { public JSONException exception = null; public void run() { try { // This is a bit of a hack (should be specific to the request, not global) bases = new String[] { removeFilename(webView.getOriginalUrl()), removeFilename(webView.getUrl()) }; if ("show".equals(action)) { bar.show(); } else if ("hide".equals(action)) { bar.hide(); } else if ("setMenu".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } menu_definition = args.getJSONArray(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ctx.invalidateOptionsMenu(); } } else if ("setTabs".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } bar.removeAllTabs(); tab_callbacks.clear(); if (!buildTabs(bar, args.getJSONArray(0))) { error.append("Invalid tab bar definition"); } } else if ("setDisplayHomeAsUpEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHomeAsUp can not be null"); return; } bar.setDisplayHomeAsUpEnabled(args.getBoolean(0)); } else if ("setDisplayOptions".equals(action)) { if (args.isNull(0)) { error.append("options can not be null"); return; } final int options = args.getInt(0); bar.setDisplayOptions(options); } else if ("setDisplayShowHomeEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHome can not be null"); return; } bar.setDisplayShowHomeEnabled(args.getBoolean(0)); } else if ("setDisplayShowTitleEnabled".equals(action)) { if (args.isNull(0)) { error.append("showTitle can not be null"); return; } bar.setDisplayShowTitleEnabled(args.getBoolean(0)); } else if ("setDisplayUseLogoEnabled".equals(action)) { if (args.isNull(0)) { error.append("useLogo can not be null"); return; } bar.setDisplayUseLogoEnabled(args.getBoolean(0)); } else if ("setHomeButtonEnabled".equals(action)) { if (args.isNull(0)) { error.append("enabled can not be null"); return; } bar.setHomeButtonEnabled(args.getBoolean(0)); } else if ("setIcon".equals(action)) { if (args.isNull(0)) { error.append("icon can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setIcon(drawable); } else if ("setListNavigation".equals(action)) { JSONArray items = null; if (args.isNull(0) == false) { items = args.getJSONArray(0); } navigation_adapter.setItems(items); bar.setListNavigationCallbacks(navigation_adapter, navigation_listener); } else if ("setLogo".equals(action)) { if (args.isNull(0)) { error.append("logo can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setLogo(drawable); } else if ("setNavigationMode".equals(action)) { if (args.isNull(0)) { error.append("mode can not be null"); return; } final int mode = args.getInt(0); bar.setNavigationMode(mode); } else if ("setSelectedNavigationItem".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } bar.setSelectedNavigationItem(args.getInt(0)); } else if ("setSubtitle".equals(action)) { if (args.isNull(0)) { error.append("subtitle can not be null"); return; } bar.setSubtitle(args.getString(0)); } else if ("setTitle".equals(action)) { if (args.isNull(0)) { error.append("title can not be null"); return; } bar.setTitle(args.getString(0)); } } catch (JSONException e) { exception = e; } finally { synchronized (this) { this.notify(); } } } // Run task synchronously { synchronized (this) { ctx.runOnUiThread(this); this.wait(); } } }.exception; if (exception != null) { throw exception; } } catch (InterruptedException e) { error.append("Function interrupted on UI thread"); } } if (error.length() == 0) { if (result.length() > 0) { callbackContext.success(result); } else { callbackContext.success(); } } else { callbackContext.error(error.toString()); } return true; }
From source file:com.native5.plugins.ActionBarPlugin.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { if (!plugin_actions.contains(action)) { return false; }/* www. j a v a2s. co m*/ final Activity ctx = (Activity) cordova; if ("isAvailable".equals(action)) { JSONObject result = new JSONObject(); result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR)); callbackContext.success(result); return true; } final ActionBar bar = ctx.getActionBar(); if (bar == null) { Window window = ctx.getWindow(); if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) { callbackContext .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!"); } else { callbackContext.error("Failed to get ActionBar"); } return true; } if (menu == null) { callbackContext.error("Options menu not initialised"); return true; } final StringBuffer error = new StringBuffer(); JSONObject result = new JSONObject(); if ("isShowing".equals(action)) { result.put("value", bar.isShowing()); } else if ("getHeight".equals(action)) { result.put("value", bar.getHeight()); } else if ("getDisplayOptions".equals(action)) { result.put("value", bar.getDisplayOptions()); } else if ("getNavigationMode".equals(action)) { result.put("value", bar.getNavigationMode()); } else if ("getSelectedNavigationItem".equals(action)) { result.put("value", bar.getSelectedNavigationIndex()); } else if ("getSubtitle".equals(action)) { result.put("value", bar.getSubtitle()); } else if ("getTitle".equals(action)) { result.put("value", bar.getTitle()); } else { try { JSONException exception = new Runnable() { public JSONException exception = null; public void run() { try { // This is a bit of a hack (should be specific to the request, not global) bases = new String[] { removeFilename(webView.getOriginalUrl()), removeFilename(webView.getUrl()) }; if ("show".equals(action)) { LOG.d("native5-action-bar", "Showing Action Bar"); bar.show(); } else if ("hide".equals(action)) { bar.hide(); } else if ("setMenu".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } menu_definition = args.getJSONArray(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ctx.invalidateOptionsMenu(); } } else if ("setTabs".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } bar.removeAllTabs(); tab_callbacks.clear(); if (!buildTabs(bar, args.getJSONArray(0))) { error.append("Invalid tab bar definition"); } } else if ("setDisplayHomeAsUpEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHomeAsUp can not be null"); return; } bar.setDisplayHomeAsUpEnabled(args.getBoolean(0)); } else if ("setDisplayOptions".equals(action)) { if (args.isNull(0)) { error.append("options can not be null"); return; } final int options = args.getInt(0); bar.setDisplayOptions(options); } else if ("setDisplayShowHomeEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHome can not be null"); return; } bar.setDisplayShowHomeEnabled(args.getBoolean(0)); } else if ("setDisplayShowTitleEnabled".equals(action)) { if (args.isNull(0)) { error.append("showTitle can not be null"); return; } bar.setDisplayShowTitleEnabled(args.getBoolean(0)); } else if ("setDisplayUseLogoEnabled".equals(action)) { if (args.isNull(0)) { error.append("useLogo can not be null"); return; } bar.setDisplayUseLogoEnabled(args.getBoolean(0)); } else if ("setHomeButtonEnabled".equals(action)) { if (args.isNull(0)) { error.append("enabled can not be null"); return; } bar.setHomeButtonEnabled(args.getBoolean(0)); } else if ("setIcon".equals(action)) { if (args.isNull(0)) { error.append("icon can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setIcon(drawable); } else if ("setListNavigation".equals(action)) { JSONArray items = null; if (args.isNull(0) == false) { items = args.getJSONArray(0); } navigation_adapter.setItems(items); bar.setListNavigationCallbacks(navigation_adapter, navigation_listener); } else if ("setLogo".equals(action)) { String uri = args.getString(0); if (args.isNull(0)) { error.append("logo can not be null"); return; } // try { // InputStream ims = ctx.getAssets().open(uri); Drawable drawable = getDrawableForURI(uri); // Drawable.createFromStream(ims, null); bar.setLogo(drawable); bar.setBackgroundDrawable(getDrawableForURI("images/logo-bg.png")); // } catch (IOException e) { // e.printStackTrace(); // } } else if ("setNavigationMode".equals(action)) { if (args.isNull(0)) { error.append("mode can not be null"); return; } final int mode = args.getInt(0); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else if ("setSelectedNavigationItem".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } bar.setSelectedNavigationItem(args.getInt(0)); } else if ("setSelectedTab".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } LOG.d("setSelectedTab", bar.getTabCount() + ""); bar.selectTab(bar.getTabAt(args.getInt(0))); } else if ("setSubtitle".equals(action)) { if (args.isNull(0)) { error.append("subtitle can not be null"); return; } bar.setSubtitle(args.getString(0)); } else if ("setTitle".equals(action)) { if (args.isNull(0)) { error.append("title can not be null"); return; } bar.setTitle(args.getString(0)); } } catch (JSONException e) { exception = e; } finally { synchronized (this) { this.notify(); } } } // Run task synchronously { synchronized (this) { ctx.runOnUiThread(this); this.wait(); } } }.exception; if (exception != null) { throw exception; } } catch (InterruptedException e) { error.append("Function interrupted on UI thread"); } } if (error.length() == 0) { if (result.length() > 0) { callbackContext.success(result); } else { callbackContext.success(); } } else { callbackContext.error(error.toString()); } return true; }
From source file:com.plusot.senselib.SenseMain.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void addMap() { View view = findViewById(R.id.main_rootlayout); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);//from w w w .j a v a2 s.c o m params.addRule(RelativeLayout.CENTER_VERTICAL); map = new MyMapView(this); LLog.d(Globals.TAG, CLASSTAG + ".addMap: Map created"); map.setZoom(14); //map.setMapListener(this); params.setMargins(0, 0, 0, 0); ((RelativeLayout) view).addView(map, 0, params); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && MAPVIEW_ID == 8000) MAPVIEW_ID = View.generateViewId(); map.setId(MAPVIEW_ID); map.setOnTouchListener(new ClickableOverlay.Listener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public boolean onTouch(MapView mapView, MotionEvent event) { //LLog.d(Globals.TAG, CLASSTAG + ".Mapview.onTouch"); if (Build.VERSION.SDK_INT >= 11) { ActionBar bar = getActionBar(); if (bar != null && !bar.isShowing()) bar.show(); } menuVisibleClicked = System.currentTimeMillis(); return false; } @Override public boolean onClick(MapView mapView, MotionEvent event) { toggleValuesVisible(); return false; } }); }