タスク一覧表示 #61
|
@ -0,0 +1,49 @@
|
|||
package one.nem.kidshift.feature.parent;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import one.nem.kidshift.model.tasks.TaskItemModel;
|
||||
|
||||
public class ParentAdapter extends RecyclerView.Adapter<ParentAdapter.MainViewHolder> {
|
||||
|
||||
private List<TaskItemModel> taskDataList;
|
||||
|
||||
ParentAdapter(List<TaskItemModel> taskDataList) { this.taskDataList = taskDataList; }
|
||||
|
||||
static class MainViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView taskTitle;
|
||||
TextView taskContents;
|
||||
|
||||
MainViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
taskTitle = itemView.findViewById(R.id.task_title_text_view);
|
||||
taskContents = itemView.findViewById(R.id.task_contents_text_view);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MainViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_parent_task_list_item, parent,false);
|
||||
return new MainViewHolder(view);
|
||||
}
|
||||
|
||||
public void onBindViewHolder(@NonNull MainViewHolder holder,int position){
|
||||
TaskItemModel taskData = this.taskDataList.get(position);
|
||||
holder.taskTitle.setText(taskData.getDisplayName());
|
||||
holder.taskContents.setText(Long.toString(taskData.getReward()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount(){
|
||||
return taskDataList.size();
|
||||
}
|
||||
}
|
|
@ -1,20 +1,45 @@
|
|||
package one.nem.kidshift.feature.parent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.hilt.android.AndroidEntryPoint;
|
||||
import one.nem.kidshift.data.TaskData;
|
||||
import one.nem.kidshift.model.tasks.TaskItemModel;
|
||||
import one.nem.kidshift.utils.KSLogger;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ParentMainFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
|
||||
@AndroidEntryPoint
|
||||
public class ParentMainFragment extends Fragment {
|
||||
|
||||
|
||||
|
||||
|
||||
@Inject
|
||||
KSLogger ksLogger;
|
||||
|
||||
@Inject
|
||||
TaskData taskData;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
|
@ -59,6 +84,34 @@ public class ParentMainFragment extends Fragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_parent_main, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_parent_main, container, false);
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.main_recycle_view);
|
||||
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
List<TaskItemModel> task = taskData.getTasks();
|
||||
|
||||
RecyclerView.Adapter mainAdapter = new ParentAdapter(task);
|
||||
recyclerView.setAdapter(mainAdapter);
|
||||
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
ksLogger.addTag("ParentFragment");
|
||||
|
||||
List<TaskItemModel> task = taskData.getTasks();
|
||||
|
||||
ksLogger.debug("取得したデータ: " + task);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,20 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ParentMainFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="🧑PARENT"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Display3"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/main_recycle_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/task_title_text_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:text="お手伝い名"
|
||||
android:textSize="24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/task_contents_text_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="円/回"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/task_title_text_view"
|
||||
app:layout_constraintTop_toBottomOf="@id/task_title_text_view" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user