From a5dcde0d54a89ee2abe1e72daff3eeee08a8387b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 12 Jul 2024 11:18:19 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B9=E3=83=AF=E3=82=A4=E3=83=97=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=83=AA=E3=83=95=E3=83=AC=E3=83=83=E3=82=B7=E3=83=A5?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/kidshift/wallet/WalletContentFragment.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/feature/wallet/src/main/java/one/nem/kidshift/wallet/WalletContentFragment.java b/feature/wallet/src/main/java/one/nem/kidshift/wallet/WalletContentFragment.java index 3a3786a..feae962 100644 --- a/feature/wallet/src/main/java/one/nem/kidshift/wallet/WalletContentFragment.java +++ b/feature/wallet/src/main/java/one/nem/kidshift/wallet/WalletContentFragment.java @@ -16,6 +16,7 @@ import one.nem.kidshift.utils.FabManager; import one.nem.kidshift.utils.KSLogger; import one.nem.kidshift.utils.ToolBarManager; import one.nem.kidshift.utils.factory.KSLoggerFactory; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @AndroidEntryPoint public class WalletContentFragment extends Fragment { @@ -38,6 +39,7 @@ public class WalletContentFragment extends Fragment { private String childId; private TextView totalRewardTextView; + private SwipeRefreshLayout swipeRefreshLayout; public WalletContentFragment() { // Required empty public constructor @@ -80,6 +82,13 @@ public class WalletContentFragment extends Fragment { totalRewardTextView = view.findViewById(R.id.totalRewardTextView); + swipeRefreshLayout = view.findViewById(R.id.swipeRefreshLayout); + + swipeRefreshLayout.setOnRefreshListener(() -> { + updateTotalReward(); + swipeRefreshLayout.setRefreshing(false); + }); + return view; } @@ -89,9 +98,14 @@ public class WalletContentFragment extends Fragment { } private void updateTotalReward() { + swipeRefreshLayout.setRefreshing(true); rewardData.getTotalReward(childId).thenAccept(totalReward -> { logger.debug("Total reward: " + totalReward); totalRewardTextView.setText(String.valueOf(totalReward) + "円"); + }).thenRun(() -> { + requireActivity().runOnUiThread(() -> { + swipeRefreshLayout.setRefreshing(false); + }); }).exceptionally(throwable -> { logger.error("Failed to get total reward: " + throwable.getMessage()); return null;