Example usage for android.view ViewGroup getTag

List of usage examples for android.view ViewGroup getTag

Introduction

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

Prototype

public Object getTag(int key) 

Source Link

Document

Returns the tag associated with this view and the specified key.

Usage

From source file:org.ayo.animate.transition.TransitionManager.java

private static ArrayList<Transition> getRunningTransitions(ViewGroup viewGroup) {
    ArrayList<Transition> transitions = (ArrayList<Transition>) viewGroup.getTag(R.id.runningTransitions);
    if (transitions == null) {
        transitions = new ArrayList<Transition>();
        viewGroup.setTag(R.id.runningTransitions, transitions);
    }//  w w  w. j  a  v a2 s . c  o m
    return transitions;
}

From source file:mobisocial.musubi.ui.widget.DbObjCursorAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Cursor cursor = getCursor();//from  w ww . j  av a2s  .  co  m

    if (!moveCursorToPosition(cursor, position)) {
        throw new IllegalStateException("couldn't move cursor to position " + position);
    }

    DbObjCursor row;
    if (convertView == null) {
        row = DbObjCursor.getInstance(mDbManager, cursor);
    } else {
        row = DbObjCursor.getInstance(mDbManager, cursor, (DbObjCursor) convertView.getTag(R.id.object_entry));
    }

    FeedRenderer renderer = ObjHelpers.getFeedRenderer(row.type);
    ViewGroup objectMainView;
    ViewHolder viewHolder;
    if (convertView == null) {
        viewHolder = new ViewHolder();
        LayoutInflater inflater = LayoutInflater.from(mContext);
        objectMainView = (ViewGroup) inflater.inflate(R.layout.objects_item, parent, false);
        viewHolder.frame = (ViewGroup) objectMainView.findViewById(R.id.object_content);
        viewHolder.objView = renderer.createView(mContext, viewHolder.frame);
        viewHolder.frame.addView(viewHolder.objView);
        viewHolder.error = objectMainView.findViewById(R.id.error_text);
        viewHolder.senderIcon = (ImageView) objectMainView.findViewById(R.id.icon);
        viewHolder.senderName = (TextView) objectMainView.findViewById(R.id.name_text);
        viewHolder.timeText = (TextView) objectMainView.findViewById(R.id.time_text);
        viewHolder.sendingIcon = (ImageView) objectMainView.findViewById(R.id.sending_icon);
        viewHolder.attachmentsIcon = (ImageView) objectMainView.findViewById(R.id.obj_attachments_icon);
        viewHolder.attachmentsText = (TextView) objectMainView.findViewById(R.id.obj_attachments);
        viewHolder.addContact = (TextView) objectMainView.findViewById(R.id.add_contact);

        objectMainView.setTag(R.id.holder, viewHolder);
        objectMainView.setTag(R.id.object_entry, row);
    } else {
        objectMainView = (ViewGroup) convertView;
        viewHolder = (ViewHolder) objectMainView.getTag(R.id.holder);
    }

    ObjHelpers.bindObjViewFrame(mContext, mDbManager, objectMainView, viewHolder, row);
    boolean allowInteractions = true;

    try {
        renderer.render(mContext, viewHolder.objView, row, allowInteractions);
        viewHolder.error.setVisibility(View.GONE);
        viewHolder.frame.setVisibility(View.VISIBLE);
    } catch (Exception e) {
        viewHolder.error.setVisibility(View.VISIBLE);
        viewHolder.frame.setVisibility(View.GONE);
        Log.e(getClass().getSimpleName(), "Error rendering type " + row.type, e);
    }
    return objectMainView;
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppStateObj.java

public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from  ww  w.j  a  v a  2s . c o m*/
    // TODO: hack to show object history in app feeds
    JSONObject appState = getAppState(context, content);
    if (appState != null) {
        content = appState;
    } else {
        Log.e(TAG, "Missing inner content, probably because of format changes");
    }

    boolean rendered = false;
    AppState ref = new AppState(content);
    String thumbnail = ref.getThumbnailImage();
    if (thumbnail != null) {
        rendered = true;
        ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        App.instance().objectImages.lazyLoadImage(thumbnail.hashCode(), thumbnail, imageView);
        frame.addView(imageView);
    }

    thumbnail = ref.getThumbnailText();
    if (thumbnail != null) {
        rendered = true;
        TextView valueTV = new TextView(context);
        valueTV.setText(thumbnail);
        valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
        frame.addView(valueTV);
    }

    thumbnail = ref.getThumbnailHtml();
    if (thumbnail != null) {
        rendered = true;
        WebView webview = new WebView(context);
        webview.loadData(thumbnail, "text/html", "UTF-8");
        webview.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        Object o = frame.getTag(R.id.object_entry);
        webview.setOnTouchListener(new WebViewClickListener(frame, (Integer) o));
        frame.addView(webview);
    }

    if (!rendered) {
        String appName = content.optString(PACKAGE_NAME);
        if (appName.contains(".")) {
            appName = appName.substring(appName.lastIndexOf(".") + 1);
        }
        String text = "Welcome to " + appName + "!";
        TextView valueTV = new TextView(context);
        valueTV.setText(text);
        valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
        frame.addView(valueTV);
    }
}