Revert "test"

This reverts commit 9694c32193.
This commit is contained in:
ろむねこ 2024-07-05 15:44:28 +09:00
parent 72b6473aac
commit 2a3dc26794
Signed by: Fujimatsu
GPG Key ID: FA1F39A1BA37D168

View File

@ -24,10 +24,7 @@ import javax.inject.Inject;
import dagger.hilt.android.AndroidEntryPoint;
import one.nem.kidshift.data.ChildData;
import one.nem.kidshift.data.KSActions;
import one.nem.kidshift.data.ParentData;
import one.nem.kidshift.data.UserSettings;
import one.nem.kidshift.data.room.utils.CacheWrapper;
import one.nem.kidshift.model.ChildModel;
import one.nem.kidshift.model.ParentModel;
import one.nem.kidshift.model.callback.ChildModelCallback;
@ -52,16 +49,6 @@ public class SettingMainFragment extends Fragment {
@Inject
FabManager fabManager;
@Inject
CacheWrapper cacheWrapper;
@Inject
UserSettings userSettings;
@Inject
KSActions ksActions;
private KSLogger logger;
TextView username;
@ -103,10 +90,15 @@ public class SettingMainFragment extends Fragment {
}
}).thenAcceptAsync(parentModel -> {
requireActivity().runOnUiThread(() -> {
username.setText(parentModel.getName() != null ? parentModel.getName() : "親の名前");
userMailAddress.setText(parentModel.getEmail() != null ? parentModel.getEmail() : "親のアドレス");
});
try {
Thread.sleep(5000); // デバッグのための遅延実際のアプリでは削除
} catch (InterruptedException e) {
e.printStackTrace();
}
// requireActivity().runOnUiThread(() -> {
// username.setText(parentModel.getName() != null ? parentModel.getName() : "親の名前");
// userMailAddress.setText(parentModel.getEmail() != null ? parentModel.getEmail() : "親のアドレス");
// });
});
}
@ -134,9 +126,9 @@ public class SettingMainFragment extends Fragment {
}
}).thenAcceptAsync(childModels -> {
mainAdapter.setChildDataList(childModels);
requireActivity().runOnUiThread(() -> {
mainAdapter.notifyItemRangeChanged(0, childModels.size());
});
// requireActivity().runOnUiThread(() -> {
// mainAdapter.notifyDataSetChanged();
// });
});
}
@ -147,20 +139,22 @@ public class SettingMainFragment extends Fragment {
CompletableFuture<Void> updateParent = updateParentInfo();
CompletableFuture<Void> updateChildList = updateChildInfo();
// swipeRefreshLayout.setRefreshing(true);
logger.debug(String.valueOf((swipeRefreshLayout == null)));
swipeRefreshLayout.setRefreshing(true);
logger.debug("アップデート開始");
return updateParent.thenCombine(updateChildList, (res1, res2) -> null)
return updateParent.thenCombineAsync(updateChildList, (res1, res2) -> null)
.thenRunAsync(() -> {
// requireActivity().runOnUiThread(() -> {
// logger.debug("アップデート完了");
// swipeRefreshLayout.setRefreshing(false);
// });
requireActivity().runOnUiThread(() -> {
logger.debug("アップデート完了");
swipeRefreshLayout.setRefreshing(false);
});
}).exceptionally(e -> {
// requireActivity().runOnUiThread(() -> {
// logger.error("アップデート失敗: " + e.getMessage());
// swipeRefreshLayout.setRefreshing(false);
// });
requireActivity().runOnUiThread(() -> {
logger.error("アップデート失敗: " + e.getMessage());
swipeRefreshLayout.setRefreshing(false);
});
return null;
});
}
@ -174,50 +168,106 @@ public class SettingMainFragment extends Fragment {
View view = inflater.inflate(R.layout.fragment_setting_main, container, false);
logger.debug("Point 2");
// ビューの取得
username = view.findViewById(R.id.username);
userMailAddress = view.findViewById(R.id.useradress);
swipeRefreshLayout = view.findViewById(R.id.swipe_refresh_layout);
RecyclerView recyclerView = view.findViewById(R.id.childrecyclerview);
logger.debug("Point 3");
// RecyclerViewの設定
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutManager);
mainAdapter = new SettingAdapter();
recyclerView.setAdapter(mainAdapter);
// updateInfo().thenRun(() -> {
// logger.debug("ユーザー情報の更新完了");
// });
logger.debug("Point 4");
// ユーザー情報の更新(初回)
updateInfo().thenRun(() -> {
logger.debug("ユーザー情報の更新完了");
});
logger.debug("Point 5");
// スワイプリフレッシュのリスナー
swipeRefreshLayout.setOnRefreshListener(() -> {
updateInfo(); // ユーザー情報の更新
});
logger.debug("Point 6");
// ダイアログの設定
LayoutInflater dialogInflater = requireActivity().getLayoutInflater();
View addChildDialogView = dialogInflater.inflate(R.layout.fragment_login_dialog_view, null);
View childListItemView = inflater.inflate(R.layout.list_item_child_name_list, container, false);
logger.debug("Point 7");
mainAdapter.setLoginButtonCallback(childId -> {
int loginCode = childData.issueLoginCode(childId).join();
TextView loginCodeTextView = addChildDialogView.findViewById(R.id.loginCode);
new StringBuilder(Integer.toString(loginCode)).insert(3, "-");
loginCodeTextView.setText(
new StringBuilder(Integer.toString(loginCode)).insert(3, "-")
);
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
builder.setTitle("ログインコード")
.setView(addChildDialogView)
.setNeutralButton("閉じる", null);
builder.show();
});
logger.debug("Point 8");
logger.debug("Point 9");
logger.debug("Point 10");
// ダイアログの表示
if (!fabManager.isShown()) fabManager.show();
fabManager.setFabEventCallback(new FabEventCallback() {
@Override
public void onClicked() {
//子供の名前追加のダイアログ
View dialogView = dialogInflater.inflate(R.layout.add_child_list_dialog, null);
new MaterialAlertDialogBuilder(requireContext())
.setTitle("お子様の名前を入力してください。")
.setView(dialogView)
.setPositiveButton("追加", (dialog, which) -> {
ChildModel childModel = new ChildModel();
childModel.setName(Objects.requireNonNull(((TextView) dialogView.findViewById(R.id.childNameEditText)).getText()).toString());
childData.addChild(childModel).thenAccept(childModel1 -> { // Debug
logger.debug("子供を追加しました: " + childModel1.getName());
}).thenRun(() -> {
updateChildInfo();
});
})
.setNeutralButton("閉じる", (dialog, which) -> {
dialog.cancel();
}).show();
}
@Override
public void onLongClicked() {
// Do nothing
}
});
logger.debug("Point 11");
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// ksActions.syncChildList().thenAcceptAsync(childList -> {
// mainAdapter.setChildDataList(childList);
// requireActivity().runOnUiThread(() -> {
// mainAdapter.notifyDataSetChanged();
// });
// });
cacheWrapper.getChildList().thenAcceptAsync(childList -> {
mainAdapter.setChildDataList(childList);
requireActivity().runOnUiThread(() -> {
// mainAdapter.notifyDataSetChanged();
});
});
CompletableFuture.supplyAsync(() -> userSettings.getCache().getParent()).thenAcceptAsync(parentModel -> {
requireActivity().runOnUiThread(() -> {
username.setText(parentModel.getName() != null ? parentModel.getName() : "親の名前");
userMailAddress.setText(parentModel.getEmail() != null ? parentModel.getEmail() : "親のアドレス");
});
});
}
@Override
public void onResume() {
super.onResume();