修正
This commit is contained in:
parent
48949d3c60
commit
6160eba7ac
|
@ -20,13 +20,14 @@
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorSurface"
|
||||||
android:minHeight="?attr/actionBarSize"
|
android:minHeight="?attr/actionBarSize"
|
||||||
android:theme="?attr/actionBarTheme"
|
android:theme="?attr/actionBarTheme"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:title="@string/app_name" />
|
app:title="@string/app_name"
|
||||||
|
android:elevation="8dp" />
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/fragmentContainerView"
|
android:id="@+id/fragmentContainerView"
|
||||||
|
|
|
@ -43,6 +43,7 @@ import dagger.hilt.android.AndroidEntryPoint;
|
||||||
import one.nem.kidshift.data.ChildData;
|
import one.nem.kidshift.data.ChildData;
|
||||||
import one.nem.kidshift.data.RewardData;
|
import one.nem.kidshift.data.RewardData;
|
||||||
import one.nem.kidshift.data.TaskData;
|
import one.nem.kidshift.data.TaskData;
|
||||||
|
import one.nem.kidshift.data.UserSettings;
|
||||||
import one.nem.kidshift.feature.common.adapter.ChildListItemAdapter;
|
import one.nem.kidshift.feature.common.adapter.ChildListItemAdapter;
|
||||||
import one.nem.kidshift.feature.common.adapter.TaskListItemAdapter;
|
import one.nem.kidshift.feature.common.adapter.TaskListItemAdapter;
|
||||||
import one.nem.kidshift.model.callback.TaskItemModelCallback;
|
import one.nem.kidshift.model.callback.TaskItemModelCallback;
|
||||||
|
@ -74,6 +75,8 @@ public class CommonHomeFragment extends Fragment {
|
||||||
RewardData rewardData;
|
RewardData rewardData;
|
||||||
@Inject
|
@Inject
|
||||||
RecyclerViewAnimUtils recyclerViewAnimUtils;
|
RecyclerViewAnimUtils recyclerViewAnimUtils;
|
||||||
|
@Inject
|
||||||
|
UserSettings userSettings;
|
||||||
|
|
||||||
|
|
||||||
private boolean isChildMode;
|
private boolean isChildMode;
|
||||||
|
@ -98,9 +101,7 @@ public class CommonHomeFragment extends Fragment {
|
||||||
CommonHomeFragment fragment = new CommonHomeFragment();
|
CommonHomeFragment fragment = new CommonHomeFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putBoolean(ARG_IS_CHILD_MODE, isChildMode);
|
args.putBoolean(ARG_IS_CHILD_MODE, isChildMode);
|
||||||
if (isChildMode) {
|
args.putString(ARG_CHILD_ID, childId);
|
||||||
args.putString(ARG_CHILD_ID, childId);
|
|
||||||
}
|
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -108,16 +109,30 @@ public class CommonHomeFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (getArguments() != null) {
|
|
||||||
isChildMode = getArguments().getBoolean(ARG_IS_CHILD_MODE);
|
|
||||||
childId = getArguments().getString(ARG_CHILD_ID);
|
|
||||||
}
|
|
||||||
logger = ksLoggerFactory.create("CommonHomeFragment");
|
logger = ksLoggerFactory.create("CommonHomeFragment");
|
||||||
|
|
||||||
if (isChildMode) {
|
if (userSettings.getAppCommonSetting().isChildMode()) {
|
||||||
logger.info("Child mode, childId: " + childId);
|
logger.debug("子供モードで起動(子供ログイン)");
|
||||||
|
isChildMode = true;
|
||||||
|
childId = userSettings.getAppCommonSetting().getChildId();
|
||||||
|
logger.debug("childId: " + childId);
|
||||||
} else {
|
} else {
|
||||||
logger.info("Parent mode");
|
if (getArguments() != null) {
|
||||||
|
isChildMode = getArguments().getBoolean(ARG_IS_CHILD_MODE) && getArguments().getBoolean(ARG_IS_CHILD_MODE);
|
||||||
|
childId = getArguments().getString(ARG_CHILD_ID) != null ? getArguments().getString(ARG_CHILD_ID) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childId != null && !childId.isEmpty()) {
|
||||||
|
isChildMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isChildMode) {
|
||||||
|
logger.debug("子供モードで起動");
|
||||||
|
logger.debug("childId: " + childId);
|
||||||
|
} else {
|
||||||
|
logger.debug("保護者モードで起動");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,9 +146,7 @@ public class CommonHomeFragment extends Fragment {
|
||||||
taskListItemAdapter = new TaskListItemAdapter();
|
taskListItemAdapter = new TaskListItemAdapter();
|
||||||
taskListItemAdapter.setCallback((taskId, taskName) -> {
|
taskListItemAdapter.setCallback((taskId, taskName) -> {
|
||||||
if (isChildMode) {
|
if (isChildMode) {
|
||||||
if (showConfirmDialog(taskName)) {
|
showConfirmDialog(taskId, taskName);
|
||||||
taskData.recordTaskCompletion(taskId, childId);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
showChildSelectDialog(taskId, taskName);
|
showChildSelectDialog(taskId, taskName);
|
||||||
}
|
}
|
||||||
|
@ -277,24 +290,22 @@ public class CommonHomeFragment extends Fragment {
|
||||||
/**
|
/**
|
||||||
* タスク完了確認ダイアログを表示 (子供モード用)
|
* タスク完了確認ダイアログを表示 (子供モード用)
|
||||||
*
|
*
|
||||||
|
* @param taskId タスクID
|
||||||
* @param taskName タスク名
|
* @param taskName タスク名
|
||||||
* @return OKボタンが押されたかどうか
|
|
||||||
*/
|
*/
|
||||||
private boolean showConfirmDialog(String taskName) {
|
private void showConfirmDialog(String taskId, String taskName) {
|
||||||
AtomicBoolean selection = new AtomicBoolean(false);
|
|
||||||
new MaterialAlertDialogBuilder(requireContext())
|
new MaterialAlertDialogBuilder(requireContext())
|
||||||
.setTitle("タスクを完了しますか?")
|
.setTitle("タスクを完了しますか?")
|
||||||
.setMessage(taskName + "を完了しますか?")
|
.setMessage(taskName + "を完了しますか?")
|
||||||
.setPositiveButton("はい", (dialog, which) -> {
|
.setPositiveButton("はい", (dialog, which) -> {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
selection.set(true);
|
taskData.recordTaskCompletion(taskId, childId);
|
||||||
})
|
})
|
||||||
.setNegativeButton("いいえ", (dialog, which) -> {
|
.setNegativeButton("いいえ", (dialog, which) -> {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
selection.set(false);
|
taskData.recordTaskCompletion(taskId, childId);
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
return selection.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,9 +62,9 @@ public class CommonSelectChildFragment extends Fragment {
|
||||||
childListRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
childListRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
recyclerViewAnimUtils.setSlideUpAnimation(childListRecyclerView);
|
recyclerViewAnimUtils.setSlideUpAnimation(childListRecyclerView);
|
||||||
adapter = new SelectShowChildListItemAdapter();
|
adapter = new SelectShowChildListItemAdapter();
|
||||||
adapter.setCallback(taskId -> {
|
adapter.setCallback(childId -> {
|
||||||
// 静的解析エラーが発生するのになぜか実行はできる↓
|
// 静的解析エラーが発生するのになぜか実行はできる↓
|
||||||
findNavController(view).navigate(CommonSelectChildFragmentDirections.actionCommonSelectChildFragmentToCommonHomeFragmentParentChild(taskId));
|
findNavController(view).navigate(CommonSelectChildFragmentDirections.actionCommonSelectChildFragmentToCommonHomeFragmentParentChild(childId));
|
||||||
});
|
});
|
||||||
CompletableFuture.runAsync(() -> childListRecyclerView.setAdapter(adapter)).thenRun(() -> childData.getChildListDirect().thenAccept(childList -> {
|
CompletableFuture.runAsync(() -> childListRecyclerView.setAdapter(adapter)).thenRun(() -> childData.getChildListDirect().thenAccept(childList -> {
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
android:name="one.nem.kidshift.feature.common.CommonHomeFragment"
|
android:name="one.nem.kidshift.feature.common.CommonHomeFragment"
|
||||||
android:label="fragment_common_home"
|
android:label="fragment_common_home"
|
||||||
tools:layout="@layout/fragment_common_home" >
|
tools:layout="@layout/fragment_common_home" >
|
||||||
|
<argument
|
||||||
|
android:name="childId"
|
||||||
|
app:argType="string" />
|
||||||
<argument
|
<argument
|
||||||
android:name="isChildMode"
|
android:name="isChildMode"
|
||||||
app:argType="boolean"
|
app:argType="boolean"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user