Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
67add714b3 |
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "org.mian.gitnex"
|
applicationId "org.mian.gitnex"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 71
|
versionCode 70
|
||||||
versionName "2.2.1"
|
versionName "2.2.0"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -192,7 +192,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
|
|
||||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||||
|
|
||||||
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(this, new Observer<List<Files>>() {
|
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Files>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Files> filesListMain) {
|
public void onChanged(@Nullable List<Files> filesListMain) {
|
||||||
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
||||||
@ -225,7 +225,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
|||||||
|
|
||||||
FilesViewModel filesModel2 = new ViewModelProvider(this).get(FilesViewModel.class);
|
FilesViewModel filesModel2 = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||||
|
|
||||||
filesModel2.getFilesList2(instanceUrl, instanceToken, owner, repo, filesDir, getContext()).observe(this, new Observer<List<Files>>() {
|
filesModel2.getFilesList2(instanceUrl, instanceToken, owner, repo, filesDir).observe(this, new Observer<List<Files>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable List<Files> filesListMain2) {
|
public void onChanged(@Nullable List<Files> filesListMain2) {
|
||||||
adapter = new FilesAdapter(getContext(), filesListMain2, FilesFragment.this);
|
adapter = new FilesAdapter(getContext(), filesListMain2, FilesFragment.this);
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package org.mian.gitnex.viewmodels;
|
package org.mian.gitnex.viewmodels;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
import androidx.lifecycle.ViewModel;
|
import androidx.lifecycle.ViewModel;
|
||||||
import org.mian.gitnex.R;
|
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
|
||||||
import org.mian.gitnex.models.Files;
|
import org.mian.gitnex.models.Files;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -26,15 +23,15 @@ public class FilesViewModel extends ViewModel {
|
|||||||
private static MutableLiveData<List<Files>> filesList;
|
private static MutableLiveData<List<Files>> filesList;
|
||||||
private static MutableLiveData<List<Files>> filesList2;
|
private static MutableLiveData<List<Files>> filesList2;
|
||||||
|
|
||||||
public LiveData<List<Files>> getFilesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
|
public LiveData<List<Files>> getFilesList(String instanceUrl, String token, String owner, String repo) {
|
||||||
|
|
||||||
filesList = new MutableLiveData<>();
|
filesList = new MutableLiveData<>();
|
||||||
loadFilesList(instanceUrl, token, owner, repo, ctx);
|
loadFilesList(instanceUrl, token, owner, repo);
|
||||||
|
|
||||||
return filesList;
|
return filesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadFilesList(String instanceUrl, String token, String owner, String repo, final Context ctx) {
|
public static void loadFilesList(String instanceUrl, String token, String owner, String repo) {
|
||||||
|
|
||||||
Call<List<Files>> call = RetrofitClient
|
Call<List<Files>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl)
|
||||||
@ -46,17 +43,16 @@ public class FilesViewModel extends ViewModel {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
Collections.sort(response.body(), new Comparator<Files>() {
|
||||||
Collections.sort(response.body(), new Comparator<Files>() {
|
@Override
|
||||||
@Override
|
public int compare(Files byType1, Files byType2) {
|
||||||
public int compare(Files byType1, Files byType2) {
|
return byType1.getType().compareTo(byType2.getType());
|
||||||
return byType1.getType().compareTo(byType2.getType());
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
if (response.isSuccessful()) {
|
||||||
filesList.postValue(response.body());
|
filesList.postValue(response.body());
|
||||||
} else {
|
} else {
|
||||||
Toasty.info(ctx, ctx.getString(R.string.noDataFilesTab));
|
|
||||||
Log.i("onResponse", String.valueOf(response.code()));
|
Log.i("onResponse", String.valueOf(response.code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,15 +66,15 @@ public class FilesViewModel extends ViewModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Files>> getFilesList2(String instanceUrl, String token, String owner, String repo, String filesDir, Context ctx) {
|
public LiveData<List<Files>> getFilesList2(String instanceUrl, String token, String owner, String repo, String filesDir) {
|
||||||
|
|
||||||
filesList2 = new MutableLiveData<>();
|
filesList = new MutableLiveData<>();
|
||||||
loadFilesList2(instanceUrl, token, owner, repo, filesDir, ctx);
|
loadFilesList2(instanceUrl, token, owner, repo, filesDir);
|
||||||
|
|
||||||
return filesList2;
|
return filesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadFilesList2(String instanceUrl, String token, String owner, String repo, String filesDir, final Context ctx) {
|
public static void loadFilesList2(String instanceUrl, String token, String owner, String repo, String filesDir) {
|
||||||
|
|
||||||
Call<List<Files>> call = RetrofitClient
|
Call<List<Files>> call = RetrofitClient
|
||||||
.getInstance(instanceUrl)
|
.getInstance(instanceUrl)
|
||||||
@ -90,17 +86,19 @@ public class FilesViewModel extends ViewModel {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
assert response.body() != null;
|
||||||
|
if(response.body().size() > 0) {
|
||||||
Collections.sort(response.body(), new Comparator<Files>() {
|
Collections.sort(response.body(), new Comparator<Files>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Files byType1, Files byType2) {
|
public int compare(Files byType1, Files byType2) {
|
||||||
return byType1.getType().compareTo(byType2.getType());
|
return byType1.getType().compareTo(byType2.getType());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
filesList2.postValue(response.body());
|
if (response.isSuccessful()) {
|
||||||
|
filesList.postValue(response.body());
|
||||||
} else {
|
} else {
|
||||||
Toasty.info(ctx, ctx.getString(R.string.noDataFilesTab));
|
|
||||||
Log.i("onResponse", String.valueOf(response.code()));
|
Log.i("onResponse", String.valueOf(response.code()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
android:visibility="gone" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,16 +0,0 @@
|
|||||||
2.2.1
|
|
||||||
- Bug fix: Crash on empty repository
|
|
||||||
|
|
||||||
2.2.0
|
|
||||||
- New: Explore repositories
|
|
||||||
- New: Files and directory browser (Require Gitea 1.9)
|
|
||||||
- New: Basic file viewer
|
|
||||||
- New: Filter files/directories
|
|
||||||
- New: Star/unstar a repository
|
|
||||||
- New: Watch/unwatch a repository
|
|
||||||
- Improvement: Added Corwdin for translation
|
|
||||||
- Improvement: Bottomsheet scroll and line dividers
|
|
||||||
- Improvement: New languages support
|
|
||||||
|
|
||||||
For more, check the release notes.
|
|
||||||
https://gitea.com/gitnex/GitNex/releases
|
|
Reference in New Issue
Block a user