Skip to content

Commit

Permalink
mylibrary: context-based activated remove button (fixes #3574) (#3587)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
strawberrybread and dogi authored Jun 10, 2024
1 parent 436cc18 commit 132d3f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1575
versionName "0.15.75"
versionCode 1576
versionName "0.15.76"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
tvDelete = requireView().findViewById(R.id.tv_delete)
filter = requireView().findViewById(R.id.filter)
initArrays()
updateTvDelete()

tvAddToLib?.setOnClickListener {
if ((selectedItems?.size ?: 0) > 0) {
confirmation = createAlertDialog()
Expand All @@ -91,6 +93,7 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
checkList()
}
}

tvDelete?.setOnClickListener {
AlertDialog.Builder(this.context)
.setMessage(R.string.confirm_removal)
Expand Down Expand Up @@ -124,6 +127,7 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
if (isMyCourseLib) tvFragmentInfo.setText(R.string.txt_myLibrary)
checkList()
selectAll?.setOnClickListener {
updateTvDelete()
val allSelected = selectedItems?.size == adapterLibrary?.getLibraryList()?.size
adapterLibrary?.selectAllItems(!allSelected)
if (allSelected) {
Expand All @@ -136,6 +140,14 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
}
}

private fun updateTvDelete(){
if (selectedItems?.size!! == 0) {
tvDelete?.isEnabled = false
} else{
tvDelete?.isEnabled = true
}
}

private fun checkList() {
if (adapterLibrary?.getLibraryList()?.isEmpty() == true) {
selectAll?.visibility = View.GONE
Expand Down Expand Up @@ -198,6 +210,7 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
override fun onSelectedListChange(list: MutableList<RealmMyLibrary?>) {
selectedItems = list
changeButtonStatus()
updateTvDelete()
}

override fun onTagClicked(realmTag: RealmTag) {
Expand Down

0 comments on commit 132d3f9

Please sign in to comment.