| | package org.ntlab.acanthus_client.views.main_menu_ui.home; |
---|
| | |
---|
| | import android.content.Context; |
---|
| | import android.view.LayoutInflater; |
---|
| | import android.view.View; |
---|
| | import android.view.ViewGroup; |
---|
| | import android.widget.BaseAdapter; |
---|
| | import android.widget.TextView; |
---|
| | |
---|
| | import org.ntlab.acanthus_client.R; |
---|
| | import org.ntlab.acanthus_client.entities.Animation; |
---|
| | import org.ntlab.acanthus_client.entities.AnimationJson; |
---|
| | import org.ntlab.acanthus_client.entities.Editor; |
---|
| | |
---|
| | import java.util.ArrayList; |
---|
| | import java.util.Collection; |
---|
| | import java.util.Iterator; |
---|
| | import java.util.HashSet; |
---|
| | |
---|
| | public class ListAnimationViewAdapter extends BaseAdapter { |
---|
| | |
---|
| | static class ViewHolder{ |
---|
| | TextView animationName; |
---|
| | TextView editorsName; |
---|
| | TextView LastUpDate; |
---|
| | } |
---|
| | |
---|
| | private LayoutInflater inflater; |
---|
| | private int itemLayoutId; |
---|
| | private ArrayList<String> titles; |
---|
| | private ArrayList<ArrayList<String>> animationEditors; |
---|
| | |
---|
| | ListAnimationViewAdapter(Context context, int itemLayoutId, |
---|
| | Collection<AnimationJson> animationJsons) { |
---|
| | super(); |
---|
| | int i = 0; |
---|
| | this.inflater = (LayoutInflater) |
---|
| | context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
---|
| | this.itemLayoutId = itemLayoutId; |
---|
| | for(AnimationJson animationJson: animationJsons){ |
---|
| | this.titles.add(animationJson.getAnimationName()); |
---|
| | ArrayList<String> editors = new ArrayList<>(); |
---|
| | for(Editor editor: animationJson.getEditor()){ |
---|
| | editors.add(editor.getEditorAccount().getName()); |
---|
| | } |
---|
| | animationEditors.add(editors); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public View getView(int position, View convertView, ViewGroup parent) { |
---|
| | ViewHolder holder; |
---|
| | // 最初だけ View を inflate して、それを再利用する |
---|
| | if (convertView == null) { |
---|
| | // activity_main.xml に list.xml を inflate して convertView とする |
---|
| | convertView = inflater.inflate(itemLayoutId, parent, false); |
---|
| | // ViewHolder を生成 |
---|
| | holder = new ViewHolder(); |
---|
| | holder.animationName = convertView.findViewById(R.id.animationName); |
---|
| | holder.editorsName = convertView.findViewById(R.id.editorsName); |
---|
| | holder.LastUpDate = convertView.findViewById(R.id.lastUpDate); |
---|
| | convertView.setTag(holder); |
---|
| | } |
---|
| | // holder を使って再利用 |
---|
| | else { |
---|
| | holder = (ViewHolder) convertView.getTag(); |
---|
| | } |
---|
| | |
---|
| | // holder の imageView にセット |
---|
| | holder.animationName.setText(titles.get(position)); |
---|
| | // 現在の position にあるファイル名リストを holder の textView にセット |
---|
| | for(String ed : animationEditors.get(position)){ |
---|
| | holder.editorsName.setText(ed); |
---|
| | |
---|
| | } |
---|
| | |
---|
| | return convertView; |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public int getCount() { |
---|
| | return 0; |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public Object getItem(int i) { |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public long getItemId(int i) { |
---|
| | return 0; |
---|
| | } |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
マージお願いします。