Files
assistant-android/app/src/main/java/com/gh/gamecenter/ShareGhActivity.java

76 lines
2.5 KiB
Java

package com.gh.gamecenter;
import android.content.*;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.*;
import butterknife.*;
import com.gh.base.BaseActivity;
import com.gh.common.util.*;
/**
* Created by khy on 2017/2/6.
*/
public class ShareGhActivity extends BaseActivity {
@BindView(R.id.gh_address_qrcode)
ImageView mGhQrcode;
@BindView(R.id.gh_address_tv)
TextView mGhAddress;
@BindView(R.id.wifi_share_btn)
Button mWifiShareBtn;
@BindView(R.id.content_ll)
LinearLayout mContentLl;
@BindView(R.id.share_rl)
RelativeLayout mShareRl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View contentView = View.inflate(this, R.layout.activity_share_gh, null);
init(contentView, "分享光环");
ButterKnife.bind(this);
mGhAddress.setText(Html.fromHtml("<u>" + "www.ghzhushou.com" + "</u>"));
createQrCode();
ShareUtils.getInstance(this).showShareWindows(mShareRl, "http://www.ghzhushou.com/link?source=appshare300", "光环助手"
, "http://image.ghzhushou.com/pic/57d604808ab49e467d8b4568.png", null, false, false);
}
@OnClick(R.id.wifi_share_btn)
public void skipWifiShare() {
Intent intent = new Intent(this, ShareGhWfifActivity.class);
startActivity(intent);
}
@OnClick(R.id.gh_address_tv)
public void copyAddress() {
ClipboardManager cmb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setText("http://www.ghzhushou.com/link?source=appshare100");
Utils.toast(this, "网址复制成功,请到微信/QQ粘贴分享");
}
private void createQrCode() {
new Thread(new Runnable() {
@Override
public void run() {
final String filePath = getExternalCacheDir().getPath() + "/ShareImg/ShareQRCode.jpg";
boolean success = QRCodeUtils.createQRImage("http://www.ghzhushou.com/link?source=appshare100"
, 200, 200, filePath, ShareGhActivity.this);
if (success) {
runOnUiThread(new Runnable() {
@Override
public void run() {
mGhQrcode.setImageBitmap(BitmapFactory.decodeFile(filePath));
}
});
}
}
}).start();
}
}