ぐるぐるさせました #111

Merged
Fujimatsu merged 8 commits from parent_swipe into main 2024-07-02 05:23:42 +00:00
6 changed files with 65 additions and 51 deletions

View File

@ -32,6 +32,7 @@ dependencies {
implementation libs.material implementation libs.material
implementation libs.navigation.fragment implementation libs.navigation.fragment
implementation libs.navigation.ui implementation libs.navigation.ui
implementation libs.androidx.swiperefreshlayout
testImplementation libs.junit testImplementation libs.junit
androidTestImplementation libs.ext.junit androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core androidTestImplementation libs.espresso.core

View File

@ -6,7 +6,9 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
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;
@ -38,6 +40,40 @@ public class ParentMainFragment extends Fragment {
public ParentMainFragment() { public ParentMainFragment() {
// Required empty public constructor // Required empty public constructor
} }
private void dataRefresh(){
SwipeRefreshLayout swipeRefreshLayout = requireView().findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setRefreshing(true);
RecyclerView recyclerView =requireView().findViewById(R.id.main_recycle_view);
recyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
List<TaskItemModel> task = taskData.getTasks(new TaskItemModelCallback() {
@Override
public void onUnchanged() {
// TODO
}
@Override
public void onUpdated(List<TaskItemModel> taskItem) {
// TODO
}
@Override
public void onFailed(String message) {
// TODO
}
}).join();
RecyclerView.Adapter mainAdapter = new ParentAdapter(task);
recyclerView.setAdapter(mainAdapter);
swipeRefreshLayout.setRefreshing(false);
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -46,37 +82,6 @@ public class ParentMainFragment extends Fragment {
//タスク一覧表示 //タスク一覧表示
View view = inflater.inflate(R.layout.fragment_parent_main, container, false); View view = inflater.inflate(R.layout.fragment_parent_main, container, false);
RecyclerView recyclerView = view.findViewById(R.id.main_recycle_view);
recyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
ksLogger.debug("タスク一覧取得開始");
List<TaskItemModel> task = taskData.getTasks(new TaskItemModelCallback() {
@Override
public void onUnchanged() {
// TODO: Do something
}
@Override
public void onUpdated(List<TaskItemModel> taskItem) {
// TODO: Do something
}
@Override
public void onFailed(String message) {
// TODO: Do something
}
}).join();
ksLogger.debug("タスク一覧取得完了");
RecyclerView.Adapter mainAdapter = new ParentAdapter(task);
recyclerView.setAdapter(mainAdapter);
//お手伝い追加ダイアログ //お手伝い追加ダイアログ
LayoutInflater inflater1 = requireActivity().getLayoutInflater(); LayoutInflater inflater1 = requireActivity().getLayoutInflater();
View view1 = inflater1.inflate(R.layout.add_task_list_dialog,null); View view1 = inflater1.inflate(R.layout.add_task_list_dialog,null);
@ -114,5 +119,10 @@ public class ParentMainFragment extends Fragment {
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
// Do something... // Do something...
SwipeRefreshLayout swipeRefreshLayout = view.findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(()->{
dataRefresh();
});
} }
} }

View File

@ -1,13 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main" android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ParentMainFragment"> tools:context=".ParentMainFragment">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<Button <Button
android:id="@+id/addtask" android:id="@+id/addtask"
@ -18,6 +22,7 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/main_recycle_view" android:id="@+id/main_recycle_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="match_parent" />
</LinearLayout> </LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -32,7 +32,7 @@ dependencies {
implementation libs.material implementation libs.material
implementation libs.navigation.fragment implementation libs.navigation.fragment
implementation libs.navigation.ui implementation libs.navigation.ui
implementation libs.swiperefreshlayout implementation libs.androidx.swiperefreshlayout
testImplementation libs.junit testImplementation libs.junit
androidTestImplementation libs.ext.junit androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core androidTestImplementation libs.espresso.core

View File

@ -80,7 +80,6 @@ public class SettingMainFragment extends Fragment {
} }
}); });
/* /*
TODO: TODO:
- コールバックの処理を実装 - コールバックの処理を実装
@ -91,7 +90,6 @@ public class SettingMainFragment extends Fragment {
- onFailed時にそれを通知 - onFailed時にそれを通知
*/ */
ParentModel parent = completableFuture.join(); ParentModel parent = completableFuture.join();
if (parent == null) { if (parent == null) {

View File

@ -1,6 +1,7 @@
[versions] [versions]
agp = "8.3.2" agp = "8.3.2"
gson = "2.11.0" gson = "2.11.0"
javafaker = "1.0.2"
junit = "4.13.2" junit = "4.13.2"
junitVersion = "1.1.5" junitVersion = "1.1.5"
espressoCore = "3.5.1" espressoCore = "3.5.1"
@ -12,7 +13,6 @@ nav = "2.7.7"
swiperefreshlayout = "1.1.0" swiperefreshlayout = "1.1.0"
retrofit = "2.11.0" retrofit = "2.11.0"
room = "2.6.1" room = "2.6.1"
javafaker = "1.0.2"
[libraries] [libraries]
converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
@ -32,11 +32,11 @@ com-google-dagger-hilt-compiler = { group="com.google.dagger", name="hilt-compil
navigation-fragment = { group="androidx.navigation", name="navigation-fragment", version.ref="nav"} navigation-fragment = { group="androidx.navigation", name="navigation-fragment", version.ref="nav"}
navigation-ui = { group="androidx.navigation", name="navigation-ui", version.ref="nav"} navigation-ui = { group="androidx.navigation", name="navigation-ui", version.ref="nav"}
navigation-dynamic-features-fragment = { group="androidx.navigation", name="navigation-dynamic-features-fragment", version.ref="nav"} navigation-dynamic-features-fragment = { group="androidx.navigation", name="navigation-dynamic-features-fragment", version.ref="nav"}
swiperefreshlayout = { group = "androidx.swiperefreshlayout", name = "swiperefreshlayout", version.ref = "swiperefreshlayout" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" } androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" } androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
androidx-swiperefreshlayout = { group = "androidx.swiperefreshlayout", name = "swiperefreshlayout", version.ref = "swiperefreshlayout" }
[plugins] [plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" } androidApplication = { id = "com.android.application", version.ref = "agp" }