Fix repo desc in recyclerview (#896)

fixes and clean up

Use Authorization.get()

minor  fixes

Fix repo desc in recyclerview

Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: opyale <opyale@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/896
Reviewed-by: opyale <opyale@noreply.codeberg.org>
Co-Authored-By: M M Arif <mmarif@noreply.codeberg.org>
Co-Committed-By: M M Arif <mmarif@noreply.codeberg.org>
This commit is contained in:
M M Arif 2021-04-15 17:05:56 +02:00
parent d72f097012
commit 23b8301fbf
14 changed files with 38 additions and 20 deletions

View File

@ -231,7 +231,6 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
drawer.addDrawerListener(toggle);
drawer.addDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerOpened(@NonNull View drawerView) {

View File

@ -71,9 +71,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
private String loginUid;
private String instanceToken;
private String repositoryOwner;
private String repositoryName;
@ -108,9 +105,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
Objects.requireNonNull(getSupportActionBar()).setTitle(repositoryName);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
loginUid = tinyDB.getString("loginUid");
instanceToken = "token " + tinyDB.getString(loginUid + "-token");
tinyDB.putString("repoIssuesState", "open");
tinyDB.putString("repoPrState", "open");
tinyDB.putString("milestoneState", "open");
@ -433,7 +427,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
Call<List<Branches>> call = RetrofitClient
.getApiInterface(ctx)
.getBranches(instanceToken, repositoryOwner, repositoryName);
.getBranches(Authorization.get(ctx), repositoryOwner, repositoryName);
call.enqueue(new Callback<List<Branches>>() {

View File

@ -45,7 +45,7 @@ public class RepoForksActivity extends BaseActivity {
private View.OnClickListener onClickListener;
private TextView noData;
private ProgressBar progressBar;
private String TAG = "RepositoryForks";
private final String TAG = "RepositoryForks";
private int resultLimit = Constants.resultLimitOldGiteaInstances;
private int pageSize = 1;

View File

@ -37,7 +37,6 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
this.context = ctx;
this.commitsList = commitsListMain;
}
@NonNull
@ -67,7 +66,6 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
((CommitsHolder) holder).bindData(commitsList.get(position));
}
}
@Override

View File

@ -59,6 +59,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
deleteDraft(getAdapterPosition());
DraftsApi draftsApi = BaseApi.getInstance(context, DraftsApi.class);
assert draftsApi != null;
draftsApi.deleteSingleDraft(getDraftId);
});

View File

@ -102,6 +102,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
assert repositoryData != null;
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {
@ -191,7 +192,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName());
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
String firstCharacter = String.valueOf(currentItem.getFullName().charAt(0));
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
@ -238,6 +239,9 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setText(currentItem.getDescription());
}
else {
holder.repoDescription.setText(context.getString(R.string.noDataDescription));
}
if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(context);

View File

@ -310,7 +310,6 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issue_comments, parent, false);
return new IssueCommentsAdapter.IssueCommentViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull IssueCommentsAdapter.IssueCommentViewHolder holder, int position) {

View File

@ -100,6 +100,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
assert repositoryData != null;
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {
@ -198,7 +199,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName());
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
String firstCharacter = String.valueOf(currentItem.getFullName().charAt(0));
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
@ -245,6 +246,9 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setText(currentItem.getDescription());
}
else {
holder.repoDescription.setText(context.getString(R.string.noDataDescription));
}
if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(context);

View File

@ -142,7 +142,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(forksModel.getName());
String firstCharacter = String.valueOf(forksModel.getName().charAt(0));
String firstCharacter = String.valueOf(forksModel.getFullName().charAt(0));
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
.endConfig().buildRoundRect(firstCharacter, color, 3);
@ -191,6 +191,9 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
if(!forksModel.getDescription().equals("")) {
repoDescription.setText(forksModel.getDescription());
}
else {
repoDescription.setText(context.getString(R.string.noDataDescription));
}
if(isRepoAdmin == null) {
isRepoAdmin = new CheckBox(context);
@ -224,6 +227,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
assert repositoryData != null;
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {

View File

@ -100,6 +100,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
assert repositoryData != null;
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {
@ -197,7 +198,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName());
String firstCharacter = String.valueOf(currentItem.getFullName().split("/")[0].charAt(0));
String firstCharacter = String.valueOf(currentItem.getFullName().charAt(0));
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
@ -244,6 +245,9 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setText(currentItem.getDescription());
}
else {
holder.repoDescription.setText(context.getString(R.string.noDataDescription));
}
if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(context);

View File

@ -100,7 +100,8 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
assert repositoryData != null;
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {
@ -194,7 +195,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName());
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
String firstCharacter = String.valueOf(currentItem.getFullName().charAt(0));
TextDrawable drawable = TextDrawable.builder()
.beginConfig()
@ -248,6 +249,9 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setText(currentItem.getDescription());
}
else {
holder.repoDescription.setText(context.getString(R.string.noDataDescription));
}
if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(context);

View File

@ -83,6 +83,7 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
assert repositoryData != null;
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {

View File

@ -100,7 +100,8 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
assert repositoryData != null;
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
if(count == 0) {
@ -195,7 +196,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(currentItem.getName());
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
String firstCharacter = String.valueOf(currentItem.getFullName().charAt(0));
TextDrawable drawable = TextDrawable.builder()
.beginConfig()
@ -249,6 +250,9 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
if(!currentItem.getDescription().equals("")) {
holder.repoDescription.setText(currentItem.getDescription());
}
else {
holder.repoDescription.setText(context.getString(R.string.noDataDescription));
}
if(holder.isRepoAdmin == null) {
holder.isRepoAdmin = new CheckBox(context);

View File

@ -65,6 +65,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
updateLayoutByPosition(getAdapterPosition());
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
assert userAccountsApi != null;
userAccountsApi.deleteAccount(Integer.parseInt(String.valueOf(accountId)));
}).setNeutralButton(context.getResources().getString(R.string.cancelButton), null)
.show();
@ -73,6 +74,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
itemView.setOnClickListener(switchAccount -> {
UserAccountsApi userAccountsApi = BaseApi.getInstance(context, UserAccountsApi.class);
assert userAccountsApi != null;
UserAccount userAccount = userAccountsApi.getAccountByName(accountName);
if(AppUtil.switchToAccount(context, userAccount)) {