feature/updateupdate #138
|
@ -0,0 +1,43 @@
|
|||
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.ChildModel;
|
||||
|
||||
public class ChildListAdapter2 extends RecyclerView.Adapter<ChildListAdapter2.MainViewHolder> {
|
||||
|
||||
private final List<ChildModel> childDataList;
|
||||
|
||||
ChildListAdapter2(List<ChildModel> childDataList){this.childDataList = childDataList;}
|
||||
|
||||
static class MainViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView actchildname;
|
||||
|
||||
MainViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
actchildname = itemView.findViewById(R.id.actchildname);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MainViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_act_child_name,parent,false);
|
||||
return new MainViewHolder(view);
|
||||
}
|
||||
|
||||
public void onBindViewHolder(@NonNull MainViewHolder holder,int position){
|
||||
ChildModel childData = this.childDataList.get(position);
|
||||
holder.actchildname.setText(childData.getName());
|
||||
}
|
||||
|
||||
public int getItemCount(){ return childDataList.size();}
|
||||
}
|
|
@ -3,6 +3,7 @@ package one.nem.kidshift.feature.parent;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -15,8 +16,14 @@ import one.nem.kidshift.model.tasks.TaskItemModel;
|
|||
|
||||
public class ParentAdapter extends RecyclerView.Adapter<ParentAdapter.MainViewHolder> {
|
||||
|
||||
public interface CompleteButtonClickedCallback {
|
||||
void onClicked(String taskId);
|
||||
}
|
||||
|
||||
private List<TaskItemModel> taskDataList;
|
||||
|
||||
private CompleteButtonClickedCallback callback;
|
||||
|
||||
// ParentAdapter(List<TaskItemModel> taskDataList) { this.taskDataList = taskDataList; }
|
||||
ParentAdapter(){
|
||||
|
||||
|
@ -26,15 +33,20 @@ public class ParentAdapter extends RecyclerView.Adapter<ParentAdapter.MainViewHo
|
|||
this.taskDataList = taskDataList;
|
||||
}
|
||||
|
||||
public void setCallback(CompleteButtonClickedCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
static class MainViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView taskTitle;
|
||||
TextView taskContents;
|
||||
Button completedButton;
|
||||
|
||||
MainViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
taskTitle = itemView.findViewById(R.id.task_title_text_view);
|
||||
taskContents = itemView.findViewById(R.id.task_contents_text_view);
|
||||
completedButton = itemView.findViewById(R.id.actbutton);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +61,9 @@ public class ParentAdapter extends RecyclerView.Adapter<ParentAdapter.MainViewHo
|
|||
TaskItemModel taskData = this.taskDataList.get(position);
|
||||
holder.taskTitle.setText(taskData.getName());
|
||||
holder.taskContents.setText(Long.toString(taskData.getReward()));
|
||||
holder.completedButton.setOnClickListener(v -> {
|
||||
this.callback.onClicked(taskData.getId());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,8 @@ import android.util.Log;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
|
@ -42,6 +44,8 @@ public class ParentMainFragment extends Fragment {
|
|||
ParentAdapter parentAdapter;
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
|
||||
|
||||
@SuppressLint("DatasetChange")
|
||||
private void updateTaskInfo(){
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
|
@ -74,6 +78,7 @@ public class ParentMainFragment extends Fragment {
|
|||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -92,6 +97,34 @@ public class ParentMainFragment extends Fragment {
|
|||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
parentAdapter = new ParentAdapter();
|
||||
parentAdapter.setCallback(new ParentAdapter.CompleteButtonClickedCallback() {
|
||||
@Override
|
||||
public void onClicked(String taskId) {
|
||||
Toast.makeText(requireContext(), "TaskID: " + taskId, Toast.LENGTH_LONG).show();
|
||||
//お手伝い完了処理
|
||||
LayoutInflater inflater2 = requireActivity().getLayoutInflater();
|
||||
View view2 = inflater2.inflate(R.layout.act_child_select_dialog,null);
|
||||
|
||||
//子供一覧表示
|
||||
RecyclerView recyclerView2 = view2.findViewById(R.id.act_recycle_view);
|
||||
|
||||
recyclerView2.setHasFixedSize(true);
|
||||
|
||||
RecyclerView.LayoutManager layoutManager2 = new LinearLayoutManager(getContext());
|
||||
recyclerView2.setLayoutManager(layoutManager2);
|
||||
|
||||
List<ChildModel> child1 = childData.getChildList().join();
|
||||
|
||||
RecyclerView.Adapter mainAdapter2 = new ChildListAdapter2(child1);
|
||||
recyclerView2.setAdapter(mainAdapter2);
|
||||
|
||||
MaterialAlertDialogBuilder builder1 = new MaterialAlertDialogBuilder(getContext());
|
||||
builder1.setTitle("お手伝いをしたお子様の名前を選択してください")
|
||||
.setView(view2)
|
||||
.setNeutralButton("閉じる",null);
|
||||
builder1.create().show();
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(parentAdapter);
|
||||
updateTaskInfo();
|
||||
|
||||
|
@ -106,8 +139,6 @@ public class ParentMainFragment extends Fragment {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
//お手伝い追加ダイアログ
|
||||
LayoutInflater inflater1 = requireActivity().getLayoutInflater();
|
||||
View view1 = inflater1.inflate(R.layout.add_task_list_dialog,null);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?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="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/act_recycle_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginEnd="1dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
31
feature/parent/src/main/res/layout/list_act_child_name.xml
Normal file
31
feature/parent/src/main/res/layout/list_act_child_name.xml
Normal file
|
@ -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">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/actchildname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="30dp"
|
||||
android:text="TextView"
|
||||
android:textSize="14dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.517" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/selectChild"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:text="完了"
|
||||
android:textSize="14dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,19 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout 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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/textContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/task_title_text_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="お手伝い名"
|
||||
android:textSize="24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
@ -21,11 +26,26 @@
|
|||
android:id="@+id/task_contents_text_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:text="円/回"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/task_title_text_view" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0">
|
||||
|
||||
<Button
|
||||
android:id="@+id/actbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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" />
|
||||
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -12,6 +12,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
@ -50,6 +51,7 @@ public class SettingMainFragment extends Fragment {
|
|||
SettingAdapter mainAdapter;
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
|
||||
public SettingMainFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
@ -182,6 +184,7 @@ public class SettingMainFragment extends Fragment {
|
|||
});
|
||||
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user