Merge pull request '大規模リファクタ' (#143) from feature/change_module into main

Reviewed-on: #143
This commit is contained in:
Fujimatsu 2024-07-07 06:44:07 +00:00
commit 376c7e38f3
24 changed files with 653 additions and 142 deletions

View File

@ -13,6 +13,7 @@
<option value="$PROJECT_DIR$/data" />
<option value="$PROJECT_DIR$/feature" />
<option value="$PROJECT_DIR$/feature/child" />
<option value="$PROJECT_DIR$/feature/common" />
<option value="$PROJECT_DIR$/feature/debug" />
<option value="$PROJECT_DIR$/feature/parent" />
<option value="$PROJECT_DIR$/feature/setting" />

View File

@ -45,6 +45,7 @@ dependencies {
implementation project(':feature:parent')
implementation project(':feature:child')
implementation project(':feature:setting')
implementation project(':feature:common')
implementation project(':data')

View File

@ -37,7 +37,14 @@ public class TaskCacheConverter {
* @return TaskItemModel
*/
public static TaskItemModel taskCacheEntityToTaskModel(TaskCacheEntity entity) {
return new TaskItemModel(entity.id, entity.name, entity.iconEmoji, entity.reward, null);
TaskItemModel model = new TaskItemModel();
model.setId(entity.id);
model.setName(entity.name);
model.setReward(entity.reward);
model.setIconEmoji(entity.iconEmoji == null ? "" : entity.iconEmoji); // Workaround
model.setBgColor(null); // TODO: 実装
model.setAttachedChildren(null); // TODO: 実装
return model;
}
/**

1
feature/common/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,51 @@
plugins {
alias(libs.plugins.androidLibrary)
id 'com.google.dagger.hilt.android'
}
android {
namespace 'one.nem.kidshift.feature.common'
compileSdk 34
defaultConfig {
minSdk 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation libs.appcompat
implementation libs.material
implementation libs.navigation.fragment
implementation libs.navigation.ui
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
implementation libs.androidx.swiperefreshlayout
// Hilt (DI)
implementation libs.com.google.dagger.hilt.android
annotationProcessor libs.com.google.dagger.hilt.compiler
implementation 'one.nem:compact-calendar-view:1.0.0'
// Project modules
implementation project(':model')
implementation project(':utils')
implementation project(':data')
implementation project(':shared')
}

View File

21
feature/common/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,26 @@
package one.nem.kidshift.feature.common;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("one.nem.kidshift.feature.common.test", appContext.getPackageName());
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@ -0,0 +1,193 @@
package one.nem.kidshift.feature.common;
import android.annotation.SuppressLint;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.sundeepk.compactcalendarview.CompactCalendarView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.kidshift.data.ChildData;
import one.nem.kidshift.data.TaskData;
import one.nem.kidshift.feature.common.adapter.ChildListItemAdapter;
import one.nem.kidshift.feature.common.adapter.TaskListItemAdapter;
import one.nem.kidshift.model.callback.TaskItemModelCallback;
import one.nem.kidshift.model.tasks.TaskItemModel;
import one.nem.kidshift.utils.KSLogger;
import one.nem.kidshift.utils.factory.KSLoggerFactory;
@AndroidEntryPoint
public class CommonHomeFragment extends Fragment {
private static final String ARG_IS_CHILD_MODE = "isChildMode";
private static final String ARG_CHILD_ID = "childId";
@Inject
KSLoggerFactory ksLoggerFactory;
@Inject
TaskData taskData;
@Inject
ChildData childData;
private boolean isChildMode;
private String childId;
private KSLogger logger;
CompactCalendarView compactCalendarView;
SwipeRefreshLayout swipeRefreshLayout;
TaskListItemAdapter taskListItemAdapter;
public CommonHomeFragment() {
// Required empty public constructor
}
// TODO: SwipeToRef
public static CommonHomeFragment newInstance(boolean isChildMode, String childId) {
CommonHomeFragment fragment = new CommonHomeFragment();
Bundle args = new Bundle();
args.putBoolean(ARG_IS_CHILD_MODE, isChildMode);
if (isChildMode) {
args.putString(ARG_CHILD_ID, childId);
}
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
isChildMode = getArguments().getBoolean(ARG_IS_CHILD_MODE);
childId = getArguments().getString(ARG_CHILD_ID);
}
logger = ksLoggerFactory.create("CommonHomeFragment");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_common_home, container, false);
compactCalendarView = view.findViewById(R.id.calendar);
taskListItemAdapter = new TaskListItemAdapter();
taskListItemAdapter.setCallback((taskId, taskName) -> {
if (isChildMode) {
if (showConfirmDialog(taskName)) {
taskData.recordTaskCompletion(taskId, childId);
}
} else {
showChildSelectDialog(taskId, taskName);
}
});
RecyclerView taskListRecyclerView = view.findViewById(R.id.taskListRecyclerView);
taskListRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
taskListRecyclerView.setAdapter(taskListItemAdapter);
swipeRefreshLayout = view.findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setOnRefreshListener(this::updateData);
return view;
}
@Override
public void onResume() {
super.onResume();
updateData();
}
private boolean showConfirmDialog(String taskName) {
AtomicBoolean selection = new AtomicBoolean(false);
new MaterialAlertDialogBuilder(requireContext())
.setTitle("タスクを完了しますか?")
.setMessage(taskName + "を完了しますか?")
.setPositiveButton("はい", (dialog, which) -> {
dialog.dismiss();
selection.set(true);
})
.setNegativeButton("いいえ", (dialog, which) -> {
dialog.dismiss();
selection.set(false);
})
.show();
return selection.get();
}
private void showChildSelectDialog(String taskId, String taskName) { // TODO: Assignされている子供かどうかを考慮するように
RecyclerView childListRecyclerView = new RecyclerView(requireContext());
childListRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// TODO: キャッシュから取得する方にする
childData.getChildListDirect().thenAccept(childModelList -> {
ChildListItemAdapter childListItemAdapter = new ChildListItemAdapter(childModelList);
childListItemAdapter.setCallback(childId -> {
taskData.recordTaskCompletion(taskId, childId);
});
childListRecyclerView.setAdapter(childListItemAdapter);
}).thenRun(() -> {
requireActivity().runOnUiThread(() -> {
new MaterialAlertDialogBuilder(requireContext())
.setTitle(taskName + "を完了したお子様を選択")
.setView(childListRecyclerView)
.setNeutralButton("閉じる", (dialog, which) -> dialog.dismiss())
.show();
});
});
}
@SuppressLint("NotifyDataSetChanged")
private CompletableFuture<Void> updateTaskInfo() { // TODO: updatedの場合の処理など実装
return taskData.getTasks(new TaskItemModelCallback() {
@Override
public void onUnchanged() {
}
@Override
public void onUpdated(List<TaskItemModel> taskItem) {
}
@Override
public void onFailed(String message) {
}
}).thenAccept(taskItemModel -> {
taskListItemAdapter.setTaskItemModelList(taskItemModel);
requireActivity().runOnUiThread(() -> {
taskListItemAdapter.notifyDataSetChanged();
});
});
}
private CompletableFuture<Void> updateCalender() {
// TODO: タスクの完了状況をカレンダーに表示
return CompletableFuture.completedFuture(null);
}
private void updateData() {
swipeRefreshLayout.setRefreshing(true);
CompletableFuture.allOf(updateTaskInfo(), updateCalender()).thenRun(() -> {
// Workaround: リスト更新処理があまりにも重くてアニメーションが壊れるため
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
swipeRefreshLayout.setRefreshing(false);
});
}
}

View File

@ -0,0 +1,74 @@
package one.nem.kidshift.feature.common.adapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import one.nem.kidshift.feature.common.R;
import one.nem.kidshift.model.ChildModel;
public class ChildListItemAdapter extends RecyclerView.Adapter<ChildListItemAdapter.ViewHolder> {
private List<ChildModel> childDataList;
private CompleteButtonClickedCallback callback;
public ChildListItemAdapter() {
// Empty constructor
}
public ChildListItemAdapter(List<ChildModel> childDataList) {
this.childDataList = childDataList;
}
public void setChildDataList(List<ChildModel> childDataList) {
this.childDataList = childDataList;
}
public void setCallback(CompleteButtonClickedCallback callback) {
this.callback = callback;
}
@NonNull
@Override
public ChildListItemAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = View.inflate(parent.getContext(), R.layout.list_item_task_completion_child, null);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ChildListItemAdapter.ViewHolder holder, int position) {
ChildModel childData = childDataList.get(position);
holder.childName.setText(childData.getName());
holder.completedButton.setOnClickListener(v -> {
if (callback != null) {
callback.onClicked(childData.getId());
}
});
}
@Override
public int getItemCount() {
return childDataList == null ? 0 : childDataList.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView childName;
Button completedButton;
public ViewHolder(@NonNull android.view.View itemView) {
super(itemView);
childName = itemView.findViewById(R.id.childNameTextView);
completedButton = itemView.findViewById(R.id.completeButton);
}
}
public interface CompleteButtonClickedCallback {
void onClicked(String taskId);
}
}

View File

@ -0,0 +1,80 @@
package one.nem.kidshift.feature.common.adapter;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import one.nem.kidshift.feature.common.R;
import one.nem.kidshift.model.tasks.TaskItemModel;
public class TaskListItemAdapter extends RecyclerView.Adapter<TaskListItemAdapter.ViewHolder> {
private List<TaskItemModel> taskItemModelList;
private CompleteButtonClickedCallback callback;
public TaskListItemAdapter() {
}
public void setTaskItemModelList(List<TaskItemModel> taskItemModelList) {
this.taskItemModelList = taskItemModelList;
}
public void setCallback(CompleteButtonClickedCallback callback) {
this.callback = callback;
}
@NonNull
@Override
public TaskListItemAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
// View view = View.inflate(parent.getContext(), R.layout.list_item_common_task, null);
// Workaround? by https://stackoverflow.com/questions/30691150/match-parent-width-does-not-work-in-recyclerview
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_common_task, parent, false);
return new ViewHolder(view);
}
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull TaskListItemAdapter.ViewHolder holder, int position) {
TaskItemModel taskItemModel = taskItemModelList.get(position);
holder.taskTitle.setText(taskItemModel.getName());
holder.taskContents.setText(taskItemModel.getReward() + ""); // TODO: ハードコードやめる
holder.completedButton.setOnClickListener(v -> {
if (callback != null) {
callback.onClicked(taskItemModel.getId(), taskItemModel.getName());
}
});
}
@Override
public int getItemCount() {
return taskItemModelList == null ? 0 : taskItemModelList.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView taskTitle;
TextView taskContents;
Button completedButton;
public ViewHolder(@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);
}
}
public interface CompleteButtonClickedCallback {
void onClicked(String taskId, String taskName);
}
}

View File

@ -0,0 +1,42 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CommonHomeFragment"
android:id="@+id/swipeRefreshLayout">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.sundeepk.compactcalendarview.CompactCalendarView
android:id="@+id/calendar"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:compactCalendarBackgroundColor="#ffe95451"
app:compactCalendarCurrentDayBackgroundColor="#B71C1C"
app:compactCalendarCurrentSelectedDayBackgroundColor="#E57373"
app:compactCalendarMultiEventIndicatorColor="#fff"
app:compactCalendarTargetHeight="250dp"
app:compactCalendarTextColor="#fff"
app:compactCalendarTextSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/taskListRecyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/calendar" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="お手伝い名"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textSize="20sp"
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_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_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@ -0,0 +1,32 @@
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:padding="8px"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/childNameTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="PLACEHOLDER"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<Button
android:id="@+id/completeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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/feature_common_navigation"
app:startDestination="@id/commonHomeFragment">
<fragment
android:id="@+id/commonHomeFragment"
android:name="one.nem.kidshift.feature.common.CommonHomeFragment"
android:label="fragment_common_home"
tools:layout="@layout/fragment_common_home" />
</navigation>

View File

@ -0,0 +1,4 @@
<resources>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>

View File

@ -0,0 +1,17 @@
package one.nem.kidshift.feature.common;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@ -45,4 +45,5 @@ dependencies {
implementation project(':model')
implementation project(':utils')
implementation project(':data')
implementation project(':feature:common')
}

View File

@ -5,6 +5,9 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
@ -22,6 +25,7 @@ import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.kidshift.data.ChildData;
import one.nem.kidshift.data.TaskData;
import one.nem.kidshift.feature.common.CommonHomeFragment;
import one.nem.kidshift.model.callback.TaskItemModelCallback;
import one.nem.kidshift.model.tasks.TaskItemModel;
import one.nem.kidshift.utils.FabManager;
@ -32,132 +36,24 @@ 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;
return inflater.inflate(R.layout.fragment_parent_main, container, false);
}
@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();
}
// FragmentManager fragmentManager = getChildFragmentManager();
// NavHostFragment navHostFragment = (NavHostFragment) fragmentManager.findFragmentById(R.id.navHostFragment);
// NavController navController = navHostFragment.getNavController();
@Override
public void onLongClicked() {
// Do nothing
}
});
// SwipeToRefresh
swipeRefreshLayout.setOnRefreshListener(this::updateTaskInfo);
}
}

View File

@ -1,28 +1,16 @@
<?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>
<!-- <androidx.fragment.app.FragmentContainerView-->
<!-- android:id="@+id/navHostFragment"-->
<!-- android:name="androidx.navigation.fragment.NavHostFragment"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:defaultNavHost="true"-->
<!-- app:navGraph="@navigation/internal_parent_navigation" />-->
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -3,11 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/feature_parent_navigation"
app:startDestination="@id/featureParentFragment">
<fragment
android:id="@+id/featureParentFragment"
android:name="one.nem.kidshift.feature.parent.ParentMainFragment"
android:label="fragment_feature_parent"
tools:layout="@layout/fragment_parent_main" />
app:startDestination="@id/feature_common_navigation">
<include app:graph="@navigation/feature_common_navigation" />
</navigation>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/internal_parent_navigation">
<include app:graph="@navigation/feature_common_navigation" />
</navigation>

View File

@ -16,6 +16,10 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
name = 'CompactCalendarView-GHPages'
url = uri('https://r-ca.github.io/CompactCalendarView/')
}
}
}
@ -29,3 +33,4 @@ include ':utils'
include ':data'
include ':model'
include ':shared'
include ':feature:common'