Skip to content

Commit

Permalink
courses: improved select all responsiveness (fixes #2594) (#2595)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Oct 11, 2023
1 parent eecf593 commit 4c725d5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1090
versionName "0.10.90"
versionCode 1091
versionName "0.10.91"
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 @@ -177,7 +177,6 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int
((ViewHoldercourse) holder).checkBox.setOnClickListener((view) -> {
Utilities.handleCheck(((CheckBox) view).isChecked(), position, (ArrayList) selectedItems, courseList);
if (listener != null) listener.onSelectedListChange(selectedItems);
notifyDataSetChanged();
});
showProgressAndRating(position, holder);
}
Expand All @@ -186,7 +185,10 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int
public boolean areAllSelected(){
if (selectedItems.size() != courseList.size()) {
areAllSelected = false;
} else {
areAllSelected = true;
}

return areAllSelected;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.ole.planet.myplanet.ui.course;


import android.app.AlertDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
Expand All @@ -12,13 +12,10 @@
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.google.gson.Gson;
import com.google.gson.JsonObject;

import org.ole.planet.myplanet.R;
import org.ole.planet.myplanet.base.BaseRecyclerFragment;
import org.ole.planet.myplanet.callback.OnCourseItemSelected;
Expand All @@ -31,13 +28,11 @@
import org.ole.planet.myplanet.ui.library.CollectionsFragment;
import org.ole.planet.myplanet.utilities.KeyboardUtils;
import org.ole.planet.myplanet.utilities.Utilities;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

import io.realm.Sort;

public class CourseFragment extends BaseRecyclerFragment<RealmMyCourse> implements OnCourseItemSelected, TagClickListener {
Expand Down Expand Up @@ -193,10 +188,17 @@ private void initializeView() {
btnRemove.setVisibility(View.GONE);
tvSelected.setVisibility(View.GONE);
}

selectAll.setOnClickListener(view -> {
boolean allSelected = selectedItems.size() == adapterCourses.getCourseList().size();
adapterCourses.selectAllItems(!allSelected);
selectAll.setText(allSelected ? getString(R.string.select_all) : getString(R.string.unselect_all));
if (allSelected) {
selectAll.setChecked(false);
selectAll.setText(getString(R.string.select_all));
} else {
selectAll.setChecked(true);
selectAll.setText(getString(R.string.unselect_all));
}
});
}

Expand All @@ -211,7 +213,6 @@ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
};

Expand Down Expand Up @@ -261,9 +262,15 @@ public void onTagClicked(RealmTag tag) {
showNoData(tvMessage, adapterCourses.getItemCount());
}

private void changeButtonStatus() {
public void changeButtonStatus() {
tvAddToLib.setEnabled(selectedItems.size() > 0);
selectAll.setText(adapterCourses.areAllSelected() ? getString(R.string.unselect_all) : getString(R.string.select_all));
if (adapterCourses.areAllSelected()) {
selectAll.setChecked(true);
selectAll.setText(getString(R.string.unselect_all));
} else {
selectAll.setChecked(false);
selectAll.setText(getString(R.string.select_all));
}
}

@Override
Expand Down Expand Up @@ -317,4 +324,4 @@ public void onPause() {
super.onPause();
saveSearchActivity();
}
}
}

0 comments on commit 4c725d5

Please sign in to comment.