diff --git a/app/src/main/java/org/ntlab/acanthus_client/entities/AnimationJson.java b/app/src/main/java/org/ntlab/acanthus_client/entities/AnimationJson.java index f63b631..1c9421e 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/entities/AnimationJson.java +++ b/app/src/main/java/org/ntlab/acanthus_client/entities/AnimationJson.java @@ -36,7 +36,7 @@ this.ownerUid = uid; } - public void addEdiotrs(Editor editor) { + public void addEditors(Editor editor) { this.editors.add(editor); } } diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeFragment.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeFragment.java index 78f985b..e2e4397 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeFragment.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeFragment.java @@ -65,7 +65,7 @@ ListView listView = (ListView) getActivity().findViewById(R.id.animation_view); - homeViewModel.updateGallery(); + homeViewModel.updateGallery(acanthus); homeViewModel.getAnimationJson().observe(getViewLifecycleOwner(), new Observer>() { @Override @@ -76,8 +76,6 @@ } }); - homeViewModel.updateGallery(); - } public void onCreateAnimationView(Animation animation){ diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java index 87252ca..bde7820 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/HomeViewModel.java @@ -42,7 +42,7 @@ public LiveData> getAnimationJson(){return this.animationMutableLiveData;} - public void updateGallery(){ + public void updateGallery(Acanthus acanthus){ Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/acanthus/") .addConverterFactory(JacksonConverterFactory.create()) @@ -56,6 +56,7 @@ public void onResponse(Call> call, Response> response) { Collection animList = response.body(); animationMutableLiveData.setValue(animList); + acanthus.setAnimationJsonList(animList); } @Override diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/ListAnimationViewAdapter.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/ListAnimationViewAdapter.java index e5c7584..8394294 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/ListAnimationViewAdapter.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/home/ListAnimationViewAdapter.java @@ -8,32 +8,29 @@ 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; + TextView createdDate; } private LayoutInflater inflater; private int itemLayoutId; private ArrayList titles = new ArrayList<>(); private ArrayList> animationEditors =new ArrayList<>(); + private ArrayList createdDates = new ArrayList<>(); ListAnimationViewAdapter(Context context, int itemLayoutId, Collection animationJsons) { super(); - int i = 0; this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.itemLayoutId = itemLayoutId; @@ -44,6 +41,7 @@ editors.add(editor.getEditorAccount().getName()); } animationEditors.add(editors); + this.createdDates.add(animationJson.getCreatedDate()); } } @@ -66,8 +64,13 @@ holder = new ViewHolder(); holder.animationName = convertView.findViewById(R.id.animationName); holder.editorsName = convertView.findViewById(R.id.editorsName); - holder.LastUpDate = convertView.findViewById(R.id.lastUpDate); + holder.createdDate = convertView.findViewById(R.id.createdDate); convertView.setTag(holder); + + holder.animationName.setText(this.titles.get(position)); + for(String s: this.animationEditors.get(position))holder.editorsName.setText(s); + holder.createdDate.setText(this.createdDates.get(position)); + } // holder を使って再利用 else { diff --git a/app/src/main/res/layout/animation_home.xml b/app/src/main/res/layout/animation_home.xml index c9bf824..8e33eaf 100644 --- a/app/src/main/res/layout/animation_home.xml +++ b/app/src/main/res/layout/animation_home.xml @@ -23,7 +23,7 @@ app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/createdDate" /> \ No newline at end of file