Java Code Examples for android.view.View#getWindowVisibility()
The following examples show how to use
android.view.View#getWindowVisibility() .
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: RecyclerBinder.java From litho with Apache License 2.0 | 6 votes |
/** * @return true if the given view is visible to user, false otherwise. The logic is leveraged from * {@link View#isVisibleToUser()}. */ private static boolean isVisibleToUser(View view) { if (view.getWindowVisibility() != View.VISIBLE) { return false; } Object current = view; while (current instanceof View) { final View currentView = (View) current; if (currentView.getAlpha() <= 0 || currentView.getVisibility() != View.VISIBLE) { return false; } current = currentView.getParent(); } return view.getGlobalVisibleRect(sDummyRect); }
Example 2
Source File: ViewUtil.java From sa-sdk-android with Apache License 2.0 | 6 votes |
@SuppressLint("NewApi") public static boolean isViewSelfVisible(View view) { if (view == null || view.getWindowVisibility() == View.GONE) { return false; } if (WindowHelper.isDecorView(view.getClass())) { return true; } if (view.getWidth() <= 0 || view.getHeight() <= 0 || view.getAlpha() <= 0.0f || !view.getLocalVisibleRect(new Rect())) { return false; } if ((view.getVisibility() == View.VISIBLE || view.getAnimation() == null || !view.getAnimation().getFillAfter()) && view.getVisibility() != View.VISIBLE) { return false; } return true; }
Example 3
Source File: TKeybord.java From Upchain-wallet with GNU Affero General Public License v3.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.KITKAT) private void clearInputMethodManagerLeak() { try { Object lock = mHField.get(inputMethodManager); // This is highly dependent on the InputMethodManager implementation. synchronized (lock) { View servedView = (View) mServedViewField.get(inputMethodManager); if (servedView != null) { boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE; if (servedViewAttached) { // The view held by the IMM was replaced without a global focus change. Let's make // sure we get notified when that view detaches. // Avoid double registration. servedView.removeOnAttachStateChangeListener(this); servedView.addOnAttachStateChangeListener(this); } else { // servedView is not attached. InputMethodManager is being stupid! Activity activity = extractActivity(servedView.getContext()); if (activity == null || activity.getWindow() == null) { // Unlikely case. Let's finish the input anyways. finishInputLockedMethod.invoke(inputMethodManager); } else { View decorView = activity.getWindow().peekDecorView(); boolean windowAttached = decorView.getWindowVisibility() != View.GONE; if (!windowAttached) { finishInputLockedMethod.invoke(inputMethodManager); } else { decorView.requestFocusFromTouch(); } } } } } } catch (IllegalAccessException | InvocationTargetException unexpected) { Log.e("IMMLeaks", "Unexpected reflection exception", unexpected); } }
Example 4
Source File: IMMLeaks.java From timecat with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) private void clearInputMethodManagerLeak() { try { Object lock = mHField.get(inputMethodManager); // This is highly dependent on the InputMethodManager implementation. synchronized (lock) { View servedView = (View) mServedViewField.get(inputMethodManager); if (servedView != null) { boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE; if (servedViewAttached) { // The view held by the IMM was replaced without a global focus change. Let's make // sure we get notified when that view detaches. // Avoid double registration. servedView.removeOnAttachStateChangeListener(this); servedView.addOnAttachStateChangeListener(this); } else { // servedView is not attached. InputMethodManager is being stupid! Activity activity = extractActivity(servedView.getContext()); if (activity == null || activity.getWindow() == null) { // Unlikely case. Let's finish the input anyways. finishInputLockedMethod.invoke(inputMethodManager); } else { View decorView = activity.getWindow().peekDecorView(); boolean windowAttached = decorView.getWindowVisibility() != View.GONE; if (!windowAttached) { finishInputLockedMethod.invoke(inputMethodManager); } else { decorView.requestFocusFromTouch(); } } } } } } catch (IllegalAccessException | InvocationTargetException unexpected) { Log.e("IMMLeaks", "Unexpected reflection exception", unexpected); } }
Example 5
Source File: VMAnimator.java From VMLibrary with Apache License 2.0 | 5 votes |
/** * 判断一个View是否在当前的屏幕中可见(肉眼真实可见) * * @return 返回true则可见 */ public static boolean isVisibleOnScreen(View view) { if (view == null) { return false; } return view.getWindowVisibility() == View.VISIBLE && view.getVisibility() == View.VISIBLE && view.isShown(); }
Example 6
Source File: IMMLeaks.java From diycode with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.KITKAT) private void clearInputMethodManagerLeak() { try { Object lock = mHField.get(inputMethodManager); // This is highly dependent on the InputMethodManager implementation. synchronized (lock) { View servedView = (View) mServedViewField.get(inputMethodManager); if (servedView != null) { boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE; if (servedViewAttached) { // The view held by the IMM was replaced without a global focus change. Let's make // sure we get notified when that view detaches. // Avoid double registration. servedView.removeOnAttachStateChangeListener(this); servedView.addOnAttachStateChangeListener(this); } else { // servedView is not attached. InputMethodManager is being stupid! Activity activity = extractActivity(servedView.getContext()); if (activity == null || activity.getWindow() == null) { // Unlikely case. Let's finish the input anyways. finishInputLockedMethod.invoke(inputMethodManager); } else { View decorView = activity.getWindow().peekDecorView(); boolean windowAttached = decorView.getWindowVisibility() != View.GONE; if (!windowAttached) { finishInputLockedMethod.invoke(inputMethodManager); } else { decorView.requestFocusFromTouch(); } } } } } } catch (IllegalAccessException | InvocationTargetException unexpected) { Log.e("IMMLeaks", "Unexpected reflection exception", unexpected); } }
Example 7
Source File: ViewSnapshot.java From sa-sdk-android with Apache License 2.0 | 5 votes |
@Override public List<RootViewInfo> call() throws Exception { mRootViews.clear(); if (AppStateManager.getInstance().isInBackground()) { return mRootViews; } Activity activity = AppStateManager.getInstance().getForegroundActivity(); if (activity != null) { JSONObject object = AopUtil.buildTitleAndScreenName(activity); VisualUtil.mergeRnScreenNameAndTitle(object); String screenName = object.optString(AopConstants.SCREEN_NAME); String activityTitle = object.optString(AopConstants.TITLE); final Window window = activity.getWindow(); final View rootView = window.getDecorView().getRootView(); final RootViewInfo info = new RootViewInfo(screenName, activityTitle, rootView); final View[] views = WindowHelper.getSortedWindowViews(); Bitmap bitmap = null; if (views != null && views.length > 0) { bitmap = mergeViewLayers(views, info); for (View view : views) { if (view.getWindowVisibility() != View.VISIBLE || view.getVisibility() != View.VISIBLE || view.getWidth() == 0 || view.getHeight() == 0 || TextUtils.equals(WindowHelper.getWindowPrefix(view), WindowHelper.getMainWindowPrefix())) continue; RootViewInfo subInfo = new RootViewInfo(screenName, activityTitle, view.getRootView()); scaleBitmap(subInfo, bitmap); mRootViews.add(subInfo); } } if (mRootViews.size() == 0) { scaleBitmap(info, bitmap); mRootViews.add(info); } } return mRootViews; }
Example 8
Source File: ViewUtil.java From sa-sdk-android with Apache License 2.0 | 5 votes |
public static boolean isWindowNeedTraverse(View root, String prefix, boolean skipOtherActivity) { if (root.hashCode() == AppStateManager.getInstance().getCurrentRootWindowsHashCode()) { return true; } if (root instanceof ViewGroup) { if (!skipOtherActivity) { return true; } if (!(root.getWindowVisibility() == View.GONE || root.getVisibility() != View.VISIBLE || TextUtils.equals(prefix, WindowHelper.getMainWindowPrefix()) || root.getWidth() == 0 || root.getHeight() == 0)) { return true; } } return false; }
Example 9
Source File: FragmentPageCalcultor.java From sa-sdk-android with Apache License 2.0 | 5 votes |
/** * 遍历 ViewTree */ public void traverseViewTree() { if (mDecorViewRef == null || mDecorViewRef.get() == null) { return; } View view = mDecorViewRef.get(); if (view instanceof ViewGroup) { if (view.getWindowVisibility() != GONE && view.getWidth() != 0 && view.getHeight() != 0 && view.getVisibility() == VISIBLE) { Log.e(TAG, "traverseViewTree"); traverseView(mDecorViewRef.get()); //遍历完后,可以处理 Frg 浏览页面事件 handleFrgs(); } } }
Example 10
Source File: IMMLeaks.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
private void clearInputMethodManagerLeak() { try { Object lock = mHField.get(inputMethodManager); // This is highly dependent on the InputMethodManager implementation. synchronized (lock) { View servedView = (View) mServedViewField.get(inputMethodManager); if (servedView != null) { boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE; if (servedViewAttached) { // The view held by the IMM was replaced without a global focus change. Let's make // sure we get notified when that view detaches. // Avoid double registration. servedView.removeOnAttachStateChangeListener(this); servedView.addOnAttachStateChangeListener(this); } else { // servedView is not attached. InputMethodManager is being stupid! Activity activity = extractActivity(servedView.getContext()); if (activity == null || activity.getWindow() == null) { // Unlikely case. Let's finish the input anyways. finishInputLockedMethod.invoke(inputMethodManager); } else { View decorView = activity.getWindow().peekDecorView(); boolean windowAttached = decorView.getWindowVisibility() != View.GONE; if (!windowAttached) { finishInputLockedMethod.invoke(inputMethodManager); } else { decorView.requestFocusFromTouch(); } } } } } } catch (Exception unexpected) { Log.e("IMMLeaks", "Unexpected reflection exception", unexpected); } }