diff --git a/common/src/main/res/layout/item_red_packet.xml b/common/src/main/res/layout/item_red_packet.xml index 4a8f18371..130bb6199 100644 --- a/common/src/main/res/layout/item_red_packet.xml +++ b/common/src/main/res/layout/item_red_packet.xml @@ -15,6 +15,7 @@ app:srcCompat="@mipmap/diamond" /> + + \ No newline at end of file diff --git a/common/src/main/res/layout/item_user_red_packet.xml b/common/src/main/res/layout/item_user_red_packet.xml new file mode 100644 index 000000000..882546cd4 --- /dev/null +++ b/common/src/main/res/layout/item_user_red_packet.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/icon_diamond2.png b/common/src/main/res/mipmap-xxhdpi/icon_diamond2.png new file mode 100644 index 000000000..e5517f232 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_diamond2.png differ diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index 5048ed398..fef1e28bc 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -147,6 +147,15 @@ + + + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/RedPacketActivity.java b/main/src/main/java/com/yunbao/main/activity/RedPacketActivity.java deleted file mode 100644 index 4de98d450..000000000 --- a/main/src/main/java/com/yunbao/main/activity/RedPacketActivity.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.yunbao.main.activity; - -import android.widget.TextView; - -import androidx.recyclerview.widget.RecyclerView; - -import com.yunbao.common.activity.AbsActivity; -import com.yunbao.main.R; - -public class RedPacketActivity extends AbsActivity { - private RecyclerView recyclerView; - @Override - protected int getLayoutId() { - return R.layout.activity_red_packet; - } - - @Override - public void init() { - super.init(); - ((TextView)findViewById(R.id.titleView)).setText("紅包記錄"); - recyclerView=findViewById(R.id.recyclerView); - } -} diff --git a/main/src/main/java/com/yunbao/main/activity/RedPacketInfoActivity.java b/main/src/main/java/com/yunbao/main/activity/RedPacketInfoActivity.java new file mode 100644 index 000000000..296212675 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/activity/RedPacketInfoActivity.java @@ -0,0 +1,29 @@ +package com.yunbao.main.activity; + +import android.content.Intent; +import android.view.View; +import android.widget.TextView; + +import com.yunbao.common.activity.AbsActivity; +import com.yunbao.main.R; + +public class RedPacketInfoActivity extends AbsActivity implements View.OnClickListener{ + @Override + protected int getLayoutId() { + return R.layout.activity_red_packet_info; + } + + @Override + protected void main() { + super.main(); + findViewById(R.id.red_packet_info).setOnClickListener(this); + } + + @Override + public void onClick(View v) { + int id=v.getId(); + if(id==R.id.red_packet_info){ + startActivity(new Intent(this, RedPacketUsersActivity.class)); + } + } +} diff --git a/main/src/main/java/com/yunbao/main/activity/RedPacketListActivity.java b/main/src/main/java/com/yunbao/main/activity/RedPacketListActivity.java new file mode 100644 index 000000000..ad98ce1c3 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/activity/RedPacketListActivity.java @@ -0,0 +1,49 @@ +package com.yunbao.main.activity; + +import android.widget.TextView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.activity.AbsActivity; +import com.yunbao.main.R; +import com.yunbao.main.adapter.RedPacketListRecyclerAdapter; +import com.yunbao.main.bean.RedPacketListBean; + +import java.util.ArrayList; +import java.util.List; + +public class RedPacketListActivity extends AbsActivity { + private RecyclerView recyclerView; + private RedPacketListRecyclerAdapter adapter; + + @Override + protected int getLayoutId() { + return R.layout.activity_red_packet; + } + + @Override + public void main() { + super.main(); + ((TextView) findViewById(R.id.titleView)).setText("紅包記錄"); + recyclerView = findViewById(R.id.recyclerView); + + adapter = new RedPacketListRecyclerAdapter(this); + recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); + recyclerView.setAdapter(adapter); + initData(); + } + + private void initData() { + List list = new ArrayList<>(); + for (int i = 1; i <= 5; i++) { + RedPacketListBean bean = new RedPacketListBean(); + bean.setTitle("攢人氣紅包" + i); + bean.setTimer("X月X日 " + i); + bean.setMoney(i * 1000 + ""); + list.add(bean); + } + adapter.setList(list); + + } +} diff --git a/main/src/main/java/com/yunbao/main/activity/RedPacketUsersActivity.java b/main/src/main/java/com/yunbao/main/activity/RedPacketUsersActivity.java new file mode 100644 index 000000000..61a340b79 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/activity/RedPacketUsersActivity.java @@ -0,0 +1,52 @@ +package com.yunbao.main.activity; + +import android.view.View; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.activity.AbsActivity; +import com.yunbao.main.R; +import com.yunbao.main.adapter.RedPacketUserRecyclerAdapter; +import com.yunbao.main.bean.RedPacketListBean; + +import java.util.ArrayList; +import java.util.List; + +public class RedPacketUsersActivity extends AbsActivity implements View.OnClickListener{ + private RecyclerView recyclerView; + private RedPacketUserRecyclerAdapter adapter; + + @Override + protected int getLayoutId() { + return R.layout.activity_red_packet_users; + } + + @Override + protected void main() { + super.main(); + recyclerView = findViewById(R.id.recyclerView); + + adapter = new RedPacketUserRecyclerAdapter(this); + recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); + recyclerView.setAdapter(adapter); + initData(); + } + + @Override + public void onClick(View v) { + int id=v.getId(); + } + private void initData() { + List list = new ArrayList<>(); + for (int i = 1; i <= 5; i++) { + RedPacketListBean bean = new RedPacketListBean(); + bean.setTitle("攢人氣紅包 - 主播昵稱的直播間" + i); + bean.setTimer("X月X日 " + i); + bean.setMoney(i * 1000 + ""); + list.add(bean); + } + adapter.setList(list); + + } +} diff --git a/main/src/main/java/com/yunbao/main/adapter/RedPacketListRecyclerAdapter.java b/main/src/main/java/com/yunbao/main/adapter/RedPacketListRecyclerAdapter.java new file mode 100644 index 000000000..a1a64e227 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/RedPacketListRecyclerAdapter.java @@ -0,0 +1,69 @@ +package com.yunbao.main.adapter; + +import android.content.Context; +import android.content.Intent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.main.R; +import com.yunbao.main.activity.RedPacketInfoActivity; +import com.yunbao.main.bean.RedPacketListBean; + +import java.util.List; + +public class RedPacketListRecyclerAdapter extends RecyclerView.Adapter { + private List list; + private Context mContext; + + public RedPacketListRecyclerAdapter(Context mContext) { + this.mContext = mContext; + } + + public void setList(List list) { + this.list = list; + notifyDataSetChanged(); + } + + @NonNull + @Override + public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ItemViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_red_packet, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull ItemViewHolder holder, int position) { + holder.setData(list.get(position)); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public class ItemViewHolder extends RecyclerView.ViewHolder { + private TextView title, timer, money; + private ImageView icon; + + public ItemViewHolder(@NonNull View itemView) { + super(itemView); + title = itemView.findViewById(R.id.title); + timer = itemView.findViewById(R.id.time); + money = itemView.findViewById(R.id.money); + icon = itemView.findViewById(R.id.icon); + itemView.setOnClickListener(v -> mContext.startActivity(new Intent(mContext, RedPacketInfoActivity.class))); + } + + private void setData(RedPacketListBean bean) { + title.setText(bean.getTitle()); + timer.setText(bean.getTimer()); + money.setText(bean.getMoney()); + itemView.setTag(bean); + } + } +} diff --git a/main/src/main/java/com/yunbao/main/adapter/RedPacketUserRecyclerAdapter.java b/main/src/main/java/com/yunbao/main/adapter/RedPacketUserRecyclerAdapter.java new file mode 100644 index 000000000..011a95a7a --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/RedPacketUserRecyclerAdapter.java @@ -0,0 +1,69 @@ +package com.yunbao.main.adapter; + +import android.content.Context; +import android.content.Intent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.main.R; +import com.yunbao.main.activity.RedPacketInfoActivity; +import com.yunbao.main.bean.RedPacketListBean; + +import java.util.List; + +public class RedPacketUserRecyclerAdapter extends RecyclerView.Adapter { + private List list; + private Context mContext; + + public RedPacketUserRecyclerAdapter(Context mContext) { + this.mContext = mContext; + } + + public void setList(List list) { + this.list = list; + notifyDataSetChanged(); + } + + @NonNull + @Override + public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ItemViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_user_red_packet, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull ItemViewHolder holder, int position) { + holder.setData(list.get(position)); + } + + @Override + public int getItemCount() { + return list.size(); + } + + public class ItemViewHolder extends RecyclerView.ViewHolder { + private TextView title, timer, money; + private ImageView icon; + + public ItemViewHolder(@NonNull View itemView) { + super(itemView); + title = itemView.findViewById(R.id.title); + timer = itemView.findViewById(R.id.time); + money = itemView.findViewById(R.id.money); + icon = itemView.findViewById(R.id.icon); + itemView.setOnClickListener(v -> mContext.startActivity(new Intent(mContext, RedPacketInfoActivity.class))); + } + + private void setData(RedPacketListBean bean) { + title.setText(bean.getTitle()); + timer.setText(bean.getTimer()); + money.setText(bean.getMoney()); + itemView.setTag(bean); + } + } +} diff --git a/main/src/main/java/com/yunbao/main/bean/RedPacketListBean.java b/main/src/main/java/com/yunbao/main/bean/RedPacketListBean.java new file mode 100644 index 000000000..16f3e0910 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/bean/RedPacketListBean.java @@ -0,0 +1,33 @@ +package com.yunbao.main.bean; + +import com.yunbao.common.bean.BaseModel; + +public class RedPacketListBean extends BaseModel { + private String title; + private String timer; + private String money; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getTimer() { + return timer; + } + + public void setTimer(String timer) { + this.timer = timer; + } + + public String getMoney() { + return money; + } + + public void setMoney(String money) { + this.money = money; + } +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index fcfa2000a..a5614849e 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -1,6 +1,8 @@ package com.yunbao.main.views; import android.content.Context; +import android.content.Intent; +import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; @@ -8,6 +10,7 @@ import android.widget.ImageView; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; +import com.yunbao.main.activity.RedPacketListActivity; /** * Created by cxf on 2018/9/22. @@ -38,7 +41,13 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy); - + img_trophy.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + mContext.startActivity(new Intent(mContext, RedPacketListActivity.class)); + return false; + } + }); } diff --git a/main/src/main/res/layout/activity_red_packet_info.xml b/main/src/main/res/layout/activity_red_packet_info.xml new file mode 100644 index 000000000..c2c0a9a58 --- /dev/null +++ b/main/src/main/res/layout/activity_red_packet_info.xml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/activity_red_packet_users.xml b/main/src/main/res/layout/activity_red_packet_users.xml new file mode 100644 index 000000000..6a9f8bfae --- /dev/null +++ b/main/src/main/res/layout/activity_red_packet_users.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file