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

The following examples show how to use android.view.View#setTag() . 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: likequanmintv   File: CommonTabLayout.java    License: Apache License 2.0 6 votes vote down vote up
/** 更新数据 */
public void notifyDataSetChanged() {
    mTabsContainer.removeAllViews();
    this.mTabCount = mTabEntitys.size();
    View tabView;
    for (int i = 0; i < mTabCount; i++) {
        if (mIconGravity == Gravity.LEFT) {
            tabView = View.inflate(mContext, R.layout.layout_tab_left, null);
        } else if (mIconGravity == Gravity.RIGHT) {
            tabView = View.inflate(mContext, R.layout.layout_tab_right, null);
        } else if (mIconGravity == Gravity.BOTTOM) {
            tabView = View.inflate(mContext, R.layout.layout_tab_bottom, null);
        } else {
            tabView = View.inflate(mContext, R.layout.layout_tab_top, null);
        }

        tabView.setTag(i);
        addTab(i, tabView);
    }

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

	if (convertView != null) {
		view = convertView;
	} else {
		view = mInflater.inflate(R.layout.country_cell, parent, false);
	}

	DialPlan c = filteredCountries.get(position);

	TextView name = (TextView) view.findViewById(R.id.country_name);
	name.setText(c.getCountryName());

	TextView dial_code = (TextView) view.findViewById(R.id.country_prefix);
	if (context != null)
		dial_code.setText(String.format(context.getString(R.string.country_code),c.getCountryCallingCode()));

	view.setTag(c);
	return view;
}
 
Example 3
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Point point = points.get(position);
    ViewHolder_GV viewHolder_gv = null;
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.carview_review, null);
        viewHolder_gv = new ViewHolder_GV(convertView);
        convertView.setTag(viewHolder_gv);

    } else {
        viewHolder_gv = (ViewHolder_GV) convertView.getTag();
    }

    viewHolder_gv.tv_carview.setText(point.getName());
    cardViewSetBackgroundColor(point, viewHolder_gv.cv_carview);

    return convertView;
}
 
Example 4
Source Project: intra42   File: LibraryListActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
    final ViewHolder holder;

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

        LayoutInflater vi = (LayoutInflater) LibraryListActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        view = vi.inflate(R.layout.list_view_library, viewGroup, false);
        holder.textViewName = view.findViewById(R.id.textViewName);
        holder.textViewLicense = view.findViewById(R.id.textViewLicense);

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

    final Item item = getItem(i);

    holder.textViewName.setText(item.name);
    holder.textViewLicense.setText(item.content);

    return view;
}
 
Example 5
Source Project: weixin   File: AddressBookAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView != null) {
			holder = (ViewHolder) convertView.getTag();
		} else {
			convertView = View.inflate(mContext, R.layout.cgt_layout_addressbook_item, null);
			holder = new ViewHolder();
			holder.userPhoto = (ImageView) convertView.findViewById(R.id.cgt_iv_userPhoto);
			holder.userName = (TextView) convertView.findViewById(R.id.cgt_tv_userName);
			convertView.setTag(holder);
		}
		
//		holder.userPhoto.setImageResource(Integer.parseInt(mList.get(position).getUserPhote()));
		holder.userPhoto.setImageResource(R.drawable.icon);
		holder.userName.setText(mList.get(position).getUserAccount());
		return convertView;
	}
 
Example 6
Source Project: talk-android   File: PickCountryCodeAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolderItem holder = null;
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.item_country_content, parent, false);
        holder = new ViewHolderItem(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolderItem) convertView.getTag();
    }

    CountryModel model = list.get(position);
    holder.countryTv.setText(model.countryName);

    return convertView;
}
 
Example 7
Source Project: sealtalk-android   File: BlackListActivity.java    License: MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHoler viewHolder = null;
    GetBlackListResponse.ResultEntity bean = dataList.get(position);
    if (convertView == null) {
        viewHolder = new ViewHoler();
        convertView = LayoutInflater.from(mContext).inflate(R.layout.black_item_new, null);
        viewHolder.mName = (TextView) convertView.findViewById(R.id.blackname);
        viewHolder.mHead = (ImageView) convertView.findViewById(R.id.blackuri);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHoler) convertView.getTag();
    }
    viewHolder.mName.setText(bean.getUser().getNickname());
    ImageLoader.getInstance().displayImage(bean.getUser().getPortraitUri(), viewHolder.mHead, App.getOptions());
    return convertView;
}
 
Example 8
Source Project: Vorolay   File: VoronoiView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {

    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        child.setTag(i);
        VoronoiRegion region = mRegions.get(i);
        child.measure(
                MeasureSpec.makeMeasureSpec((int) region.width, MeasureSpec.AT_MOST),
                MeasureSpec.makeMeasureSpec((int) region.height, MeasureSpec.AT_MOST)
        );
        int curWidth = child.getMeasuredWidth();
        int curHeight = child.getMeasuredHeight();

        //set children into the center of the region rectangle
        child.layout(
                (int) region.center_rect.x - curWidth / 2,
                (int) region.center_rect.y - curHeight / 2,
                (int) region.center_rect.x + curWidth,
                (int) region.center_rect.y + curHeight
        );
    }
}
 
Example 9
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View view = convertView;

    if (view == null) {
        view = LayoutInflater
                        .from(parent.getContext())
                        .inflate(R.layout.layout_select_place_item, parent, false);
        view.setTag(R.id.text_place_name, view
                        .findViewById(R.id.text_place_name));
        view.setTag(R.id.text_place_address, view
                        .findViewById(R.id.text_place_address));
        view.setTag(R.id.text_distance, view
                        .findViewById(R.id.text_distance));
    }

    final Venue venue = mVenues[position];

    ((TextView) view.getTag(R.id.text_place_name)).setText(venue.name);
    ((TextView) view.getTag(R.id.text_place_address))
                    .setText(venue.address);
    ((TextView) view.getTag(R.id.text_distance)).setText(String
                    .format(mDistanceFormat, venue.distance));

    return view;
}
 
Example 10
Source Project: ChatKeyboard   File: MediaGridAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context
                .LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.keyboard_media_item, parent, false);
        viewHolder = new ViewHolder(convertView);
        viewHolder.ivImage.setLayoutParams(new LinearLayout.LayoutParams(mSize, mSize));
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    viewHolder.ivImage.setImageDrawable(ContextCompat.getDrawable(mContext, getItem(position)
            .getDrawableId()));

    viewHolder.tvText.setText(getItem(position).getText());

    convertView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            getItem(position).getMediaListener().onMediaClick(getItem(position).getId());
        }
    });

    return convertView;
}
 
Example 11
Source Project: candybar   File: CreditsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    ViewHolder holder;
    if (view == null) {
        view = View.inflate(mContext, R.layout.fragment_credits_item_list, null);
        holder = new ViewHolder(view);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }

    Credit credit = mCredits.get(position);
    holder.title.setText(credit.getName());
    holder.subtitle.setText(credit.getContribution());
    holder.container.setOnClickListener(view1 -> {
        String link = credit.getLink();
        if (URLUtil.isValidUrl(link)) {
            try {
                mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
            } catch (ActivityNotFoundException e) {
                LogUtil.e(Log.getStackTraceString(e));
            }
        }
    });

    if (credit.getContribution().length() == 0) {
        holder.subtitle.setVisibility(View.GONE);
    } else {
        holder.subtitle.setVisibility(View.VISIBLE);
    }

    ImageLoader.getInstance().displayImage(credit.getImage(),
            new ImageViewAware(holder.image), mOptions.build(),
            new ImageSize(144, 144), null, null);
    return view;
}
 
Example 12
Source Project: AndroidProjects   File: ListViewAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        binding = DataBindingUtil.inflate(mLayoutInflater, R.layout.item_list, parent, false);
        convertView = binding.getRoot();
        convertView.setTag(binding);
    } else {
        binding = (ItemListBinding) convertView.getTag();
    }
    binding.setData(data.get(position));
    return convertView;
}
 
Example 13
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = layoutInflater.inflate(R.layout.game_list_item, null);
        convertView.setTag(new ViewHolder(convertView));
    }
    initializeViews((T)getItem(position), (ViewHolder) convertView.getTag());
    return convertView;
}
 
Example 14
@Override
protected void bindView(View v, int partition, Cursor cursor, int position) {
    TextView text = (TextView)v.findViewById(R.id.item_name);
    
 
    Configuration config = mLauncher.getResources().getConfiguration();
    if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        text.setGravity(Gravity.RIGHT);
    }
    
    String title = cursor.getString(1);
    text.setText(title);

    v.setTag(new SettingsPosition(partition, position));

    Resources res = mLauncher.getResources();
    
    boolean current = false;
    String state = "";
    
    
    switch (partition) {
    case SettingsPanel.HOME_SETTINGS_POSITION:
        switch (position) {
            case 0:
                current = mLauncher.shouldShowSearchBar();
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 1:
                state = mLauncher.getWorkspaceTransitionEffect();
                state = mapEffectToValue(state);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 2:
                current = mLauncher.shouldHideWorkspaceIconLables();
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 3:
                current = SettingsProvider.getBoolean(mContext,
                        SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
                        R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            default:
                ((TextView) v.findViewById(R.id.item_state)).setText("");
        }
        break;
    case SettingsPanel.DRAWER_SETTINGS_POSITION:
        switch (position) {
            case 0:
                state = mLauncher.getAppsCustomizeTransitionEffect();
                state = mapEffectToValue(state);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 1:
                updateDrawerSortSettingsItem(v);
                break;
            case 2:
                current = SettingsProvider.getBoolean(mContext,
                        SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
                        R.bool.preferences_interface_drawer_hide_icon_labels_default);
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            default:
                ((TextView) v.findViewById(R.id.item_state)).setText("");
        }
        break;
    default:
        switch (position) {
            case 0:
                current = SettingsProvider.getBoolean(mContext,
                        SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
                        R.bool.preferences_interface_general_icons_large_default);
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
           
                
            default:
                ((TextView) v.findViewById(R.id.item_state)).setText("");
        }
}

v.setOnClickListener(mSettingsItemListener);
    
}
 
Example 15
Source Project: letv   File: CashierAcitivity.java    License: Apache License 2.0 4 votes vote down vote up
private View inflaterOthersView() {
    final View othersView = View.inflate(this.context, ResourceUtil.getLayoutResource(this.context, "lepay_cashier_paychannel_other"), null);
    ImageView itemIcon = (ImageView) othersView.findViewById(ResourceUtil.getIdResource(this.context, "lepay_paychannel_item_icon"));
    TextView itemTitle = (TextView) othersView.findViewById(ResourceUtil.getIdResource(this.context, "lepay_paychannel_item_title"));
    final ImageView arrawicon = (ImageView) othersView.findViewById(ResourceUtil.getIdResource(this.context, "lepay_cashier_paytype_other_selector_icon"));
    arrawicon.setImageResource(ResourceUtil.getDrawableResource(this.context, "icon_down"));
    itemIcon.setImageResource(ResourceUtil.getDrawableResource(this.context, "lepay_icon_more"));
    itemTitle.setText(ResourceUtil.getStringResource(this.context, "lepay_ohters_paytype"));
    othersView.setTag(Boolean.FALSE);
    othersView.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            int count;
            int i;
            if (((Boolean) view.getTag()).booleanValue()) {
                arrawicon.setImageResource(ResourceUtil.getDrawableResource(CashierAcitivity.this.context, "icon_down"));
                count = CashierAcitivity.this.lepay_cashier_paytype_list.getChildCount();
                for (i = 0; i < count; i++) {
                    View v = CashierAcitivity.this.lepay_cashier_paytype_list.getChildAt(i);
                    CheckBox checkBox = (CheckBox) v.findViewById(ResourceUtil.getIdResource(CashierAcitivity.this, "lepay_paychannel_item_checkbox"));
                    if (checkBox != null) {
                        if (((Boolean) checkBox.getTag()).booleanValue()) {
                            v.setVisibility(8);
                        } else {
                            v.setVisibility(0);
                        }
                    }
                }
                othersView.setTag(Boolean.FALSE);
                return;
            }
            arrawicon.setImageResource(ResourceUtil.getDrawableResource(CashierAcitivity.this.context, "icon_up"));
            count = CashierAcitivity.this.lepay_cashier_paytype_list.getChildCount();
            for (i = 0; i < count; i++) {
                CashierAcitivity.this.lepay_cashier_paytype_list.getChildAt(i).setVisibility(0);
            }
            othersView.setTag(Boolean.TRUE);
        }
    });
    othersView.performClick();
    othersView.performClick();
    return othersView;
}
 
Example 16
Source Project: retrowatch   File: MessageListAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder holder;
	View v = convertView;
	ContentObject co = getItem(position);
	
	if(v == null) {
		LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		v = li.inflate(R.layout.list_message_list, null);
		holder = new ViewHolder();
		
		holder.mItemContainer = (LinearLayout) v.findViewById(R.id.msg_item_container);
		holder.mItemContainer.setOnTouchListener(mListItemTouchListener);
		holder.mTextInfo = (TextView) v.findViewById(R.id.msg_info);
		holder.mTextOrigin = (TextView) v.findViewById(R.id.msg_origin);
		holder.mTextConverted = (TextView) v.findViewById(R.id.msg_converted);
		
		v.setTag(holder);
	} else {
		holder = (ViewHolder) v.getTag();
	}
	
	holder.mContentObject = co;
	
	if (co != null && holder != null) {
		if(co.mIsEnabled)
			holder.mItemContainer.setBackgroundColor(mContext.getResources().getColor(R.color.lightblue1));
		else
			holder.mItemContainer.setBackgroundColor(mContext.getResources().getColor(R.color.graye));
		
		holder.mTextInfo.setText(Utils.getMessageTypeString(co.mContentType) + " : " + co.mPackageName);
		if(co.mOriginalString != null) {
			holder.mTextOrigin.setText(co.mOriginalString);
		} else {
			holder.mTextOrigin.setText("");
		}
		if(co.mFilteredString != null) {
			holder.mTextConverted.setText("--> " + co.mFilteredString);
		} else {
			holder.mTextConverted.setText("");
		}
	}
	
	return v;
}
 
Example 17
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
	ViewHolder holder;
	EcuDataPv currPv = getItem(position);
	int pid = Objects.requireNonNull(currPv).getAsInt(EcuDataPv.FID_PID);

	// if no recycled convertView delivered, then create a new one
	if (convertView == null)
	{
		convertView = mInflater.inflate(resourceId, parent, false);

		holder = new ViewHolder();
		// get all views into view holder
		holder.gauge = convertView.findViewById(R.id.gauge);
		holder.tvDescr = convertView.findViewById(R.id.label);

		// remember this view holder
		convertView.setTag(holder);
	}
	else
	{
		// recall previous holder
		holder = (ViewHolder)convertView.getTag();
	}

	convertView.getLayoutParams().width = minWidth;
	convertView.getLayoutParams().height = minHeight;

	// if no rendering component is registered with PV, then create and register new one
	DialChart chartView = (DialChart)currPv.getRenderingComponent();
	if(chartView == null)
	{
		CategorySeries category = (CategorySeries) currPv.get(FID_GAUGE_SERIES);

		Number minValue = (Number) currPv.get(EcuDataPv.FID_MIN);
		Number maxValue = (Number) currPv.get(EcuDataPv.FID_MAX);
		if (minValue == null) minValue = 0f;
		if (maxValue == null) maxValue = 255f;

		DialRenderer renderer = new DialRenderer();
		renderer.setScale(1.25f);

		// dial background
		renderer.setPanEnabled(false);
		renderer.setShowLegend(false);
		renderer.setShowLabels(true);

		renderer.setLabelsTextSize(mDisplayMetrics.densityDpi / 10);
		renderer.setLabelsColor(Color.WHITE);
		renderer.setShowLabels(true);

		renderer.setVisualTypes(new DialRenderer.Type[]{DialRenderer.Type.NEEDLE});

		renderer.setMinValue(minValue.doubleValue());
		renderer.setMaxValue(maxValue.doubleValue());

		renderer.setChartTitle(currPv.getUnits());
		renderer.setChartTitleTextSize(mDisplayMetrics.densityDpi/10);

		SimpleSeriesRenderer r = new SimpleSeriesRenderer();
		r.setColor(ChartActivity.getItemColor(pid!=0?pid:position));
		try
		{
			r.setChartValuesFormat(labelFormat);
		}
		catch (Exception e)
		{
			// ignore
		}
		renderer.addSeriesRenderer(0, r);


		// create chart view and register with PV
		chartView = new DialChart(category, renderer);
		currPv.setRenderingComponent(chartView);
	}
	convertView.setBackgroundColor(ChartActivity.getItemColor(pid!=0?pid:position) & 0x08FFFFFF);

	// set new values for display
	holder.tvDescr.setTextColor(ChartActivity.getItemColor(pid!=0?pid:position));
	holder.tvDescr.setText(String.valueOf(currPv.get(EcuDataPv.FID_DESCRIPT)));
	// replace DialChart if needed
	holder.gauge.removeViewAt(0);
	holder.gauge.addView(new GraphicalView(getContext(), chartView), 0);

	return convertView;
}
 
Example 18
private void refreshList(boolean doReread) {
    if (GPLog.LOG_HEAVY)
        GPLog.addLogEntry(this, "refreshing gps maps list"); //$NON-NLS-1$
    gpslogItems = new LogMapItem[0];
    try {
        if (doReread) {
            List<LogMapItem> logsList = DaoGpsLog.getGpslogs();
            Collections.sort(logsList, mapItemSorter);
            gpslogItems = logsList.toArray(new LogMapItem[logsList.size()]);
        }
    } catch (IOException e) {
        GPLog.error(this, e.getLocalizedMessage(), e);
    }

    ArrayAdapter<MapItem> arrayAdapter = new ArrayAdapter<MapItem>(this, R.layout.activity_gpsdatalist_row, gpslogItems) {
        class ViewHolder {
            TextView nameView;
            CheckBox visibleView;
            Button colorView;
            ImageButton propertiesButton;
        }

        @Override
        public View getView(final int position, View cView, ViewGroup parent) {

            ViewHolder holder;
            // Recycle existing view if passed as parameter
            View rowView = cView;
            if (rowView == null) {
                LayoutInflater inflater = getLayoutInflater();
                rowView = inflater.inflate(R.layout.activity_gpsdatalist_row, parent, false);
                holder = new ViewHolder();
                holder.nameView = rowView.findViewById(R.id.filename);
                holder.visibleView = rowView.findViewById(R.id.visible);
                holder.colorView = rowView.findViewById(R.id.colorButton);
                holder.propertiesButton = rowView.findViewById(R.id.propertiesButton);
                rowView.setTag(holder);
            } else {
                holder = (ViewHolder) rowView.getTag();
            }


            final MapItem item = gpslogItems[position];

            Drawable background = holder.colorView.getBackground();
            if (background instanceof GradientDrawable) {
                int color = ColorUtilities.toColor(item.getColor());
                GradientDrawable gd = (GradientDrawable) background;
                gd.setStroke(1, Color.BLACK);
                gd.setColor(color);
            }
            holder.nameView.setText(item.getName());

            holder.visibleView.setChecked(item.isVisible());
            holder.visibleView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    item.setVisible(isChecked);
                    item.setDirty(true);
                }
            });
            holder.propertiesButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(GpsDataListActivity.this, GpsLogPropertiesActivity.class);
                    intent.putExtra(Constants.PREFS_KEY_GPSLOG4PROPERTIES, gpslogItems[position]);
                    startActivityForResult(intent, GPSDATAPROPERTIES_RETURN_CODE);
                }
            });

            return rowView;
        }

    };
    mListView.setAdapter(arrayAdapter);
}
 
Example 19
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    int rowType = getItemViewType(position);

    if (convertView == null) {
        holder = new ViewHolder();
        switch (rowType) {
            case TYPE_ITEM:
                convertView = layoutInflater.inflate(R.layout.list_item_shipping, parent, false);
                holder.title = convertView.findViewById(R.id.shipping_title);
                holder.description = convertView.findViewById(R.id.shipping_description);
                holder.price = convertView.findViewById(R.id.shipping_price);
                holder.isSelected = convertView.findViewById(R.id.shipping_is_selected);
                holder.separator = convertView.findViewById(R.id.shipping_separator);
                holder.shopInfo = convertView.findViewById(R.id.shipping_shop_info);
                break;
            default:
                convertView = layoutInflater.inflate(R.layout.list_item_shipping_section, parent, false);
                holder.title = convertView.findViewById(R.id.shipping_title);
                break;
        }
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    final Shipping item = shippingList.get(position);
    if (rowType == TYPE_SEPARATOR) {
        holder.title.setText(item.getName());
    } else {
        // First item without top line separator
        if (position == 0) {
            holder.separator.setVisibility(View.GONE);
        } else {
            holder.separator.setVisibility(View.VISIBLE);
        }

        // Highlight selected item
        if (selectedId != CONST.DEFAULT_EMPTY_ID && item.getId() == selectedId) {
            holder.title.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
            holder.isSelected.setVisibility(View.VISIBLE);
        } else {
            holder.title.setTextColor(ContextCompat.getColor(context, R.color.textPrimary));
            holder.isSelected.setVisibility(View.INVISIBLE);
        }

        holder.title.setText(item.getName());

        // Set price
        if (item.getPrice() == 0) {
            holder.price.setText(R.string.free);
        } else {
            holder.price.setText(context.getResources().getString(R.string.format_plus, item.getPriceFormatted()));
        }


        if (item.getBranch() != null) {
            if (item.getBranch().getName() != null && !item.getBranch().getName().isEmpty())
                holder.title.setText(item.getBranch().getName());
            holder.description.setText(item.getBranch().getAddress());
            holder.description.setVisibility(View.VISIBLE);
            holder.shopInfo.setVisibility(View.VISIBLE);
            holder.shopInfo.setOnClickListener(new View.OnClickListener() {
                private long mLastClickTime = 0;

                @Override
                public void onClick(View v) {
                    if (SystemClock.elapsedRealtime() - mLastClickTime < 1000)
                        return;
                    mLastClickTime = SystemClock.elapsedRealtime();

                    FragmentManager fm = fragment.getFragmentManager();
                    MapDialogFragment mapDialog = MapDialogFragment.newInstance(fragment, item, item.getBranch());
                    mapDialog.setRetainInstance(true);
                    mapDialog.show(fm, MapDialogFragment.class.getSimpleName());
                }
            });
        } else {
            holder.shopInfo.setVisibility(View.INVISIBLE);
            if (item.getDescription() != null && !item.getDescription().isEmpty()) {
                holder.description.setText(item.getDescription());
                holder.description.setVisibility(View.VISIBLE);
            } else
                holder.description.setVisibility(View.GONE);
        }
    }
    return convertView;
}
 
Example 20
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    view.setTag(R.id.fragment_root_view, this);
    Log.i(TAG + getClass().getSimpleName() + TAG_2, "onViewCreated");
}