List of usage examples for android.view Window findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:Main.java
public static View getRootView(Window w) { return w.findViewById(android.R.id.content).getRootView(); }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static void setCompatToolbarOverlay(Activity activity, Drawable overlay) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;/*from w ww . ja va 2s. co m*/ final Window window = activity.getWindow(); final View view = window.findViewById(android.support.v7.appcompat.R.id.decor_content_parent); if (!(view instanceof ActionBarOverlayLayout)) return; try { final Field field = ActionBarOverlayLayout.class.getDeclaredField("mWindowContentOverlay"); field.setAccessible(true); field.set(view, overlay); } catch (Exception ignore) { } }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static void setCompatContentViewOverlay(Activity activity, Drawable overlay) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;/*w w w . j av a 2s . c o m*/ final Window window = activity.getWindow(); View contentLayout = window.findViewById(android.support.v7.appcompat.R.id.action_bar_activity_content); if (contentLayout == null) { contentLayout = window.findViewById(android.R.id.content); } if (contentLayout instanceof ContentFrameLayout) { ((ContentFrameLayout) contentLayout).setForeground(overlay); } }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static void setWindowOverlayViewOverlay(Activity activity, Drawable overlay) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;/*from w w w .j a v a 2 s .co m*/ final Window window = activity.getWindow(); final View windowOverlay = window.findViewById(R.id.window_overlay); if (windowOverlay == null) { return; } ViewSupport.setBackground(windowOverlay, overlay); }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static Drawable getCompatToolbarOverlay(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return null; final Window window = activity.getWindow(); final View view = window.findViewById(android.support.v7.appcompat.R.id.decor_content_parent); if (!(view instanceof ActionBarOverlayLayout)) { final View contentLayout = window .findViewById(android.support.v7.appcompat.R.id.action_bar_activity_content); if (contentLayout instanceof ContentFrameLayout) { return ((ContentFrameLayout) contentLayout).getForeground(); }/*from ww w . j a v a2s .c o m*/ return null; } try { final Field field = ActionBarOverlayLayout.class.getDeclaredField("mWindowContentOverlay"); field.setAccessible(true); return (Drawable) field.get(view); } catch (Exception ignore) { } return null; }
From source file:com.hellofyc.base.app.AppSupportDelegate.java
public View findViewById(Window window, @IdRes int id) { return window != null ? window.findViewById(id) : null; }
From source file:com.cleanwiz.applock.ui.activity.SplashActivity.java
public void showUpdateDialog(String intro) { final AlertDialog updateDialogDlg = new AlertDialog.Builder(this).create(); updateDialogDlg.show();/*from w w w .j a v a 2s. c o m*/ Window win = updateDialogDlg.getWindow(); win.setContentView(R.layout.dialog_update); TextView tvMsg = (TextView) win.findViewById(R.id.tvMsg); tvMsg.setText(intro); Button btOk = (Button) win.findViewById(R.id.btOk); ImageView closeImageView = (ImageView) win.findViewById(R.id.updateclose); closeImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub updateDialogDlg.dismiss(); SplashHandler handler = new SplashHandler(); Message msg = new Message(); msg.what = CHECKVERSION_CANCEL; handler.sendMessage(msg); } }); btOk.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { SplashHandler handler = new SplashHandler(); Message msg = new Message(); msg.what = CHECKVERSION_DOWN; handler.sendMessage(msg); } }); updateDialogDlg.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { // TODO Auto-generated method stub List<UpdateVersionManafer> updateVersionManafers = updateVersionManagerService.getVersionManafers(); for (UpdateVersionManafer updateVersionManafer : updateVersionManafers) { updateVersionManafer.setLasttipdate(new Date().getTime()); updateVersionManagerService.modifyTipsDate(updateVersionManafer); break; } SplashHandler handler = new SplashHandler(); Message msg = new Message(); msg.what = CHECKVERSION_CANCEL; handler.sendMessage(msg); } }); }
From source file:kr.co.cashqc.MainActivity.java
private int getScreenSize() { Display display = MainActivity.this.getWindowManager().getDefaultDisplay(); int screenHeight = display.getHeight();// ? ? ? Window window = getWindow(); int topBarHeight = window.findViewById(Window.ID_ANDROID_CONTENT).getTop();// ? // ?? // ? // ?. return screenHeight - topBarHeight; }
From source file:com.kaliturin.blacklist.fragments.SettingsFragment.java
private void showFilePathDialog(@StringRes int titleId, final TextView.OnEditorActionListener listener) { if (!isAdded()) return;/* w ww. j av a2 s . co m*/ String filePath = Environment.getExternalStorageDirectory().getPath() + "/Download/" + DatabaseAccessHelper.DATABASE_NAME; @IdRes final int editId = 1; // create dialog DialogBuilder dialog = new DialogBuilder(getContext()); dialog.setTitle(titleId); dialog.addEdit(editId, filePath, getString(R.string.File_path)); dialog.addButtonLeft(getString(R.string.CANCEL), null); dialog.addButtonRight(getString(R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Window window = ((Dialog) dialog).getWindow(); if (window != null) { TextView textView = (TextView) window.findViewById(editId); if (textView != null) { listener.onEditorAction(textView, 0, null); } } } }); dialog.show(); }
From source file:cz.metaverse.android.bilingualreader.helper.BookPanelOnTouchListener.java
/** * The entry method for any touch-related event. * @param view The WebView where the swipe took place * @param event The MotionEvent of the swipe *///from w w w .j av a 2 s . co m @Override public boolean onTouch(View view, MotionEvent event) { // Provide data to the GestureDetector. gestureDetector.onTouchEvent(event); /* * Handle Double Tap Swipe in real time. * This handling isn't in onDoubleTapEvent() because that method has a limit how many times * it gets called after which it isn't called at all until the user lifts the finger in which * case it gets called one last time. That is not workable for on-the-fly resizing of panels. */ if (isDoubleTapSwipe) { float absDiffX = Math.abs(doubleTapOriginX - event.getX()); float absDiffY = Math.abs(doubleTapOriginY - event.getY()); // If the swipe was over predefined threshold value high and it was higher than wider, // or if the swipe was over predefined threshold value wide and it was wider than higher. if (doubleTapSwipeEscapedBounds || // Bounds for PORTRAIT orientation. (absDiffY > threshold_swipe_up_or_down_change_panel_size_px && absDiffY > absDiffX && doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT) || // Bounds for LANDSCAPE orientation. (absDiffX > threshold_swipe_left_right_change_panel_size_px && absDiffX > absDiffY && doubleTapSwipe_orientation != Configuration.ORIENTATION_PORTRAIT)) { if (!doubleTapSwipeEscapedBounds) { // This is the first time doubleTapSwipe escaped it's bounds // - we're officially in the set-panels-size mode. doubleTapSwipeEscapedBounds = true; // Find out and save the relevant dimensions of our view/display Window window = activity.getWindow(); if (doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT) { doubleTapSwipe_contentStartsAtHeight = window.findViewById(Window.ID_ANDROID_CONTENT) .getTop(); doubleTapSwipe_viewHeight = window.getDecorView().getHeight(); } else { doubleTapSwipe_contentStartsAtHeight = window.findViewById(Window.ID_ANDROID_CONTENT) .getLeft(); doubleTapSwipe_viewHeight = window.getDecorView().getWidth(); } } // Compute the panels weight float useCoordinate = (doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT) ? event.getRawY() : event.getRawX(); newPanelsWeight = (useCoordinate - doubleTapSwipe_contentStartsAtHeight) / (doubleTapSwipe_viewHeight - doubleTapSwipe_contentStartsAtHeight); // If the weight is close to 0.5, let it stick to it. if (Math.abs(0.5 - newPanelsWeight) < PANEL_RESIZE_SNAP_WEIGHT_AROUND_HALF) { newPanelsWeight = 0.5f; } // Assure that the weight is between the allowed minimum and maximum. newPanelsWeight = Func.minMaxRange(Func.PANEL_WEIGHT_MIN, newPanelsWeight, Func.PANEL_WEIGHT_MAX); // Change relative panel size on the fly. governor.changePanelsWeight(newPanelsWeight); //Log.v(LOG, "[" + panelPosition + "] doubleTapSwipe " + newPanelsWeight); //+ " = (" + event.getRawY() + " - " + contentViewTop + ") / " + (height - contentViewTop)); } } /* * Handle ACTION_UP event for scrolling, because onScroll (almost?) never gets * called with the last MotionEvent.ACTION_UP. * Don't forget to mirror any changes made here in the onScroll() method as well, to be safe. */ if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) { Log.d(LOG, "[" + panelPosition + "] OnTouchListener --> onTouch ACTION_UP - scrollY: " + webView.getScrollY()); // Only if it's not DoubleTapSwipe, that is handled separately. if (!isDoubleTapSwipe) { // Evaluate if the scroll that has just ended constitutes some gesture. handleScrollEnd(event); } } // Modify the event so that it is passed on in a state where the X coordinate hasn't changed at all. // This prevents the "over scroll glow effect" on pages that have some (hidden) horizontal scroll. // -- Disabled because it causes the wrong scroll position to be loaded after opening a page // sometimes (but not every time), for some unknown reason. //event.setLocation(touchOriginX, event.getY()); view.performClick(); // Android system mandates we pass the baton to the onClick listener now. return view.onTouchEvent(event); }