Merge branch 'dev_6.5.4_头像优化' into dev_6.5.4_联系方式

This commit is contained in:
zlzw 2023-07-19 15:35:48 +08:00
commit 3108c898c2
10 changed files with 274 additions and 1 deletions

View File

@ -0,0 +1,40 @@
package com.yunbao.common.bean;
public class UserAvatarSelectBean {
private int id;
private String url;
private int select;
public UserAvatarSelectBean(int id, String url, int select) {
this.id = id;
this.url = url;
this.select = select;
}
public UserAvatarSelectBean() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getSelect() {
return select;
}
public void setSelect(int select) {
this.select = select;
}
}

View File

@ -43,6 +43,7 @@ public class RouteUtil {
public static final String PATH_RED_PACKET_LIST = "/main/RedPacketListActivity"; public static final String PATH_RED_PACKET_LIST = "/main/RedPacketListActivity";
public static final String PATH_RED_PACKET_INFO = "/main/RedPacketInfoActivity"; public static final String PATH_RED_PACKET_INFO = "/main/RedPacketInfoActivity";
public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity"; public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity";
public static final String PATH_SELECT_AVATAR="/main/UserAvatarSelectActivity";
public static void forwardFansActivity(String uid) { public static void forwardFansActivity(String uid) {
ARouter.getInstance().build(PATH_FANSACTIVITY) ARouter.getInstance().build(PATH_FANSACTIVITY)
@ -294,4 +295,12 @@ public class RouteUtil {
.withInt("id", id) .withInt("id", id)
.navigation(); .navigation();
} }
/**
* 系统头像选择
*/
public static void forwardUserAvatarSelect(){
ARouter.getInstance().build(PATH_SELECT_AVATAR)
.navigation();
}
} }

View File

@ -156,6 +156,8 @@
<activity <activity
android:name=".activity.RedPacketUsersActivity" android:name=".activity.RedPacketUsersActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity android:name=".activity.UserAvatarSelectActivity"
android:screenOrientation="portrait" />
</application> </application>
</manifest> </manifest>

View File

@ -0,0 +1,53 @@
package com.yunbao.main.activity;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.bean.UserAvatarSelectBean;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.main.R;
import com.yunbao.main.adapter.UserAvatarSelectAdapter;
import java.util.ArrayList;
import java.util.List;
@Route(path = RouteUtil.PATH_SELECT_AVATAR)
public class UserAvatarSelectActivity extends AbsActivity {
RecyclerView recyclerView;
UserAvatarSelectAdapter adapter;
List<UserAvatarSelectBean> list;
TextView titleView;
@Override
protected int getLayoutId() {
return R.layout.activity_user_select_avatar;
}
@Override
protected void main() {
super.main();
titleView=findViewById(R.id.titleView);
titleView.setText("選擇頭像");
recyclerView = findViewById(R.id.recyclerView);
adapter = new UserAvatarSelectAdapter(mContext);
recyclerView.setLayoutManager(new GridLayoutManager(mContext, 3));
recyclerView.setAdapter(adapter);
test();
}
private void test() {
list = new ArrayList<>();
for (int i = 0; i < 6; i++) {
UserAvatarSelectBean bean = new UserAvatarSelectBean(i,
"https://downs.yaoulive.com/20220906170849_79c553dc1319fb5c215e06e01674eba4?imageView2/2/w/600/h/600",
i == 3 ? 1 : 0
);
list.add(bean);
}
adapter.setList(list);
}
}

View File

@ -0,0 +1,77 @@
package com.yunbao.main.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.bean.UserAvatarSelectBean;
import com.yunbao.common.custom.RatioRoundImageView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.main.R;
import java.util.List;
public class UserAvatarSelectAdapter extends RecyclerView.Adapter<UserAvatarSelectAdapter.AvatarSelectViewHolder> {
private Context mContext;
private List<UserAvatarSelectBean> list;
private int select = 0;
public void setList(List<UserAvatarSelectBean> list) {
this.list = list;
notifyDataSetChanged();
}
public UserAvatarSelectAdapter(Context mContext) {
this.mContext = mContext;
}
@NonNull
@Override
public AvatarSelectViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new AvatarSelectViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_user_avatar_select, parent, false));
}
@Override
public void onBindViewHolder(@NonNull AvatarSelectViewHolder holder, int position) {
holder.setData(list.get(position), position);
}
@Override
public int getItemCount() {
return list.size();
}
public class AvatarSelectViewHolder extends RecyclerView.ViewHolder {
private View hide;
private View show;
private RatioRoundImageView avatar;
public AvatarSelectViewHolder(@NonNull View itemView) {
super(itemView);
hide = itemView.findViewById(R.id.hideCover);
show = itemView.findViewById(R.id.showCover);
avatar = itemView.findViewById(R.id.avatar);
itemView.setOnClickListener(v -> {
select = (int) v.getTag();
notifyDataSetChanged();
});
}
public void setData(UserAvatarSelectBean bean, int position) {
ImgLoader.display(itemView.getContext(), bean.getUrl(), avatar);
if (select == position) {
show.setVisibility(View.VISIBLE);
hide.setVisibility(View.GONE);
} else {
show.setVisibility(View.INVISIBLE);
hide.setVisibility(View.VISIBLE);
}
itemView.setTag(position);
}
}
}

View File

@ -8,6 +8,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.main.R; import com.yunbao.main.R;
import com.yunbao.main.activity.RedPacketListActivity; import com.yunbao.main.activity.RedPacketListActivity;
@ -41,7 +42,13 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy); ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy);
img_trophy.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
RouteUtil.forwardUserAvatarSelect();
return false;
}
});
} }
public void setCurPosition(int position){ public void setCurPosition(int position){

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FFC300"/>
</shape>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#80000000"/>
</shape>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#333333"
xmlns:app="http://schemas.android.com/apk/res-auto">
<include
android:id="@+id/include"
layout="@layout/view_title2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="85dp"
android:layout_height="85dp"
android:layout_marginStart="22dp"
android:layout_marginTop="32dp">
<View
android:id="@+id/showCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_user_avatar_select_selected"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.yunbao.common.custom.RatioRoundImageView
android:id="@+id/avatar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="2dp"
android:src="@mipmap/icon_green_science"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:ri_ratio="0.5"
app:riv_oval="true" />
<View
android:id="@+id/hideCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="2dp"
android:background="@drawable/bg_user_avatar_select_unselected"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>