Repository forks (#606)
Repository forks Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/606 Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
parent
f1ecc42876
commit
ea36a3f6d6
@ -84,6 +84,7 @@
|
|||||||
<activity android:name=".activities.SettingsReportsActivity" />
|
<activity android:name=".activities.SettingsReportsActivity" />
|
||||||
<activity android:name=".activities.AddNewTeamMemberActivity" />
|
<activity android:name=".activities.AddNewTeamMemberActivity" />
|
||||||
<activity android:name=".activities.SettingsDraftsActivity" />
|
<activity android:name=".activities.SettingsDraftsActivity" />
|
||||||
|
<activity android:name=".activities.RepoForksActivity" />
|
||||||
|
|
||||||
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
<!-- Version < 3.0. DeX Mode and Screen Mirroring support -->
|
||||||
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
<meta-data android:name="com.samsung.android.keepalive.density" android:value="true"/>
|
||||||
|
@ -0,0 +1,295 @@
|
|||||||
|
package org.mian.gitnex.activities;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.text.method.ScrollingMovementMethod;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.adapters.RepoForksAdapter;
|
||||||
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
|
import org.mian.gitnex.helpers.StaticGlobalVariables;
|
||||||
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
|
import org.mian.gitnex.helpers.Version;
|
||||||
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RepoForksActivity extends BaseActivity {
|
||||||
|
|
||||||
|
final Context ctx = this;
|
||||||
|
private Context appCtx;
|
||||||
|
private View.OnClickListener onClickListener;
|
||||||
|
private TextView noData;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private String TAG = "RepositoryForks";
|
||||||
|
private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
|
||||||
|
private int pageSize = 1;
|
||||||
|
|
||||||
|
private RecyclerView recyclerView;
|
||||||
|
private List<UserRepositories> forksList;
|
||||||
|
private RepoForksAdapter adapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutResourceId() {
|
||||||
|
|
||||||
|
return R.layout.activity_forks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("DefaultLocale")
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
appCtx = getApplicationContext();
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(appCtx);
|
||||||
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
|
final String loginUid = tinyDb.getString("loginUid");
|
||||||
|
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||||
|
|
||||||
|
String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
|
||||||
|
assert repoFullNameForForks != null;
|
||||||
|
String[] parts = repoFullNameForForks.split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
|
||||||
|
TextView toolbar_title = findViewById(R.id.toolbar_title);
|
||||||
|
toolbar_title.setMovementMethod(new ScrollingMovementMethod());
|
||||||
|
toolbar_title.setText(String.format("%s : %s", ctx.getResources().getString(R.string.infoTabRepoForksCount), repoName));
|
||||||
|
|
||||||
|
ImageView closeActivity = findViewById(R.id.close);
|
||||||
|
noData = findViewById(R.id.noData);
|
||||||
|
progressBar = findViewById(R.id.progress_bar);
|
||||||
|
SwipeRefreshLayout swipeRefresh = findViewById(R.id.pullToRefresh);
|
||||||
|
|
||||||
|
initCloseListener();
|
||||||
|
closeActivity.setOnClickListener(onClickListener);
|
||||||
|
|
||||||
|
// if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
|
||||||
|
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
|
||||||
|
resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
recyclerView = findViewById(R.id.recyclerView);
|
||||||
|
forksList = new ArrayList<>();
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
|
||||||
|
DividerItemDecoration.VERTICAL);
|
||||||
|
recyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||||
|
|
||||||
|
swipeRefresh.setRefreshing(false);
|
||||||
|
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
|
||||||
|
}, 200));
|
||||||
|
|
||||||
|
adapter = new RepoForksAdapter(ctx, forksList);
|
||||||
|
adapter.setLoadMoreListener(() -> recyclerView.post(() -> {
|
||||||
|
|
||||||
|
if(forksList.size() == resultLimit || pageSize == resultLimit) {
|
||||||
|
|
||||||
|
int page = (forksList.size() + resultLimit) / resultLimit;
|
||||||
|
loadMore(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, resultLimit);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
recyclerView.setHasFixedSize(true);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadInitial(String instanceUrl, String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
|
||||||
|
|
||||||
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, ctx)
|
||||||
|
.getApiInterface()
|
||||||
|
.getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||||
|
|
||||||
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
|
assert response.body() != null;
|
||||||
|
if(response.body().size() > 0) {
|
||||||
|
|
||||||
|
forksList.clear();
|
||||||
|
forksList.addAll(response.body());
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
noData.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
forksList.clear();
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
noData.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
Log.e(TAG, t.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadMore(String instanceUrl, String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
|
||||||
|
|
||||||
|
//add loading progress view
|
||||||
|
forksList.add(new UserRepositories("load"));
|
||||||
|
adapter.notifyItemInserted((forksList.size() - 1));
|
||||||
|
|
||||||
|
Call<List<UserRepositories>> call = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, ctx)
|
||||||
|
.getApiInterface()
|
||||||
|
.getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<List<UserRepositories>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<List<UserRepositories>> call, @NonNull Response<List<UserRepositories>> response) {
|
||||||
|
|
||||||
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
|
//remove loading view
|
||||||
|
forksList.remove(forksList.size() - 1);
|
||||||
|
|
||||||
|
List<UserRepositories> result = response.body();
|
||||||
|
|
||||||
|
assert result != null;
|
||||||
|
if(result.size() > 0) {
|
||||||
|
|
||||||
|
pageSize = result.size();
|
||||||
|
forksList.addAll(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
adapter.setMoreDataAvailable(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter.notifyDataChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Log.e(TAG, String.valueOf(response.code()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<List<UserRepositories>> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
Log.e(TAG, t.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.search_menu, menu);
|
||||||
|
|
||||||
|
MenuItem searchItem = menu.findItem(R.id.action_search);
|
||||||
|
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||||
|
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
|
|
||||||
|
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextSubmit(String query) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onQueryTextChange(String newText) {
|
||||||
|
|
||||||
|
filter(newText);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void filter(String text) {
|
||||||
|
|
||||||
|
List<UserRepositories> arr = new ArrayList<>();
|
||||||
|
|
||||||
|
for(UserRepositories d : forksList) {
|
||||||
|
if(d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
|
||||||
|
arr.add(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter.updateList(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCloseListener() {
|
||||||
|
|
||||||
|
onClickListener = view -> {
|
||||||
|
getIntent().removeExtra("repoFullNameForForks");
|
||||||
|
finish();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,6 +21,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
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.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -180,6 +181,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
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 repoForksList = view.findViewById(R.id.repoForksList);
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||||
@ -214,6 +216,15 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
repoForksList.setOnClickListener(forks -> {
|
||||||
|
|
||||||
|
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
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.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -177,6 +178,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
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 repoForksList = view.findViewById(R.id.repoForksList);
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
|
bottomSheetHeader.setText(String.format("%s / %s", repoFullName.getText().toString().split("/")[0], repoFullName.getText().toString().split("/")[1]));
|
||||||
@ -211,6 +213,15 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
repoForksList.setOnClickListener(forks -> {
|
||||||
|
|
||||||
|
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForForks", repoFullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
396
app/src/main/java/org/mian/gitnex/adapters/RepoForksAdapter.java
Normal file
396
app/src/main/java/org/mian/gitnex/adapters/RepoForksAdapter.java
Normal file
@ -0,0 +1,396 @@
|
|||||||
|
package org.mian.gitnex.adapters;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||||
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
|
import org.mian.gitnex.database.models.Repository;
|
||||||
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
|
import org.mian.gitnex.models.WatchInfo;
|
||||||
|
import java.util.List;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Author M M Arif
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
|
private Context ctx;
|
||||||
|
private final int TYPE_LOAD = 0;
|
||||||
|
private List<UserRepositories> forksList;
|
||||||
|
private OnLoadMoreListener loadMoreListener;
|
||||||
|
private boolean isLoading = false;
|
||||||
|
private boolean isMoreDataAvailable = true;
|
||||||
|
|
||||||
|
public RepoForksAdapter(Context ctx, List<UserRepositories> forksListMain) {
|
||||||
|
|
||||||
|
this.ctx = ctx;
|
||||||
|
this.forksList = forksListMain;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(ctx);
|
||||||
|
|
||||||
|
if(viewType == TYPE_LOAD) {
|
||||||
|
return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new 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;
|
||||||
|
loadMoreListener.onLoadMore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getItemViewType(position) == TYPE_LOAD) {
|
||||||
|
|
||||||
|
((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
|
||||||
|
if(forksList.get(position).getName() != null) {
|
||||||
|
return TYPE_LOAD;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
|
||||||
|
return forksList.size();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ForksHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
private ImageView image;
|
||||||
|
private TextView repoName;
|
||||||
|
private TextView repoDescription;
|
||||||
|
private TextView fullName;
|
||||||
|
private CheckBox isRepoAdmin;
|
||||||
|
private ImageView repoPrivatePublic;
|
||||||
|
private TextView repoStars;
|
||||||
|
private TextView repoForks;
|
||||||
|
private TextView repoOpenIssuesCount;
|
||||||
|
private TextView repoType;
|
||||||
|
private LinearLayout archiveRepo;
|
||||||
|
private TextView repoBranch;
|
||||||
|
private ImageView reposDropdownMenu;
|
||||||
|
|
||||||
|
ForksHolder(View itemView) {
|
||||||
|
|
||||||
|
super(itemView);
|
||||||
|
|
||||||
|
repoName = itemView.findViewById(R.id.repoName);
|
||||||
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
||||||
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
||||||
|
image = itemView.findViewById(R.id.imageAvatar);
|
||||||
|
fullName = itemView.findViewById(R.id.repoFullName);
|
||||||
|
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
||||||
|
repoStars = itemView.findViewById(R.id.repoStars);
|
||||||
|
repoForks = itemView.findViewById(R.id.repoForks);
|
||||||
|
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
||||||
|
reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
||||||
|
repoType = itemView.findViewById(R.id.repoType);
|
||||||
|
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
||||||
|
repoBranch = itemView.findViewById(R.id.repoBranch);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
void bindData(UserRepositories forksModel) {
|
||||||
|
|
||||||
|
repoDescription.setVisibility(View.GONE);
|
||||||
|
repoBranch.setText(forksModel.getDefault_branch());
|
||||||
|
|
||||||
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||||
|
int color = generator.getColor(forksModel.getName());
|
||||||
|
String firstCharacter = String.valueOf(forksModel.getName().charAt(0));
|
||||||
|
|
||||||
|
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
|
||||||
|
.endConfig().buildRoundRect(firstCharacter, color, 3);
|
||||||
|
|
||||||
|
if(forksModel.getAvatar_url() != null) {
|
||||||
|
if(!forksModel.getAvatar_url().equals("")) {
|
||||||
|
PicassoService.getInstance(ctx).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated)
|
||||||
|
.transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(image);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
image.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
image.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
repoName.setText(forksModel.getName());
|
||||||
|
|
||||||
|
if(!forksModel.getDescription().equals("")) {
|
||||||
|
repoDescription.setVisibility(View.VISIBLE);
|
||||||
|
repoDescription.setText(forksModel.getDescription());
|
||||||
|
}
|
||||||
|
fullName.setText(forksModel.getFullname());
|
||||||
|
|
||||||
|
if(forksModel.getPrivateFlag()) {
|
||||||
|
repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
||||||
|
repoType.setText(R.string.strPrivate);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
repoPrivatePublic.setVisibility(View.GONE);
|
||||||
|
repoType.setText(R.string.strPublic);
|
||||||
|
}
|
||||||
|
|
||||||
|
repoStars.setText(forksModel.getStars_count());
|
||||||
|
repoForks.setText(forksModel.getForks_count());
|
||||||
|
repoOpenIssuesCount.setText(forksModel.getOpen_issues_count());
|
||||||
|
|
||||||
|
if(isRepoAdmin == null) {
|
||||||
|
isRepoAdmin = new CheckBox(ctx);
|
||||||
|
}
|
||||||
|
isRepoAdmin.setChecked(forksModel.getPermissions().isAdmin());
|
||||||
|
|
||||||
|
if(forksModel.isArchived()) {
|
||||||
|
archiveRepo.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
archiveRepo.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemView.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
Context context = v.getContext();
|
||||||
|
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
||||||
|
TextView repoType_ = v.findViewById(R.id.repoType);
|
||||||
|
|
||||||
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
||||||
|
|
||||||
|
TinyDB tinyDb = new TinyDB(context);
|
||||||
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
||||||
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
||||||
|
//tinyDb.putBoolean("resumeIssues", true);
|
||||||
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
||||||
|
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
||||||
|
|
||||||
|
String[] parts = repoFullName.getText().toString().split("/");
|
||||||
|
final String repoOwner = parts[0];
|
||||||
|
final String repoName = parts[1];
|
||||||
|
|
||||||
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
||||||
|
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
||||||
|
|
||||||
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
||||||
|
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());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//store if user is watching this repo
|
||||||
|
{
|
||||||
|
|
||||||
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||||
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
|
WatchInfo watch = new WatchInfo();
|
||||||
|
|
||||||
|
Call<WatchInfo> call;
|
||||||
|
|
||||||
|
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
||||||
|
|
||||||
|
call.enqueue(new Callback<WatchInfo>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
||||||
|
|
||||||
|
if(response.isSuccessful()) {
|
||||||
|
|
||||||
|
assert response.body() != null;
|
||||||
|
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
tinyDb.putBoolean("repoWatch", false);
|
||||||
|
|
||||||
|
if(response.code() != 404) {
|
||||||
|
|
||||||
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
||||||
|
|
||||||
|
tinyDb.putBoolean("repoWatch", false);
|
||||||
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
context.startActivity(intent);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
reposDropdownMenu.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
final Context context = v.getContext();
|
||||||
|
|
||||||
|
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
||||||
|
|
||||||
|
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
||||||
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
||||||
|
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
||||||
|
TextView repoForksList = view.findViewById(R.id.repoForksList);
|
||||||
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
|
bottomSheetHeader
|
||||||
|
.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||||
|
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
||||||
|
dialog.setContentView(view);
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
||||||
|
|
||||||
|
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
||||||
|
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
||||||
|
context.startActivity(intentOpenInBrowser);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
repoStargazers.setOnClickListener(stargazers -> {
|
||||||
|
|
||||||
|
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
||||||
|
intent.putExtra("repoFullNameForStars", fullName.getText());
|
||||||
|
context.startActivity(intent);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
repoWatchers.setOnClickListener(watchers -> {
|
||||||
|
|
||||||
|
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
repoForksList.setOnClickListener(watchers -> {
|
||||||
|
|
||||||
|
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static class LoadHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
LoadHolder(View itemView) {
|
||||||
|
|
||||||
|
super(itemView);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoreDataAvailable(boolean moreDataAvailable) {
|
||||||
|
|
||||||
|
isMoreDataAvailable = moreDataAvailable;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyDataChanged() {
|
||||||
|
|
||||||
|
notifyDataSetChanged();
|
||||||
|
isLoading = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnLoadMoreListener {
|
||||||
|
|
||||||
|
void onLoadMore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoadMoreListener(RepoForksAdapter.OnLoadMoreListener loadMoreListener) {
|
||||||
|
|
||||||
|
this.loadMoreListener = loadMoreListener;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateList(List<UserRepositories> list) {
|
||||||
|
|
||||||
|
forksList = list;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
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.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -178,6 +179,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
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 repoForksList = view.findViewById(R.id.repoForksList);
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||||
@ -212,6 +214,15 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
repoForksList.setOnClickListener(forks -> {
|
||||||
|
|
||||||
|
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
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.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -173,6 +174,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
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 repoForksList = view.findViewById(R.id.repoForksList);
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||||
@ -189,7 +191,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
repoStargazers.setOnClickListener(openInBrowser -> {
|
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());
|
||||||
@ -198,7 +200,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
repoWatchers.setOnClickListener(openInBrowser -> {
|
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());
|
||||||
@ -207,6 +209,15 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
repoForksList.setOnClickListener(forks -> {
|
||||||
|
|
||||||
|
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
|||||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.activities.RepoStargazersActivity;
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
||||||
import org.mian.gitnex.activities.RepoWatchersActivity;
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoForksActivity;
|
||||||
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.database.api.RepositoriesApi;
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
||||||
@ -176,6 +177,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
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 repoForksList = view.findViewById(R.id.repoForksList);
|
||||||
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
||||||
|
|
||||||
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
||||||
@ -210,6 +212,15 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
repoForksList.setOnClickListener(forks -> {
|
||||||
|
|
||||||
|
Intent intentW = new Intent(context, RepoForksActivity.class);
|
||||||
|
intentW.putExtra("repoFullNameForForks", fullName.getText());
|
||||||
|
context.startActivity(intentW);
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,14 +75,10 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
|
|
||||||
createNewRepo = v.findViewById(R.id.addNewRepo);
|
createNewRepo = v.findViewById(R.id.addNewRepo);
|
||||||
|
|
||||||
createNewRepo.setOnClickListener(new View.OnClickListener() {
|
createNewRepo.setOnClickListener(view -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
@ -102,18 +98,11 @@ public class RepositoriesFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
|
||||||
@Override
|
|
||||||
public void onRefresh() {
|
swipeRefresh.setRefreshing(false);
|
||||||
new Handler().postDelayed(new Runnable() {
|
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit);
|
||||||
@Override
|
}, 50));
|
||||||
public void run() {
|
|
||||||
swipeRefresh.setRefreshing(false);
|
|
||||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit);
|
|
||||||
}
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit);
|
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit);
|
||||||
|
|
||||||
|
@ -321,4 +321,7 @@ public interface ApiInterface {
|
|||||||
|
|
||||||
@DELETE("repos/{owner}/{repo}/branches/{branch}") // delete branch
|
@DELETE("repos/{owner}/{repo}/branches/{branch}") // delete branch
|
||||||
Call<JsonElement> deleteBranch(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("branch") String branchName);
|
Call<JsonElement> deleteBranch(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("branch") String branchName);
|
||||||
|
|
||||||
|
@GET("repos/{owner}/{repo}/forks") // get all repo forks
|
||||||
|
Call<List<UserRepositories>> getRepositoryForks(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Query("page") int page, @Query("limit") int limit);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class Issues {
|
|||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class userObject {
|
public static class userObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String login;
|
private String login;
|
||||||
@ -71,7 +71,7 @@ public class Issues {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class labelsObject {
|
public static class labelsObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
@ -95,7 +95,7 @@ public class Issues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class pullRequestObject {
|
public static class pullRequestObject {
|
||||||
|
|
||||||
private boolean merged;
|
private boolean merged;
|
||||||
private String merged_at;
|
private String merged_at;
|
||||||
@ -109,7 +109,7 @@ public class Issues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class milestoneObject {
|
public static class milestoneObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
@ -153,7 +153,7 @@ public class Issues {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class assigneesObject {
|
public static class assigneesObject {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String login;
|
private String login;
|
||||||
|
@ -33,9 +33,13 @@ public class UserRepositories {
|
|||||||
private String avatar_url;
|
private String avatar_url;
|
||||||
private boolean archived;
|
private boolean archived;
|
||||||
|
|
||||||
|
public UserRepositories(String body) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
private permissionsObject permissions;
|
private permissionsObject permissions;
|
||||||
|
|
||||||
public class permissionsObject {
|
public static class permissionsObject {
|
||||||
|
|
||||||
private boolean admin;
|
private boolean admin;
|
||||||
private boolean push;
|
private boolean push;
|
||||||
|
85
app/src/main/res/layout/activity_forks.xml
Normal file
85
app/src/main/res/layout/activity_forks.xml
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="?attr/primaryBackgroundColor">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/appbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/Widget.AppCompat.SearchView">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/primaryBackgroundColor"
|
||||||
|
tools:ignore="UnusedAttribute">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/close"
|
||||||
|
android:layout_width="@dimen/close_button_size"
|
||||||
|
android:layout_height="@dimen/close_button_size"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:contentDescription="@string/close"
|
||||||
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/toolbar_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/commitTitle"
|
||||||
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:ellipsize="none"
|
||||||
|
android:scrollbars="horizontal"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/pullToRefresh"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/primaryBackgroundColor"
|
||||||
|
android:scrollbars="vertical" />
|
||||||
|
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/noData"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="15dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/noDataFound"
|
||||||
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
style="@style/Base.Widget.AppCompat.ProgressBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:visibility="visible" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -71,6 +71,18 @@
|
|||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:padding="12dp" />
|
android:padding="12dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/repoForksList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/infoTabRepoForksCount"
|
||||||
|
android:drawableStart="@drawable/ic_fork"
|
||||||
|
android:drawablePadding="24dp"
|
||||||
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user