diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 387fd362..3c50b0ad 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -2,9 +2,6 @@
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoStargazersActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoStargazersActivity.java
index 8fbbfc6a..dc369a47 100644
--- a/app/src/main/java/org/mian/gitnex/activities/RepoStargazersActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/RepoStargazersActivity.java
@@ -1,6 +1,5 @@
package org.mian.gitnex.activities;
-import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoWatchersActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoWatchersActivity.java
new file mode 100644
index 00000000..d312bb6b
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/RepoWatchersActivity.java
@@ -0,0 +1,95 @@
+package org.mian.gitnex.activities;
+
+import android.os.Bundle;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProvider;
+import android.view.View;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import org.mian.gitnex.R;
+import org.mian.gitnex.adapters.RepoWatchersAdapter;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.models.UserInfo;
+import org.mian.gitnex.util.TinyDB;
+import org.mian.gitnex.viewmodels.RepoWatchersViewModel;
+import java.util.List;
+
+/**
+ * Author M M Arif
+ */
+
+public class RepoWatchersActivity extends AppCompatActivity {
+
+ private TextView noDataWatchers;
+ private View.OnClickListener onClickListener;
+ private RepoWatchersAdapter adapter;
+ private GridView mGridView;
+ private ProgressBar mProgressBar;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_repo_watchers);
+
+ TinyDB tinyDb = new TinyDB(getApplicationContext());
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ ImageView closeActivity = findViewById(R.id.close);
+ TextView toolbarTitle = findViewById(R.id.toolbar_title);
+ noDataWatchers = findViewById(R.id.noDataWatchers);
+ mGridView = findViewById(R.id.gridView);
+ mProgressBar = findViewById(R.id.progress_bar);
+
+ String repoFullNameForWatchers = getIntent().getStringExtra("repoFullNameForWatchers");
+ String[] parts = repoFullNameForWatchers.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ toolbarTitle.setText(R.string.repoWatchersInMenu);
+
+ fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
+
+ }
+
+ private void fetchDataAsync(String instanceUrl, String instanceToken, String repoOwner, String repoName) {
+
+ RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
+
+ repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName).observe(this, new Observer>() {
+ @Override
+ public void onChanged(@Nullable List watchersListMain) {
+ adapter = new RepoWatchersAdapter(getApplicationContext(), watchersListMain);
+ if(adapter.getCount() > 0) {
+ mGridView.setAdapter(adapter);
+ noDataWatchers.setVisibility(View.GONE);
+ }
+ else {
+ adapter.notifyDataSetChanged();
+ mGridView.setAdapter(adapter);
+ noDataWatchers.setVisibility(View.VISIBLE);
+ }
+ mProgressBar.setVisibility(View.GONE);
+ }
+ });
+
+ }
+
+ private void initCloseListener() {
+ onClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finish();
+ }
+ };
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
index cb1967ee..737591fc 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
@@ -16,6 +16,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
+import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import java.lang.reflect.Field;
@@ -117,6 +118,9 @@ public class MyReposListAdapter extends RecyclerView.Adapter watchersList;
+ private Context mCtx;
+
+ private class ViewHolder {
+
+ private ImageView memberAvatar;
+ private TextView memberName;
+
+ ViewHolder(View v) {
+ memberAvatar = v.findViewById(R.id.memberAvatar);
+ memberName = v.findViewById(R.id.memberName);
+ }
+ }
+
+ public RepoWatchersAdapter(Context mCtx, List membersListMain) {
+ this.mCtx = mCtx;
+ this.watchersList = membersListMain;
+ }
+
+ @Override
+ public int getCount() {
+ return watchersList.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @SuppressLint("InflateParams")
+ @Override
+ public View getView(int position, View finalView, ViewGroup parent) {
+
+ RepoWatchersAdapter.ViewHolder viewHolder;
+
+ if (finalView == null) {
+ finalView = LayoutInflater.from(mCtx).inflate(R.layout.repo_watchers_list, null);
+ viewHolder = new RepoWatchersAdapter.ViewHolder(finalView);
+ finalView.setTag(viewHolder);
+ }
+ else {
+ viewHolder = (RepoWatchersAdapter.ViewHolder) finalView.getTag();
+ }
+
+ initData(viewHolder, position);
+ return finalView;
+
+ }
+
+ private void initData(RepoWatchersAdapter.ViewHolder viewHolder, int position) {
+
+ UserInfo currentItem = watchersList.get(position);
+ Picasso.get().load(currentItem.getAvatar()).transform(new RoundedTransformation(100, 0)).resize(200, 200).centerCrop().into(viewHolder.memberAvatar);
+
+ if(!currentItem.getFullname().equals("")) {
+ viewHolder.memberName.setText(currentItem.getFullname());
+ }
+ else {
+ viewHolder.memberName.setText(currentItem.getLogin());
+ }
+
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java
index 33bbf5d1..c04c2927 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java
@@ -20,6 +20,7 @@ import com.amulyakhare.textdrawable.util.ColorGenerator;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
+import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import java.lang.reflect.Field;
@@ -119,6 +120,9 @@ public class ReposListAdapter extends RecyclerView.Adapter> getRepoStargazers(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
+
+ @GET("repos/{owner}/{repo}/subscribers") // get all repo watchers
+ Call> getRepoWatchers(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
}
\ No newline at end of file
diff --git a/app/src/main/java/org/mian/gitnex/viewmodels/RepoWatchersViewModel.java b/app/src/main/java/org/mian/gitnex/viewmodels/RepoWatchersViewModel.java
new file mode 100644
index 00000000..1eee06a3
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/viewmodels/RepoWatchersViewModel.java
@@ -0,0 +1,60 @@
+package org.mian.gitnex.viewmodels;
+
+import android.util.Log;
+import androidx.annotation.NonNull;
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.models.UserInfo;
+import java.util.List;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
+/**
+ * Author M M Arif
+ */
+
+public class RepoWatchersViewModel extends ViewModel {
+
+ private static MutableLiveData> watchersList;
+
+ public LiveData> getRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
+
+ watchersList = new MutableLiveData<>();
+ loadRepoWatchers(instanceUrl, token, repoOwner, repoName);
+
+ return watchersList;
+ }
+
+ public static void loadRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl)
+ .getApiInterface()
+ .getRepoWatchers(token, repoOwner, repoName);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull Response> response) {
+
+ if(response.isSuccessful()) {
+ if(response.code() == 200) {
+ watchersList.postValue(response.body());
+
+ }
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, Throwable t) {
+ Log.i("onFailure", t.toString());
+ }
+
+ });
+
+ }
+}
diff --git a/app/src/main/res/layout/activity_repo_watchers.xml b/app/src/main/res/layout/activity_repo_watchers.xml
new file mode 100644
index 00000000..57e98d4e
--- /dev/null
+++ b/app/src/main/res/layout/activity_repo_watchers.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/repo_watchers_list.xml b/app/src/main/res/layout/repo_watchers_list.xml
new file mode 100644
index 00000000..78904d5d
--- /dev/null
+++ b/app/src/main/res/layout/repo_watchers_list.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 1ff6452e..4b3fa6cd 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -402,6 +402,7 @@
No stars found
No watchers found
Star
+ Watcher
OK
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 9a3e2c93..e46158b5 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -402,6 +402,7 @@
No stars found
No watchers found
Star
+ Watcher
OK
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 879caaa1..2e6e281f 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -402,6 +402,7 @@
No stars found
No watchers found
Star
+ Watcher
OK
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5fbdf843..0e3c9fef 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -438,6 +438,7 @@
No stars found
No watchers found
Star
+ Watcher
OK