From 8a222378a2d0573f55710597d2e7506b7a3e2de4 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Tue, 7 Nov 2023 19:55:07 +0300 Subject: [PATCH] courses: refresh myCourses on change (fixes #2684) (#2685) Co-authored-by: dogi --- app/build.gradle | 4 ++-- .../myplanet/ui/course/CourseFragment.java | 21 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f7434f1d59..802e9ded11 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1135 - versionName "0.11.35" + versionCode 1136 + versionName "0.11.36" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java index 780270f381..c72a717447 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java @@ -99,7 +99,8 @@ public void afterTextChanged(Editable s) { .setMessage(R.string.are_you_sure_you_want_to_delete_these_courses) .setPositiveButton(R.string.yes, (dialogInterface, i) -> { deleteSelected(true); - checkList(); + CourseFragment newFragment = new CourseFragment(); + recreateFragment(newFragment); }) .setNegativeButton(R.string.no, null).show()); getView().findViewById(R.id.btn_collections).setOnClickListener(view -> { @@ -320,9 +321,19 @@ public void onPause() { } public void recreateFragment(Fragment fragment) { - FragmentTransaction transaction = getFragmentManager().beginTransaction(); - transaction.replace(R.id.fragment_container, fragment); - transaction.addToBackStack(null); - transaction.commit(); + if(isMyCourseLib){ + Bundle args = new Bundle(); + args.putBoolean("isMyCourseLib", true); + fragment.setArguments(args); + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + transaction.replace(R.id.fragment_container, fragment); + transaction.addToBackStack(null); + transaction.commit(); + } else{ + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + transaction.replace(R.id.fragment_container, fragment); + transaction.addToBackStack(null); + transaction.commit(); + } } } \ No newline at end of file