Example usage for android.view View getClass

List of usage examples for android.view View getClass

Introduction

In this page you can find the example usage for android.view View getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:ch.tutti.android.bottomsheet.ResolverDrawerLayout.java

private View findListChildUnder(float x, float y) {
    View v = findChildUnder(x, y);
    while (v != null) {
        x -= v.getX();//from www  . j av a2  s.c  o m
        y -= v.getY();
        if (v instanceof AbsListView || RECYCLERVIEW_CLASS_NAME.equals(v.getClass().getName())) {
            // One more after this.
            return findChildUnder((ViewGroup) v, x, y);
        }
        v = v instanceof ViewGroup ? findChildUnder((ViewGroup) v, x, y) : null;
    }
    return v;
}

From source file:com.adhere.view.swipe.SwipeRefreshLayout.java

private void ensureTarget() {
    // Don't bother getting the parent height if the parent hasn't been laid
    // out yet.//from ww  w.ja va  2s.  co  m
    if (mTarget == null) {
        for (int i = 0; i < getChildCount(); i++) {
            View child = getChildAt(i);
            if (child.getClass().isAssignableFrom(RecyclerView.class)) {
                mTarget = child;
                break;
            }
        }
    }
}

From source file:org.telegram.ui.LaunchActivity.java

public void fixBackButton() {
    if (android.os.Build.VERSION.SDK_INT == 19) {
        //workaround for back button dissapear
        try {//from www .  jav  a2  s  . c  o m
            Class firstClass = getSupportActionBar().getClass();
            Class aClass = firstClass.getSuperclass();
            if (aClass == android.support.v7.app.ActionBar.class) {

            } else {
                Field field = aClass.getDeclaredField("mActionBar");
                field.setAccessible(true);
                android.app.ActionBar bar = (android.app.ActionBar) field.get(getSupportActionBar());

                field = bar.getClass().getDeclaredField("mActionView");
                field.setAccessible(true);
                View v = (View) field.get(bar);
                aClass = v.getClass();

                field = aClass.getDeclaredField("mHomeLayout");
                field.setAccessible(true);
                v = (View) field.get(v);
                v.setVisibility(View.VISIBLE);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.yahala.ui.LaunchActivity.java

public void fixBackButton() {
    if (Build.VERSION.SDK_INT == 19) {
        //workaround for back button dissapear
        try {/*  w w w .java2s.co  m*/
            Class firstClass = getSupportActionBar().getClass();
            Class aClass = firstClass.getSuperclass();
            if (aClass == ActionBar.class) {
            } else {
                Field field = aClass.getDeclaredField("mActionBar");
                field.setAccessible(true);
                android.app.ActionBar bar = (android.app.ActionBar) field.get(getSupportActionBar());

                field = bar.getClass().getDeclaredField("mActionView");
                field.setAccessible(true);
                View v = (View) field.get(bar);
                aClass = v.getClass();

                field = aClass.getDeclaredField("mHomeLayout");
                field.setAccessible(true);
                v = (View) field.get(v);
                v.setVisibility(View.VISIBLE);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:org.faudroids.boredrudolf.ui.CustomSwipeRefreshLayout.java

private boolean canChildrenScrollHorizontally(View view, MotionEvent event, int direction) {
    if (view instanceof ViewGroup) {
        final ViewGroup viewgroup = (ViewGroup) view;
        int count = viewgroup.getChildCount();
        for (int i = 0; i < count; ++i) {
            View child = viewgroup.getChildAt(i);
            Rect bounds = new Rect();
            child.getHitRect(bounds);// w w  w.  j a  v a 2  s.c  o m
            if (bounds.contains((int) event.getX(), (int) event.getY())) {
                if (DEBUG)
                    Log.d(TAG, "in child " + child.getClass().getName());
                return canViewScrollHorizontally(child, event, direction);
            }
        }
    }
    return false;
}

From source file:com.mobeta.dslv.SimpleDragSortCursorAdapter.java

/**
 * Binds all of the field names passed into the "to" parameter of the
 * constructor with their corresponding cursor columns as specified in the
 * "from" parameter./*from  w ww  . ja  va 2 s .c om*/
 *
 * Binding occurs in two phases. First, if a
 * {@link android.widget.SimpleCursorAdapter.ViewBinder} is available,
 * {@link ViewBinder#setViewValue(View, Cursor, int)}
 * is invoked. If the returned value is true, binding has occured. If the
 * returned value is false and the view to bind is a TextView,
 * {@link #setViewText(TextView, String)} is invoked. If the returned value is
 * false and the view to bind is an ImageView,
 * {@link #setViewImage(ImageView, String)} is invoked. If no appropriate
 * binding can be found, an {@link IllegalStateException} is thrown.
 *
 * @throws IllegalStateException if binding cannot occur
 * 
 * @see android.widget.CursorAdapter#bindView(View,
 *      Context, Cursor)
 * @see #getViewBinder()
 * @see #setViewBinder(android.widget.SimpleCursorAdapter.ViewBinder)
 * @see #setViewImage(ImageView, String)
 * @see #setViewText(TextView, String)
 */
@Override
public void bindView(View view, Context context, Cursor cursor) {
    final ViewBinder binder = mViewBinder;
    final int count = mTo.length;
    final int[] from = mFrom;
    final int[] to = mTo;

    for (int i = 0; i < count; i++) {
        final View v = view.findViewById(to[i]);
        if (v != null) {
            boolean bound = false;
            if (binder != null) {
                bound = binder.setViewValue(v, cursor, from[i]);
            }

            if (!bound) {
                String text = cursor.getString(from[i]);
                if (text == null) {
                    text = "";
                }

                if (v instanceof TextView) {
                    setViewText((TextView) v, text);
                } else if (v instanceof ImageView) {
                    setViewImage((ImageView) v, text);
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a "
                            + " view that can be bounds by this SimpleCursorAdapter");
                }
            }
        }
    }
}

From source file:com.mobeta.android.dslv.SimpleDragSortCursorAdapter.java

/**
 * Binds all of the field names passed into the "to" parameter of the
 * constructor with their corresponding cursor columns as specified in the
 * "from" parameter.//from  www . ja  va2  s  .  c  om
 *
 * Binding occurs in two phases. First, if a
 * {@link android.widget.SimpleCursorAdapter.ViewBinder} is available,
 * {@link ViewBinder#setViewValue(android.view.View, android.database.Cursor, int)}
 * is invoked. If the returned value is true, binding has occured. If the
 * returned value is false and the view to bind is a TextView,
 * {@link #setViewText(TextView, String)} is invoked. If the returned value
 * is false and the view to bind is an ImageView,
 * {@link #setViewImage(ImageView, String)} is invoked. If no appropriate
 * binding can be found, an {@link IllegalStateException} is thrown.
 *
 * @throws IllegalStateException
 *             if binding cannot occur
 *
 * @see android.widget.CursorAdapter#bindView(android.view.View,
 *      android.content.Context, android.database.Cursor)
 * @see #getViewBinder()
 * @see #setViewBinder(android.widget.SimpleCursorAdapter.ViewBinder)
 * @see #setViewImage(ImageView, String)
 * @see #setViewText(TextView, String)
 */
@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    final ViewBinder binder = this.mViewBinder;
    final int count = this.mTo.length;
    final int[] from = this.mFrom;
    final int[] to = this.mTo;
    for (int i = 0; i < count; i++) {
        final View v = view.findViewById(to[i]);
        if (v != null) {
            boolean bound = false;
            if (binder != null) {
                bound = binder.setViewValue(v, cursor, from[i]);
            }
            if (!bound) {
                String text = cursor.getString(from[i]);
                if (text == null) {
                    text = "";
                }
                if (v instanceof TextView) {
                    setViewText((TextView) v, text);
                } else if (v instanceof ImageView) {
                    setViewImage((ImageView) v, text);
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a "
                            + " view that can be bounds by this SimpleCursorAdapter");
                }
            }
        }
    }
}

From source file:com.blandware.android.atleap.loader.ViewLoadable.java

/**
 * Binds all of the field names passed into the "to" parameter of the
 * constructor with their corresponding cursor columns as specified in the
 * "from" parameter.//w  ww .j  a v  a 2s .c om
 *
 * Binding occurs in two phases. First, if a
 * {@link com.blandware.android.atleap.loader.ViewLoadable.ViewBinder} is available,
 * {@link ViewBinder#setViewValue(android.view.View, android.database.Cursor, int)}
 * is invoked. If the returned value is true, binding has occured. If the
 * returned value is false and the view to bind is a TextView,
 * {@link #setViewText(android.widget.TextView, String)} is invoked. If the returned value is
 * false and the view to bind is an ImageView,
 * {@link #setViewImage(android.widget.ImageView, String)} is invoked. If no appropriate
 * binding can be found, an {@link IllegalStateException} is thrown.
 *
 * @throws IllegalStateException if binding cannot occur
 *
 * @see com.blandware.android.atleap.loader.ViewLoadable#bindView(android.database.Cursor)
 * @see #getViewBinder()
 * @see #setViewBinder(com.blandware.android.atleap.loader.ViewLoadable.ViewBinder)
 * @see #setViewImage(android.widget.ImageView, String)
 * @see #setViewText(android.widget.TextView, String)
 */
public void bindView(Cursor cursor) {
    if (cursor == null || cursor.getCount() == 0)
        return;

    cursor.moveToFirst();

    final ViewBinder binder = mViewBinder;
    final int count = mTo.length;
    final int[] from = mFrom;
    final int[] to = mTo;

    for (int i = 0; i < count; i++) {
        final View v = mView.findViewById(to[i]);
        if (v != null) {
            boolean bound = false;
            if (binder != null) {
                bound = binder.setViewValue(v, cursor, from[i]);
            }

            if (!bound) {
                String text = cursor.getString(from[i]);
                if (text == null) {
                    text = "";
                }

                if (v instanceof TextView) {
                    setViewText((TextView) v, text);
                } else if (v instanceof ImageView) {
                    setViewImage((ImageView) v, text);
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a "
                            + " view that can be bounds by this SimpleCursorAdapter");
                }
            }
        }
    }
}

From source file:me.futuretechnology.util.ui.AltCursorAdapter.java

/**
 * Binds all of the field names passed into the "to" parameter of the constructor with their corresponding cursor
 * columns as specified in the "from" parameter.
 * <p/>//from w w w  .  j a va  2  s .co  m
 * Binding occurs in two phases. First, if a {@link AltCursorAdapter.ViewBinder} is available,
 * {@link ViewBinder#setViewValue(android.view.View, android.database.Cursor, int)} is invoked. If the returned
 * value is true, binding has occurred. If the returned value is false and the view to bind is a TextView,
 * {@link #setViewText(TextView, String)} is invoked. If the returned value is false and the view to bind is an
 * ImageView, {@link #setViewImage(ImageView, String)} is invoked. If no appropriate binding can be found, an
 * {@link IllegalStateException} is thrown.
 *
 * @throws IllegalStateException if binding cannot occur
 * @see android.widget.CursorAdapter#bindView(android.view.View, android.content.Context, android.database.Cursor)
 * @see #getViewBinder()
 * @see #setViewBinder(AltCursorAdapter.ViewBinder)
 * @see #setViewImage(ImageView, String)
 * @see #setViewText(TextView, String)
 */
@Override
public void bindView(View view, Context context, Cursor cursor) {
    ViewBinder binder = mViewBinder;
    int count = mTo.length;
    int[] from = mFrom;
    int[] to = mTo;

    for (int i = 0; i < count; i++) {
        View v = view.findViewById(to[i]);
        if (v != null) {
            boolean bound = false;
            if (binder != null) {
                bound = binder.setViewValue(v, cursor, from[i]);
            }

            if (!bound) {
                String text = cursor.getString(from[i]);
                if (text == null) {
                    text = "";
                }

                if (v instanceof TextView) {
                    setViewText((TextView) v, text);
                } else if (v instanceof ImageView) {
                    setViewImage((ImageView) v, text);
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a "
                            + " view that can be bounds by this AltCursorAdapter");
                }
            }
        }
    }
}

From source file:com.google.android.demos.jamendo.widget.SimpleFeedAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    for (int i = 0; i < mFrom.length; i++) {
        final View v = view.findViewById(mTo[i]);
        if (v != null) {
            int columnIndex = cursor.getColumnIndexOrThrow(mFrom[i]);
            if (!setViewValue(v, cursor, columnIndex)) {
                String value = cursor.getString(columnIndex);
                if (value == null) {
                    value = "";
                }//from  www .j  av  a  2 s  . co m
                if (v instanceof TextView) {
                    TextView textView = (TextView) v;
                    textView.setText(value);
                } else if (v instanceof ImageView) {
                    ImageView imageView = (ImageView) v;
                    try {
                        imageView.setImageResource(Integer.parseInt(value));
                    } catch (NumberFormatException e) {
                        if (TextUtils.isEmpty(value)) {
                            value = mDefaultImageUrl;
                        }
                        mImageLoader.bind(this, imageView, value);
                    }
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a "
                            + " view that can be bound by this " + getClass().getSimpleName());
                }
            }
        }
    }
}