mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 08:40:03 +02:00
Fix #1004 - Order followed tags (ASC)
This commit is contained in:
parent
520a36946a
commit
5aae22483f
1 changed files with 9 additions and 0 deletions
|
@ -32,12 +32,15 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityFollowedTagsBinding;
|
||||
import app.fedilab.android.databinding.PopupAddFollowedTagtBinding;
|
||||
import app.fedilab.android.mastodon.client.entities.api.MastodonList;
|
||||
import app.fedilab.android.mastodon.client.entities.api.Tag;
|
||||
import app.fedilab.android.mastodon.client.entities.app.Timeline;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
|
@ -75,6 +78,7 @@ public class FollowedTagActivity extends BaseBarActivity implements FollowedTagA
|
|||
.observe(FollowedTagActivity.this, tags -> {
|
||||
if (tags != null && tags.tags != null && tags.tags.size() > 0) {
|
||||
tagList = new ArrayList<>(tags.tags);
|
||||
sortAsc(tagList);
|
||||
followedTagAdapter = new FollowedTagAdapter(tagList);
|
||||
followedTagAdapter.actionOnTag = this;
|
||||
binding.notContent.setVisibility(View.GONE);
|
||||
|
@ -167,6 +171,8 @@ public class FollowedTagActivity extends BaseBarActivity implements FollowedTagA
|
|||
if (newTag != null) {
|
||||
tagList.add(0, newTag);
|
||||
followedTagAdapter.notifyItemInserted(0);
|
||||
sortAsc(tagList);
|
||||
followedTagAdapter.notifyItemRangeChanged(0, tagList.size());
|
||||
} else {
|
||||
Toasty.error(FollowedTagActivity.this, getString(R.string.not_valid_tag_name), Toasty.LENGTH_LONG).show();
|
||||
}
|
||||
|
@ -183,6 +189,9 @@ public class FollowedTagActivity extends BaseBarActivity implements FollowedTagA
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void sortAsc(List<Tag> tagList) {
|
||||
Collections.sort(tagList, (obj1, obj2) -> obj1.name.compareToIgnoreCase(obj2.name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||
|
|
Loading…
Reference in a new issue