mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-26 16:04:07 +08:00
Load default list of explore repositories
This commit is contained in:
parent
29cc8a2ad4
commit
536665be5f
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "org.mian.gitnex"
|
applicationId "org.mian.gitnex"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 80
|
versionCode 90
|
||||||
versionName "2.3.0"
|
versionName "2.4.0-dev"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -26,6 +26,7 @@ import org.mian.gitnex.models.UserRepositories;
|
|||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author M M Arif
|
* Author M M Arif
|
||||||
@ -102,7 +103,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
fMenuHelper.setAccessible(true);
|
fMenuHelper.setAccessible(true);
|
||||||
menuHelper = fMenuHelper.get(popupMenu);
|
menuHelper = fMenuHelper.get(popupMenu);
|
||||||
argTypes = new Class[] { boolean.class };
|
argTypes = new Class[] { boolean.class };
|
||||||
menuHelper.getClass().getDeclaredMethod("setForceShowIcon",
|
Objects.requireNonNull(menuHelper).getClass().getDeclaredMethod("setForceShowIcon",
|
||||||
argTypes).invoke(menuHelper, true);
|
argTypes).invoke(menuHelper, true);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -23,7 +23,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
|||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
import org.mian.gitnex.models.ExploreRepositories;
|
import org.mian.gitnex.models.ExploreRepositories;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
|
||||||
import org.mian.gitnex.util.TinyDB;
|
import org.mian.gitnex.util.TinyDB;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -76,8 +75,6 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
|
||||||
|
|
||||||
final View v = inflater.inflate(R.layout.fragment_explore_repo, container, false);
|
final View v = inflater.inflate(R.layout.fragment_explore_repo, container, false);
|
||||||
//setHasOptionsMenu(true);
|
//setHasOptionsMenu(true);
|
||||||
((MainActivity) Objects.requireNonNull(getActivity())).setActionBarTitle(getResources().getString(R.string.pageTitleExplore));
|
((MainActivity) Objects.requireNonNull(getActivity())).setActionBarTitle(getResources().getString(R.string.pageTitleExplore));
|
||||||
@ -92,6 +89,8 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||||
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
||||||
|
|
||||||
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
@ -106,10 +105,43 @@ public class ExploreRepositoriesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
int limitDefault = 10;
|
||||||
|
loadDefaultList(instanceUrl, instanceToken, loginUid, repoTypeInclude, sort, order, getContext(), limitDefault);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadDefaultList(String instanceUrl, String instanceToken, String loginUid, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||||
|
|
||||||
|
Call<ExploreRepositories> call = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), null, repoTypeInclude, sort, order, limit);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<ExploreRepositories>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||||
|
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
assert response.body() != null;
|
||||||
|
getReposList(response.body().getSearchedData(), context);
|
||||||
|
} else {
|
||||||
|
Log.i("onResponse", String.valueOf(response.code()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||||
|
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||||
|
|
||||||
Call<ExploreRepositories> call = RetrofitClient
|
Call<ExploreRepositories> call = RetrofitClient
|
||||||
|
Loading…
Reference in New Issue
Block a user