added repos avatars

This commit is contained in:
M M Arif 2019-10-01 18:56:20 +05:00
parent 69082b424a
commit 19cd5b6c5e
10 changed files with 66 additions and 28 deletions

View File

@ -13,11 +13,13 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.squareup.picasso.Picasso;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import java.lang.reflect.Field;
@ -46,7 +48,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
private TextView fullNameMy;
private ImageView repoPrivatePublicMy;
private TextView repoStarsMy;
private TextView repoWatchersMy;
private TextView repoForksMy;
private TextView repoOpenIssuesCountMy;
private MyReposViewHolder(View itemView) {
@ -57,7 +59,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
fullNameMy = itemView.findViewById(R.id.repoFullNameMy);
repoPrivatePublicMy = itemView.findViewById(R.id.imageRepoTypeMy);
repoStarsMy = itemView.findViewById(R.id.repoStarsMy);
repoWatchersMy = itemView.findViewById(R.id.repoWatchersMy);
repoForksMy = itemView.findViewById(R.id.repoForksMy);
repoOpenIssuesCountMy = itemView.findViewById(R.id.repoOpenIssuesCountMy);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
@ -175,9 +177,14 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
.width(28)
.height(28)
.endConfig()
.buildRoundRect(firstCharacter, color, 4);
.buildRoundRect(firstCharacter, color, 3);
if (!currentItem.getAvatar_url().equals("")) {
Picasso.get().load(currentItem.getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.imageMy);
} else {
holder.imageMy.setImageDrawable(drawable);
}
holder.imageMy.setImageDrawable(drawable);
holder.mTextView1My.setText(currentItem.getName());
if (!currentItem.getDescription().equals("")) {
holder.mTextView2My.setVisibility(View.VISIBLE);
@ -191,7 +198,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
holder.repoPrivatePublicMy.setImageResource(R.drawable.ic_public);
}
holder.repoStarsMy.setText(currentItem.getStars_count());
holder.repoWatchersMy.setText(currentItem.getWatchers_count());
holder.repoForksMy.setText(currentItem.getForks_count());
holder.repoOpenIssuesCountMy.setText(currentItem.getOpen_issues_count());
}

View File

@ -17,11 +17,13 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.squareup.picasso.Picasso;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import java.lang.reflect.Field;
@ -46,7 +48,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
private TextView fullName;
private ImageView repoPrivatePublic;
private TextView repoStars;
private TextView repoWatchers;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private ReposViewHolder(View itemView) {
@ -58,7 +60,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
fullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars);
repoWatchers = itemView.findViewById(R.id.repoWatchers);
repoForks = itemView.findViewById(R.id.repoForks);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
@ -177,9 +179,14 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
.width(28)
.height(28)
.endConfig()
.buildRoundRect(firstCharacter, color, 4);
.buildRoundRect(firstCharacter, color, 3);
if (!currentItem.getAvatar_url().equals("")) {
Picasso.get().load(currentItem.getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
} else {
holder.image.setImageDrawable(drawable);
}
holder.image.setImageDrawable(drawable);
holder.mTextView1.setText(currentItem.getName());
if (!currentItem.getDescription().equals("")) {
holder.mTextView2.setVisibility(View.VISIBLE);
@ -193,7 +200,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoWatchers.setText(currentItem.getWatchers_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
}

View File

@ -13,11 +13,13 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.squareup.picasso.Picasso;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import java.lang.reflect.Field;
@ -46,7 +48,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
private TextView fullName;
private ImageView repoPrivatePublic;
private TextView repoStars;
private TextView repoWatchers;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private OrgReposViewHolder(View itemView) {
@ -57,7 +59,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
fullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars);
repoWatchers = itemView.findViewById(R.id.repoWatchers);
repoForks = itemView.findViewById(R.id.repoForks);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
@ -176,9 +178,14 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
.width(28)
.height(28)
.endConfig()
.buildRoundRect(firstCharacter, color, 4);
.buildRoundRect(firstCharacter, color, 3);
if (!currentItem.getAvatar_url().equals("")) {
Picasso.get().load(currentItem.getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
} else {
holder.image.setImageDrawable(drawable);
}
holder.image.setImageDrawable(drawable);
holder.mTextView1.setText(currentItem.getName());
if (!currentItem.getDescription().equals("")) {
holder.mTextView2.setVisibility(View.VISIBLE);
@ -192,7 +199,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoWatchers.setText(currentItem.getWatchers_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
}

View File

@ -13,11 +13,13 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.amulyakhare.textdrawable.TextDrawable;
import com.amulyakhare.textdrawable.util.ColorGenerator;
import com.squareup.picasso.Picasso;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.TinyDB;
import java.lang.reflect.Field;
@ -46,7 +48,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
private TextView fullName;
private ImageView repoPrivatePublic;
private TextView repoStars;
private TextView repoWatchers;
private TextView repoForks;
private TextView repoOpenIssuesCount;
private StarredReposViewHolder(View itemView) {
@ -57,7 +59,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
fullName = itemView.findViewById(R.id.repoFullName);
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
repoStars = itemView.findViewById(R.id.repoStars);
repoWatchers = itemView.findViewById(R.id.repoWatchers);
repoForks = itemView.findViewById(R.id.repoForks);
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
@ -176,9 +178,14 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
.width(28)
.height(28)
.endConfig()
.buildRoundRect(firstCharacter, color, 4);
.buildRoundRect(firstCharacter, color, 3);
if (!currentItem.getAvatar_url().equals("")) {
Picasso.get().load(currentItem.getAvatar_url()).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
} else {
holder.image.setImageDrawable(drawable);
}
holder.image.setImageDrawable(drawable);
holder.mTextView1.setText(currentItem.getName());
if (!currentItem.getDescription().equals("")) {
holder.mTextView2.setVisibility(View.VISIBLE);
@ -192,7 +199,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
holder.repoPrivatePublic.setImageResource(R.drawable.ic_public);
}
holder.repoStars.setText(currentItem.getStars_count());
holder.repoWatchers.setText(currentItem.getWatchers_count());
holder.repoForks.setText(currentItem.getForks_count());
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
}

View File

@ -28,6 +28,7 @@ public class UserRepositories {
private String website;
private String forks_count;
private Boolean has_issues;
private String avatar_url;
public int getId() {
return id;
@ -100,4 +101,8 @@ public class UserRepositories {
public Boolean getHas_issues() {
return has_issues;
}
public String getAvatar_url() {
return avatar_url;
}
}

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M14,4l2.29,2.29 -2.88,2.88 1.42,1.42 2.88,-2.88L20,10L20,4zM10,4L4,4v6l2.29,-2.29 4.71,4.7L11,20h2v-8.41l-5.29,-5.3z"/>
</vector>

View File

@ -112,11 +112,11 @@
android:textSize="16sp" />
<TextView
android:id="@+id/repoWatchersMy"
android:id="@+id/repoForksMy"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight=".25"
android:drawableStart="@drawable/ic_watchers"
android:drawableStart="@drawable/ic_forks_24"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"

View File

@ -112,11 +112,11 @@
android:textSize="14sp" />
<TextView
android:id="@+id/repoWatchers"
android:id="@+id/repoForks"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight=".25"
android:drawableStart="@drawable/ic_watchers"
android:drawableStart="@drawable/ic_forks_24"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"

View File

@ -109,11 +109,11 @@
android:textSize="14sp" />
<TextView
android:id="@+id/repoWatchers"
android:id="@+id/repoForks"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight=".25"
android:drawableStart="@drawable/ic_watchers"
android:drawableStart="@drawable/ic_forks_24"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"

View File

@ -110,11 +110,11 @@
android:textSize="14sp" />
<TextView
android:id="@+id/repoWatchers"
android:id="@+id/repoForks"
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight=".25"
android:drawableStart="@drawable/ic_watchers"
android:drawableStart="@drawable/ic_forks_24"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"