mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-03-09 08:07:48 +01:00
Show owner of repo and allow nav to it (#1165)
- show owner next to repo name (and allow click on it) - if you click on the back button of the toolbar on repo details, it navigates to the owner now - cleaned up repos adapter Closes #965 Closes #1162 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1165 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
a95d2718b4
commit
9d428f1b11
@ -28,6 +28,7 @@ import com.google.android.material.tabs.TabLayout;
|
|||||||
import com.google.android.material.tabs.TabLayoutMediator;
|
import com.google.android.material.tabs.TabLayoutMediator;
|
||||||
import org.gitnex.tea4j.v2.models.Branch;
|
import org.gitnex.tea4j.v2.models.Branch;
|
||||||
import org.gitnex.tea4j.v2.models.Milestone;
|
import org.gitnex.tea4j.v2.models.Milestone;
|
||||||
|
import org.gitnex.tea4j.v2.models.Organization;
|
||||||
import org.gitnex.tea4j.v2.models.Repository;
|
import org.gitnex.tea4j.v2.models.Repository;
|
||||||
import org.gitnex.tea4j.v2.models.WatchInfo;
|
import org.gitnex.tea4j.v2.models.WatchInfo;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
@ -137,7 +138,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
|
||||||
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
TextView toolbarTitle = findViewById(R.id.toolbar_title);
|
||||||
toolbarTitle.setText(repository.getName());
|
toolbarTitle.setText(repository.getFullName());
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
Objects.requireNonNull(getSupportActionBar()).setTitle(repository.getName());
|
Objects.requireNonNull(getSupportActionBar()).setTitle(repository.getName());
|
||||||
@ -178,7 +179,26 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
|||||||
|
|
||||||
if(id == android.R.id.home) {
|
if(id == android.R.id.home) {
|
||||||
|
|
||||||
finish();
|
if(!getIntent().getBooleanExtra("openedFromUserOrg", false)) {
|
||||||
|
RetrofitClient.getApiInterface(ctx).orgGet(repository.getOwner()).enqueue(new Callback<>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<Organization> call, @NonNull 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);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<Organization> call, @NonNull Throwable t) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(id == R.id.repoMenu) {
|
else if(id == R.id.repoMenu) {
|
||||||
|
@ -44,6 +44,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
private OnLoadMoreListener loadMoreListener;
|
private OnLoadMoreListener loadMoreListener;
|
||||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
private boolean isLoading = false, isMoreDataAvailable = true;
|
||||||
private final TinyDB tinyDb;
|
private final TinyDB tinyDb;
|
||||||
|
public boolean isUserOrg = false;
|
||||||
|
|
||||||
public ReposListAdapter(List<org.gitnex.tea4j.v2.models.Repository> reposListMain, Context ctx) {
|
public ReposListAdapter(List<org.gitnex.tea4j.v2.models.Repository> reposListMain, Context ctx) {
|
||||||
this.context = ctx;
|
this.context = ctx;
|
||||||
@ -109,7 +110,9 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
||||||
repo.saveToDB(context);
|
repo.saveToDB(context);
|
||||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
||||||
|
if(isUserOrg) {
|
||||||
|
intent.putExtra("openedFromUserOrg", true);
|
||||||
|
}
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,185 +0,0 @@
|
|||||||
package org.mian.gitnex.adapters.profile;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|
||||||
import org.gitnex.tea4j.v2.models.Repository;
|
|
||||||
import org.mian.gitnex.R;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author M M Arif
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class RepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
private List<Repository> reposList;
|
|
||||||
private Runnable loadMoreListener;
|
|
||||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
|
||||||
|
|
||||||
public RepositoriesAdapter(Context ctx, List<Repository> reposListMain) {
|
|
||||||
this.context = ctx;
|
|
||||||
this.reposList = reposListMain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
|
||||||
return new RepositoriesAdapter.RepositoriesHolder(inflater.inflate(R.layout.list_repositories, parent, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
|
||||||
|
|
||||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
|
||||||
isLoading = true;
|
|
||||||
loadMoreListener.run();
|
|
||||||
}
|
|
||||||
((RepositoriesAdapter.RepositoriesHolder) holder).bindData(reposList.get(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int position) {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return reposList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
private Repository userRepositories;
|
|
||||||
|
|
||||||
private final ImageView avatar;
|
|
||||||
private final TextView repoName;
|
|
||||||
private final TextView orgName;
|
|
||||||
private final TextView repoDescription;
|
|
||||||
private CheckBox isRepoAdmin;
|
|
||||||
private final TextView repoStars;
|
|
||||||
private final TextView repoLastUpdated;
|
|
||||||
|
|
||||||
RepositoriesHolder(View itemView) {
|
|
||||||
|
|
||||||
super(itemView);
|
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
|
||||||
orgName = itemView.findViewById(R.id.orgName);
|
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
|
||||||
avatar = itemView.findViewById(R.id.imageAvatar);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
|
||||||
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
|
||||||
Context context = v.getContext();
|
|
||||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
|
||||||
repo.saveToDB(context);
|
|
||||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
void bindData(Repository userRepositories) {
|
|
||||||
|
|
||||||
this.userRepositories = userRepositories;
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
|
||||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
|
||||||
|
|
||||||
Locale locale = context.getResources().getConfiguration().locale;
|
|
||||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
|
||||||
|
|
||||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
|
||||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
|
||||||
repoStars.setText(String.valueOf(userRepositories.getStarsCount()));
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
|
||||||
int color = generator.getColor(userRepositories.getName());
|
|
||||||
String firstCharacter = String.valueOf(userRepositories.getFullName().charAt(0));
|
|
||||||
|
|
||||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
|
||||||
|
|
||||||
if(userRepositories.getAvatarUrl() != null) {
|
|
||||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
|
||||||
PicassoService
|
|
||||||
.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avatar.setImageDrawable(drawable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avatar.setImageDrawable(drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(userRepositories.getUpdatedAt() != null) {
|
|
||||||
|
|
||||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, TimeHelper.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
|
||||||
if(timeFormat.equals("pretty")) {
|
|
||||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
repoLastUpdated.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!userRepositories.getDescription().equals("")) {
|
|
||||||
repoDescription.setText(userRepositories.getDescription());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
repoDescription.setText(context.getString(R.string.noDataDescription));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isRepoAdmin == null) {
|
|
||||||
isRepoAdmin = new CheckBox(context);
|
|
||||||
}
|
|
||||||
isRepoAdmin.setChecked(userRepositories.getPermissions().isAdmin());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
|
||||||
isMoreDataAvailable = moreDataAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
public void notifyDataChanged() {
|
|
||||||
notifyDataSetChanged();
|
|
||||||
isLoading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
|
||||||
this.loadMoreListener = loadMoreListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateList(List<Repository> list) {
|
|
||||||
reposList = list;
|
|
||||||
notifyDataChanged();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
package org.mian.gitnex.adapters.profile;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
|
||||||
import org.mian.gitnex.R;
|
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
|
||||||
import org.mian.gitnex.helpers.AppUtil;
|
|
||||||
import org.mian.gitnex.helpers.ClickListener;
|
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
|
||||||
import org.mian.gitnex.helpers.TimeHelper;
|
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
|
||||||
import org.mian.gitnex.helpers.contexts.RepositoryContext;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author M M Arif
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class StarredRepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
private List<org.gitnex.tea4j.v2.models.Repository> reposList;
|
|
||||||
private Runnable loadMoreListener;
|
|
||||||
private boolean isLoading = false, isMoreDataAvailable = true;
|
|
||||||
|
|
||||||
public StarredRepositoriesAdapter(Context ctx, List<org.gitnex.tea4j.v2.models.Repository> reposListMain) {
|
|
||||||
this.context = ctx;
|
|
||||||
this.reposList = reposListMain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
|
||||||
return new StarredRepositoriesAdapter.StarredRepositoriesHolder(inflater.inflate(R.layout.list_repositories, parent, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
|
||||||
|
|
||||||
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
|
||||||
isLoading = true;
|
|
||||||
loadMoreListener.run();
|
|
||||||
}
|
|
||||||
((StarredRepositoriesAdapter.StarredRepositoriesHolder) holder).bindData(reposList.get(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemViewType(int position) {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return reposList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
class StarredRepositoriesHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
private org.gitnex.tea4j.v2.models.Repository userRepositories;
|
|
||||||
|
|
||||||
private final ImageView avatar;
|
|
||||||
private final TextView repoName;
|
|
||||||
private final TextView orgName;
|
|
||||||
private final TextView repoDescription;
|
|
||||||
private CheckBox isRepoAdmin;
|
|
||||||
private final TextView repoStars;
|
|
||||||
private final TextView repoLastUpdated;
|
|
||||||
|
|
||||||
StarredRepositoriesHolder(View itemView) {
|
|
||||||
|
|
||||||
super(itemView);
|
|
||||||
repoName = itemView.findViewById(R.id.repoName);
|
|
||||||
orgName = itemView.findViewById(R.id.orgName);
|
|
||||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
|
||||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
|
||||||
avatar = itemView.findViewById(R.id.imageAvatar);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
|
||||||
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
|
||||||
Context context = v.getContext();
|
|
||||||
RepositoryContext repo = new RepositoryContext(userRepositories, context);
|
|
||||||
repo.saveToDB(context);
|
|
||||||
Intent intent = repo.getIntent(context, RepoDetailActivity.class);
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
void bindData(org.gitnex.tea4j.v2.models.Repository userRepositories) {
|
|
||||||
|
|
||||||
this.userRepositories = userRepositories;
|
|
||||||
TinyDB tinyDb = TinyDB.getInstance(context);
|
|
||||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
|
||||||
|
|
||||||
Locale locale = context.getResources().getConfiguration().locale;
|
|
||||||
String timeFormat = tinyDb.getString("dateFormat", "pretty");
|
|
||||||
|
|
||||||
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
|
||||||
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
|
||||||
repoStars.setText(String.valueOf(userRepositories.getStarsCount()));
|
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.Companion.getMATERIAL();
|
|
||||||
int color = generator.getColor(userRepositories.getName());
|
|
||||||
String firstCharacter = String.valueOf(userRepositories.getFullName().charAt(0));
|
|
||||||
|
|
||||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
|
||||||
|
|
||||||
if(userRepositories.getAvatarUrl() != null) {
|
|
||||||
if(!userRepositories.getAvatarUrl().equals("")) {
|
|
||||||
PicassoService
|
|
||||||
.getInstance(context).get().load(userRepositories.getAvatarUrl()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(avatar);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avatar.setImageDrawable(drawable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avatar.setImageDrawable(drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(userRepositories.getUpdatedAt() != null) {
|
|
||||||
|
|
||||||
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, TimeHelper
|
|
||||||
.formatTime(userRepositories.getUpdatedAt(), locale, timeFormat, context)));
|
|
||||||
if(timeFormat.equals("pretty")) {
|
|
||||||
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdatedAt()), context));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
repoLastUpdated.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!userRepositories.getDescription().equals("")) {
|
|
||||||
repoDescription.setText(userRepositories.getDescription());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
repoDescription.setText(context.getString(R.string.noDataDescription));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isRepoAdmin == null) {
|
|
||||||
isRepoAdmin = new CheckBox(context);
|
|
||||||
}
|
|
||||||
isRepoAdmin.setChecked(userRepositories.getPermissions().isAdmin());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
|
||||||
isMoreDataAvailable = moreDataAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
public void notifyDataChanged() {
|
|
||||||
notifyDataSetChanged();
|
|
||||||
isLoading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoadMoreListener(Runnable loadMoreListener) {
|
|
||||||
this.loadMoreListener = loadMoreListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateList(List<org.gitnex.tea4j.v2.models.Repository> list) {
|
|
||||||
reposList = list;
|
|
||||||
notifyDataChanged();
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,12 +12,16 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.gitnex.tea4j.v2.models.Organization;
|
||||||
import org.gitnex.tea4j.v2.models.Repository;
|
import org.gitnex.tea4j.v2.models.Repository;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.activities.OrganizationDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoForksActivity;
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
|
import org.mian.gitnex.activities.ProfileActivity;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.databinding.FragmentRepoInfoBinding;
|
import org.mian.gitnex.databinding.FragmentRepoInfoBinding;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
@ -33,6 +37,7 @@ import java.util.Locale;
|
|||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author M M Arif
|
* @author M M Arif
|
||||||
@ -143,6 +148,20 @@ public class RepoInfoFragment extends Fragment {
|
|||||||
|
|
||||||
if (isAdded()) {
|
if (isAdded()) {
|
||||||
assert repoInfo != null;
|
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());
|
binding.repoMetaName.setText(repoInfo.getName());
|
||||||
|
|
||||||
if(!repoInfo.getDescription().isEmpty()) {
|
if(!repoInfo.getDescription().isEmpty()) {
|
||||||
|
@ -90,6 +90,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
|||||||
repositoriesViewModel.getRepositories(page, resultLimit, "", "org", orgName, getContext()).observe(getViewLifecycleOwner(), reposListMain -> {
|
repositoriesViewModel.getRepositories(page, resultLimit, "", "org", orgName, getContext()).observe(getViewLifecycleOwner(), reposListMain -> {
|
||||||
|
|
||||||
adapter = new ReposListAdapter(reposListMain, getContext());
|
adapter = new ReposListAdapter(reposListMain, getContext());
|
||||||
|
adapter.isUserOrg = true;
|
||||||
adapter.setLoadMoreListener(new ReposListAdapter.OnLoadMoreListener() {
|
adapter.setLoadMoreListener(new ReposListAdapter.OnLoadMoreListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import org.gitnex.tea4j.v2.models.Repository;
|
import org.gitnex.tea4j.v2.models.Repository;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.profile.RepositoriesAdapter;
|
import org.mian.gitnex.adapters.ReposListAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.databinding.FragmentRepositoriesBinding;
|
import org.mian.gitnex.databinding.FragmentRepositoriesBinding;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
@ -41,7 +41,7 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
private FragmentRepositoriesBinding fragmentRepositoriesBinding;
|
private FragmentRepositoriesBinding fragmentRepositoriesBinding;
|
||||||
|
|
||||||
private List<Repository> reposList;
|
private List<Repository> reposList;
|
||||||
private RepositoriesAdapter adapter;
|
private ReposListAdapter adapter;
|
||||||
|
|
||||||
private int pageSize;
|
private int pageSize;
|
||||||
private int resultLimit;
|
private int resultLimit;
|
||||||
@ -86,13 +86,25 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
adapter = new RepositoriesAdapter(context, reposList);
|
adapter = new ReposListAdapter(reposList, context);
|
||||||
adapter.setLoadMoreListener(() -> fragmentRepositoriesBinding.recyclerView.post(() -> {
|
adapter.isUserOrg = true;
|
||||||
if(reposList.size() == resultLimit || pageSize == resultLimit) {
|
adapter.setLoadMoreListener(new ReposListAdapter.OnLoadMoreListener() {
|
||||||
int page = (reposList.size() + resultLimit) / resultLimit;
|
|
||||||
loadMore(username, page, resultLimit);
|
@Override
|
||||||
|
public void onLoadMore() {
|
||||||
|
fragmentRepositoriesBinding.recyclerView.post(() -> {
|
||||||
|
if(reposList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
int page = (reposList.size() + resultLimit) / resultLimit;
|
||||||
|
loadMore(username, page, resultLimit);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}));
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
|
||||||
fragmentRepositoriesBinding.recyclerView.setHasFixedSize(true);
|
fragmentRepositoriesBinding.recyclerView.setHasFixedSize(true);
|
||||||
@ -110,7 +122,8 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
Call<List<Repository>> call = RetrofitClient
|
Call<List<Repository>> call = RetrofitClient
|
||||||
.getApiInterface(context).userListRepos(username, 1, resultLimit);
|
.getApiInterface(context).userListRepos(username, 1, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Repository>>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||||
|
|
||||||
@ -166,7 +179,7 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
Call<List<Repository>> call = RetrofitClient.getApiInterface(context).userListRepos(username, page, resultLimit);
|
Call<List<Repository>> call = RetrofitClient.getApiInterface(context).userListRepos(username, page, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Repository>>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||||
|
@ -18,7 +18,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import org.gitnex.tea4j.v2.models.Repository;
|
import org.gitnex.tea4j.v2.models.Repository;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.adapters.profile.StarredRepositoriesAdapter;
|
import org.mian.gitnex.adapters.ReposListAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.databinding.FragmentRepositoriesBinding;
|
import org.mian.gitnex.databinding.FragmentRepositoriesBinding;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
import org.mian.gitnex.helpers.AlertDialogs;
|
||||||
@ -41,7 +41,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
private FragmentRepositoriesBinding fragmentRepositoriesBinding;
|
private FragmentRepositoriesBinding fragmentRepositoriesBinding;
|
||||||
|
|
||||||
private List<Repository> reposList;
|
private List<Repository> reposList;
|
||||||
private StarredRepositoriesAdapter adapter;
|
private ReposListAdapter adapter;
|
||||||
|
|
||||||
private int pageSize;
|
private int pageSize;
|
||||||
private int resultLimit;
|
private int resultLimit;
|
||||||
@ -86,13 +86,24 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
adapter.notifyDataChanged();
|
adapter.notifyDataChanged();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
adapter = new StarredRepositoriesAdapter(context, reposList);
|
adapter = new ReposListAdapter(reposList, context);
|
||||||
adapter.setLoadMoreListener(() -> fragmentRepositoriesBinding.recyclerView.post(() -> {
|
adapter.setLoadMoreListener(new ReposListAdapter.OnLoadMoreListener() {
|
||||||
if(reposList.size() == resultLimit || pageSize == resultLimit) {
|
|
||||||
int page = (reposList.size() + resultLimit) / resultLimit;
|
@Override
|
||||||
loadMore(username, page, resultLimit);
|
public void onLoadMore() {
|
||||||
|
fragmentRepositoriesBinding.recyclerView.post(() -> {
|
||||||
|
if(reposList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
int page = (reposList.size() + resultLimit) / resultLimit;
|
||||||
|
loadMore(username, page, resultLimit);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}));
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFinished() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
|
||||||
fragmentRepositoriesBinding.recyclerView.setHasFixedSize(true);
|
fragmentRepositoriesBinding.recyclerView.setHasFixedSize(true);
|
||||||
@ -111,7 +122,8 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
.getApiInterface(context)
|
.getApiInterface(context)
|
||||||
.userListStarred(username, 1, resultLimit);
|
.userListStarred(username, 1, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Repository>>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||||
|
|
||||||
@ -169,7 +181,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
|||||||
.getApiInterface(context)
|
.getApiInterface(context)
|
||||||
.userListStarred(username, page, resultLimit);
|
.userListStarred(username, page, resultLimit);
|
||||||
|
|
||||||
call.enqueue(new Callback<List<Repository>>() {
|
call.enqueue(new Callback<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
public void onResponse(@NonNull Call<List<Repository>> call, @NonNull Response<List<Repository>> response) {
|
||||||
|
@ -70,14 +70,41 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/repoMetaName"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:orientation="horizontal">
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:textSize="22sp"
|
<TextView
|
||||||
android:textStyle="bold" />
|
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
|
<TextView
|
||||||
android:id="@+id/repoMetaDescription"
|
android:id="@+id/repoMetaDescription"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user