mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Add server avatar to user accounts (#594)
Add server avatar to user accounts Co-authored-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: M M Arif <mmarif@swatian.com> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/594 Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
parent
26f54280a1
commit
060c86c090
@ -10,7 +10,9 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.database.models.UserAccount;
|
import org.mian.gitnex.database.models.UserAccount;
|
||||||
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||||
import org.mian.gitnex.helpers.TinyDB;
|
import org.mian.gitnex.helpers.TinyDB;
|
||||||
import org.mian.gitnex.helpers.Toasty;
|
import org.mian.gitnex.helpers.Toasty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,6 +34,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
private TextView userId;
|
private TextView userId;
|
||||||
private ImageView activeAccount;
|
private ImageView activeAccount;
|
||||||
private ImageView deleteAccount;
|
private ImageView deleteAccount;
|
||||||
|
private ImageView repoAvatar;
|
||||||
|
|
||||||
private UserAccountsViewHolder(View itemView) {
|
private UserAccountsViewHolder(View itemView) {
|
||||||
|
|
||||||
@ -41,6 +44,7 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
userId = itemView.findViewById(R.id.userId);
|
userId = itemView.findViewById(R.id.userId);
|
||||||
activeAccount = itemView.findViewById(R.id.activeAccount);
|
activeAccount = itemView.findViewById(R.id.activeAccount);
|
||||||
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
deleteAccount = itemView.findViewById(R.id.deleteAccount);
|
||||||
|
repoAvatar = itemView.findViewById(R.id.repoAvatar);
|
||||||
|
|
||||||
deleteAccount.setOnClickListener(itemDelete -> {
|
deleteAccount.setOnClickListener(itemDelete -> {
|
||||||
// use later to delete an account
|
// use later to delete an account
|
||||||
@ -93,6 +97,8 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
|
|||||||
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
|
holder.userId.setText(String.format("@%s", currentItem.getUserName()));
|
||||||
holder.accountUrl.setText(url);
|
holder.accountUrl.setText(url);
|
||||||
|
|
||||||
|
PicassoService.getInstance(mCtx).get().load(url + "img/favicon.png").placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.repoAvatar);
|
||||||
|
|
||||||
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
if(tinyDB.getInt("currentActiveAccountId") == currentItem.getAccountId()) {
|
||||||
holder.activeAccount.setVisibility(View.VISIBLE);
|
holder.activeAccount.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,29 @@
|
|||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="15dp"
|
||||||
android:background="?attr/primaryBackgroundColor">
|
android:background="?attr/primaryBackgroundColor">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/layoutFrame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/repoAvatar"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
android:contentDescription="@string/repoContentAvatar"
|
||||||
|
android:src="@drawable/ic_android" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/frameAccountsInfo"
|
android:id="@+id/frameAccountsInfo"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:layout_toEndOf="@+id/repoAvatar"
|
||||||
android:layout_marginBottom="10dp">
|
android:layout_marginBottom="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -24,7 +39,8 @@
|
|||||||
android:layout_weight=".95"
|
android:layout_weight=".95"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/activeAccount"
|
android:id="@+id/activeAccount"
|
||||||
@ -53,8 +69,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="0dp"
|
android:layout_marginBottom="0dp"
|
||||||
|
android:layout_toEndOf="@+id/repoAvatar"
|
||||||
|
android:layout_below="@+id/frameAccountsInfo"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user