Show owner in repo details

This commit is contained in:
qwerty287 2022-07-07 14:45:59 +02:00
parent 9ecc96ba9c
commit a92d8a9d81
No known key found for this signature in database
GPG key ID: E0464C650D9D25B2
3 changed files with 53 additions and 11 deletions

View file

@ -12,12 +12,11 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import org.apache.commons.io.FileUtils;
import org.gitnex.tea4j.v2.models.Organization;
import org.gitnex.tea4j.v2.models.Repository;
import org.jetbrains.annotations.NotNull;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.activities.*;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.FragmentRepoInfoBinding;
import org.mian.gitnex.helpers.AlertDialogs;
@ -33,6 +32,7 @@ import java.util.Locale;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* @author M M Arif
@ -143,6 +143,20 @@ public class RepoInfoFragment extends Fragment {
if (isAdded()) {
assert repoInfo != null;
binding.repoMetaOwner.setText(repoInfo.getOwner().getLogin());
binding.repoMetaOwner.setOnClickListener((v) -> RetrofitClient.getApiInterface(ctx).orgGet(repository.getOwner()).enqueue(new Callback<>() {
@Override
public void onResponse(@NotNull Call<Organization> call, @NotNull Response<Organization> response) {
Intent intent = new Intent(ctx, response.isSuccessful() ? OrganizationDetailActivity.class : ProfileActivity.class);
intent.putExtra(response.isSuccessful() ? "orgName" : "username", repository.getOwner());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
@Override
public void onFailure(@NotNull Call<Organization> call, @NotNull Throwable t) {}
}));
binding.repoMetaName.setText(repoInfo.getName());
if(!repoInfo.getDescription().isEmpty()) {

View file

@ -122,7 +122,8 @@ public class RepositoriesFragment extends Fragment {
Call<List<Repository>> call = RetrofitClient
.getApiInterface(context).userListRepos(username, 1, resultLimit);
call.enqueue(new Callback<List<Repository>>() {
call.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {

View file

@ -70,14 +70,41 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/repoMetaName"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:layout_marginBottom="5dp"
android:textSize="22sp"
android:textStyle="bold" />
android:orientation="horizontal">
<TextView
android:id="@+id/repoMetaOwner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="22sp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:layout_marginBottom="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:text="/"
android:textSize="22sp"
android:textStyle="bold"
tools:ignore="HardcodedText"/>
<TextView
android:id="@+id/repoMetaName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:layout_marginBottom="5dp"
android:textSize="22sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/repoMetaDescription"