Sort by folder 1st approach

This commit is contained in:
M M Arif 2019-10-02 17:58:29 +05:00
parent d2213c0c14
commit 06b71586c1
2 changed files with 11 additions and 3 deletions

View File

@ -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);
}
});

View File

@ -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 {