リファクタ WIP

This commit is contained in:
rca 2024-07-06 12:43:16 +09:00
parent 01c9f84a61
commit dbe706ccbf

View File

@ -9,17 +9,14 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject; import javax.inject.Inject;
@ -47,6 +44,7 @@ public class ParentMainFragment extends Fragment {
ParentAdapter parentAdapter; ParentAdapter parentAdapter;
SwipeRefreshLayout swipeRefreshLayout; SwipeRefreshLayout swipeRefreshLayout;
LayoutInflater layoutInflater;
@SuppressLint("DatasetChange") @SuppressLint("DatasetChange")
private void updateTaskInfo(){ private void updateTaskInfo(){
@ -84,6 +82,7 @@ public class ParentMainFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.logger = ksLoggerFactory.create("ParentMainFragment"); this.logger = ksLoggerFactory.create("ParentMainFragment");
this.layoutInflater = requireActivity().getLayoutInflater();
} }
@SuppressLint("MissingInflatedId") @SuppressLint("MissingInflatedId")
@ -105,18 +104,9 @@ public class ParentMainFragment extends Fragment {
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
parentAdapter = new ParentAdapter(); parentAdapter = new ParentAdapter();
parentAdapter.setCallback(new ParentAdapter.CompleteButtonClickedCallback() { parentAdapter.setCallback(taskId -> {
@Override View childListView = layoutInflater.inflate(R.layout.act_child_select_dialog, null);
public void onClicked(String taskId) { RecyclerView recyclerView2 = childListView.findViewById(R.id.act_recycle_view);
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()); RecyclerView.LayoutManager layoutManager2 = new LinearLayoutManager(getContext());
recyclerView2.setLayoutManager(layoutManager2); recyclerView2.setLayoutManager(layoutManager2);
@ -138,15 +128,14 @@ public class ParentMainFragment extends Fragment {
} }
}).join(); }).join();
RecyclerView.Adapter mainAdapter2 = new ChildListAdapter2(child1); DialogChildListAdapter mainAdapter2 = new DialogChildListAdapter(child1);
recyclerView2.setAdapter(mainAdapter2); recyclerView2.setAdapter(mainAdapter2);
MaterialAlertDialogBuilder builder1 = new MaterialAlertDialogBuilder(getContext()); MaterialAlertDialogBuilder builder1 = new MaterialAlertDialogBuilder(requireContext());
builder1.setTitle("お手伝いをしたお子様の名前を選択してください") builder1.setTitle("お手伝いをしたお子様の名前を選択してください")
.setView(view2) .setView(childListView)
.setNeutralButton("閉じる",null); .setNeutralButton("閉じる",null);
builder1.create().show(); builder1.create().show();
}
}); });
recyclerView.setAdapter(parentAdapter); recyclerView.setAdapter(parentAdapter);
updateTaskInfo(); updateTaskInfo();