List of usage examples for android.view View hasOnClickListeners
public boolean hasOnClickListeners()
From source file:Main.java
/** * Recursive crawls the view hierarchy of `viewGroup` in order to find a clickable child and click it. *///from w ww. ja v a 2 s .c o m private static boolean recursiveClickFirstChildView(final @NonNull ViewGroup viewGroup) { try { boolean continueRecursing = true; for (int idx = 0; idx < viewGroup.getChildCount() && continueRecursing; idx++) { final View child = viewGroup.getChildAt(idx); if (child.hasOnClickListeners()) { child.performClick(); return false; } else { continueRecursing = recursiveClickFirstChildView((ViewGroup) child); } } } catch (ClassCastException | NullPointerException ignored) { } return true; }
From source file:Main.java
/** * Remove an onclick listener/* ww w. jav a2s . c o m*/ * @param view the root view of the layout */ public static void unBindListener(View view) { if (view != null) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { if (view.hasOnClickListeners()) { view.setOnClickListener(null); } } else { view.setOnClickListener(null); } if (view instanceof ViewGroup && !(view instanceof AdapterView)) { ViewGroup viewGroup = (ViewGroup) view; int viewGroupChildCount = viewGroup.getChildCount(); for (int i = 0; i < viewGroupChildCount; i++) { unBindListener(viewGroup.getChildAt(i)); } } } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.oasisfeng.nevo.decorators.media.MediaPlayerDecorator.java
/** @return continue or not */ private boolean findClickable(final ViewGroup views, final Predicate<View> callback) { for (int i = 0; i < views.getChildCount(); i++) { final View view = views.getChildAt(i); if (view instanceof ViewGroup) { if (!findClickable((ViewGroup) view, callback)) return false; } else if (view.hasOnClickListeners()) if (!callback.apply(view)) return false; }// ww w .j a va 2s .c o m return true; }
From source file:com.malin.rxjava.activity.MainActivity.java
/** * Remove an onclick listener/*from www .jav a 2 s. c o m*/ * * @param view * @author malin.myemail@gmail.com * @website https://github.com/androidmalin * @data 2016/01/22 */ private void unBingListener(View view) { if (view != null) { try { if (view.hasOnClickListeners()) { view.setOnClickListener(null); } if (view instanceof ViewGroup && !(view instanceof AdapterView)) { ViewGroup viewGroup = (ViewGroup) view; int viewGroupChildCount = viewGroup.getChildCount(); for (int i = 0; i < viewGroupChildCount; i++) { unBingListener(viewGroup.getChildAt(i)); } } } catch (Exception e) { e.printStackTrace(); } } }