mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Merge branch '206-repos-in-explore-screen' of gitnex/GitNex into master
This commit is contained in:
commit
6e02fc1827
@ -6,8 +6,8 @@ android {
|
||||
applicationId "org.mian.gitnex"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 80
|
||||
versionName "2.3.0"
|
||||
versionCode 90
|
||||
versionName "2.4.0-dev"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -26,6 +26,7 @@ import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -102,7 +103,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
fMenuHelper.setAccessible(true);
|
||||
menuHelper = fMenuHelper.get(popupMenu);
|
||||
argTypes = new Class[] { boolean.class };
|
||||
menuHelper.getClass().getDeclaredMethod("setForceShowIcon",
|
||||
Objects.requireNonNull(menuHelper).getClass().getDeclaredMethod("setForceShowIcon",
|
||||
argTypes).invoke(menuHelper, true);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -23,7 +23,6 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.models.ExploreRepositories;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -76,8 +75,6 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(Objects.requireNonNull(getContext()));
|
||||
|
||||
final View v = inflater.inflate(R.layout.fragment_explore_repo, container, false);
|
||||
//setHasOptionsMenu(true);
|
||||
((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);
|
||||
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
||||
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient
|
||||
|
Loading…
Reference in New Issue
Block a user