parent
de53e6db38
commit
67b2ef13f6
@ -0,0 +1,93 @@
|
||||
package com.android.activity.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
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.android.R;
|
||||
import com.android.bean.Good;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.FutureTarget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class GoodsAdapter extends RecyclerView.Adapter<GoodsAdapter.ViewHolder> {
|
||||
private ArrayList<Good> goodArrayList;
|
||||
private Context context;
|
||||
|
||||
public GoodsAdapter(ArrayList<Good> goodArrayList,Context context) {
|
||||
this.goodArrayList = goodArrayList;
|
||||
this.context = context;
|
||||
Log.e("goodsAdapter","GoodsAdapter");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public GoodsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.goods_show_item,parent,false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull GoodsAdapter.ViewHolder holder, int position) {
|
||||
String strTvTitle;
|
||||
String strTvCount;
|
||||
String imageUrl;
|
||||
|
||||
if (goodArrayList.get(position) != null){
|
||||
strTvTitle = goodArrayList.get(position).getContent();
|
||||
strTvCount = goodArrayList.get(position).getPrice().toString();
|
||||
imageUrl = (String) goodArrayList.get(position).getImageUrlList().get(0);
|
||||
Log.e("imageUrl", (String) goodArrayList.get(position).getImageUrlList().get(0));
|
||||
holder.getTvTitle().setText(strTvTitle);
|
||||
holder.getTvCount().setText(strTvCount);
|
||||
|
||||
Glide.with(context)
|
||||
.load(imageUrl)
|
||||
.into(holder.getIvGoods());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (goodArrayList != null)
|
||||
return goodArrayList.size();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView ivGoods;
|
||||
private TextView tvTitle;
|
||||
private TextView tvCount;
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ivGoods = itemView.findViewById(R.id.iv_goods);
|
||||
tvTitle = itemView.findViewById(R.id.tv_title);
|
||||
tvCount = itemView.findViewById(R.id.tv_count);
|
||||
}
|
||||
|
||||
public ImageView getIvGoods() {
|
||||
return ivGoods;
|
||||
}
|
||||
|
||||
public TextView getTvTitle() {
|
||||
return tvTitle;
|
||||
}
|
||||
|
||||
|
||||
public TextView getTvCount() {
|
||||
return tvCount;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.android.utils.constraint;
|
||||
|
||||
public class LoginConstraint {
|
||||
public static final String AppId_VALUE = "appId:b34ac21286ae45938add627b418a4871";
|
||||
public static final String AppSecret_VALUE = "appId:b34ac21286ae45938add627b418a4871";
|
||||
public static final String BASE_URL = "http://47.107.52.7:88/member/";
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11,9h2L13,6h3L16,4h-3L13,1h-2v3L8,4v2h3v3zM7,18c-1.1,0 -1.99,0.9 -1.99,2S5.9,22 7,22s2,-0.9 2,-2 -0.9,-2 -2,-2zM17,18c-1.1,0 -1.99,0.9 -1.99,2s0.89,2 1.99,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM7.17,14.75l0.03,-0.12 0.9,-1.63h7.45c0.75,0 1.41,-0.41 1.75,-1.03l3.86,-7.01L19.42,4h-0.01l-1.1,2 -2.76,5L8.53,11l-0.13,-0.27L6.16,6l-0.95,-2 -0.94,-2L1,2v2h2l3.6,7.59 -1.35,2.45c-0.16,0.28 -0.25,0.61 -0.25,0.96 0,1.1 0.9,2 2,2h12v-2L7.42,15c-0.13,0 -0.25,-0.11 -0.25,-0.25z"/>
|
||||
</vector>
|
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 76 KiB |
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:padding="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:id="@+id/iv_goods"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="90dp"
|
||||
>
|
||||
</ImageView>
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/iv_goods"
|
||||
android:text="手机"
|
||||
android:textSize="20dp"
|
||||
android:layout_marginTop="10dp">
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/tv_price"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_title"
|
||||
android:text="价格: "
|
||||
android:textSize="15dp"
|
||||
android:textColor="#FF8F03"
|
||||
android:layout_marginTop="15dp">
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/tv_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/tv_price"
|
||||
android:layout_toRightOf="@id/tv_price"
|
||||
android:textSize="15dp"
|
||||
android:text="1000"
|
||||
android:textColor="#FF8F03">
|
||||
</TextView>
|
||||
<!-- <Button-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content">-->
|
||||
|
||||
<!-- </Button>-->
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
Loading…
Reference in new issue