柬埔寨通 v6.1.5版本的 MD5 值为:9b68581ac30883219d6a25858a099d6b
以下内容为反编译后的 BusinessShareCardActivity.java 源代码,内容仅作参考
package net.duohuo.magappx.circle.business;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.BindString;
import butterknife.BindView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jianpuzhaitong.forum.R;
import com.zxing.encoding.EncodingHandler;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import net.duohuo.core.fresco.FrescoImageView;
import net.duohuo.core.ioc.Ioc;
import net.duohuo.core.util.FileUtil;
import net.duohuo.core.util.IUtil;
import net.duohuo.core.util.SafeJsonUtil;
import net.duohuo.magappx.MagBizWebView;
import net.duohuo.magappx.UrlScheme;
import net.duohuo.magappx.common.base.MagBaseActivity;
import net.duohuo.magappx.common.comp.share.Share;
import net.duohuo.magappx.common.comp.share.SharePopWindow;
import net.duohuo.magappx.common.util.FrescoResizeUtil;
import net.duohuo.magappx.main.login.model.UserPreference;
public class BusinessShareCardActivity extends MagBaseActivity {
@BindView(R.id.address)
TextView addressV;
@BindString(R.string.app_name)
String appName;
@BindView(R.id.avatar)
FrescoImageView avatarV;
@BindView(R.id.des)
TextView desV;
private int displayWidth;
@BindView(R.id.fromApp)
TextView fromAppV;
@BindView(R.id.heard)
FrescoImageView heardv;
private int imageHeight;
private int imageWidth;
@BindView(R.id.leav)
FrescoImageView leaV;
private int maxWebHeight;
@BindView(R.id.froum_user)
TextView namev;
@BindView(R.id.new_activity)
TextView newActivity;
@BindView(R.id.phone)
TextView phoneV;
@BindView(R.id.pic)
FrescoImageView picV;
@BindView(R.id.qrcode)
ImageView qrcodeV;
@BindView(R.id.share_card_box)
LinearLayout shareCardBoxV;
@BindView(R.id.store_name)
TextView storeNameV;
@BindView(R.id.web_fade)
View webFadeV;
@BindView(R.id.webView)
MagBizWebView webView;
JSONObject jsonObject = new JSONObject();
String url = "";
String heardPic = "";
String name = "";
String des = "";
boolean loadFinished = false;
boolean isLoadFinished = true;
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) {
int measuredHeight;
super.handleMessage(message);
if (message.what != 0 || (measuredHeight = BusinessShareCardActivity.this.webView.getMeasuredHeight()) == 0 || measuredHeight <= BusinessShareCardActivity.this.maxWebHeight) {
return;
}
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) BusinessShareCardActivity.this.webView.getLayoutParams();
layoutParams.height = BusinessShareCardActivity.this.maxWebHeight;
layoutParams.width = BusinessShareCardActivity.this.displayWidth;
BusinessShareCardActivity.this.webView.setLayoutParams(layoutParams);
BusinessShareCardActivity.this.webFadeV.setVisibility(0);
}
};
public void initWebView() {
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.business_share_card_acyivity);
int displayWidth = IUtil.getDisplayWidth() - IUtil.dip2px(this, 20.0f);
this.displayWidth = displayWidth;
this.maxWebHeight = (displayWidth * 560) / 670;
setTitle("商家名片");
int displayWidth2 = IUtil.getDisplayWidth();
ViewGroup.LayoutParams layoutParams = this.picV.getLayoutParams();
layoutParams.width = displayWidth2;
int i = (displayWidth2 * 9) / 16;
layoutParams.height = i;
this.picV.setWidthAndHeight(displayWidth2, i);
this.picV.setLayoutParams(layoutParams);
int displayWidth3 = IUtil.getDisplayWidth() - IUtil.dip2px(getActivity(), 180.0f);
ViewGroup.LayoutParams layoutParams2 = this.storeNameV.getLayoutParams();
layoutParams2.width = -2;
layoutParams2.height = -2;
this.storeNameV.setLayoutParams(layoutParams2);
this.storeNameV.setMaxWidth(displayWidth3);
this.jsonObject = JSON.parseObject(getIntent().getStringExtra("merchant"));
this.url = getIntent().getStringExtra("linkUrl");
this.heardPic = this.jsonObject.getString("head");
this.name = this.jsonObject.getString("title");
this.des = this.jsonObject.getString("des");
initWebView();
this.avatarV.asCircle(IUtil.dip2px(getActivity(), 5.0f));
this.avatarV.loadView(((UserPreference) Ioc.get(UserPreference.class)).getHead(), R.color.image_def);
this.namev.setText(((UserPreference) Ioc.get(UserPreference.class)).getName() + " 的邀请");
this.picV.loadView(this.jsonObject.getString("cover_pic"), R.color.image_def);
this.heardv.loadView(this.heardPic, R.color.image_def);
this.storeNameV.setText(this.name);
FrescoResizeUtil.loadPic(this.leaV, this.jsonObject.getString("group_icon"));
this.desV.setText(this.des);
this.phoneV.setText(this.jsonObject.getString("phone"));
this.addressV.setText(SafeJsonUtil.getString(SafeJsonUtil.getJSONObjectFromArray(SafeJsonUtil.getJSONArray(this.jsonObject, "shop_address"), 0), "place_des"));
this.newActivity.setVisibility(8);
this.webView.loadDataWithBaseURL("https://app.jpztong.com/", this.jsonObject.getString("content"), "text/html", "utf-8", null);
this.qrcodeV.setImageBitmap(EncodingHandler.createQRImage(this.url, IUtil.dip2px(this, 80.0f), BitmapFactory.decodeResource(getResources(), R.drawable.icon_256x256)));
this.fromAppV.setText(this.appName);
setDataNavi();
this.shareCardBoxV.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
BusinessShareCardActivity.this.shareCardBoxV.getViewTreeObserver().removeOnGlobalLayoutListener(this);
BusinessShareCardActivity businessShareCardActivity = BusinessShareCardActivity.this;
businessShareCardActivity.imageWidth = businessShareCardActivity.shareCardBoxV.getWidth();
BusinessShareCardActivity businessShareCardActivity2 = BusinessShareCardActivity.this;
businessShareCardActivity2.imageHeight = businessShareCardActivity2.shareCardBoxV.getHeight();
}
});
}
private void setDataNavi() {
getNavigator().setActionText("分享", new View.OnClickListener() {
@Override
public void onClick(View view) {
SharePopWindow sharePopWindow = new SharePopWindow(BusinessShareCardActivity.this.getActivity());
sharePopWindow.hideOtherFunction();
Share share = new Share();
Bitmap screen = BusinessShareCardActivity.this.getScreen();
if (screen != null && screen.getWidth() > 720) {
screen = BusinessShareCardActivity.this.setImgSize(screen);
}
share.mBitmap = screen;
share.type = 1;
share.platforms = "ALL";
share.pic = BusinessShareCardActivity.this.heardPic;
share.title = BusinessShareCardActivity.this.name;
share.description = TextUtils.isEmpty(BusinessShareCardActivity.this.des) ? "暂无签名" : BusinessShareCardActivity.this.des;
share.coverPicUrl = BusinessShareCardActivity.this.jsonObject.getString("group_icon");
share.typeText = share.personalCard;
share.toChatUrl = UrlScheme.appcode + "://userHome?userId=" + BusinessShareCardActivity.this.jsonObject.getString("merchant_id");
share.shareType = share.shareChatCard;
sharePopWindow.setShare(share);
sharePopWindow.hideShareCard();
sharePopWindow.hideShareChat();
sharePopWindow.hideShareChatItem();
sharePopWindow.show(BusinessShareCardActivity.this.getActivity());
}
});
}
public Bitmap setImgSize(Bitmap bitmap) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float f = 720.0f / width;
Matrix matrix = new Matrix();
matrix.postScale(f, f);
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
}
private long getAvailMemory() {
return Runtime.getRuntime().maxMemory();
}
public Bitmap getScreen() {
if (this.isLoadFinished) {
int height = this.webView.getHeight();
int i = this.maxWebHeight;
if (height <= i) {
i = this.webView.getHeight();
}
this.imageHeight += i;
if (this.shareCardBoxV.getHeight() != 0 && this.imageHeight > this.shareCardBoxV.getHeight() + this.webView.getContentHeight()) {
this.imageHeight = this.shareCardBoxV.getHeight();
}
this.isLoadFinished = false;
}
if (Bitmap.createBitmap(this.imageWidth, 1, Bitmap.Config.ARGB_8888).getRowBytes() * this.imageHeight >= getAvailMemory()) {
return null;
}
Bitmap createBitmap = Bitmap.createBitmap(this.imageWidth, this.imageHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
canvas.drawColor(-1);
this.shareCardBoxV.draw(canvas);
return createBitmap;
}
private String getPicPath() {
File file = new File(FileUtil.getCacheDir(), "share_qrcode.png");
if (file.exists()) {
file.delete();
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
getScreen().compress(Bitmap.CompressFormat.PNG, 90, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
return FileUtil.getCacheDir() + "/share_qrcode.png";
}
@Override
public void onDestroy() {
super.onDestroy();
this.mHandler.removeCallbacksAndMessages(null);
}
}