柬埔寨通 v6.1.5版本的 MD5 值为:9b68581ac30883219d6a25858a099d6b
以下内容为反编译后的 BusinessHomeDataView.java 源代码,内容仅作参考
package net.duohuo.magappx.circle.business.dataview;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
import butterknife.BindViews;
import butterknife.OnClick;
import com.jianpuzhaitong.forum.R;
import com.tencent.smtt.sdk.WebView;
import com.umeng.socialize.common.SocializeConstants;
import java.util.regex.Pattern;
import net.duohuo.core.build.UrlSchemeProxy;
import net.duohuo.core.dataview.DataView;
import net.duohuo.core.db.DhDB;
import net.duohuo.core.dialog.DialogCallBack;
import net.duohuo.core.dialog.IDialog;
import net.duohuo.core.fresco.FrescoImageView;
import net.duohuo.core.ioc.Ioc;
import net.duohuo.core.ioc.IocContainer;
import net.duohuo.core.net.Net;
import net.duohuo.core.net.Result;
import net.duohuo.core.net.Task;
import net.duohuo.core.util.IUtil;
import net.duohuo.magappx.API;
import net.duohuo.magappx.MagBizWebView;
import net.duohuo.magappx.UrlScheme;
import net.duohuo.magappx.chat.activity.ChatMapActivity;
import net.duohuo.magappx.circle.business.ShopPopuView;
import net.duohuo.magappx.circle.business.model.BusinessHomeBean;
import net.duohuo.magappx.circle.business.model.BusinessShopInfoBean;
import net.duohuo.magappx.circle.business.model.UserRecordClickDbBean;
import net.duohuo.magappx.common.base.MagBaseActivity;
import net.duohuo.magappx.common.util.Constants;
import net.duohuo.magappx.common.util.FrescoResizeUtil;
import net.duohuo.magappx.common.view.FlowLayout;
import net.duohuo.magappx.main.login.UserApi;
@Deprecated
public class BusinessHomeDataView extends DataView<BusinessHomeBean> {
MagBaseActivity activity;
@BindView(R.id.attention_img)
ImageView attentionImg;
@BindView(R.id.attention_text)
TextView attentionTextV;
@BindView(R.id.bg_view)
View bgView;
@BindView(R.id.bottom_view)
View bottomView;
@BindView(R.id.webView)
MagBizWebView bottomWebView;
BusinessShopInfoBean businessShopInfoBean;
@BindView(R.id.business_shop)
View businessShopV;
@BindView(R.id.click_count)
TextView clickCount;
@BindView(R.id.content)
TextView contentV;
DhDB db;
@BindView(R.id.discount)
View discountView;
@BindView(R.id.distribution_price)
TextView distributionPrice;
@BindView(R.id.pic_error_view)
ViewGroup errorView;
private boolean isNoAttention;
@BindViews({R.id.coupon, R.id.promotion, R.id.pay})
TextView[] labels;
@BindView(R.id.layout)
ViewGroup layoutV;
@BindView(R.id.leav)
FrescoImageView leavPic;
@BindView(R.id.like_pic)
ImageView likePic;
boolean loadFinished;
@BindView(R.id.padding_view)
View paddingView;
@BindView(R.id.phone)
TextView phoneTextView;
@BindView(R.id.pic)
FrescoImageView picV;
@BindView(R.id.pic_view)
LinearLayout pivView;
@BindViews({R.id.score_img1, R.id.score_img2, R.id.score_img3, R.id.score_img4, R.id.score_img5})
ImageView[] scoreImgs;
@BindView(R.id.score)
TextView scoreV;
@BindView(R.id.scrollView)
View scrollView;
@BindView(R.id.shop_circle)
View shopCircle;
@BindView(R.id.shop_count)
TextView shopCount;
@BindView(R.id.shop_img)
FrescoImageView shopImg;
@BindView(R.id.shop_name)
TextView shopName;
@BindView(R.id.shop_time)
TextView shopTime;
@BindView(R.id.shop_view)
ViewGroup shopView;
@BindView(R.id.starting_price)
TextView startingPrice;
@BindView(R.id.store_name)
TextView storeName;
int[] tagBorders;
int[] tagTextColors;
@BindView(R.id.title)
TextView titleText;
@BindView(R.id.topic_flow_layout)
FlowLayout topicFlowLayoutV;
UserRecordClickDbBean userRecordClickDbBean;
@BindView(R.id.youhui_card)
LinearLayout youhuiCardView;
@BindView(R.id.youhui_layout)
LinearLayout youhuiView;
public void initWebView() {
}
public BusinessHomeDataView(Context context, String str, BusinessShopInfoBean businessShopInfoBean) {
super(context);
this.loadFinished = false;
this.tagBorders = new int[]{R.drawable.btn_round_pink_border, R.drawable.bg_round_green_border, R.drawable.btn_round_cyan_border, R.drawable.btn_round_purple_border};
setView(View.inflate(context, R.layout.layout_business_home_index, null));
this.activity = (MagBaseActivity) context;
if (TextUtils.isEmpty(str) || "1".equals(str)) {
display();
} else {
hide();
}
this.businessShopInfoBean = businessShopInfoBean;
this.paddingView.setVisibility(8);
this.businessShopV.setVisibility(8);
int displayWidth = IUtil.getDisplayWidth() / 4;
ViewGroup.LayoutParams layoutParams = this.shopImg.getLayoutParams();
layoutParams.width = displayWidth;
layoutParams.height = (displayWidth * 27) / 40;
this.shopImg.setLayoutParams(layoutParams);
for (int i = 0; i < 5; i++) {
this.scoreImgs[i].setImageResource(R.drawable.tag_gstar);
}
int displayWidth2 = IUtil.getDisplayWidth();
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.picV.getLayoutParams();
layoutParams2.width = displayWidth2;
int i2 = (displayWidth2 * 9) / 16;
layoutParams2.height = i2;
this.picV.setWidthAndHeight(displayWidth2, i2);
this.picV.setLayoutParams(layoutParams2);
initWebView();
this.db = (DhDB) Ioc.get(DhDB.class);
int displayWidth3 = IUtil.getDisplayWidth() - IUtil.dip2px(getContext(), 173.0f);
ViewGroup.LayoutParams layoutParams3 = this.storeName.getLayoutParams();
layoutParams3.width = -2;
layoutParams3.height = -2;
this.storeName.setLayoutParams(layoutParams3);
this.storeName.setMaxWidth(displayWidth3);
setShopInfo(businessShopInfoBean);
}
private void display() {
this.errorView.setVisibility(8);
this.bottomView.setVisibility(0);
this.scrollView.setVisibility(0);
}
private void hide() {
this.errorView.setVisibility(0);
this.bottomView.setVisibility(8);
this.scrollView.setVisibility(8);
}
public void setShopInfo(BusinessShopInfoBean businessShopInfoBean) {
for (int i = 0; i < 3; i++) {
this.labels[i].setVisibility(8);
}
if (businessShopInfoBean != null) {
this.paddingView.setVisibility(0);
this.businessShopV.setVisibility(0);
this.shopImg.loadView(businessShopInfoBean.getIcon(), R.color.image_def);
this.shopName.setText(businessShopInfoBean.getName());
this.scoreV.setText(businessShopInfoBean.getLevel());
SpannableString spannableString = new SpannableString("起送¥" + businessShopInfoBean.getSendPrice());
ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.red_r));
spannableString.setSpan(foregroundColorSpan, 2, ("¥" + businessShopInfoBean.getSendPrice()).length() + 2, 18);
this.startingPrice.setText(spannableString);
SpannableString spannableString2 = new SpannableString("配送¥" + businessShopInfoBean.getDeliveryPrice());
StringBuilder sb = new StringBuilder();
sb.append("¥");
sb.append(businessShopInfoBean.getDeliveryPrice());
spannableString2.setSpan(foregroundColorSpan, 2, sb.toString().length() + 2, 18);
this.distributionPrice.setText(spannableString2);
int size = businessShopInfoBean.getXygActivity().size() > 3 ? 3 : businessShopInfoBean.getXygActivity().size();
for (int i2 = 0; i2 < size; i2++) {
this.labels[i2].setVisibility(0);
this.labels[i2].setText(businessShopInfoBean.getXygActivity().get(i2));
}
float parseFloat = Float.parseFloat(businessShopInfoBean.getLevel());
if (parseFloat == 0.0f) {
for (int i3 = 0; i3 < 5; i3++) {
this.scoreImgs[i3].setImageResource(R.drawable.tag_gstar);
}
}
if (parseFloat == 0.5f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_halfstar);
for (int i4 = 1; i4 < 5; i4++) {
this.scoreImgs[i4].setImageResource(R.drawable.tag_gstar);
}
}
if (parseFloat == 1.0f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
for (int i5 = 1; i5 < 5; i5++) {
this.scoreImgs[i5].setImageResource(R.drawable.tag_gstar);
}
}
if (parseFloat == 1.5f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[1].setImageResource(R.drawable.tag_halfstar);
for (int i6 = 2; i6 < 5; i6++) {
this.scoreImgs[i6].setImageResource(R.drawable.tag_gstar);
}
}
if (parseFloat == 2.0f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[1].setImageResource(R.drawable.tag_rstar);
for (int i7 = 2; i7 < 5; i7++) {
this.scoreImgs[i7].setImageResource(R.drawable.tag_gstar);
}
}
if (parseFloat == 2.5f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[1].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[2].setImageResource(R.drawable.tag_halfstar);
this.scoreImgs[3].setImageResource(R.drawable.tag_gstar);
this.scoreImgs[4].setImageResource(R.drawable.tag_gstar);
}
if (parseFloat == 3.0f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[1].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[2].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[3].setImageResource(R.drawable.tag_gstar);
this.scoreImgs[4].setImageResource(R.drawable.tag_gstar);
}
if (parseFloat == 3.5f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[1].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[2].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[3].setImageResource(R.drawable.tag_halfstar);
this.scoreImgs[4].setImageResource(R.drawable.tag_gstar);
}
if (parseFloat == 4.0f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[1].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[2].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[3].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[4].setImageResource(R.drawable.tag_gstar);
}
if (parseFloat == 4.5f) {
this.scoreImgs[0].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[1].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[2].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[3].setImageResource(R.drawable.tag_rstar);
this.scoreImgs[4].setImageResource(R.drawable.tag_halfstar);
}
if (parseFloat == 5.0f) {
for (int i8 = 0; i8 < 5; i8++) {
this.scoreImgs[i8].setImageResource(R.drawable.tag_rstar);
}
}
}
}
@Override
public void bindView(final BusinessHomeBean businessHomeBean) {
this.picV.loadView(businessHomeBean.getCoverPic(), R.color.image_def);
this.storeName.setText(businessHomeBean.getTitle());
this.shopTime.setText(businessHomeBean.getDes());
FrescoResizeUtil.loadPic(this.leavPic, businessHomeBean.getGroupIcon());
UserRecordClickDbBean userRecordClickDbBean = (UserRecordClickDbBean) this.db.queryFrist(UserRecordClickDbBean.class, "userId = ?", businessHomeBean.getMerchantId());
this.userRecordClickDbBean = userRecordClickDbBean;
if (userRecordClickDbBean != null && userRecordClickDbBean.userId == Integer.parseInt(businessHomeBean.getMerchantId())) {
this.likePic.setBackgroundResource(R.drawable.merchant_home_like);
} else {
this.likePic.setBackgroundResource(R.drawable.merchant_home_like_n);
}
this.clickCount.setText(businessHomeBean.getClick() + "喜欢");
this.phoneTextView.setText(businessHomeBean.getPhone());
this.titleText.setText(businessHomeBean.getShopAddresses().get(0).getTitle());
this.contentV.setText(businessHomeBean.getShopAddresses().get(0).getPlaceDes());
this.shopCount.setText(businessHomeBean.getShopAddressCount() + "家门店");
this.shopCount.setVisibility(businessHomeBean.getShopAddressCount() == 1 ? 8 : 0);
int displayWidth = (IUtil.getDisplayWidth() - IUtil.dip2px(getContext(), 80.0f)) / IUtil.dip2px(getContext(), 50.0f);
int size = businessHomeBean.getPhotoAlba().size();
this.pivView.removeAllViews();
if (size < displayWidth) {
for (int i = 0; i < size; i++) {
FrescoImageView frescoImageView = new FrescoImageView(getContext());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(IUtil.dip2px(getContext(), 45.0f), IUtil.dip2px(getContext(), 45.0f));
layoutParams.rightMargin = IUtil.dip2px(getContext(), 5.0f);
frescoImageView.setLayoutParams(layoutParams);
frescoImageView.loadView(businessHomeBean.getPhotoAlba().get(i).getPicUrl(), R.color.image_def);
this.pivView.addView(frescoImageView);
}
} else {
for (int i2 = 0; i2 < displayWidth; i2++) {
FrescoImageView frescoImageView2 = new FrescoImageView(getContext());
LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(IUtil.dip2px(getContext(), 45.0f), IUtil.dip2px(getContext(), 45.0f));
layoutParams2.rightMargin = IUtil.dip2px(getContext(), 5.0f);
frescoImageView2.setLayoutParams(layoutParams2);
frescoImageView2.loadView(businessHomeBean.getPhotoAlba().get(i2).getPicUrl(), R.color.image_def);
this.pivView.addView(frescoImageView2);
}
}
this.topicFlowLayoutV.removeAllViews();
if (businessHomeBean.getTags() != null && businessHomeBean.getTags().size() > 0) {
for (int i3 = 0; i3 < businessHomeBean.getTags().size(); i3++) {
TextView textView = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.tags_textview, (ViewGroup) null);
textView.setText(businessHomeBean.getTags().get(i3).getName());
this.topicFlowLayoutV.addView(textView);
GradientDrawable gradientDrawable = (GradientDrawable) textView.getBackground();
if (!TextUtils.isEmpty(businessHomeBean.getTags().get(i3).getColor())) {
gradientDrawable.setStroke(2, Color.parseColor(businessHomeBean.getTags().get(i3).getColor()));
textView.setTextColor(Color.parseColor(businessHomeBean.getTags().get(i3).getColor()));
} else {
textView.setBackgroundResource(this.tagBorders[0]);
textView.setTextColor(this.tagTextColors[0]);
}
}
}
if (businessHomeBean.getBusinessCardCount() == 0) {
this.youhuiView.setVisibility(8);
this.youhuiCardView.setVisibility(8);
} else {
this.youhuiView.setVisibility(0);
this.youhuiCardView.setVisibility(0);
int size2 = businessHomeBean.getBusinessCards().size() <= 3 ? businessHomeBean.getBusinessCards().size() : 3;
for (final int i4 = 0; i4 < size2; i4++) {
View inflate = LayoutInflater.from(getContext()).inflate(R.layout.coupon_layout, (ViewGroup) null);
this.youhuiCardView.addView(inflate);
((LinearLayout) inflate.findViewById(R.id.coupon_layout)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
UrlScheme.toUrl(BusinessHomeDataView.this.getContext(), businessHomeBean.getBusinessCards().get(i4).getLink());
}
});
((FrescoImageView) inflate.findViewById(R.id.youhui_pic)).loadView(businessHomeBean.getBusinessCards().get(i4).getBusinessIcon(), R.color.image_def);
((TextView) inflate.findViewById(R.id.youhui_title)).setText(businessHomeBean.getBusinessCards().get(i4).getName());
((TextView) inflate.findViewById(R.id.youhui_content)).setText(businessHomeBean.getBusinessCards().get(i4).getDes());
((TextView) inflate.findViewById(R.id.surplus_number)).setText("剩余" + businessHomeBean.getBusinessCards().get(i4).getNumber() + "份");
}
}
bindView(businessHomeBean.getRelationStatus());
businessHomeBean.getBusinessCircleNumber();
this.shopCircle.setVisibility((businessHomeBean.getBusinessCircleNumber() == 0 || businessHomeBean.getBusinessCircleNumber() == 0) ? 8 : 0);
this.bottomWebView.setVisibility(TextUtils.isEmpty(businessHomeBean.getContent()) ? 8 : 0);
this.bgView.setVisibility(TextUtils.isEmpty(businessHomeBean.getContent()) ? 8 : 0);
if (TextUtils.isEmpty(businessHomeBean.getContent())) {
return;
}
this.bottomWebView.loadDataWithBaseURL("https://app.jpztong.com/", businessHomeBean.getContent(), "text/html", "utf-8", null);
}
public boolean isNumeric(String str) {
return Pattern.compile("[0-9]*").matcher(str).matches();
}
@OnClick({R.id.order, R.id.business_shop})
public void orderClick() {
if (this.businessShopInfoBean != null) {
UrlScheme.toUrl(getContext(), this.businessShopInfoBean.getLink());
}
}
@OnClick({R.id.pic})
public void clickPic() {
UrlScheme.toUrl(getContext(), getData().getCoverPicLink());
}
@OnClick({R.id.like_view})
public void lickClick() {
StringBuilder sb;
boolean isNumeric = isNumeric(getData().getClick());
if (this.userRecordClickDbBean == null) {
UserRecordClickDbBean userRecordClickDbBean = new UserRecordClickDbBean();
this.userRecordClickDbBean = userRecordClickDbBean;
userRecordClickDbBean.userId = Integer.parseInt(getData().getMerchantId());
this.db.save(this.userRecordClickDbBean);
this.likePic.setBackgroundResource(R.drawable.merchant_home_like);
TextView textView = this.clickCount;
if (isNumeric) {
sb = new StringBuilder();
sb.append(Integer.parseInt(getData().getClick()) + 1);
} else {
sb = new StringBuilder();
sb.append(getData().getClick());
}
sb.append("喜欢");
textView.setText(sb.toString());
}
}
@OnClick({R.id.youhui_text})
public void YouhuiClick() {
UrlSchemeProxy.allCoupon(getContext()).userId(getData().getMerchantId()).go();
}
@OnClick({R.id.photo_layout, R.id.phone_layout, R.id.address_layout, R.id.shop_circle, R.id.guanzhu_layout, R.id.consultation})
public void onClick(View view) {
switch (view.getId()) {
case R.id.address_layout:
if (getData().getShopAddressCount() == 1) {
Intent intent = new Intent(this.context, (Class<?>) ChatMapActivity.class);
intent.putExtra(Constants.LATITUDE, getData().getShopAddresses().get(0).getLat());
intent.putExtra(Constants.LONGITUDE, getData().getShopAddresses().get(0).getLng());
intent.putExtra("title", getData().getShopAddresses().get(0).getTitle());
intent.putExtra("des", getData().getShopAddresses().get(0).getPlaceDes());
intent.putExtra("isWatching", true);
this.context.startActivity(intent);
return;
}
UrlSchemeProxy.storeActivity(this.context).userId(getData().getMerchantId()).go();
return;
case R.id.consultation:
new ShopPopuView(getContext(), getData()).showAtLocation(this.bottomView, 17, 0, 0);
return;
case R.id.guanzhu_layout:
guanzhu();
return;
case R.id.phone_layout:
call();
return;
case R.id.photo_layout:
UrlSchemeProxy.photoActivity(getContext()).title(getData().getTitle()).userId(getData().getMerchantId()).go();
return;
case R.id.shop_circle:
if (getData().getBusinessCircleNumber() == 1) {
UrlSchemeProxy.businessCircle(this.context).fid(getData().getFid()).circleId(Integer.valueOf(getData().getCircleId())).go();
return;
} else {
UrlSchemeProxy.business_circle(this.context).userId(getData().getMerchantId()).go();
return;
}
default:
return;
}
}
public void call() {
((IDialog) IocContainer.getShare().get(IDialog.class)).showDialog(getContext(), "", "是否要拨打电话" + getData().getPhone(), "取消", "确定", new DialogCallBack() {
@Override
public void onClick(int i) {
if (i == -1) {
Intent intent = new Intent("android.intent.action.DIAL");
intent.setData(Uri.parse(WebView.SCHEME_TEL + BusinessHomeDataView.this.getData().getPhone()));
BusinessHomeDataView.this.getContext().startActivity(intent);
}
}
});
}
public void guanzhu() {
UserApi.afterLogin(this.activity, new UserApi.LoginCallBack() {
@Override
public void onLogin() {
BusinessHomeDataView businessHomeDataView = BusinessHomeDataView.this;
businessHomeDataView.isNoAttention = -1 == businessHomeDataView.getData().getRelationStatus();
if (!BusinessHomeDataView.this.isNoAttention) {
((IDialog) IocContainer.getShare().get(IDialog.class)).showDialog(BusinessHomeDataView.this.context, "", "是否要取消关注?", "否", "是", new DialogCallBack() {
@Override
public void onClick(int i) {
if (i == -1) {
BusinessHomeDataView.this.attentionToNet(API.User.fansRemove, true, 0);
}
}
});
} else {
BusinessHomeDataView.this.attentionToNet(API.User.fansAdd, false, -1);
}
}
});
}
public void attentionToNet(String str, boolean z, final int i) {
Net url = Net.url(str);
if (z) {
url.param("remove_his", Integer.valueOf(i));
}
url.param(SocializeConstants.TENCENT_UID, getData().getMerchantId());
url.get(new Task<Result>() {
@Override
public void onResult(Result result) {
if (result.success()) {
if (i == -1) {
BusinessHomeDataView.this.bindView(0);
BusinessHomeDataView.this.getData().setRelationStatus(0);
} else {
BusinessHomeDataView.this.bindView(-1);
BusinessHomeDataView.this.getData().setRelationStatus(-1);
}
}
}
});
}
public void bindView(int i) {
boolean z = -1 == i;
this.isNoAttention = z;
this.attentionTextV.setText(z ? "关注" : "已关注");
this.attentionImg.setImageResource(this.isNoAttention ? R.drawable.merchant_ciecle_icon_guanzhu3x : R.drawable.merchant_ciecle_icon_yiguanzhu3x);
}
}