You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
package org.transdroid.core.gui.remoterss; |
|
|
|
import android.content.Context; |
|
import android.view.View; |
|
import android.view.ViewGroup; |
|
import android.widget.BaseAdapter; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssItem; |
|
|
|
import java.util.ArrayList; |
|
import java.util.List; |
|
|
|
public class RemoteRssItemsAdapter extends BaseAdapter { |
|
protected Context context; |
|
protected List<RemoteRssItem> items; |
|
|
|
public RemoteRssItemsAdapter(Context context) { |
|
this.context = context; |
|
items = new ArrayList<>(); |
|
} |
|
|
|
@Override |
|
public int getCount() { |
|
return items.size(); |
|
} |
|
|
|
@Override |
|
public Object getItem(int position) { |
|
return items.get(position); |
|
} |
|
|
|
@Override |
|
public long getItemId(int position) { |
|
return position; |
|
} |
|
|
|
@Override |
|
public View getView(int position, View convertView, ViewGroup parent) { |
|
RemoteRssItemView itemView; |
|
|
|
if (convertView == null) { |
|
itemView = RemoteRssItemView_.build(context); |
|
} else { |
|
itemView = (RemoteRssItemView) convertView; |
|
} |
|
|
|
itemView.bind((RemoteRssItem) getItem(position)); |
|
|
|
return itemView; |
|
} |
|
|
|
public void updateItems(List<RemoteRssItem> remoteItems) { |
|
items = remoteItems; |
|
notifyDataSetChanged(); |
|
} |
|
}
|
|
|