不要になった実装を削除
This commit is contained in:
parent
2a35d18fe5
commit
801b00e7ea
|
@ -32,132 +32,14 @@ import one.nem.kidshift.utils.models.FabEventCallback;
|
|||
@AndroidEntryPoint
|
||||
public class ParentMainFragment extends Fragment {
|
||||
|
||||
@Inject
|
||||
KSLoggerFactory ksLoggerFactory;
|
||||
@Inject
|
||||
TaskData taskData;
|
||||
@Inject
|
||||
ChildData childData;
|
||||
@Inject
|
||||
FabManager fabManager;
|
||||
|
||||
private KSLogger logger;
|
||||
|
||||
ParentAdapter parentAdapter;
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
LayoutInflater layoutInflater;
|
||||
|
||||
@SuppressLint({"DatasetChange", "NotifyDataSetChanged"})
|
||||
private void updateTaskInfo(){
|
||||
swipeRefreshLayout.setRefreshing(true);
|
||||
taskData.getTasks(new TaskItemModelCallback() {
|
||||
@Override
|
||||
public void onUnchanged() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdated(List<TaskItemModel> taskItem) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String message) {
|
||||
|
||||
}
|
||||
}).thenAccept(taskItemModel -> {
|
||||
parentAdapter.setTaskDataList(taskItemModel);
|
||||
try { // Workaround
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
// Do nothing
|
||||
}
|
||||
requireActivity().runOnUiThread(()-> {
|
||||
parentAdapter.notifyDataSetChanged(); // Workaround
|
||||
});
|
||||
}).thenRun(() -> swipeRefreshLayout.setRefreshing(false));
|
||||
}
|
||||
|
||||
public ParentMainFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.logger = ksLoggerFactory.create("ParentMainFragment");
|
||||
this.layoutInflater = requireActivity().getLayoutInflater();
|
||||
}
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View view = inflater.inflate(R.layout.fragment_parent_main, container, false);
|
||||
|
||||
swipeRefreshLayout = view.findViewById(R.id.swipe_refresh_layout);
|
||||
|
||||
RecyclerView recyclerView = view.findViewById(R.id.main_recycle_view);
|
||||
|
||||
recyclerView.setHasFixedSize(true);
|
||||
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
parentAdapter = new ParentAdapter();
|
||||
parentAdapter.setCallback(taskId -> {
|
||||
View childListView = layoutInflater.inflate(R.layout.act_child_select_dialog, null);
|
||||
RecyclerView childListRecyclerView = childListView.findViewById(R.id.act_recycle_view);
|
||||
childListRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
childData.getChildListDirect().thenAccept(childModelList -> childListRecyclerView.setAdapter(new TackCompleteDialogChildListAdapter(childModelList))).thenRun(() -> {
|
||||
MaterialAlertDialogBuilder builder1 = new MaterialAlertDialogBuilder(requireContext());
|
||||
builder1.setTitle("お手伝いをしたお子様の名前を選択してください")
|
||||
.setView(childListView)
|
||||
.setNeutralButton("閉じる", (dialog, which) -> dialog.dismiss());
|
||||
builder1.show();
|
||||
}).join();
|
||||
|
||||
});
|
||||
recyclerView.setAdapter(parentAdapter);
|
||||
|
||||
updateTaskInfo();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
// FABイベント設定
|
||||
if (!fabManager.isShown()) fabManager.show();
|
||||
fabManager.setFabEventCallback(new FabEventCallback() {
|
||||
@Override
|
||||
public void onClicked() {
|
||||
View childListView = layoutInflater.inflate(R.layout.add_task_list_dialog, null);
|
||||
RecyclerView childListRecyclerView = childListView.findViewById(R.id.taskchild);
|
||||
childData.getChildListDirect().thenAccept(childModelList ->
|
||||
childListRecyclerView.setAdapter(
|
||||
new AddTaskDialogChildListAdapter(childModelList)))
|
||||
.thenRun(() -> {
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
|
||||
builder.setTitle("お手伝い名追加")
|
||||
.setView(childListView)
|
||||
.setPositiveButton("追加", null)
|
||||
.setNeutralButton("閉じる", null);
|
||||
builder.show();
|
||||
}).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongClicked() {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
|
||||
// SwipeToRefresh
|
||||
swipeRefreshLayout.setOnRefreshListener(this::updateTaskInfo);
|
||||
return inflater.inflate(R.layout.fragment_parent_main, container, false);
|
||||
}
|
||||
}
|
|
@ -1,28 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<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:id="@+id/swipe_refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ParentMainFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/addtask"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/main_recycle_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
tools:context=".ParentMainFragment"/>
|
Loading…
Reference in New Issue
Block a user