Show ContributorsTab only if you have permission to (#402)
add isRepoAdmin extend Adapters add check to RepoDetails refactor var names reformat code Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/402 Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
parent
ab47e409e9
commit
b8d8b34b0e
@ -125,6 +125,15 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
}
|
||||
}
|
||||
|
||||
// only show Collaborators if you have permission to
|
||||
final View collaboratorTab = vg.getChildAt(9);
|
||||
if (tinyDb.getBoolean("isRepoAdmin")) {
|
||||
collaboratorTab.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else {
|
||||
collaboratorTab.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||
|
||||
|
@ -7,6 +7,7 @@ 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;
|
||||
@ -21,7 +22,6 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
@ -42,6 +42,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
private Context mCtx;
|
||||
|
||||
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context mCtx) {
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.searchedReposList = dataList;
|
||||
}
|
||||
@ -49,21 +50,24 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
static class ReposSearchViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView image;
|
||||
private TextView mTextView1;
|
||||
private TextView mTextView2;
|
||||
private TextView repoName;
|
||||
private TextView repoDescription;
|
||||
private TextView fullName;
|
||||
private CheckBox isRepoAdmin;
|
||||
private ImageView repoPrivatePublic;
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
private TextView repoOpenIssuesCount;
|
||||
|
||||
private ReposSearchViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
|
||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
fullName = itemView.findViewById(R.id.repoFullName);
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||
repoStars = itemView.findViewById(R.id.repoStars);
|
||||
repoForks = itemView.findViewById(R.id.repoForks);
|
||||
@ -81,6 +85,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
TinyDB tinyDb = new TinyDB(context);
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
@ -133,8 +138,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
@ -182,6 +186,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
@NonNull
|
||||
@Override
|
||||
public ExploreRepositoriesAdapter.ReposSearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repos, parent, false);
|
||||
return new ExploreRepositoriesAdapter.ReposSearchViewHolder(v);
|
||||
}
|
||||
@ -192,26 +197,19 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
final UserRepositories currentItem = searchedReposList.get(position);
|
||||
|
||||
|
||||
holder.mTextView2.setVisibility(View.GONE);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.fontSize(18)
|
||||
.toUpperCase()
|
||||
.width(28)
|
||||
.height(28)
|
||||
.endConfig()
|
||||
.buildRoundRect(firstCharacter, color, 3);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(currentItem.getAvatar_url() != null) {
|
||||
if(!currentItem.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holder.image.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
@ -219,10 +217,10 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
holder.image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
holder.mTextView1.setText(currentItem.getName());
|
||||
holder.repoName.setText(currentItem.getName());
|
||||
if(!currentItem.getDescription().equals("")) {
|
||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
||||
holder.mTextView2.setText(currentItem.getDescription());
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
@ -234,11 +232,17 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||
if(holder.isRepoAdmin == null) {
|
||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return searchedReposList.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,15 +4,16 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
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 com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
@ -46,9 +47,10 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
static class ReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView image;
|
||||
private TextView mTextView1;
|
||||
private TextView mTextView2;
|
||||
private TextView repoName;
|
||||
private TextView repoDescription;
|
||||
private TextView fullName;
|
||||
private CheckBox isRepoAdmin;
|
||||
private ImageView repoPrivatePublic;
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
@ -58,8 +60,9 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
private ReposViewHolder(View itemView) {
|
||||
|
||||
super(itemView);
|
||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
fullName = itemView.findViewById(R.id.repoFullName);
|
||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||
@ -82,6 +85,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
@ -134,8 +138,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
final Context context = v.getContext();
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||
|
||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||
@ -177,9 +180,11 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
||||
|
||||
this.mCtx = mCtx;
|
||||
this.reposList = reposListMain;
|
||||
reposListFull = new ArrayList<>(reposList);
|
||||
@ -188,6 +193,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
@NonNull
|
||||
@Override
|
||||
public ReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repos, parent, false);
|
||||
return new ReposViewHolder(v);
|
||||
}
|
||||
@ -196,26 +202,19 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) {
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.mTextView2.setVisibility(View.GONE);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
||||
|
||||
TextDrawable drawable = TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.fontSize(18)
|
||||
.toUpperCase()
|
||||
.width(28)
|
||||
.height(28)
|
||||
.endConfig()
|
||||
.buildRoundRect(firstCharacter, color, 3);
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||
|
||||
if(currentItem.getAvatar_url() != null) {
|
||||
if(!currentItem.getAvatar_url().equals("")) {
|
||||
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holder.image.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
@ -223,10 +222,10 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
holder.image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
holder.mTextView1.setText(currentItem.getName());
|
||||
holder.repoName.setText(currentItem.getName());
|
||||
if(!currentItem.getDescription().equals("")) {
|
||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
||||
holder.mTextView2.setText(currentItem.getDescription());
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
@ -240,27 +239,36 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||
if(holder.isRepoAdmin == null) {
|
||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return reposList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
|
||||
return reposFilter;
|
||||
}
|
||||
|
||||
private Filter reposFilter = new Filter() {
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
List<UserRepositories> filteredList = new ArrayList<>();
|
||||
|
||||
if(constraint == null || constraint.length() == 0) {
|
||||
filteredList.addAll(reposListFull);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||
|
||||
for(UserRepositories item : reposListFull) {
|
||||
@ -278,6 +286,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
||||
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
|
||||
reposList.clear();
|
||||
reposList.addAll((List) results.values);
|
||||
notifyDataSetChanged();
|
||||
|
@ -7,6 +7,7 @@ import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
@ -46,9 +47,10 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
static class OrgReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView image;
|
||||
private TextView mTextView1;
|
||||
private TextView mTextView2;
|
||||
private TextView repoName;
|
||||
private TextView repoDescription;
|
||||
private TextView fullName;
|
||||
private CheckBox isRepoAdmin;
|
||||
private ImageView repoPrivatePublic;
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
@ -57,8 +59,9 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
|
||||
private OrgReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
fullName = itemView.findViewById(R.id.repoFullName);
|
||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||
@ -79,6 +82,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
@ -193,7 +197,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
public void onBindViewHolder(@NonNull RepositoriesByOrgAdapter.OrgReposViewHolder holder, int position) {
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.mTextView2.setVisibility(View.GONE);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -220,10 +224,10 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
holder.image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
holder.mTextView1.setText(currentItem.getName());
|
||||
holder.repoName.setText(currentItem.getName());
|
||||
if (!currentItem.getDescription().equals("")) {
|
||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
||||
holder.mTextView2.setText(currentItem.getDescription());
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
@ -238,6 +242,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||
|
||||
if (holder.isRepoAdmin == null) {
|
||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageView;
|
||||
@ -46,9 +47,10 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
static class StarredReposViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView image;
|
||||
private TextView mTextView1;
|
||||
private TextView mTextView2;
|
||||
private TextView repoName;
|
||||
private TextView repoDescription;
|
||||
private TextView fullName;
|
||||
private CheckBox isRepoAdmin;
|
||||
private ImageView repoPrivatePublic;
|
||||
private TextView repoStars;
|
||||
private TextView repoForks;
|
||||
@ -57,8 +59,9 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
|
||||
private StarredReposViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
||||
repoName = itemView.findViewById(R.id.repoName);
|
||||
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||
image = itemView.findViewById(R.id.imageAvatar);
|
||||
fullName = itemView.findViewById(R.id.repoFullName);
|
||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||
@ -79,6 +82,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
tinyDb.putString("repoFullName", fullName.getText().toString());
|
||||
tinyDb.putString("repoType", repoType.getText().toString());
|
||||
tinyDb.putBoolean("resumeIssues", true);
|
||||
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||
|
||||
//store if user is watching this repo
|
||||
{
|
||||
@ -194,7 +198,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
public void onBindViewHolder(@NonNull StarredReposListAdapter.StarredReposViewHolder holder, int position) {
|
||||
|
||||
UserRepositories currentItem = reposList.get(position);
|
||||
holder.mTextView2.setVisibility(View.GONE);
|
||||
holder.repoDescription.setVisibility(View.GONE);
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(currentItem.getName());
|
||||
@ -221,10 +225,10 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
holder.image.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
holder.mTextView1.setText(currentItem.getName());
|
||||
holder.repoName.setText(currentItem.getName());
|
||||
if (!currentItem.getDescription().equals("")) {
|
||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
||||
holder.mTextView2.setText(currentItem.getDescription());
|
||||
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||
holder.repoDescription.setText(currentItem.getDescription());
|
||||
}
|
||||
holder.fullName.setText(currentItem.getFullname());
|
||||
if(currentItem.getPrivateFlag()) {
|
||||
@ -238,6 +242,10 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
||||
holder.repoStars.setText(currentItem.getStars_count());
|
||||
holder.repoForks.setText(currentItem.getForks_count());
|
||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||
if (holder.isRepoAdmin == null) {
|
||||
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||
}
|
||||
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,10 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
+ * Template Author M M Arif
|
||||
+ * Author 6543
|
||||
+ */
|
||||
* + * Template Author M M Arif
|
||||
* + * Author 6543
|
||||
* +
|
||||
*/
|
||||
|
||||
public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
@ -50,9 +51,11 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private OnFragmentInteractionListener mListener;
|
||||
|
||||
public ExploreRepositoriesFragment() {
|
||||
|
||||
}
|
||||
|
||||
public static ExploreRepositoriesFragment newInstance(String param1, String param2) {
|
||||
|
||||
ExploreRepositoriesFragment fragment = new ExploreRepositoriesFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(repoOwnerF, param1);
|
||||
@ -63,6 +66,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
if(getArguments() != null) {
|
||||
String repoName = getArguments().getString(repoNameF);
|
||||
@ -71,8 +75,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
final View v = inflater.inflate(R.layout.fragment_explore_repo, container, false);
|
||||
//setHasOptionsMenu(true);
|
||||
@ -90,8 +93,10 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
|
||||
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!searchKeyword.getText().toString().equals("")) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
@ -112,10 +117,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
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<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), null, repoTypeInclude, sort, order, limit);
|
||||
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
@ -125,7 +127,8 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
getReposList(response.body().getSearchedData(), context);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
@ -133,6 +136,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||
}
|
||||
|
||||
@ -142,10 +146,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
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
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getApiInterface()
|
||||
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
||||
Call<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
||||
|
||||
call.enqueue(new Callback<ExploreRepositories>() {
|
||||
|
||||
@ -155,7 +156,8 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
if(response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
getReposList(response.body().getSearchedData(), context);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
|
||||
@ -163,6 +165,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||
|
||||
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||
}
|
||||
|
||||
@ -178,8 +181,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
if(adapter.getItemCount() > 0) {
|
||||
@ -199,6 +201,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
}
|
||||
|
||||
public void onButtonPressed(Uri uri) {
|
||||
|
||||
if(mListener != null) {
|
||||
mListener.onFragmentInteraction(uri);
|
||||
}
|
||||
@ -206,11 +209,15 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
public interface OnFragmentInteractionListener {
|
||||
|
||||
void onFragmentInteraction(Uri uri);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String userLogin = tinyDb.getString("userLogin");
|
||||
tinyDb.putBoolean("isRepoAdmin", true);
|
||||
|
||||
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
||||
|
||||
|
@ -32,87 +32,139 @@ public class UserRepositories {
|
||||
private Boolean has_issues;
|
||||
private String avatar_url;
|
||||
|
||||
private permissionsObject permissions;
|
||||
|
||||
public class permissionsObject {
|
||||
|
||||
private boolean admin;
|
||||
private boolean push;
|
||||
private boolean pull;
|
||||
|
||||
public boolean isAdmin() {
|
||||
|
||||
return admin;
|
||||
}
|
||||
|
||||
public boolean canPush() {
|
||||
|
||||
return push;
|
||||
}
|
||||
|
||||
public boolean canPull() {
|
||||
|
||||
return pull;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
|
||||
return full_name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
public permissionsObject getPermissions() {
|
||||
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public Boolean getPrivateFlag() {
|
||||
|
||||
return privateFlag;
|
||||
}
|
||||
|
||||
public String getStars_count() {
|
||||
|
||||
return stars_count;
|
||||
}
|
||||
|
||||
public String getOpen_pull_count() {
|
||||
|
||||
return open_pr_counter;
|
||||
}
|
||||
|
||||
public String getRelease_count() {
|
||||
|
||||
return release_counter;
|
||||
}
|
||||
|
||||
public String getWatchers_count() {
|
||||
|
||||
return watchers_count;
|
||||
}
|
||||
|
||||
public String getOpen_issues_count() {
|
||||
|
||||
return open_issues_count;
|
||||
}
|
||||
|
||||
public String getHtml_url() {
|
||||
|
||||
return html_url;
|
||||
}
|
||||
|
||||
public String getDefault_branch() {
|
||||
|
||||
return default_branch;
|
||||
}
|
||||
|
||||
public Date getCreated_at() {
|
||||
|
||||
return created_at;
|
||||
}
|
||||
|
||||
public Date getUpdated_at() {
|
||||
|
||||
return updated_at;
|
||||
}
|
||||
|
||||
public String getClone_url() {
|
||||
|
||||
return clone_url;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
public String getSsh_url() {
|
||||
|
||||
return ssh_url;
|
||||
}
|
||||
|
||||
public String getWebsite() {
|
||||
|
||||
return website;
|
||||
}
|
||||
|
||||
public String getForks_count() {
|
||||
|
||||
return forks_count;
|
||||
}
|
||||
|
||||
public Boolean getHas_issues() {
|
||||
|
||||
return has_issues;
|
||||
}
|
||||
|
||||
public String getAvatar_url() {
|
||||
|
||||
return avatar_url;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,6 +83,14 @@
|
||||
android:textSize="16sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/repoIsAdmin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:buttonTint="#FFFFFF"
|
||||
android:checked="false"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
Loading…
x
Reference in New Issue
Block a user