mirror of https://codeberg.org/gitnex/GitNex.git
Sort by folder 1st approach
This commit is contained in:
parent
d2213c0c14
commit
06b71586c1
|
@ -22,7 +22,6 @@ import org.mian.gitnex.helpers.Authorization;
|
|||
import org.mian.gitnex.models.Files;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.FilesViewModel;
|
||||
import org.mian.gitnex.viewmodels.ReleasesViewModel;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -96,9 +95,9 @@ public class FilesFragment extends Fragment {
|
|||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
FilesViewModel.loadFilesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
}
|
||||
}, 50);
|
||||
}, 200);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import androidx.lifecycle.ViewModel;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.models.Files;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
@ -40,6 +42,13 @@ public class FilesViewModel extends ViewModel {
|
|||
@Override
|
||||
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
||||
|
||||
Collections.sort(response.body(), new Comparator<Files>() {
|
||||
@Override
|
||||
public int compare(Files byType1, Files byType2) {
|
||||
return byType1.getType().compareTo(byType2.getType());
|
||||
}
|
||||
});
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
filesList.postValue(response.body());
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue