Org level labels in issue labels (#763)

Adding null checks.

Minor cleanups.

Merge branch 'master' into org-labels-in-issue

Fix repo size

Add new instances

Merge branch 'master' into org-labels-in-issue

Add org level labels to issue labels

Co-authored-by: opyale <opyale@noreply.codeberg.org>
Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/763
Reviewed-by: opyale <opyale@noreply.codeberg.org>
This commit is contained in:
M M Arif 2020-11-05 13:10:17 +01:00
parent a92da6a6d4
commit 639cf51027
5 changed files with 42 additions and 18 deletions

View File

@ -179,6 +179,8 @@
<data android:host="gitea.com" />
<data android:host="try.gitea.io" />
<data android:host="code.obermui.de" />
<data android:host="git.fsfe.org" />
<data android:host="opendev.org" />
</intent-filter>
</activity>

View File

@ -63,7 +63,7 @@ public class LabelsActions {
Call<List<Labels>> call = RetrofitClient
.getApiInterface(ctx)
.getlabels(Authorization.get(ctx), repoOwner, repoName);
.getLabels(Authorization.get(ctx), repoOwner, repoName);
call.enqueue(new Callback<List<Labels>>() {
@ -71,26 +71,45 @@ public class LabelsActions {
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> response) {
labelsList.clear();
List<Labels> labelsList_ = response.body();
labelsBinding.progressBar.setVisibility(View.GONE);
labelsBinding.dialogFrame.setVisibility(View.VISIBLE);
if (response.code() == 200) {
assert labelsList_ != null;
if(response.body() != null) {
if(labelsList_.size() > 0) {
labelsList.addAll(labelsList_);
}
else {
dialogLabels.dismiss();
Toasty.warning(ctx, ctx.getResources().getString(R.string.noLabelsFound));
labelsList.addAll(response.body());
}
labelsBinding.labelsRecyclerView.setAdapter(labelsAdapter);
// Load organization labels
Call<List<Labels>> callOrgLabels = RetrofitClient
.getApiInterface(ctx)
.getOrganizationLabels(Authorization.get(ctx), repoOwner);
callOrgLabels.enqueue(new Callback<List<Labels>>() {
@Override
public void onResponse(@NonNull Call<List<Labels>> call, @NonNull retrofit2.Response<List<Labels>> responseOrg) {
labelsBinding.progressBar.setVisibility(View.GONE);
labelsBinding.dialogFrame.setVisibility(View.VISIBLE);
if(responseOrg.body() != null) {
labelsList.addAll(responseOrg.body());
}
if(labelsList.isEmpty()) {
dialogLabels.dismiss();
Toasty.warning(ctx, ctx.getResources().getString(R.string.noLabelsFound));
}
labelsBinding.labelsRecyclerView.setAdapter(labelsAdapter);
}
@Override public void onFailure(@NonNull Call<List<Labels>> call, @NonNull Throwable t) {}
});
}
else {

View File

@ -262,7 +262,7 @@ public class RepoInfoFragment extends Fragment {
repoMetaForks.setText(repoInfo.getForks_count());
repoMetaWatchers.setText(repoInfo.getWatchers_count());
repoMetaSize.setText(FileUtils.byteCountToDisplaySize((int) repoInfo.getSize()));
repoMetaSize.setText(FileUtils.byteCountToDisplaySize((int) (repoInfo.getSize() * 1024)));
repoMetaCreatedAt.setText(TimeHelper.formatTime(repoInfo.getCreated_at(), new Locale(locale), timeFormat, ctx));
if(timeFormat.equals("pretty")) {

View File

@ -176,7 +176,10 @@ public interface ApiInterface {
Call<JsonElement> createNewIssue(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body CreateIssue jsonStr);
@GET("repos/{owner}/{repo}/labels") // get labels list
Call<List<Labels>> getlabels(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
Call<List<Labels>> getLabels(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
@GET("orgs/{owner}/labels") // get org labels list
Call<List<Labels>> getOrganizationLabels(@Header("Authorization") String token, @Path("owner") String ownerName);
@GET("users/{username}/repos") // get current logged in user repositories
Call<List<UserRepositories>> getCurrentUserRepositories(@Header("Authorization") String token, @Path("username") String username, @Query("page") int page, @Query("limit") int limit);

View File

@ -33,7 +33,7 @@ public class LabelsViewModel extends ViewModel {
Call<List<Labels>> call = RetrofitClient
.getApiInterface(ctx)
.getlabels(token, owner, repo);
.getLabels(token, owner, repo);
call.enqueue(new Callback<List<Labels>>() {