Example usage for android.view View getTag

List of usage examples for android.view View getTag

Introduction

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

Prototype

@ViewDebug.ExportedProperty
public Object getTag() 

Source Link

Document

Returns this view's tag.

Usage

From source file:Main.java

public static void showViewSlide(View view) {
    if (view.getTag() == null)
        view.setTag(true);/* w ww .  j  av a 2s  . c  o  m*/

    boolean isVisible = (boolean) view.getTag();
    if (!isVisible) {
        view.setTag(true);
        view.animate().translationY(0).setDuration(200).setInterpolator(new AccelerateInterpolator()).start();
    }
}

From source file:Main.java

public static boolean shouldRedraw(View view, String tag) {
    if (null == view.getTag() || !view.getTag().equals(tag)) {
        return true;
    }//from  w  ww.  j a v  a2s .co  m
    return false;
}

From source file:Main.java

public static String getViewLogTag(View v) {
    return v.getClass().getSimpleName() + "[" + v.getTag() + "]";
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T extends View> T getViewByHolder(View view, int id) {
    SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();
    if (viewHolder == null) {
        viewHolder = new SparseArray<View>();
        view.setTag(viewHolder);// w  ww  .  j  a v a 2 s.c o m
    }
    View childView = viewHolder.get(id);
    if (childView == null) {
        childView = view.findViewById(id);
        viewHolder.put(id, childView);
    }
    return (T) childView;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T extends View> T get(View view, int id) {
    SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();
    if (viewHolder == null) {
        viewHolder = new SparseArray<View>();
        view.setTag(viewHolder);//www .ja  va  2s. c o  m
    }
    View childView = viewHolder.get(id);
    if (childView == null) {
        childView = view.findViewById(id);
        viewHolder.put(id, childView);
    }
    return (T) childView;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T extends View> T obtainView(View convertView, int id) {
    SparseArray<View> holder = (SparseArray<View>) convertView.getTag();
    if (holder == null) {
        holder = new SparseArray<View>();
        convertView.setTag(holder);/*from  w w w  . j  a  va2 s .  c  om*/
    }
    View childView = holder.get(id);
    if (childView == null) {
        childView = convertView.findViewById(id);
        holder.put(id, childView);
    }
    return (T) childView;
}

From source file:Main.java

public static <T extends View> T hold(View view, int id) {
    SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();

    if (viewHolder == null) {
        viewHolder = new SparseArray<View>();
        view.setTag(viewHolder);/* w  w  w  .ja  v a2  s.co  m*/
    }

    View childView = viewHolder.get(id);

    if (childView == null) {
        childView = view.findViewById(id);
        viewHolder.put(id, childView);
    }

    return (T) childView;
}

From source file:Main.java

public static <T extends View> T get(View view, int id) {
    SparseArrayCompat<View> viewHolder = (SparseArrayCompat<View>) view.getTag();
    if (viewHolder == null) {
        viewHolder = new SparseArrayCompat<>();
        view.setTag(viewHolder);//from w w w .ja v a  2s .  com
    }
    View childView = viewHolder.get(id);
    if (childView == null) {
        childView = view.findViewById(id);
        viewHolder.put(id, childView);
    }
    return (T) childView;
}

From source file:Main.java

public static ArrayList<View> getViewsByTag(ViewGroup root, String tag) {
    ArrayList<View> views = new ArrayList<View>();
    final int childCount = root.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = root.getChildAt(i);
        if (child instanceof ViewGroup) {
            views.addAll(getViewsByTag((ViewGroup) child, tag));
        }/*w  w  w  . j  av  a 2s.  co  m*/

        final Object tagObj = child.getTag();
        if (tagObj != null && tagObj.equals(tag)) {
            views.add(child);
        }

    }
    return views;
}

From source file:com.android.launcher3.accessibility.WorkspaceAccessibilityHelper.java

public static String getDescriptionForDropOver(View overChild, Context context) {
    ItemInfo info = (ItemInfo) overChild.getTag();
    if (info instanceof ShortcutInfo) {
        return context.getString(R.string.create_folder_with, info.title);
    } else if (info instanceof FolderInfo) {
        if (TextUtils.isEmpty(info.title)) {
            // Find the first item in the folder.
            FolderInfo folder = (FolderInfo) info;
            ShortcutInfo firstItem = null;
            for (ShortcutInfo shortcut : folder.contents) {
                if (firstItem == null || firstItem.rank > shortcut.rank) {
                    firstItem = shortcut;
                }/*from w w  w. j  av a  2 s  . c  o m*/
            }

            if (firstItem != null) {
                return context.getString(R.string.add_to_folder_with_app, firstItem.title);
            }
        }
        return context.getString(R.string.add_to_folder, info.title);
    }
    return "";
}