Java Code Examples for android.view.View#getTag()

The following examples show how to use android.view.View#getTag() . These examples are extracted from open source projects. 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 Project: XDroidMvp   File: SimpleListAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    H holder = null;
    T item = data.get(position);

    if (convertView == null) {
        convertView = View.inflate(context, getLayoutId(), null);
        holder = newViewHolder(convertView);

        convertView.setTag(holder);
    } else {
        holder = (H) convertView.getTag();
    }

    convert(holder, item, position);

    return convertView;
}
 
Example 2
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    ItemFolderListHolder holder;
    if (convertView == null) {
        convertView = inflate(context, R.layout.item_folder_list, null);
        holder = new ItemFolderListHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ItemFolderListHolder) convertView.getTag();
    }

    PictureFolder pictureFolder = pictureFolderList.get(position);
    ImageLoader.load(context, pictureFolder.folderCover.pictureAbsPath, holder.getIvFolderCover());

    holder.getTvFolderName().setText(pictureFolder.folderName);
    holder.getTvPictureCount().setText(context.getResources().getString(R.string.folder_picture_count,pictureFolder.pictureItemList.size()));

    if (TextUtils.equals(currentSelectFolderPath, pictureFolder.folderAbsPath)) {
        holder.getIvFolderCheck().setVisibility(View.VISIBLE);
    } else {
        holder.getIvFolderCheck().setVisibility(View.GONE);
    }

    return convertView;
}
 
Example 3
Source Project: YiBo   File: AppGridAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	AppGridHolder holder;
       if (convertView == null) {
           convertView = inflater.inflate(R.layout.list_item_app, null);
           holder = new AppGridHolder(convertView);
           convertView.setTag(holder);
       } else {
            holder = (AppGridHolder)convertView.getTag();
       }

       AppGrid appGrid = (AppGrid)getItem(position);
       if (appGrid != null) {
       	holder.ivApp.setImageDrawable(theme.getDrawable(appGrid.appImageName));
           holder.tvAppName.setText(appGrid.appNameId);
       }
       return convertView;
}
 
Example 4
Source Project: gcm   File: InstanceIdFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.iid_get_token:
            getActivity().startActivity(new Intent(getActivity(), TokenActivity.class));
            break;
        case R.id.widget_itbr_button:
            String authorizedEntity = (String) v.getTag(R.id.tag_senderid);
            String scope = (String) v.getTag(R.id.tag_scope);
            mInstanceIdHelper.deleteTokenInBackground(authorizedEntity, scope);
            break;
        case R.id.iid_delete_instance_id:
            confirmAndDeleteInstanceId();
            break;
    }
}
 
Example 5
Source Project: CodePolitan   File: BenihListAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View itemView, ViewGroup parent)
{
    Holder holder;
    if (itemView == null)
    {
        itemView = LayoutInflater.from(context).inflate(getItemView(), parent, false);
        holder = onCreateViewHolder(itemView);
        itemView.setTag(holder);
    } else
    {
        holder = (Holder) itemView.getTag();
    }

    holder.bind(data.get(position));

    return itemView;
}
 
Example 6
private View getCustomView(int position, View convertView, ViewGroup parent) {
  ViewHolder viewHolder;
  if (convertView == null) {
    convertView = mInflater.inflate(R.layout.item_country, parent, false);
    viewHolder = new ViewHolder();
    viewHolder.mName = (TextView) convertView.findViewById(R.id.name);
    viewHolder.mDialCode = (TextView) convertView.findViewById(R.id.dial_code);
    viewHolder.mFlag = (ImageView) convertView.findViewById(R.id.flag);
    convertView.setTag(viewHolder);
  } else {
    viewHolder = (ViewHolder) convertView.getTag();
  }
  Country country = getItem(position);
  viewHolder.mFlag.setImageResource(country.getResId(getContext()));
  viewHolder.mName.setText(country.getDisplayName());
  viewHolder.mDialCode.setText(String.valueOf(country.getDialCode()));
  return convertView;

}
 
Example 7
Source Project: Passbook   File: EditFragment.java    License: Apache License 2.0 6 votes vote down vote up
void startDrag(View v) {
    mDragged = (EntryHolder)v.getTag();
    mDragged.mEntryContainer.setVisibility(View.INVISIBLE);
    mDragged.mEntryLayout.setAlpha(0.0f);
    mIndex = mEntries.indexOf(mDragged);
    mItemHeight = mDragged.mEntryLayout.getMeasuredHeight();
    mScrollHeight = mScroll.getMeasuredHeight();
    mAdjustScrollY = mScrollHeight - mItemHeight;
    if(mToolbarContainer!=null) {
        mAdjustScrollY -= mHeader.getMeasuredHeight();
    }
    mDeleteView.setX(mDragged.mAutoPwd.getX());
    float y = mDragged.mEntryLayout.getY() + (mDragged.mEntryLayout.getMeasuredHeight()
            - mDeleteView.getMeasuredHeight()) / 2;
    mDeleteView.setY(y);
    mDeleteView.setVisibility(View.VISIBLE);
}
 
Example 8
@Override
public void onClick(View widget) {
    // TODO 处理 帖子内跳转事件
    String url = getURL();

    ArrayList<String> imgs = (ArrayList<String>) widget.getTag(R.id.poste_image_data);
    if (imgs != null && imgs.contains(url)) {
        Context a = widget.getContext();
        final int index = imgs.indexOf(url);
        String[] img = new String[imgs.size()];
        img = imgs.toArray(img);
        ActivityUtils.openPhotosActivity(a, index, img);
        return;
    }

    L.i("%s ", url);
    if (url.startsWith(Utils.SLASH) || url.startsWith(App.getSiteUrl())) {
        handleInAppClicked(widget);
    } else {
        openUrl(widget);
    }
}
 
Example 9
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView != null) {
        viewHolder = (ViewHolder) convertView.getTag();
    } else {
        convertView = LayoutInflater.from(context).inflate(R.layout.item_list_drop_down, null);
        viewHolder = new ViewHolder(convertView);
        convertView.setTag(viewHolder);
    }
    fillValue(position, viewHolder);
    return convertView;
}
 
Example 10
@Override
public View getView(View convertView) {
    View view;
    CheckBoxHolder holder;
    
    if (convertView == null) {
        ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.listview_row_checkbox, null);
        TextView textLabel = (TextView) rootView.findViewById(R.id.text_label);
        CheckBox checkBox = (CheckBox) rootView.findViewById(R.id.checkbox);
        CheckBoxListener listener = new CheckBoxListener(field);
        
        checkBox.setOnCheckedChangeListener(listener);
        holder = new CheckBoxHolder(textLabel, checkBox, listener);
        
        rootView.setTag(holder);
        view = rootView;
    } else {
        view = convertView;
        holder = (CheckBoxHolder) view.getTag();
    }

    RowCosmetics.setTextLabel(field, holder.textLabel);
    holder.listener.setField(field);
    
    if (field.getValue().equals(Field.TRUE)) holder.checkBox.setChecked(true);
    else if (field.getValue().equals(Field.EMPTY_FIELD)) holder.checkBox.setChecked(false);

    if(readOnly){
        holder.checkBox.setEnabled(false);
    } else {
        holder.checkBox.setEnabled(true);
    }
    return view;
}
 
Example 11
Source Project: letv   File: ItemTouchUIUtilImpl.java    License: Apache License 2.0 5 votes vote down vote up
public void onDraw(Canvas c, RecyclerView recyclerView, View view, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    if (isCurrentlyActive && view.getTag(R.id.item_touch_helper_previous_elevation) == null) {
        Float originalElevation = Float.valueOf(ViewCompat.getElevation(view));
        ViewCompat.setElevation(view, 1.0f + findMaxElevation(recyclerView, view));
        view.setTag(R.id.item_touch_helper_previous_elevation, originalElevation);
    }
    super.onDraw(c, recyclerView, view, dX, dY, actionState, isCurrentlyActive);
}
 
Example 12
private View buildView(int position, View convertView, ViewGroup parent, boolean isDropDownView) {
    if (getItemViewType(position) == HINT_TYPE) {
        return getHintView(parent, isDropDownView);
    }
    //workaround to have multiple types in spinner
    if (convertView != null) {
        convertView = (convertView.getTag() != null && convertView.getTag() instanceof Integer && (Integer) convertView.getTag() != HINT_TYPE) ? convertView : null;
    }
    position = hint != null ? position - 1 : position;
    return isDropDownView ? mSpinnerAdapter.getDropDownView(position, convertView, parent) : mSpinnerAdapter.getView(position, convertView, parent);
}
 
Example 13
public static void setDelegate(final View view) {
  final String accessibilityHint = (String) view.getTag(R.id.accessibility_hint);
  final AccessibilityRole accessibilityRole = (AccessibilityRole) view.getTag(R.id.accessibility_role);
  // if a view already has an accessibility delegate, replacing it could cause problems,
  // so leave it alone.
  if (!ViewCompat.hasAccessibilityDelegate(view) &&
    (accessibilityHint != null || accessibilityRole != null)) {
    ViewCompat.setAccessibilityDelegate(
      view,
      new AccessibilityDelegateCompat() {
        @Override
        public void onInitializeAccessibilityNodeInfo(
          View host, AccessibilityNodeInfoCompat info) {
          super.onInitializeAccessibilityNodeInfo(host, info);
          setRole(info, accessibilityRole, view.getContext());
          if (!(accessibilityHint == null)) {
            String contentDescription=(String)info.getContentDescription();
            if (contentDescription != null) {
              contentDescription = contentDescription + ", " + accessibilityHint;
              info.setContentDescription(contentDescription);
            } else {
              info.setContentDescription(accessibilityHint);
            }
          }
        }
      });
  }
}
 
Example 14
Source Project: AndroidDemo   File: ViewHolder.java    License: MIT License 5 votes vote down vote up
public static ViewHolder getViewHolder(Context context, View convertView,int layoutId) {
    if (convertView == null)
        return new ViewHolder(context, layoutId);
    else
        return (ViewHolder) convertView.getTag();

}
 
Example 15
Source Project: GSYVideoPlayer   File: ListVideoAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = inflater.inflate(R.layout.list_video_item, null);
        holder.videoContainer = (FrameLayout) convertView.findViewById(R.id.list_item_container);
        holder.playerBtn = (ImageView) convertView.findViewById(R.id.list_item_btn);
        holder.imageView = new ImageView(context);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    //增加封面
    holder.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    holder.imageView.setImageResource(R.mipmap.xxx1);
    smallVideoHelper.addVideoPlayer(position, holder.imageView, TAG, holder.videoContainer, holder.playerBtn);
    holder.playerBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            notifyDataSetChanged();
            //listVideoUtil.setLoop(true);
            smallVideoHelper.setPlayPositionAndTag(position, TAG);
            //final String url = "https://res.exexm.com/cw_145225549855002";
            final String url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
            gsySmallVideoHelperBuilder.setVideoTitle("title " + position)
                    .setUrl(url);
            smallVideoHelper.startPlay();

            //必须在startPlay之后设置才能生效
            //smallVideoHelper.getGsyVideoPlayer().getTitleTextView().setVisibility(View.VISIBLE);
        }
    });
    return convertView;
}
 
Example 16
Source Project: litho   File: MountState.java    License: Apache License 2.0 5 votes vote down vote up
static ComponentFocusChangeListener getComponentFocusChangeListener(View v) {
  if (v instanceof ComponentHost) {
    return ((ComponentHost) v).getComponentFocusChangeListener();
  } else {
    return (ComponentFocusChangeListener) v.getTag(R.id.component_focus_change_listener);
  }
}
 
Example 17
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final BottomSheetMutliChoiseItemData data = getItem(position);
    final ViewHolder holder;
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        convertView = inflater.inflate(R.layout.bottom_sheet_mutli_choise_item, parent, false);
        holder = new ViewHolder();
        holder.mLayout = convertView.findViewById(R.id.layout_item);
        holder.imageView = convertView.findViewById(R.id.img_tag);
        holder.textView = convertView.findViewById(R.id.txt_bottom_sheet_item_text);
        holder.descView = convertView.findViewById(R.id.txt_bottom_sheet_item_desc);
        holder.markView = convertView.findViewById(R.id.bottom_sheet_choose_mark);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    if (data.image != null) {
        holder.imageView.setVisibility(View.VISIBLE);
        holder.imageView.setImageDrawable(data.image);
    } else {
        holder.imageView.setVisibility(View.GONE);
    }

    holder.textView.setText(data.text);
    if (!TextUtils.isEmpty(data.desc)) {
        holder.descView.setText(data.desc);
        holder.descView.setVisibility(View.VISIBLE);
    } else {
        holder.descView.setVisibility(View.GONE);
    }

    if (data.isDisabled) {
        holder.textView.setEnabled(false);
        convertView.setEnabled(false);
    } else {
        holder.textView.setEnabled(true);
        convertView.setEnabled(true);
    }

    holder.markView.setOnCheckedChangeListener((buttonView, isChecked) -> {
        if (isChecked) {
            addCheckedIndex(position);
        } else {
            setUnCheckedIndex(position);
        }
    });

    if (mCheckedIndex.contains(position)) {
        holder.markView.setChecked(true);
    } else {
        holder.markView.setChecked(false);
    }

    convertView.setOnClickListener(v -> {

        holder.markView.setChecked(!holder.markView.isChecked());

        if (mOnSheetItemClickListener != null) {
            mOnSheetItemClickListener.onClick(mDialog, v, position);
        }
    });
    return convertView;
}
 
Example 18
Source Project: material   File: Spinner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(View v) {
	int position = (Integer) v.getTag();
	if(mOnItemClickListener != null)
		mOnItemClickListener.onItemClick(null, v, position, 0);			
}
 
Example 19
Source Project: intra42   File: ListAdapterCorrections.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    final ViewHolder holder;

    if (convertView == null) {
        holder = new ViewHolder();

        LayoutInflater vi = LayoutInflater.from(activity);

        convertView = vi.inflate(R.layout.list_view_corrections, parent, false);
        holder.textViewWith = convertView.findViewById(R.id.textViewWith);
        holder.textViewLogin = convertView.findViewById(R.id.textViewLogin);
        holder.textViewProject = convertView.findViewById(R.id.textViewProject);
        holder.textViewDate = convertView.findViewById(R.id.textViewDate);
        holder.linearLayoutWith = convertView.findViewById(R.id.linearLayoutWith);
        holder.linearLayoutOn = convertView.findViewById(R.id.linearLayoutOn);
        holder.linearLayoutDate = convertView.findViewById(R.id.linearLayoutDate);

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    ScaleTeams item = getItem(position);

    if (item.corrector != null && item.corrector.isMe(activity.app) && item.correcteds != null) {
        StringBuilder login = new StringBuilder();
        String sep = "";
        for (UsersLTE u : item.correcteds) {
            login.append(sep).append(u.login);
            sep = ", ";
        }
        holder.textViewLogin.setText(login);
    } else if (item.corrector != null && !item.corrector.isMe(activity.app))
        holder.textViewLogin.setText(item.corrector.login);
    else {
        holder.textViewLogin.setText(R.string.evaluation_someone);
    }

    if (item.corrector != null && item.corrector.isMe(activity.app))
        holder.textViewWith.setText(R.string.evaluation_correct_someone);
    else
        holder.textViewWith.setText(R.string.evaluation_corrected_by);

    if (item.scale != null && item.scale.name != null)
        holder.textViewProject.setText(item.scale.name);
    else {
        holder.linearLayoutOn.setVisibility(View.GONE);
    }

    if (item.beginAt == null)
        holder.textViewDate.setVisibility(View.GONE);
    else {
        String str = DateTool.getTodayTomorrow(activity, item.beginAt, true) + DateTool.getDateTimeLong(item.beginAt);
        holder.textViewDate.setVisibility(View.VISIBLE);
        holder.textViewDate.setText(str);
    }

    return convertView;
}
 
Example 20
/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 */
private void addInScreen(View child, long container, long screenId, int x, int y,
        int spanX, int spanY) {
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(new HotseatIconKeyEventListener());

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(true);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = mLauncher.getViewIdForItem(info);

    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, -1, childId, lp, markCellsAsOccupied)) {
        // TODO: This branch occurs when the workspace is adding views
        // outside of the defined grid
        // maybe we should be deleting these items from the LauncherModel?
    }

    if (!(child instanceof Folder)) {
        child.setHapticFeedbackEnabled(false);
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}