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));
|
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||||
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import android.graphics.Typeface;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -21,7 +22,6 @@ import org.mian.gitnex.activities.RepoStargazersActivity;
|
|||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.helpers.AlertDialogs;
|
|
||||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
@ -38,207 +38,211 @@ import retrofit2.Callback;
|
|||||||
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepositoriesAdapter.ReposSearchViewHolder> {
|
||||||
|
|
||||||
|
|
||||||
private List<UserRepositories> searchedReposList;
|
private List<UserRepositories> searchedReposList;
|
||||||
private Context mCtx;
|
private Context mCtx;
|
||||||
|
|
||||||
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context mCtx) {
|
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context mCtx) {
|
||||||
this.mCtx = mCtx;
|
|
||||||
this.searchedReposList = dataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ReposSearchViewHolder extends RecyclerView.ViewHolder {
|
this.mCtx = mCtx;
|
||||||
|
this.searchedReposList = dataList;
|
||||||
|
}
|
||||||
|
|
||||||
private ImageView image;
|
static class ReposSearchViewHolder extends RecyclerView.ViewHolder {
|
||||||
private TextView mTextView1;
|
|
||||||
private TextView mTextView2;
|
|
||||||
private TextView fullName;
|
|
||||||
private ImageView repoPrivatePublic;
|
|
||||||
private TextView repoStars;
|
|
||||||
private TextView repoForks;
|
|
||||||
private TextView repoOpenIssuesCount;
|
|
||||||
|
|
||||||
private ReposSearchViewHolder(View itemView) {
|
private ImageView image;
|
||||||
super(itemView);
|
private TextView repoName;
|
||||||
|
private TextView repoDescription;
|
||||||
|
private TextView fullName;
|
||||||
|
private CheckBox isRepoAdmin;
|
||||||
|
private ImageView repoPrivatePublic;
|
||||||
|
private TextView repoStars;
|
||||||
|
private TextView repoForks;
|
||||||
|
private TextView repoOpenIssuesCount;
|
||||||
|
|
||||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
private ReposSearchViewHolder(View itemView) {
|
||||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
super(itemView);
|
||||||
|
|
||||||
Context context = v.getContext();
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
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);
|
||||||
|
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||||
|
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
itemView.setOnClickListener(v -> {
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
Context context = v.getContext();
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
|
||||||
|
|
||||||
//store if user is watching this repo
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
{
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
||||||
String[] parts = repoFullName.getText().toString().split("/");
|
|
||||||
final String repoOwner = parts[0];
|
|
||||||
final String repoName = parts[1];
|
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
|
||||||
|
|
||||||
WatchRepository watch = new WatchRepository();
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
|
|
||||||
Call<WatchRepository> call;
|
//store if user is watching this repo
|
||||||
|
{
|
||||||
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
|
String[] parts = repoFullName.getText().toString().split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
WatchRepository watch = new WatchRepository();
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchRepository>() {
|
Call<WatchRepository> call;
|
||||||
|
|
||||||
@Override
|
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) {
|
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
call.enqueue(new Callback<WatchRepository>() {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) {
|
||||||
|
|
||||||
}
|
if(response.isSuccessful()) {
|
||||||
else {
|
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
}
|
tinyDb.putBoolean("repoWatch", false);
|
||||||
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) {
|
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
}
|
||||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
});
|
public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) {
|
||||||
}
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
tinyDb.putBoolean("repoWatch", false);
|
||||||
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||||
|
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
context.startActivity(intent);
|
||||||
|
|
||||||
final Context context = v.getContext();
|
});
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
reposDropdownMenu.setOnClickListener(v -> {
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
final Context context = v.getContext();
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
|
||||||
|
|
||||||
bottomSheetHeader.setText(fullName.getText());
|
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
||||||
dialog.setContentView(view);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
|
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||||
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
bottomSheetHeader.setText(fullName.getText());
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||||
context.startActivity(intentOpenInBrowser);
|
dialog.setContentView(view);
|
||||||
dialog.dismiss();
|
dialog.show();
|
||||||
|
|
||||||
});
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||||
|
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
||||||
|
context.startActivity(intentOpenInBrowser);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
});
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
|
||||||
context.startActivity(intent);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
repoStargazers.setOnClickListener(stargazers -> {
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
||||||
|
intent.putExtra("repoFullNameForStars", fullName.getText());
|
||||||
|
context.startActivity(intent);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
});
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
|
||||||
context.startActivity(intentW);
|
|
||||||
dialog.dismiss();
|
|
||||||
|
|
||||||
});
|
repoWatchers.setOnClickListener(watchers -> {
|
||||||
|
|
||||||
});
|
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
});
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onBindViewHolder(@NonNull final ExploreRepositoriesAdapter.ReposSearchViewHolder holder, int position) {
|
|
||||||
|
|
||||||
final UserRepositories currentItem = searchedReposList.get(position);
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull final ExploreRepositoriesAdapter.ReposSearchViewHolder holder, int position) {
|
||||||
|
|
||||||
|
final UserRepositories currentItem = searchedReposList.get(position);
|
||||||
|
|
||||||
|
|
||||||
holder.mTextView2.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
||||||
|
|
||||||
TextDrawable drawable = TextDrawable.builder()
|
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||||
.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() != null) {
|
||||||
if (!currentItem.getAvatar_url().equals("")) {
|
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);
|
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 {
|
}
|
||||||
holder.image.setImageDrawable(drawable);
|
else {
|
||||||
}
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
holder.image.setImageDrawable(drawable);
|
else {
|
||||||
}
|
holder.image.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
holder.mTextView1.setText(currentItem.getName());
|
holder.repoName.setText(currentItem.getName());
|
||||||
if (!currentItem.getDescription().equals("")) {
|
if(!currentItem.getDescription().equals("")) {
|
||||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||||
holder.mTextView2.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.fullName.setText(currentItem.getFullname());
|
holder.fullName.setText(currentItem.getFullname());
|
||||||
if(currentItem.getPrivateFlag()) {
|
if(currentItem.getPrivateFlag()) {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||||
}
|
}
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
holder.repoForks.setText(currentItem.getForks_count());
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_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();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return searchedReposList.size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,16 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||||
@ -39,249 +40,257 @@ import retrofit2.Callback;
|
|||||||
|
|
||||||
public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.ReposViewHolder> implements Filterable {
|
public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.ReposViewHolder> implements Filterable {
|
||||||
|
|
||||||
private List<UserRepositories> reposList;
|
private List<UserRepositories> reposList;
|
||||||
private Context mCtx;
|
private Context mCtx;
|
||||||
private List<UserRepositories> reposListFull;
|
private List<UserRepositories> reposListFull;
|
||||||
|
|
||||||
static class ReposViewHolder extends RecyclerView.ViewHolder {
|
static class ReposViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private ImageView image;
|
||||||
private TextView mTextView1;
|
private TextView repoName;
|
||||||
private TextView mTextView2;
|
private TextView repoDescription;
|
||||||
private TextView fullName;
|
private TextView fullName;
|
||||||
private ImageView repoPrivatePublic;
|
private CheckBox isRepoAdmin;
|
||||||
private TextView repoStars;
|
private ImageView repoPrivatePublic;
|
||||||
private TextView repoForks;
|
private TextView repoStars;
|
||||||
private TextView repoOpenIssuesCount;
|
private TextView repoForks;
|
||||||
private TextView repoType;
|
private TextView repoOpenIssuesCount;
|
||||||
|
private TextView repoType;
|
||||||
|
|
||||||
private ReposViewHolder(View itemView) {
|
private ReposViewHolder(View itemView) {
|
||||||
|
|
||||||
super(itemView);
|
super(itemView);
|
||||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
fullName = itemView.findViewById(R.id.repoFullName);
|
||||||
repoStars = itemView.findViewById(R.id.repoStars);
|
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||||
repoForks = itemView.findViewById(R.id.repoForks);
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
repoForks = itemView.findViewById(R.id.repoForks);
|
||||||
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||||
repoType = itemView.findViewById(R.id.repoType);
|
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||||
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
|
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
Context context = v.getContext();
|
Context context = v.getContext();
|
||||||
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
||||||
TextView repoType_ = v.findViewById(R.id.repoType);
|
TextView repoType_ = v.findViewById(R.id.repoType);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoDetailActivity.class);
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(context);
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType_.getText().toString());
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
|
|
||||||
//store if user is watching this repo
|
//store if user is watching this repo
|
||||||
{
|
{
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
String[] parts = repoFullName.getText().toString().split("/");
|
String[] parts = repoFullName.getText().toString().split("/");
|
||||||
final String repoOwner = parts[0];
|
final String repoOwner = parts[0];
|
||||||
final String repoName = parts[1];
|
final String repoName = parts[1];
|
||||||
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
WatchRepository watch = new WatchRepository();
|
WatchRepository watch = new WatchRepository();
|
||||||
|
|
||||||
Call<WatchRepository> call;
|
Call<WatchRepository> call;
|
||||||
|
|
||||||
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
call.enqueue(new Callback<WatchRepository>() {
|
call.enqueue(new Callback<WatchRepository>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) {
|
public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) {
|
||||||
|
|
||||||
if(response.isSuccessful()) {
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
tinyDb.putBoolean("repoWatch", false);
|
||||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
tinyDb.putBoolean("repoWatch", false);
|
tinyDb.putBoolean("repoWatch", false);
|
||||||
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reposDropdownMenu.setOnClickListener(v -> {
|
reposDropdownMenu.setOnClickListener(v -> {
|
||||||
|
|
||||||
final Context context = v.getContext();
|
final Context context = v.getContext();
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
|
||||||
|
|
||||||
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(fullName.getText());
|
bottomSheetHeader.setText(fullName.getText());
|
||||||
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||||
dialog.setContentView(view);
|
dialog.setContentView(view);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||||
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
||||||
context.startActivity(intentOpenInBrowser);
|
context.startActivity(intentOpenInBrowser);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(stargazers -> {
|
repoStargazers.setOnClickListener(stargazers -> {
|
||||||
|
|
||||||
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
||||||
intent.putExtra("repoFullNameForStars", fullName.getText());
|
intent.putExtra("repoFullNameForStars", fullName.getText());
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(watchers -> {
|
repoWatchers.setOnClickListener(watchers -> {
|
||||||
|
|
||||||
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||||
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
||||||
context.startActivity(intentW);
|
context.startActivity(intentW);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public ReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
}
|
||||||
this.mCtx = mCtx;
|
|
||||||
this.reposList = reposListMain;
|
|
||||||
reposListFull = new ArrayList<>(reposList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
public ReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
this.mCtx = mCtx;
|
||||||
public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) {
|
this.reposList = reposListMain;
|
||||||
|
reposListFull = new ArrayList<>(reposList);
|
||||||
|
}
|
||||||
|
|
||||||
UserRepositories currentItem = reposList.get(position);
|
@NonNull
|
||||||
holder.mTextView2.setVisibility(View.GONE);
|
@Override
|
||||||
|
public ReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repos, parent, false);
|
||||||
int color = generator.getColor(currentItem.getName());
|
return new ReposViewHolder(v);
|
||||||
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
}
|
||||||
|
|
||||||
TextDrawable drawable = TextDrawable.builder()
|
@Override
|
||||||
.beginConfig()
|
public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) {
|
||||||
.useFont(Typeface.DEFAULT)
|
|
||||||
.fontSize(18)
|
|
||||||
.toUpperCase()
|
|
||||||
.width(28)
|
|
||||||
.height(28)
|
|
||||||
.endConfig()
|
|
||||||
.buildRoundRect(firstCharacter, color, 3);
|
|
||||||
|
|
||||||
if (currentItem.getAvatar_url() != null) {
|
UserRepositories currentItem = reposList.get(position);
|
||||||
if (!currentItem.getAvatar_url().equals("")) {
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
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 {
|
|
||||||
holder.image.setImageDrawable(drawable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.image.setImageDrawable(drawable);
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.mTextView1.setText(currentItem.getName());
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
if (!currentItem.getDescription().equals("")) {
|
int color = generator.getColor(currentItem.getName());
|
||||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
||||||
holder.mTextView2.setText(currentItem.getDescription());
|
|
||||||
}
|
|
||||||
holder.fullName.setText(currentItem.getFullname());
|
|
||||||
if(currentItem.getPrivateFlag()) {
|
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
|
||||||
holder.repoType.setText(R.string.strPrivate);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
|
||||||
holder.repoType.setText(R.string.strPublic);
|
|
||||||
}
|
|
||||||
holder.repoStars.setText(currentItem.getStars_count());
|
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
|
||||||
|
|
||||||
}
|
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||||
|
|
||||||
@Override
|
if(currentItem.getAvatar_url() != null) {
|
||||||
public int getItemCount() {
|
if(!currentItem.getAvatar_url().equals("")) {
|
||||||
return reposList.size();
|
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 {
|
||||||
|
holder.image.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.image.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
holder.repoName.setText(currentItem.getName());
|
||||||
public Filter getFilter() {
|
if(!currentItem.getDescription().equals("")) {
|
||||||
return reposFilter;
|
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||||
}
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
|
}
|
||||||
|
holder.fullName.setText(currentItem.getFullname());
|
||||||
|
if(currentItem.getPrivateFlag()) {
|
||||||
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock_bold);
|
||||||
|
holder.repoType.setText(R.string.strPrivate);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
|
||||||
|
holder.repoType.setText(R.string.strPublic);
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
|
||||||
private Filter reposFilter = new Filter() {
|
}
|
||||||
@Override
|
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
|
||||||
List<UserRepositories> filteredList = new ArrayList<>();
|
|
||||||
|
|
||||||
if (constraint == null || constraint.length() == 0) {
|
@Override
|
||||||
filteredList.addAll(reposListFull);
|
public int getItemCount() {
|
||||||
} else {
|
|
||||||
String filterPattern = constraint.toString().toLowerCase().trim();
|
|
||||||
|
|
||||||
for (UserRepositories item : reposListFull) {
|
return reposList.size();
|
||||||
if (item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
}
|
||||||
filteredList.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FilterResults results = new FilterResults();
|
@Override
|
||||||
results.values = filteredList;
|
public Filter getFilter() {
|
||||||
|
|
||||||
return results;
|
return reposFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Filter reposFilter = new Filter() {
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
||||||
reposList.clear();
|
@Override
|
||||||
reposList.addAll((List) results.values);
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
List<UserRepositories> filteredList = new ArrayList<>();
|
||||||
};
|
|
||||||
|
if(constraint == null || constraint.length() == 0) {
|
||||||
|
filteredList.addAll(reposListFull);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String filterPattern = constraint.toString().toLowerCase().trim();
|
||||||
|
|
||||||
|
for(UserRepositories item : reposListFull) {
|
||||||
|
if(item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
||||||
|
filteredList.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FilterResults results = new FilterResults();
|
||||||
|
results.values = filteredList;
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -46,9 +47,10 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
static class OrgReposViewHolder extends RecyclerView.ViewHolder {
|
static class OrgReposViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private ImageView image;
|
||||||
private TextView mTextView1;
|
private TextView repoName;
|
||||||
private TextView mTextView2;
|
private TextView repoDescription;
|
||||||
private TextView fullName;
|
private TextView fullName;
|
||||||
|
private CheckBox isRepoAdmin;
|
||||||
private ImageView repoPrivatePublic;
|
private ImageView repoPrivatePublic;
|
||||||
private TextView repoStars;
|
private TextView repoStars;
|
||||||
private TextView repoForks;
|
private TextView repoForks;
|
||||||
@ -57,8 +59,9 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
private OrgReposViewHolder(View itemView) {
|
private OrgReposViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
fullName = itemView.findViewById(R.id.repoFullName);
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
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("repoFullName", fullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
|
|
||||||
//store if user is watching this repo
|
//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) {
|
public void onBindViewHolder(@NonNull RepositoriesByOrgAdapter.OrgReposViewHolder holder, int position) {
|
||||||
|
|
||||||
UserRepositories currentItem = reposList.get(position);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.mTextView2.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -220,10 +224,10 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.mTextView1.setText(currentItem.getName());
|
holder.repoName.setText(currentItem.getName());
|
||||||
if (!currentItem.getDescription().equals("")) {
|
if (!currentItem.getDescription().equals("")) {
|
||||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||||
holder.mTextView2.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.fullName.setText(currentItem.getFullname());
|
holder.fullName.setText(currentItem.getFullname());
|
||||||
if(currentItem.getPrivateFlag()) {
|
if(currentItem.getPrivateFlag()) {
|
||||||
@ -238,6 +242,11 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
holder.repoForks.setText(currentItem.getForks_count());
|
holder.repoForks.setText(currentItem.getForks_count());
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||||
|
|
||||||
|
if (holder.isRepoAdmin == null) {
|
||||||
|
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||||
|
}
|
||||||
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,6 +7,7 @@ import android.graphics.Typeface;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.Filter;
|
import android.widget.Filter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -46,9 +47,10 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
static class StarredReposViewHolder extends RecyclerView.ViewHolder {
|
static class StarredReposViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private ImageView image;
|
private ImageView image;
|
||||||
private TextView mTextView1;
|
private TextView repoName;
|
||||||
private TextView mTextView2;
|
private TextView repoDescription;
|
||||||
private TextView fullName;
|
private TextView fullName;
|
||||||
|
private CheckBox isRepoAdmin;
|
||||||
private ImageView repoPrivatePublic;
|
private ImageView repoPrivatePublic;
|
||||||
private TextView repoStars;
|
private TextView repoStars;
|
||||||
private TextView repoForks;
|
private TextView repoForks;
|
||||||
@ -57,8 +59,9 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
|
|
||||||
private StarredReposViewHolder(View itemView) {
|
private StarredReposViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
mTextView1 = itemView.findViewById(R.id.repoName);
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
mTextView2 = itemView.findViewById(R.id.repoDescription);
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
image = itemView.findViewById(R.id.imageAvatar);
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
fullName = itemView.findViewById(R.id.repoFullName);
|
fullName = itemView.findViewById(R.id.repoFullName);
|
||||||
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
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("repoFullName", fullName.getText().toString());
|
||||||
tinyDb.putString("repoType", repoType.getText().toString());
|
tinyDb.putString("repoType", repoType.getText().toString());
|
||||||
tinyDb.putBoolean("resumeIssues", true);
|
tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
|
|
||||||
//store if user is watching this repo
|
//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) {
|
public void onBindViewHolder(@NonNull StarredReposListAdapter.StarredReposViewHolder holder, int position) {
|
||||||
|
|
||||||
UserRepositories currentItem = reposList.get(position);
|
UserRepositories currentItem = reposList.get(position);
|
||||||
holder.mTextView2.setVisibility(View.GONE);
|
holder.repoDescription.setVisibility(View.GONE);
|
||||||
|
|
||||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
int color = generator.getColor(currentItem.getName());
|
int color = generator.getColor(currentItem.getName());
|
||||||
@ -221,10 +225,10 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
holder.image.setImageDrawable(drawable);
|
holder.image.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.mTextView1.setText(currentItem.getName());
|
holder.repoName.setText(currentItem.getName());
|
||||||
if (!currentItem.getDescription().equals("")) {
|
if (!currentItem.getDescription().equals("")) {
|
||||||
holder.mTextView2.setVisibility(View.VISIBLE);
|
holder.repoDescription.setVisibility(View.VISIBLE);
|
||||||
holder.mTextView2.setText(currentItem.getDescription());
|
holder.repoDescription.setText(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
holder.fullName.setText(currentItem.getFullname());
|
holder.fullName.setText(currentItem.getFullname());
|
||||||
if(currentItem.getPrivateFlag()) {
|
if(currentItem.getPrivateFlag()) {
|
||||||
@ -238,6 +242,10 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
holder.repoStars.setText(currentItem.getStars_count());
|
holder.repoStars.setText(currentItem.getStars_count());
|
||||||
holder.repoForks.setText(currentItem.getForks_count());
|
holder.repoForks.setText(currentItem.getForks_count());
|
||||||
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
||||||
|
if (holder.isRepoAdmin == null) {
|
||||||
|
holder.isRepoAdmin = new CheckBox(mCtx);
|
||||||
|
}
|
||||||
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,187 +30,194 @@ import retrofit2.Callback;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+ * Template Author M M Arif
|
* + * Template Author M M Arif
|
||||||
+ * Author 6543
|
* + * Author 6543
|
||||||
+ */
|
* +
|
||||||
|
*/
|
||||||
|
|
||||||
public class ExploreRepositoriesFragment extends Fragment {
|
public class ExploreRepositoriesFragment extends Fragment {
|
||||||
|
|
||||||
private static String repoNameF = "param2";
|
private static String repoNameF = "param2";
|
||||||
private static String repoOwnerF = "param1";
|
private static String repoOwnerF = "param1";
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private TextView noData;
|
private TextView noData;
|
||||||
private TextView searchKeyword;
|
private TextView searchKeyword;
|
||||||
private Boolean repoTypeInclude = true;
|
private Boolean repoTypeInclude = true;
|
||||||
private String sort = "updated";
|
private String sort = "updated";
|
||||||
private String order = "desc";
|
private String order = "desc";
|
||||||
private int limit = 50;
|
private int limit = 50;
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
private OnFragmentInteractionListener mListener;
|
||||||
|
|
||||||
public ExploreRepositoriesFragment() {
|
public ExploreRepositoriesFragment() {
|
||||||
}
|
|
||||||
|
|
||||||
public static ExploreRepositoriesFragment newInstance(String param1, String param2) {
|
}
|
||||||
ExploreRepositoriesFragment fragment = new ExploreRepositoriesFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(repoOwnerF, param1);
|
|
||||||
args.putString(repoNameF, param2);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public static ExploreRepositoriesFragment newInstance(String param1, String param2) {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if (getArguments() != null) {
|
|
||||||
String repoName = getArguments().getString(repoNameF);
|
|
||||||
String repoOwner = getArguments().getString(repoOwnerF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
ExploreRepositoriesFragment fragment = new ExploreRepositoriesFragment();
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
Bundle args = new Bundle();
|
||||||
Bundle savedInstanceState) {
|
args.putString(repoOwnerF, param1);
|
||||||
|
args.putString(repoNameF, param2);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
final View v = inflater.inflate(R.layout.fragment_explore_repo, container, false);
|
@Override
|
||||||
//setHasOptionsMenu(true);
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
TinyDB tinyDb = new TinyDB(getContext());
|
super.onCreate(savedInstanceState);
|
||||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
if(getArguments() != null) {
|
||||||
final String loginUid = tinyDb.getString("loginUid");
|
String repoName = getArguments().getString(repoNameF);
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
String repoOwner = getArguments().getString(repoOwnerF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
searchKeyword = v.findViewById(R.id.searchKeyword);
|
@Override
|
||||||
noData = v.findViewById(R.id.noData);
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
|
||||||
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
|
||||||
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
final View v = inflater.inflate(R.layout.fragment_explore_repo, container, false);
|
||||||
|
//setHasOptionsMenu(true);
|
||||||
|
|
||||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
TinyDB tinyDb = new TinyDB(getContext());
|
||||||
@Override
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
if(!searchKeyword.getText().toString().equals("")) {
|
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
|
||||||
mRecyclerView.setVisibility(View.GONE);
|
|
||||||
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
int limitDefault = 10;
|
searchKeyword = v.findViewById(R.id.searchKeyword);
|
||||||
loadDefaultList(instanceUrl, instanceToken, loginUid, repoTypeInclude, sort, order, getContext(), limitDefault);
|
noData = v.findViewById(R.id.noData);
|
||||||
|
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||||
|
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
||||||
|
|
||||||
return v;
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
|
|
||||||
private void loadDefaultList(String instanceUrl, String instanceToken, String loginUid, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
@Override
|
||||||
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
|
||||||
Call<ExploreRepositories> call = RetrofitClient
|
if(actionId == EditorInfo.IME_ACTION_SEND) {
|
||||||
.getInstance(instanceUrl, getContext())
|
if(!searchKeyword.getText().toString().equals("")) {
|
||||||
.getApiInterface()
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), null, repoTypeInclude, sort, order, limit);
|
mRecyclerView.setVisibility(View.GONE);
|
||||||
|
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
call.enqueue(new Callback<ExploreRepositories>() {
|
int limitDefault = 10;
|
||||||
|
loadDefaultList(instanceUrl, instanceToken, loginUid, repoTypeInclude, sort, order, getContext(), limitDefault);
|
||||||
|
|
||||||
@Override
|
return v;
|
||||||
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()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
private void loadDefaultList(String instanceUrl, String instanceToken, String loginUid, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||||
|
|
||||||
@Override
|
Call<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), null, repoTypeInclude, sort, order, limit);
|
||||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
|
||||||
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
call.enqueue(new Callback<ExploreRepositories>() {
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||||
|
|
||||||
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
if(response.isSuccessful()) {
|
||||||
|
assert response.body() != null;
|
||||||
|
getReposList(response.body().getSearchedData(), context);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.i("onResponse", String.valueOf(response.code()));
|
||||||
|
}
|
||||||
|
|
||||||
Call<ExploreRepositories> call = RetrofitClient
|
}
|
||||||
.getInstance(instanceUrl, getContext())
|
|
||||||
.getApiInterface()
|
|
||||||
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<ExploreRepositories>() {
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
@Override
|
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||||
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
|
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||||
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
|
||||||
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
Call<ExploreRepositories> call = RetrofitClient.getInstance(instanceUrl, getContext()).getApiInterface().queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
||||||
|
|
||||||
}
|
call.enqueue(new Callback<ExploreRepositories>() {
|
||||||
|
|
||||||
private void getReposList(List<UserRepositories> dataList, Context context) {
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<ExploreRepositories> call, @NonNull Response<ExploreRepositories> response) {
|
||||||
|
|
||||||
ExploreRepositoriesAdapter adapter = new ExploreRepositoriesAdapter(dataList, context);
|
if(response.isSuccessful()) {
|
||||||
|
assert response.body() != null;
|
||||||
|
getReposList(response.body().getSearchedData(), context);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.i("onResponse", String.valueOf(response.code()));
|
||||||
|
}
|
||||||
|
|
||||||
mRecyclerView.setVisibility(View.VISIBLE);
|
}
|
||||||
|
|
||||||
mRecyclerView.setHasFixedSize(true);
|
@Override
|
||||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
public void onFailure(@NonNull Call<ExploreRepositories> call, @NonNull Throwable t) {
|
||||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
|
|
||||||
DividerItemDecoration.VERTICAL);
|
|
||||||
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
|
||||||
|
|
||||||
if(adapter.getItemCount() > 0) {
|
Log.i("onFailure", Objects.requireNonNull(t.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
mRecyclerView.setAdapter(adapter);
|
});
|
||||||
noData.setVisibility(View.GONE);
|
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
|
||||||
noData.setVisibility(View.VISIBLE);
|
private void getReposList(List<UserRepositories> dataList, Context context) {
|
||||||
mProgressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
}
|
ExploreRepositoriesAdapter adapter = new ExploreRepositoriesAdapter(dataList, context);
|
||||||
|
|
||||||
}
|
mRecyclerView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
public void onButtonPressed(Uri uri) {
|
mRecyclerView.setHasFixedSize(true);
|
||||||
if (mListener != null) {
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
mListener.onFragmentInteraction(uri);
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||||
}
|
mRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if(adapter.getItemCount() > 0) {
|
||||||
public void onDetach() {
|
|
||||||
super.onDetach();
|
mRecyclerView.setAdapter(adapter);
|
||||||
mListener = null;
|
noData.setVisibility(View.GONE);
|
||||||
}
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
noData.setVisibility(View.VISIBLE);
|
||||||
|
mProgressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onButtonPressed(Uri uri) {
|
||||||
|
|
||||||
|
if(mListener != null) {
|
||||||
|
mListener.onFragmentInteraction(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
|
||||||
|
super.onDetach();
|
||||||
|
mListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnFragmentInteractionListener {
|
||||||
|
|
||||||
|
void onFragmentInteraction(Uri uri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnFragmentInteractionListener {
|
|
||||||
void onFragmentInteraction(Uri uri);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ public class MyRepositoriesFragment extends Fragment {
|
|||||||
final String loginUid = tinyDb.getString("loginUid");
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
final String userLogin = tinyDb.getString("userLogin");
|
final String userLogin = tinyDb.getString("userLogin");
|
||||||
|
tinyDb.putBoolean("isRepoAdmin", true);
|
||||||
|
|
||||||
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
final SwipeRefreshLayout swipeRefresh = v.findViewById(R.id.pullToRefresh);
|
||||||
|
|
||||||
|
@ -9,110 +9,162 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class UserRepositories {
|
public class UserRepositories {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private String full_name;
|
private String full_name;
|
||||||
private String description;
|
private String description;
|
||||||
@SerializedName("private")
|
@SerializedName("private")
|
||||||
private boolean privateFlag;
|
private boolean privateFlag;
|
||||||
private String stars_count;
|
private String stars_count;
|
||||||
private String watchers_count;
|
private String watchers_count;
|
||||||
private String open_issues_count;
|
private String open_issues_count;
|
||||||
private String open_pr_counter;
|
private String open_pr_counter;
|
||||||
private String release_counter;
|
private String release_counter;
|
||||||
private String html_url;
|
private String html_url;
|
||||||
private String default_branch;
|
private String default_branch;
|
||||||
private Date created_at;
|
private Date created_at;
|
||||||
private Date updated_at;
|
private Date updated_at;
|
||||||
private String clone_url;
|
private String clone_url;
|
||||||
private long size;
|
private long size;
|
||||||
private String ssh_url;
|
private String ssh_url;
|
||||||
private String website;
|
private String website;
|
||||||
private String forks_count;
|
private String forks_count;
|
||||||
private Boolean has_issues;
|
private Boolean has_issues;
|
||||||
private String avatar_url;
|
private String avatar_url;
|
||||||
|
|
||||||
public int getId() {
|
private permissionsObject permissions;
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public class permissionsObject {
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFullname() {
|
private boolean admin;
|
||||||
return full_name;
|
private boolean push;
|
||||||
}
|
private boolean pull;
|
||||||
|
|
||||||
public String getDescription() {
|
public boolean isAdmin() {
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getPrivateFlag() {
|
return admin;
|
||||||
return privateFlag;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getStars_count() {
|
public boolean canPush() {
|
||||||
return stars_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOpen_pull_count() {
|
return push;
|
||||||
return open_pr_counter;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getRelease_count() {
|
public boolean canPull() {
|
||||||
return release_counter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWatchers_count() {
|
return pull;
|
||||||
return watchers_count;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getOpen_issues_count() {
|
}
|
||||||
return open_issues_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHtml_url() {
|
public int getId() {
|
||||||
return html_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefault_branch() {
|
return id;
|
||||||
return default_branch;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated_at() {
|
public String getName() {
|
||||||
return created_at;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getUpdated_at() {
|
return name;
|
||||||
return updated_at;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getClone_url() {
|
public String getFullname() {
|
||||||
return clone_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSize() {
|
return full_name;
|
||||||
return size;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getSsh_url() {
|
public String getDescription() {
|
||||||
return ssh_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebsite() {
|
return description;
|
||||||
return website;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getForks_count() {
|
public permissionsObject getPermissions() {
|
||||||
return forks_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getHas_issues() {
|
return permissions;
|
||||||
return has_issues;
|
}
|
||||||
}
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAvatar_url() {
|
|
||||||
return avatar_url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,14 @@
|
|||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:visibility="gone" />
|
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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user