parent
1e377bef39
commit
f39ffdb47b
@ -0,0 +1,73 @@
|
||||
package com.android.activity.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.R;
|
||||
import com.android.bean.BaseRecords;
|
||||
import com.android.bean.queryBean.UserGoodsRecords;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class UserRecordsAdapter extends RecyclerView.Adapter<UserRecordsAdapter.UserRecordsAdapterHolder> {
|
||||
private Context context;
|
||||
private BaseRecords<UserGoodsRecords> recordsData;
|
||||
private Long userId;
|
||||
|
||||
public UserRecordsAdapter(Context context, BaseRecords<UserGoodsRecords> recordsData,Long userId) {
|
||||
this.context = context;
|
||||
this.recordsData = recordsData;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserRecordsAdapterHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).
|
||||
inflate(R.layout.recycleview_message_item, parent, false);
|
||||
return new UserRecordsAdapterHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull UserRecordsAdapterHolder holder, int position) {
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy 年 MM 月 dd 日 HH 时 mm 分 ss 秒");
|
||||
String sd = sdf.format(new Date(Long.parseLong(String.valueOf(recordsData.getRecords().get(position).getCreateTime())))); // 时间戳转换成时间
|
||||
if (recordsData.getRecords().get(position).getSellerId() == userId){
|
||||
holder.getTvName().setText("当前用户发布了:"+recordsData.getRecords().get(position).getGoodsDescription()+" "+sd);
|
||||
}else {
|
||||
holder.getTvName().setText("当前用户购买了: "+recordsData.getRecords().get(position).getGoodsDescription()+" "+sd);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return recordsData.getSize();
|
||||
}
|
||||
|
||||
public class UserRecordsAdapterHolder extends RecyclerView.ViewHolder {
|
||||
private TextView tvName;
|
||||
|
||||
public UserRecordsAdapterHolder(@NonNull View itemView) {
|
||||
|
||||
super(itemView);
|
||||
tvName = itemView.findViewById(R.id.tv_message_item_desc);
|
||||
}
|
||||
|
||||
public TextView getTvName() {
|
||||
return tvName;
|
||||
}
|
||||
|
||||
public void setTvName(TextView tvName) {
|
||||
this.tvName = tvName;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,18 @@
|
||||
package com.android.model.goods;
|
||||
|
||||
import com.android.bean.BaseRecords;
|
||||
import com.android.bean.Good;
|
||||
import com.android.bean.GoodRecords;
|
||||
import com.android.bean.GoodsType;
|
||||
import com.android.bean.ResponseData;
|
||||
import com.android.bean.User;
|
||||
import com.android.bean.queryBean.UserGoodsRecords;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GoodsListener {
|
||||
void onGetAllGoodsType(ResponseData<List<GoodsType>> responseData);
|
||||
void onGetAllGoodSuccess(ResponseData<GoodRecords> responseData);
|
||||
void onGetUserRecordsSuccess(ResponseData<BaseRecords<UserGoodsRecords>> responseData);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="20dp"/>
|
||||
<solid android:color="@color/whitesmoke"/>
|
||||
|
||||
</shape>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="20dp"/>
|
||||
<solid android:color="@color/white"/>
|
||||
</shape>
|
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp">
|
||||
<RelativeLayout
|
||||
android:id="@+id/q"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/m_hImg"-->
|
||||
<!-- android:layout_width="30dp"-->
|
||||
<!-- android:layout_height="30dp"-->
|
||||
<!-- />-->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_message_user_name"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:background="@drawable/edittext_shape1"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/teal_200"
|
||||
android:textSize="15sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/r"
|
||||
android:layout_toRightOf="@+id/q"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:background="@drawable/edittext_shape2">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_message_item_desc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:layout_marginEnd="145dp"
|
||||
android:layout_marginBottom="7dp"
|
||||
android:text="发布了"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="15sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_below="@+id/r">
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_goodsdescription"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:text="商品描述"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/tv_goods_description"
|
||||
android:text="商品描述"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_below="@+id/layout_goodsdescription"
|
||||
android:id="@+id/layout_goods"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:text="价格(元)"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/tv_message_price"
|
||||
android:text="价格"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_below="@+id/layout_goods"
|
||||
android:id="@+id/layout_message_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:text="发布时间"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/tv_message_create_time"
|
||||
android:text="发布"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_toRightOf="@+id/layout_message_time"
|
||||
android:layout_below="@+id/layout_goods"
|
||||
android:id="@+id/layout_message_seller_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginStart="100dp">
|
||||
<TextView
|
||||
android:text="发布时间"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/tv_message_seller_time"
|
||||
android:text="发布"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_below="@+id/layout_message_time"
|
||||
android:id="@+id/layout_seller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:text="卖家"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/tv_seller"
|
||||
android:text="卖家"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_toRightOf="@+id/layout_message_time"
|
||||
android:layout_below="@+id/layout_message_seller_time"
|
||||
android:id="@+id/layout_buyer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginStart="100dp">
|
||||
<TextView
|
||||
android:text="买家"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/tv_buyer"
|
||||
android:text="买家"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
Loading…
Reference in new issue