2019-10-10 15:40:43 +02:00
|
|
|
package org.mian.gitnex.adapters;
|
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2019-10-10 15:40:43 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2020-04-14 21:25:36 +02:00
|
|
|
import android.widget.CheckBox;
|
2019-10-10 15:40:43 +02:00
|
|
|
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;
|
2021-02-11 11:23:35 +01:00
|
|
|
import org.gitnex.tea4j.models.UserRepositories;
|
|
|
|
import org.gitnex.tea4j.models.WatchInfo;
|
2019-10-10 15:40:43 +02:00
|
|
|
import org.mian.gitnex.R;
|
2019-10-10 17:49:12 +02:00
|
|
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
2020-04-01 13:26:32 +02:00
|
|
|
import org.mian.gitnex.clients.PicassoService;
|
2020-04-05 11:54:34 +02:00
|
|
|
import org.mian.gitnex.clients.RetrofitClient;
|
2021-04-13 20:56:50 +02:00
|
|
|
import org.mian.gitnex.database.api.BaseApi;
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
2020-07-07 19:15:01 +02:00
|
|
|
import org.mian.gitnex.database.models.Repository;
|
2021-04-13 16:19:42 +02:00
|
|
|
import org.mian.gitnex.helpers.AppUtil;
|
|
|
|
import org.mian.gitnex.helpers.ClickListener;
|
2019-10-10 15:40:43 +02:00
|
|
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
2021-04-13 16:19:42 +02:00
|
|
|
import org.mian.gitnex.helpers.TimeHelper;
|
2020-07-07 19:15:01 +02:00
|
|
|
import org.mian.gitnex.helpers.TinyDB;
|
2020-04-05 11:54:34 +02:00
|
|
|
import org.mian.gitnex.helpers.Toasty;
|
2021-04-13 16:19:42 +02:00
|
|
|
import org.ocpsoft.prettytime.PrettyTime;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
2019-10-10 15:40:43 +02:00
|
|
|
import java.util.List;
|
2021-04-13 16:19:42 +02:00
|
|
|
import java.util.Locale;
|
2020-04-05 11:54:34 +02:00
|
|
|
import retrofit2.Call;
|
|
|
|
import retrofit2.Callback;
|
2019-10-10 15:40:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Author M M Arif
|
|
|
|
*/
|
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
private final Context context;
|
2021-09-29 11:29:39 +02:00
|
|
|
private final int TYPE_LOAD = 0;
|
|
|
|
private List<UserRepositories> reposList;
|
2022-02-25 23:35:51 +01:00
|
|
|
private Runnable loadMoreListener;
|
2021-09-29 11:29:39 +02:00
|
|
|
private boolean isLoading = false, isMoreDataAvailable = true;
|
|
|
|
private final TinyDB tinyDb;
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
public ExploreRepositoriesAdapter(List<UserRepositories> dataList, Context ctx) {
|
|
|
|
this.context = ctx;
|
|
|
|
this.reposList = dataList;
|
2021-09-29 11:29:39 +02:00
|
|
|
this.tinyDb = TinyDB.getInstance(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(context);
|
|
|
|
if(viewType == TYPE_LOAD) {
|
|
|
|
return new ExploreRepositoriesAdapter.RepositoriesHolder(inflater.inflate(R.layout.list_repositories, parent, false));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return new ExploreRepositoriesAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
|
|
|
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
|
|
|
|
isLoading = true;
|
2022-02-25 23:35:51 +01:00
|
|
|
loadMoreListener.run();
|
2021-09-29 11:29:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(getItemViewType(position) == TYPE_LOAD) {
|
|
|
|
((ExploreRepositoriesAdapter.RepositoriesHolder) holder).bindData(reposList.get(position));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemViewType(int position) {
|
|
|
|
if(reposList.get(position).getFullName() != null) {
|
|
|
|
return TYPE_LOAD;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 1;
|
|
|
|
}
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
return reposList.size();
|
|
|
|
}
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
class RepositoriesHolder extends RecyclerView.ViewHolder {
|
2021-04-13 16:19:42 +02:00
|
|
|
private UserRepositories userRepositories;
|
|
|
|
|
|
|
|
private final ImageView image;
|
|
|
|
private final TextView repoName;
|
|
|
|
private final TextView orgName;
|
|
|
|
private final TextView repoDescription;
|
2020-04-14 21:25:36 +02:00
|
|
|
private CheckBox isRepoAdmin;
|
2021-04-13 16:19:42 +02:00
|
|
|
private final TextView repoStars;
|
|
|
|
private final TextView repoLastUpdated;
|
2021-10-05 17:16:22 +02:00
|
|
|
private final View spacerView;
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
RepositoriesHolder(View itemView) {
|
2020-04-14 21:25:36 +02:00
|
|
|
super(itemView);
|
|
|
|
repoName = itemView.findViewById(R.id.repoName);
|
2021-04-13 16:19:42 +02:00
|
|
|
orgName = itemView.findViewById(R.id.orgName);
|
2020-04-14 21:25:36 +02:00
|
|
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
|
|
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
2021-04-13 16:19:42 +02:00
|
|
|
image = itemView.findViewById(R.id.imageAvatar);
|
2020-04-14 21:25:36 +02:00
|
|
|
repoStars = itemView.findViewById(R.id.repoStars);
|
2021-04-13 16:19:42 +02:00
|
|
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
2021-10-05 17:16:22 +02:00
|
|
|
spacerView = itemView.findViewById(R.id.spacerView);
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
itemView.setOnClickListener(v -> {
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
Context context = v.getContext();
|
|
|
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
2021-04-13 16:19:42 +02:00
|
|
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("resumeIssues", true);
|
|
|
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
2021-04-13 16:19:42 +02:00
|
|
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
if(userRepositories.getPrivateFlag()) {
|
|
|
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] parts = userRepositories.getFullName().split("/");
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
final String repoOwner = parts[0];
|
|
|
|
final String repoName = parts[1];
|
|
|
|
|
|
|
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
2021-04-13 20:56:50 +02:00
|
|
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
|
|
|
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
2021-04-15 17:05:56 +02:00
|
|
|
assert repositoryData != null;
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
|
|
|
|
|
|
|
if(count == 0) {
|
|
|
|
|
|
|
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
|
|
|
tinyDb.putLong("repositoryId", id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
|
|
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
|
|
|
}
|
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
//store if user is watching this repo
|
|
|
|
{
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
WatchInfo watch = new WatchInfo();
|
|
|
|
Call<WatchInfo> call;
|
2020-11-02 16:17:00 +01:00
|
|
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
call.enqueue(new Callback<WatchInfo>() {
|
2020-04-14 21:25:36 +02:00
|
|
|
@Override
|
2020-05-21 20:58:00 +02:00
|
|
|
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
if(response.isSuccessful()) {
|
2020-04-15 00:41:40 +02:00
|
|
|
assert response.body() != null;
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
2021-05-30 19:28:14 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("repoWatch", false);
|
2020-04-15 00:41:40 +02:00
|
|
|
if(response.code() != 404) {
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
2020-04-15 00:41:40 +02:00
|
|
|
}
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
@Override
|
2020-05-21 20:58:00 +02:00
|
|
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("repoWatch", false);
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
context.startActivity(intent);
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
});
|
|
|
|
}
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
|
void bindData(UserRepositories userRepositories) {
|
|
|
|
this.userRepositories = userRepositories;
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
|
|
|
Locale locale = context.getResources().getConfiguration().locale;
|
|
|
|
String timeFormat = tinyDb.getString("dateFormat");
|
2021-04-13 16:19:42 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
orgName.setText(userRepositories.getFullName().split("/")[0]);
|
|
|
|
repoName.setText(userRepositories.getFullName().split("/")[1]);
|
|
|
|
repoStars.setText(userRepositories.getStars_count());
|
2020-04-14 21:25:36 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
|
|
|
int color = generator.getColor(userRepositories.getName());
|
|
|
|
String firstCharacter = String.valueOf(userRepositories.getFullName().charAt(0));
|
2020-04-14 21:25:36 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
2020-04-14 21:25:36 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
if(userRepositories.getAvatar_url() != null) {
|
|
|
|
if(!userRepositories.getAvatar_url().equals("")) {
|
|
|
|
PicassoService.getInstance(context).get().load(userRepositories.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(image);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
image.setImageDrawable(drawable);
|
|
|
|
}
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
|
|
|
else {
|
2021-09-29 11:29:39 +02:00
|
|
|
image.setImageDrawable(drawable);
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2021-04-13 16:19:42 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
if(userRepositories.getUpdated_at() != null) {
|
|
|
|
|
|
|
|
switch(timeFormat) {
|
|
|
|
case "pretty": {
|
|
|
|
PrettyTime prettyTime = new PrettyTime(locale);
|
|
|
|
String createdTime = prettyTime.format(userRepositories.getUpdated_at());
|
|
|
|
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
|
|
|
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(userRepositories.getUpdated_at()), context));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "normal": {
|
|
|
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
|
|
|
String createdTime = formatter.format(userRepositories.getUpdated_at());
|
|
|
|
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "normal1": {
|
|
|
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
|
|
|
|
String createdTime = formatter.format(userRepositories.getUpdated_at());
|
|
|
|
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
|
|
|
break;
|
|
|
|
}
|
2021-04-13 16:19:42 +02:00
|
|
|
}
|
|
|
|
}
|
2021-09-29 11:29:39 +02:00
|
|
|
else {
|
|
|
|
repoLastUpdated.setVisibility(View.GONE);
|
|
|
|
}
|
2020-04-14 21:25:36 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
if(!userRepositories.getDescription().equals("")) {
|
2021-10-05 17:16:22 +02:00
|
|
|
repoDescription.setVisibility(View.VISIBLE);
|
2021-09-29 11:29:39 +02:00
|
|
|
repoDescription.setText(userRepositories.getDescription());
|
2021-10-05 17:16:22 +02:00
|
|
|
spacerView.setVisibility(View.GONE);
|
2021-09-29 11:29:39 +02:00
|
|
|
}
|
|
|
|
else {
|
2021-10-05 17:16:22 +02:00
|
|
|
repoDescription.setVisibility(View.GONE);
|
|
|
|
spacerView.setVisibility(View.VISIBLE);
|
2021-09-29 11:29:39 +02:00
|
|
|
}
|
2020-06-06 21:41:19 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
if(isRepoAdmin == null) {
|
|
|
|
isRepoAdmin = new CheckBox(context);
|
|
|
|
}
|
|
|
|
isRepoAdmin.setChecked(userRepositories.getPermissions().isAdmin());
|
2021-04-13 16:19:42 +02:00
|
|
|
}
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
static class LoadHolder extends RecyclerView.ViewHolder {
|
|
|
|
LoadHolder(View itemView) {
|
|
|
|
super(itemView);
|
|
|
|
}
|
|
|
|
}
|
2020-04-14 21:25:36 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
|
|
|
isMoreDataAvailable = moreDataAvailable;
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2019-10-10 15:40:43 +02:00
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
2020-09-30 16:53:31 +02:00
|
|
|
public void notifyDataChanged() {
|
|
|
|
notifyDataSetChanged();
|
2021-09-29 11:29:39 +02:00
|
|
|
isLoading = false;
|
|
|
|
}
|
|
|
|
|
2022-02-25 23:35:51 +01:00
|
|
|
public void setLoadMoreListener(Runnable loadMoreListener) {
|
2021-09-29 11:29:39 +02:00
|
|
|
this.loadMoreListener = loadMoreListener;
|
2020-09-30 16:53:31 +02:00
|
|
|
}
|
|
|
|
|
2021-09-29 11:29:39 +02:00
|
|
|
public void updateList(List<UserRepositories> list) {
|
|
|
|
reposList = list;
|
|
|
|
notifyDataChanged();
|
|
|
|
}
|
2019-10-10 15:40:43 +02:00
|
|
|
}
|