|
@@ -3,6 +3,9 @@ package com.android.chmo.ui.adpater;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
import android.graphics.BitmapFactory;
|
|
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
|
|
+import android.util.TypedValue;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
@@ -18,26 +21,28 @@ import com.android.chmo.ui.activity.model.ModelDetailActivity;
|
|
|
import com.android.chmo.utils.PixelUtils;
|
|
import com.android.chmo.utils.PixelUtils;
|
|
|
import com.android.chmo.utils.XUtilsImage;
|
|
import com.android.chmo.utils.XUtilsImage;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Created by Administrator on 2018/8/1.
|
|
* Created by Administrator on 2018/8/1.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
public class BrokerAdapter extends CommonAdapter<BrokerInfo> {
|
|
public class BrokerAdapter extends CommonAdapter<BrokerInfo> {
|
|
|
private BaseActivity baseActivity;
|
|
private BaseActivity baseActivity;
|
|
|
- private int imgWidth;
|
|
|
|
|
- private int imgHeight;
|
|
|
|
|
|
|
+ private int imgWidth;
|
|
|
|
|
+ private int imgHeight;
|
|
|
|
|
|
|
|
|
|
|
|
|
public BrokerAdapter(BaseActivity activity) {
|
|
public BrokerAdapter(BaseActivity activity) {
|
|
|
super(activity);
|
|
super(activity);
|
|
|
baseActivity = activity;
|
|
baseActivity = activity;
|
|
|
- imgWidth = PixelUtils.getWindowWidth() / 3-20;
|
|
|
|
|
- imgHeight = (int)Math.round(1.34 * imgWidth) ;
|
|
|
|
|
|
|
+ imgWidth = PixelUtils.getWindowWidth() / 3 - 20;
|
|
|
|
|
+ imgHeight = (int) Math.round(1.34 * imgWidth);
|
|
|
try {
|
|
try {
|
|
|
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.def_img1);
|
|
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.def_img1);
|
|
|
imgWidth = bitmap.getWidth();
|
|
imgWidth = bitmap.getWidth();
|
|
|
imgHeight = bitmap.getHeight();
|
|
imgHeight = bitmap.getHeight();
|
|
|
- }catch (OutOfMemoryError e){
|
|
|
|
|
|
|
+ } catch (OutOfMemoryError e) {
|
|
|
System.runFinalization();
|
|
System.runFinalization();
|
|
|
System.gc();
|
|
System.gc();
|
|
|
}
|
|
}
|
|
@@ -46,71 +51,93 @@ public class BrokerAdapter extends CommonAdapter<BrokerInfo> {
|
|
|
@Override
|
|
@Override
|
|
|
public View getItemView(int position, View convertView, ViewGroup parent) {
|
|
public View getItemView(int position, View convertView, ViewGroup parent) {
|
|
|
ViewHolder holder = null;
|
|
ViewHolder holder = null;
|
|
|
- if(null != convertView) {
|
|
|
|
|
|
|
+ if (null != convertView) {
|
|
|
holder = (ViewHolder) convertView.getTag();
|
|
holder = (ViewHolder) convertView.getTag();
|
|
|
}
|
|
}
|
|
|
if (null == holder) {
|
|
if (null == holder) {
|
|
|
holder = new ViewHolder();
|
|
holder = new ViewHolder();
|
|
|
convertView = mInflater.inflate(R.layout.list_broker_item, null);
|
|
convertView = mInflater.inflate(R.layout.list_broker_item, null);
|
|
|
- holder.headImage = (ImageView) convertView.findViewById(R.id.head);
|
|
|
|
|
- holder.nameView = (TextView) convertView.findViewById(R.id.name);
|
|
|
|
|
- holder.modelCountView = (TextView) convertView.findViewById(R.id.model_count);
|
|
|
|
|
|
|
+ holder.headImage = convertView.findViewById(R.id.head);
|
|
|
|
|
+ holder.nameView = convertView.findViewById(R.id.name);
|
|
|
|
|
+ holder.modelCountView = convertView.findViewById(R.id.model_count);
|
|
|
holder.brokerClick = convertView.findViewById(R.id.brokerClick);
|
|
holder.brokerClick = convertView.findViewById(R.id.brokerClick);
|
|
|
- holder.imgContainer = (LinearLayout) convertView.findViewById(R.id.imageContainer);
|
|
|
|
|
|
|
+ holder.rvPhotos = convertView.findViewById(R.id.rv_photos);
|
|
|
|
|
+ holder.rvPhotos.setLayoutManager(new LinearLayoutManager(baseActivity, LinearLayoutManager.HORIZONTAL, false));
|
|
|
convertView.setTag(holder);
|
|
convertView.setTag(holder);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
final BrokerInfo info = mList.get(position);
|
|
final BrokerInfo info = mList.get(position);
|
|
|
holder.nameView.setText(info.name);
|
|
holder.nameView.setText(info.name);
|
|
|
holder.modelCountView.setText("模特" + info.modelcount + "人");
|
|
holder.modelCountView.setText("模特" + info.modelcount + "人");
|
|
|
- XUtilsImage.display(holder.headImage, HttpApi.getImgUrl(info.logo),R.mipmap.def_img3);
|
|
|
|
|
- fillModelImages(holder, info);
|
|
|
|
|
-
|
|
|
|
|
- holder.brokerClick.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
- Intent intent = new Intent(baseActivity, BrokerModelActivity.class);
|
|
|
|
|
- intent.putExtra("broker", info);
|
|
|
|
|
- baseActivity.openPage(intent);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ XUtilsImage.display(holder.headImage, HttpApi.getImgUrl(info.logo), R.mipmap.def_img3);
|
|
|
|
|
+
|
|
|
|
|
+ photoAdapter adapter = new photoAdapter(info);
|
|
|
|
|
+ holder.rvPhotos.setAdapter(adapter);
|
|
|
|
|
+
|
|
|
|
|
+ holder.brokerClick.setOnClickListener(v -> {
|
|
|
|
|
+ Intent intent = new Intent(baseActivity, BrokerModelActivity.class);
|
|
|
|
|
+ intent.putExtra("broker", info);
|
|
|
|
|
+ baseActivity.openPage(intent);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
return convertView;
|
|
return convertView;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void fillModelImages(ViewHolder holder, BrokerInfo info) {
|
|
|
|
|
- holder.imgContainer.removeAllViews();
|
|
|
|
|
- if(info.modelphoto == null) {
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ private class ViewHolder {
|
|
|
|
|
+ ImageView headImage;
|
|
|
|
|
+ TextView nameView;
|
|
|
|
|
+ TextView modelCountView;
|
|
|
|
|
+ View brokerClick;
|
|
|
|
|
+ RecyclerView rvPhotos;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ class photoHolder extends RecyclerView.ViewHolder {
|
|
|
|
|
+
|
|
|
|
|
+ public photoHolder(View itemView) {
|
|
|
|
|
+ super(itemView);
|
|
|
}
|
|
}
|
|
|
- for (int i=0; i < info.modelphoto.size(); i++) {
|
|
|
|
|
- ImageView imageView = new ImageView(mContext);
|
|
|
|
|
- imageView.setImageResource(R.mipmap.def_img1);
|
|
|
|
|
- XUtilsImage.display(imageView, HttpApi.getImgUrl(info.modelphoto.get(i)), R.mipmap.def_img1);
|
|
|
|
|
-
|
|
|
|
|
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(imgWidth,imgHeight);
|
|
|
|
|
- lp.rightMargin = 10;
|
|
|
|
|
- holder.imgContainer.addView(imageView,lp);
|
|
|
|
|
-
|
|
|
|
|
- final String modelPk = info.photopk.get(i);
|
|
|
|
|
- imageView.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View v) {
|
|
|
|
|
- Intent intent = new Intent(baseActivity, ModelDetailActivity.class);
|
|
|
|
|
- intent.putExtra("modelPk", modelPk);
|
|
|
|
|
- baseActivity.openPage(intent);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ class photoAdapter extends RecyclerView.Adapter<photoHolder> {
|
|
|
|
|
+ private BrokerInfo data;
|
|
|
|
|
+
|
|
|
|
|
+ public void setData(BrokerInfo data) {
|
|
|
|
|
+ this.data = data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public photoAdapter(BrokerInfo data) {
|
|
|
|
|
+ this.data = data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public photoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
|
|
|
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(imgWidth, imgHeight);
|
|
|
|
|
+ params.rightMargin = 10;
|
|
|
|
|
+ ImageView imageView = new ImageView(baseActivity);
|
|
|
|
|
+ imageView.setLayoutParams(params);
|
|
|
|
|
+ return new photoHolder(imageView);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onBindViewHolder(photoHolder holder, int position) {
|
|
|
|
|
+ ImageView imageView = (ImageView) holder.itemView;
|
|
|
|
|
+ XUtilsImage.display(imageView, HttpApi.getImgUrl(data.modelphoto.get(position)), R.mipmap.def_img1);
|
|
|
|
|
+ final String modelPk = data.photopk.get(position);
|
|
|
|
|
+ imageView.setOnClickListener(v -> {
|
|
|
|
|
+ Intent intent = new Intent(baseActivity, ModelDetailActivity.class);
|
|
|
|
|
+ intent.putExtra("modelPk", modelPk);
|
|
|
|
|
+ baseActivity.openPage(intent);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int getItemCount() {
|
|
|
|
|
+ if (data != null) {
|
|
|
|
|
+ return data.modelphoto.size();
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- private class ViewHolder {
|
|
|
|
|
- ImageView headImage;
|
|
|
|
|
- TextView nameView;
|
|
|
|
|
- TextView modelCountView;
|
|
|
|
|
- View brokerClick;
|
|
|
|
|
- LinearLayout imgContainer;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|