com.zhy.adapter.abslistview.ViewHolder Java Examples

The following examples show how to use com.zhy.adapter.abslistview.ViewHolder. 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 File: ListViewActivity.java    From ViewCapture with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_view);
    setActionBarTitle("ListView Capture");
    listView = findViewById(R.id.listView);
    CommonAdapter commonAdapter=new CommonAdapter<String>(this, R.layout.layout_item, Arrays.asList(getResources().getStringArray(R.array.listView_item))) {
        @Override
        protected void convert(ViewHolder viewHolder, String item, int position) {
            TextView textView = viewHolder.getView(R.id.tv);
            textView.setText(item);
        }
    };
    listView.setAdapter(commonAdapter);
    listView.addFooterView(LayoutInflater.from(this).inflate(R.layout.layout_add_item, null));
}
 
Example #2
Source File: ItemViewDelegateManager.java    From baseAdapter with Apache License 2.0 6 votes vote down vote up
public void convert(ViewHolder holder, T item, int position)
{
    int delegatesCount = delegates.size();
    for (int i = 0; i < delegatesCount; i++)
    {
        ItemViewDelegate<T> delegate = delegates.valueAt(i);

        if (delegate.isForViewType(item, position))
        {
            delegate.convert(holder, item, position);
            return;
        }
    }
    throw new IllegalArgumentException(
            "No ItemViewDelegateManager added that matches position=" + position + " in data source");
}
 
Example #3
Source File: HomeMessageFragment.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@Override
protected void initView() {
    super.initView();


    adapter = new CommonAdapter<ConversationDbObject>(mContext, R.layout.coversation_list_item, items) {
        @Override
        protected void convert(ViewHolder viewHolder, ConversationDbObject item, int position) {

            viewHolder.setText(R.id.list_user_name, item.getId());
            viewHolder.setText(R.id.list_content, item.getLatestmsgtext());

            String time = TimeUtil.getHourStrTime(item.getLatestmsgtimestamp());
            viewHolder.setText(R.id.list_time, time);
            viewHolder.setText(R.id.list_unreadCount, Integer.toString(item.getUnreadcount()));
            TextView unreadText = viewHolder.getView(R.id.list_unreadCount);
            if (item.getUnreadcount() == 0) {
                unreadText.setVisibility(View.GONE);
            } else {
                unreadText.setVisibility(View.VISIBLE);
            }
        }
    };
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            BaseActivity activity = (BaseActivity)mContext;
            Bundle bundle = new Bundle();
            bundle.putString("username", items.get(i).getId());
            activity.openActivity(ChatActivity.class, bundle);


            // 清空未读消息
            clearUnread(i);
        }
    });
}
 
Example #4
Source File: HomeContactFrament.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@Override
protected void initView() {
    super.initView();


    adapter = new CommonAdapter<UserModel>(mContext, R.layout.contact_list_item, users) {
        @Override
        protected void convert(ViewHolder viewHolder, UserModel item, int position) {

            viewHolder.setText(R.id.contact_user_name, item.getName());
            viewHolder.setText(R.id.contact_user_state, item.isOnline()?"[在线]":"[离线]");
        }
    };

    listView.setAdapter(adapter);


    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            BaseActivity activity = (BaseActivity)mContext;

            Bundle bundle = new Bundle();
            bundle.putString("username", users.get(i).getName());
            activity.openActivity(ChatActivity.class, bundle);


            clearUnread(i);
        }
    });
}
 
Example #5
Source File: MsgSendItemDelagate.java    From baseAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public void convert(ViewHolder holder, ChatMessage chatMessage, int position)
{
    holder.setText(R.id.chat_send_content, chatMessage.getContent());
    holder.setText(R.id.chat_send_name, chatMessage.getName());
    holder.setImageResource(R.id.chat_send_icon, chatMessage.getIcon());
}
 
Example #6
Source File: MsgComingItemDelagate.java    From baseAdapter with Apache License 2.0 5 votes vote down vote up
@Override
public void convert(ViewHolder holder, ChatMessage chatMessage, int position)
{
    holder.setText(R.id.chat_from_content, chatMessage.getContent());
    holder.setText(R.id.chat_from_name, chatMessage.getName());
    holder.setImageResource(R.id.chat_from_icon, chatMessage.getIcon());
}
 
Example #7
Source File: ItemViewDelegate.java    From baseAdapter with Apache License 2.0 votes vote down vote up
public abstract void convert(ViewHolder holder, T t, int position);