diff --git a/app/build.gradle b/app/build.gradle
index c18dd3a469..e5a42e50fc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -124,4 +124,7 @@ dependencies {
// compile 'com.jakewharton.rxbinding:rxbinding-design:0.3.0'
//添加友盟依赖工程
compile project(':PushSDK')
+ // zxing 二维码扫描以及生成
+ compile 'com.google.zxing:core:3.2.1'
+ compile 'com.google.zxing:android-core:3.2.1'
}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/common/util/DialogUtils.java b/app/src/main/java/com/gh/common/util/DialogUtils.java
index 7309a8591f..846b97c6df 100644
--- a/app/src/main/java/com/gh/common/util/DialogUtils.java
+++ b/app/src/main/java/com/gh/common/util/DialogUtils.java
@@ -10,6 +10,7 @@ import android.text.Html;
import android.text.Spanned;
import android.view.View;
import android.view.Window;
+import android.widget.CheckBox;
import android.widget.TextView;
import com.gh.gamecenter.R;
@@ -88,6 +89,66 @@ public class DialogUtils {
dialog.show();
}
+ public static void showInstallHintDialog(Context context ,final ConfiremListener cmListener) {
+
+
+ final Dialog dialog = new Dialog(context);
+
+ View view = View.inflate(context, R.layout.dialog_install_hint, null);
+
+ // 标题
+ TextView alertdialog_title = (TextView) view.findViewById(R.id.installhint_title);
+ alertdialog_title.setText("重要提示");
+ Spanned content = Html.fromHtml("如果您使用的是华为手机或OPPO手机,安装游戏时请选择“" +
+ "继续安装" +
+ "”(请记住不要选择“官方推荐”或“软件商店安装”)");
+ // 内容
+ TextView alertdialog_content = (TextView) view.findViewById(R.id.installhint_content);
+ alertdialog_content.setText(content);
+
+ // 确定按钮
+ TextView installhint_confirm = (TextView) view.findViewById(R.id.installhint_confirm);
+ installhint_confirm.setText("知道了");
+
+ final CheckBox installhint_checkBox = (CheckBox) view.findViewById(R.id.installhint_checkbox);
+
+ TextView installhint_cancel = (TextView) view.findViewById(R.id.installhint_cancel);
+
+ installhint_cancel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (installhint_checkBox.isChecked()) {
+ installhint_checkBox.setChecked(false);
+ } else {
+ installhint_checkBox.setChecked(true);
+ }
+ }
+ });
+
+ installhint_confirm.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dialog.dismiss();
+ if (installhint_checkBox.isChecked()) {
+ if (cmListener != null) {
+ cmListener.onConfirem();
+ }
+ }
+ }
+ });
+
+ dialog.setOnDismissListener(new Dialog.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ isShow = false;
+ }
+ });
+
+ dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ dialog.setContentView(view);
+ dialog.show();
+ }
+
public static void showHintDialog(Context context, String title, CharSequence msg, String confirm) {
final Dialog dialog = new Dialog(context);
diff --git a/app/src/main/java/com/gh/common/util/GiftUtils.java b/app/src/main/java/com/gh/common/util/GiftUtils.java
index 8dc19fa8eb..96ae560ac4 100644
--- a/app/src/main/java/com/gh/common/util/GiftUtils.java
+++ b/app/src/main/java/com/gh/common/util/GiftUtils.java
@@ -58,11 +58,11 @@ public class GiftUtils {
}
//初始化存号箱 获取存号箱所有礼包
- public static void getCunHaoXiang(Context context) {
- getCunHaoXiang(context, true);
+ public static void getCunHaoXiang(final Context context, final GiftDao giftDao) {
+ getCunHaoXiang(context, true, giftDao);
}
- private static void getCunHaoXiang(final Context context, final boolean isCheck) {
+ private static void getCunHaoXiang(final Context context, final boolean isCheck, final GiftDao giftDao) {
new Thread(new Runnable() {
@Override
@@ -73,7 +73,7 @@ public class GiftUtils {
.subscribe(new Response>(){
@Override
public void onResponse(List response) {
- GiftDao giftDao = new GiftDao(context);
+ super.onResponse(response);
for (GiftEntity giftEntity : response) {
giftDao.add(new GiftInfo(giftEntity.getGiftId(), giftEntity.getContent(), giftEntity.getIcon()
, giftEntity.getName(),giftEntity.getPlatform(), giftEntity.getGiftStatus()
@@ -86,10 +86,11 @@ public class GiftUtils {
@Override
public void onFailure(Throwable e) {
+ super.onFailure(e);
if (e instanceof HttpException) {
HttpException exception = (HttpException) e;
if (exception.code() == 401) {
- getCunHaoXiang(context, false);
+ getCunHaoXiang(context, false, giftDao);
return;
}
}
@@ -207,7 +208,7 @@ public class GiftUtils {
switch (giftEntity.getGiftStatus()) {
case "coming":
- giftBtn.setText("未开始");
+ giftBtn.setText("未开抢");
giftBtn.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "ling":
@@ -220,14 +221,18 @@ public class GiftUtils {
break;
case "used_up":
giftBtn.setText("已领光");
- giftBtn.setBackgroundResource(R.drawable.textview_cancel_style);
+ giftBtn.setBackgroundResource(R.drawable.textview_cancel_up);
break;
case "finish":
giftBtn.setText("已结束");
- giftBtn.setBackgroundResource(R.drawable.textview_cancel_style);
+ giftBtn.setBackgroundResource(R.drawable.textview_cancel_up);
break;
- case "check":
- giftBtn.setText("查看");
+ case "linged":
+ giftBtn.setText("已领取");
+ giftBtn.setBackgroundResource(R.drawable.textview_blue_style);
+ break;
+ case "taoed":
+ giftBtn.setText("已淘号");
giftBtn.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "copy":
@@ -245,9 +250,9 @@ public class GiftUtils {
if (isInstallRequired && !isAppInstalled(giftBtn.getContext(), giftEntity.getPackageName())) {
DialogUtils.showHintDialog(giftBtn.getContext(), "条件不符"
- , "请检查是否符合领取条件:安装游戏" + giftEntity.getGame().getName()
+ , "请先安装《" + giftEntity.getGame().getName()
+ PlatformUtils.getInstance(giftBtn.getContext())
- .getPlatformName(giftEntity.getPlatform()) + "版", "知道了");
+ .getPlatformName(giftEntity.getPlatform()) + "》版", "知道了");
return;
}
@@ -279,16 +284,27 @@ public class GiftUtils {
return;
}
- Utils.toast(giftBtn.getContext(), "领取成功");
+// Utils.toast(giftBtn.getContext(), "领取成功");
giftDao.add(new GiftInfo(giftEntity.getId(), giftEntity.getContent(), giftEntity.getIcon()
, giftEntity.getName(),giftEntity.getPlatform(), giftEntity.getGiftStatus(), giftEntity.getGame().getId()
, giftEntity.getGame().getName(), giftCode, giftEntity.getAvailable(), giftEntity.getTotal()));
EventBus.getDefault().post(new EBReuse("giftChanged"));
- giftEntity.setGiftStatus("check");
+ giftEntity.setGiftStatus("linged");
adapter.initGiftDao();
adapter.notifyDataSetChanged();
+
+ final String finalGiftCode = giftCode;
+ DialogUtils.showWarningDialog(giftBtn.getContext(), "领取成功", "礼包码:" + giftCode +
+ "\n请尽快使用,礼包码将于60分钟后进入淘号池"
+ , "关闭", " 复制礼包码"
+ , new DialogUtils.ConfiremListener() {
+ @Override
+ public void onConfirem() {
+ copyLink(finalGiftCode, giftBtn.getContext());
+ }
+ }, null);
}
@Override
@@ -308,8 +324,8 @@ public class GiftUtils {
Utils.toast(giftBtn.getContext(), "礼包领取时间已结束");
} else if ("fetched".equals(detail)) {
Utils.toast(giftBtn.getContext(), "你已领过这个礼包了");
- getCunHaoXiang(giftBtn.getContext());
- giftBtn.setText("查看");
+ getCunHaoXiang(giftBtn.getContext(), giftDao);
+ giftBtn.setText("复制");
giftBtn.setBackgroundResource(R.drawable.textview_blue_style);
} else if ("try tao".equals(detail) || "used up".equals(detail)) {
DialogUtils.showHintDialog(giftBtn.getContext(), "礼包已领光"
@@ -358,9 +374,20 @@ public class GiftUtils {
EventBus.getDefault().post(new EBReuse("giftChanged"));
- giftEntity.setGiftStatus("check");
+ giftEntity.setGiftStatus("taoed");
adapter.initGiftDao();
adapter.notifyDataSetChanged();
+
+ final String finalGiftCode = giftCode;
+ DialogUtils.showWarningDialog(giftBtn.getContext(), "淘号成功", "礼包码:" + giftCode +
+ "\n淘号礼包不保证可用,请尽快进入游戏尝试兑换"
+ , "关闭", " 复制礼包码"
+ , new DialogUtils.ConfiremListener() {
+ @Override
+ public void onConfirem() {
+ copyLink(finalGiftCode, giftBtn.getContext());
+ }
+ }, null);
}
@Override
@@ -380,8 +407,8 @@ public class GiftUtils {
Utils.toast(giftBtn.getContext(), "礼包领取时间已结束");
} else if ("fetched".equals(detail)) {
Utils.toast(giftBtn.getContext(), "你已领过这个礼包了");
- getCunHaoXiang(giftBtn.getContext());
- giftBtn.setText("查看");
+ getCunHaoXiang(giftBtn.getContext(), giftDao);
+ giftBtn.setText("复制");
giftBtn.setBackgroundResource(R.drawable.textview_blue_style);
} else if ("try tao".equals(detail) || "used up".equals(detail)) {
DialogUtils.showHintDialog(giftBtn.getContext(), "礼包已领光"
@@ -429,6 +456,6 @@ public class GiftUtils {
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setText(copyContent);
- Utils.toast(context,copyContent + "复制成功");
+ Utils.toast(context,copyContent + " 复制成功");
}
}
diff --git a/app/src/main/java/com/gh/common/util/NotificationUtils.java b/app/src/main/java/com/gh/common/util/NotificationUtils.java
index 706f256446..33e9a6b2d3 100644
--- a/app/src/main/java/com/gh/common/util/NotificationUtils.java
+++ b/app/src/main/java/com/gh/common/util/NotificationUtils.java
@@ -32,18 +32,18 @@ public class NotificationUtils {
+ PlatformUtils.getInstance(context).getPlatformName(downloadEntity.getPlatform());
} else {
if (downloadEntity.isPlugin()) {
- text = downloadEntity.getName() + "-"
- + PlatformUtils.getInstance(context).getPlatformName(downloadEntity.getPlatform()) + " 下载完成";
+ text = downloadEntity.getName()
+ + PlatformUtils.getInstance(context).getPlatformName(downloadEntity.getPlatform());
} else {
- text = downloadEntity.getName() + " 下载完成";
+ text = downloadEntity.getName();
}
- title = "点击立即安装";
+ title = "下载完成,点击立即安装";
}
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.logo)
- .setTicker(text)
- .setContentTitle(title)
- .setContentText(text)
+ .setTicker(title)
+ .setContentTitle(text)
+ .setContentText(title)
.setContentIntent(pendingIntent).build();
// notification.defaults = Notification.DEFAULT_SOUND;// 添加系统默认声音
notification.flags |= Notification.FLAG_AUTO_CANCEL; // // FLAG_AUTO_CANCEL表明当通知被用户点击时,通知将被清除。
@@ -72,9 +72,9 @@ public class NotificationUtils {
intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.logo)
- .setTicker("你有" + downloadingSize + "个游戏正在下载中")
- .setContentTitle("点击查看详情")
- .setContentText("你有" + downloadingSize + "个游戏正在下载中")
+ .setTicker("点击查看详情")
+ .setContentTitle("你有" + downloadingSize + "个游戏正在下载中" )
+ .setContentText("点击查看详情")
.setContentIntent(pendingIntent).build();
// notification.defaults = Notification.DEFAULT_SOUND;// 添加系统默认声音
notification.flags |= Notification.FLAG_NO_CLEAR; // 通知无法手动清除
diff --git a/app/src/main/java/com/gh/common/util/QRCodeUtils.java b/app/src/main/java/com/gh/common/util/QRCodeUtils.java
new file mode 100644
index 0000000000..e35ef249ad
--- /dev/null
+++ b/app/src/main/java/com/gh/common/util/QRCodeUtils.java
@@ -0,0 +1,73 @@
+package com.gh.common.util;
+
+import android.graphics.Bitmap;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.WriterException;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by khy on 2016/12/1.
+ */
+public class QRCodeUtils {
+ /**
+ * 生成二维码Bitmap
+ *
+ * @param content 内容
+ * @param widthPix 图片宽度
+ * @param heightPix 图片高度
+ * @param filePath 用于存储二维码图片的文件路径
+ * @return 生成二维码及保存文件是否成功
+ */
+ public static boolean createQRImage(String content, int widthPix, int heightPix, String filePath) {
+ try {
+ if (content == null || "".equals(content)) {
+ return false;
+ }
+
+ //配置参数
+ Map hints = new HashMap<>();
+ hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
+ //容错级别
+ hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+ //设置空白边距的宽度
+ hints.put(EncodeHintType.MARGIN, 0); //default is 4
+ // 图像数据转换,使用了矩阵转换
+ Utils.log("QRCode====" + content);
+ BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, widthPix, heightPix, hints);
+ int[] pixels = new int[widthPix * heightPix];
+ // 下面这里按照二维码的算法,逐个生成二维码的图片,
+ // 两个for循环是图片横列扫描的结果
+ for (int y = 0; y < heightPix; y++) {
+ for (int x = 0; x < widthPix; x++) {
+ if (bitMatrix.get(x, y)) {
+ pixels[y * widthPix + x] = 0xff000000;
+ } else {
+ pixels[y * widthPix + x] = 0xffffffff;
+ }
+ }
+ }
+
+ // 生成二维码图片的格式,使用ARGB_8888
+ Bitmap bitmap = Bitmap.createBitmap(widthPix, heightPix, Bitmap.Config.ARGB_8888);
+ bitmap.setPixels(pixels, 0, widthPix, 0, 0, widthPix, heightPix);
+
+ FileOutputStream fileOutputStream = new FileOutputStream(filePath);
+ //必须使用compress方法将bitmap保存到文件中再进行读取。直接返回的bitmap是没有任何压缩的,内存消耗巨大!
+ return bitmap != null && bitmap.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(filePath));
+ } catch (WriterException | IOException e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+}
diff --git a/app/src/main/java/com/gh/download/DownloadManager.java b/app/src/main/java/com/gh/download/DownloadManager.java
index 27aa895c1d..23b17adfd0 100644
--- a/app/src/main/java/com/gh/download/DownloadManager.java
+++ b/app/src/main/java/com/gh/download/DownloadManager.java
@@ -2,15 +2,20 @@ package com.gh.download;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.v4.util.ArrayMap;
import android.widget.Toast;
+import com.gh.common.constant.Config;
import com.gh.common.constant.Constants;
import com.gh.common.util.DataCollectionUtils;
+import com.gh.common.util.DialogUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.MD5Utils;
+import com.gh.common.util.PackageUtils;
import com.gh.common.util.Utils;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
@@ -209,12 +214,27 @@ public class DownloadManager {
createDownload(context, gameEntity.getApk().get(0), gameEntity, method, entrance, location);
}
- public static void createDownload(Context context,
- ApkEntity apkEntity,
- GameEntity gameEntity,
- String method,
- String entrance,
- String location) {
+ public static void createDownload(final Context context,
+ ApkEntity apkEntity,
+ GameEntity gameEntity,
+ String method,
+ String entrance,
+ String location) {
+
+ // 安装指引
+ if ("Huawei".equals(Build.BRAND) || "Oppo".equals(Build.BRAND)) {
+ SharedPreferences sp = context.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
+ final SharedPreferences.Editor edit = sp.edit();
+ if (sp.getBoolean("InstallHint" + PackageUtils.getVersionName(context), true)) {
+ DialogUtils.showInstallHintDialog(context,
+ new DialogUtils.ConfiremListener() {
+ @Override
+ public void onConfirem() {
+ edit.putBoolean("InstallHint" + PackageUtils.getVersionName(context), false).apply();
+ }
+ });
+ }
+ }
DownloadEntity downloadEntity = new DownloadEntity();
downloadEntity.setUrl(apkEntity.getUrl());
diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java
index 33336b5f1e..ed346e2e11 100644
--- a/app/src/main/java/com/gh/gamecenter/MainActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java
@@ -391,7 +391,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
TokenUtils.getToken(MainActivity.this, false);
TokenUtils.checkDeviceInfo(MainActivity.this);
initConcern(); // 初始化关注
- GiftUtils.getCunHaoXiang(MainActivity.this);
+ GiftUtils.getCunHaoXiang(MainActivity.this, new GiftDao(MainActivity.this));
}
}.start();
}
diff --git a/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java b/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java
index 05afdf22e0..04f1338d8a 100644
--- a/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java
@@ -2,10 +2,13 @@ package com.gh.gamecenter;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
+import android.text.TextUtils;
import android.view.View;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -13,6 +16,7 @@ import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.BaseActivity;
import com.gh.common.util.MessageShareUtils;
+import com.gh.common.util.QRCodeUtils;
import com.gh.gamecenter.manager.SystemBarTintManager;
import com.tencent.tauth.Tencent;
@@ -30,7 +34,7 @@ public class ShareCardActivity extends BaseActivity {
@BindView(R.id.sharecard_content) TextView mShareContentTv;
@BindView(R.id.sharecard_game_name) TextView mShareGameNameTv;
@BindView(R.id.sharecard_game_icon) SimpleDraweeView mShareGameIconDv;
- @BindView(R.id.sharecard_qrcode) SimpleDraweeView mShareQrCodeDv;
+ @BindView(R.id.sharecard_qrcode) ImageView mShareQrCodeDv;
@BindView(R.id.sharecard_screenshot) LinearLayout mShareScreenshotLl;
@BindView(R.id.reuse_actionbar) RelativeLayout mActionbar;
@BindView(R.id.sharecard_bottom) LinearLayout mShareBottomLl;
@@ -41,6 +45,7 @@ public class ShareCardActivity extends BaseActivity {
String gameIconUrl;
String shareContent;
String picName;
+ String newsId;
//接收QQ或者QQ空间分享回调
@Override
@@ -60,6 +65,7 @@ public class ShareCardActivity extends BaseActivity {
gameName = extras.getString("gameName");
gameIconUrl = extras.getString("gameIconUrl");
shareContent = extras.getString("shareContent");
+ newsId = extras.getString("newsId");
picName = "shareImg.jpg";
@@ -78,7 +84,7 @@ public class ShareCardActivity extends BaseActivity {
mShareGameNameTv.setText(gameName);
mShareContentTv.setText(Html.fromHtml(shareContent));
mShareGameIconDv.setImageURI(gameIconUrl);
- mShareQrCodeDv.setImageURI("res:///" + R.drawable.test_qrcode);
+ mShareQrCodeDv.setImageResource(R.drawable.test_qrcode);
// 延迟操作,等待截图部分绘制完成
handler.postDelayed(new Runnable() {
@@ -91,6 +97,28 @@ public class ShareCardActivity extends BaseActivity {
MessageShareUtils.getInstance(ShareCardActivity.this).showShareWindows(mShareBottomLl, drawingCache, picName, false);
}
}, 200);
+
+ if (!TextUtils.isEmpty(newsId)) {
+ createQrCode();
+ }
+ }
+
+ 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/article/" + newsId+ ".html", 200, 200, filePath);
+ if (success) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mShareQrCodeDv.setImageBitmap(BitmapFactory.decodeFile(filePath));
+ }
+ });
+ }
+ }
+ }).start();
}
public void saveBitmap(Bitmap bm) {
diff --git a/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java b/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java
index 437069760a..24de4d708a 100644
--- a/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java
@@ -2,11 +2,13 @@ package com.gh.gamecenter;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Animatable;
import android.os.Bundle;
import android.text.Html;
+import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -22,6 +24,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.image.ImageInfo;
import com.gh.base.BaseActivity;
import com.gh.common.util.MessageShareUtils;
+import com.gh.common.util.QRCodeUtils;
import com.gh.gamecenter.manager.SystemBarTintManager;
import com.gh.gamecenter.retrofit.ObservableUtil;
import com.tencent.tauth.Tencent;
@@ -47,7 +50,7 @@ public class ShareCardPicActivity extends BaseActivity {
@BindView(R.id.sharecard_content) TextView mShareContentTv;
@BindView(R.id.sharecard_game_name) TextView mShareGameNameTv;
@BindView(R.id.sharecard_game_icon) SimpleDraweeView mShareGameIconDv;
- @BindView(R.id.sharecard_qrcode) SimpleDraweeView mShareQrCodeDv;
+ @BindView(R.id.sharecard_qrcode) ImageView mShareQrCodeDv;
@BindView(R.id.sharecard_game_content_img) SimpleDraweeView mShareContentImgRv;
@BindView(R.id.sharecard_screenshot) ScrollView mShareScreenshotRl;
@BindView(R.id.reuse_actionbar) RelativeLayout mActionbar;
@@ -69,6 +72,8 @@ public class ShareCardPicActivity extends BaseActivity {
private CountDownLatch latch;
+ private String newsId;
+
//接收QQ或者QQ空间分享回调
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@@ -87,6 +92,7 @@ public class ShareCardPicActivity extends BaseActivity {
gameName = extras.getString("gameName");
gameIconUrl = extras.getString("gameIconUrl");
shareContent = extras.getString("shareContent");
+ newsId = extras.getString("newsId");
List arrImg = extras.getStringArrayList("shareArrImg");
picName = "shareImgPic.jpg";
@@ -126,7 +132,7 @@ public class ShareCardPicActivity extends BaseActivity {
mShareGameNameTv.setText(gameName);
mShareContentTv.setText(Html.fromHtml(shareContent));
mShareGameIconDv.setImageURI(gameIconUrl);
- mShareQrCodeDv.setImageURI("res:///" + R.drawable.test_qrcode);
+ mShareQrCodeDv.setImageResource(R.drawable.test_qrcode);
if (shareArrImg.size() > 1) {
mShareChangImageIcon.setImageResource(R.drawable.sharecard_chang_img);
@@ -136,6 +142,27 @@ public class ShareCardPicActivity extends BaseActivity {
mShareChangImageTv.setTextColor(getResources().getColor(R.color.hint));
}
+ if (!TextUtils.isEmpty(newsId)) {
+ createQrCode();
+ }
+ }
+
+ 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/article/" + newsId+ ".html", 200, 200, filePath);
+ if (success) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mShareQrCodeDv.setImageBitmap(BitmapFactory.decodeFile(filePath));
+ }
+ });
+ }
+ }
+ }).start();
}
private void setContentImage(String url){
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java
index 66ce597f41..e2651e53f5 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java
@@ -146,8 +146,8 @@ public class GiftDetailAdapter extends RecyclerView.Adapter安装游戏: " +
- mGiftEntity.getGame().getName() + PlatformUtils.getInstance(mContext)
+ Spanned content = Html.fromHtml("领取条件:" + "安装《" +
+ mGiftEntity.getGame().getName() + "》" + PlatformUtils.getInstance(mContext)
.getPlatformName(mGiftEntity.getPlatform()) + "版");
textView.setText(content);
holder.gamedetail_item_news_list.addView(textView);
@@ -185,7 +185,7 @@ public class GiftDetailAdapter extends RecyclerView.Adapter" + count + "%" + "");
} else if ("tao".equals(mGiftEntity.getGiftStatus())) {
- content = Html.fromHtml("剩余:" + "" + count + "%" + "");
+ content = Html.fromHtml("剩余:" + count + "%");
} else if ("used_up".equals(mGiftEntity.getGiftStatus())) {
content = Html.fromHtml("剩余:0% ");
}
@@ -199,8 +199,16 @@ public class GiftDetailAdapter extends RecyclerView.Adapter) mConcernEntity.getImg());
intent.putExtras(bundle);
mContext.startActivity(intent);
@@ -394,6 +397,9 @@ public class MessageDetailAdapter extends RecyclerView.Adapter response) {
super.onResponse(response);
giftList = response;
- notifyDataSetChanged();
- initPosition();
+ getGiftStatus(giftList);
}
@Override
@@ -157,6 +160,63 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
});
}
+ //获取礼包状态
+ private void getGiftStatus(List response) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0, size = response.size(); i < size; i++) {
+ builder.append(response.get(i).getId());
+ builder.append("-");
+ }
+ if (builder.length() == 0) return;
+ builder.deleteCharAt(builder.length() - 1);
+ String ids = builder.toString();
+
+ GiftUtils.getGiftStatus(ids, new GiftUtils.PostGiftListener() {
+ @Override
+ public void postSucced(Object response) {
+ List statusList = (List) response;
+ GiftDao giftDao = new GiftDao(context);
+
+ for (GiftInfo giftInfo : giftDao.getAll()) {
+ for (int i = 0; i < statusList.size(); i++) {
+ if (giftInfo.getGiftId().equals(statusList.get(i).getId())) {
+ if ("ling".equals(giftInfo.getGiftStatus())) {
+ statusList.get(i).setStatus("linged");
+ } else {
+ statusList.get(i).setStatus("taoed");
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < giftList.size(); i++) {
+ GiftEntity giftEntity = giftList.get(i);
+ for (GiftStatusEntity giftStatusEntity : statusList) {
+ if (giftEntity.getId().equals(giftStatusEntity.getId())) {
+ giftEntity.setGiftStatus(giftStatusEntity.getStatus());
+ giftEntity.setAvailable(giftStatusEntity.getAvailable());
+ giftEntity.setTotal(giftStatusEntity.getTotal());
+ }
+ if ("finish".equals(giftEntity.getGiftStatus())) {
+ giftList.remove(i);
+ i--;
+ break;
+ }
+ }
+ }
+
+ notifyDataSetChanged();
+ initPosition();
+ }
+
+ @Override
+ public void postFailed(Throwable error) {
+
+ }
+ });
+ }
+
+
private void getSkinDigest() {
RetrofitManager.getApi().getGameSkin(gameEntity.getId())
.subscribeOn(Schedulers.io())
diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameGiftGalleryAdapter.java b/app/src/main/java/com/gh/gamecenter/gamedetail/GameGiftGalleryAdapter.java
index 40801bd94b..992b55b41f 100644
--- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameGiftGalleryAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameGiftGalleryAdapter.java
@@ -2,12 +2,14 @@ package com.gh.gamecenter.gamedetail;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gh.base.AppController;
+import com.gh.common.util.Utils;
import com.gh.gamecenter.GiftDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.GiftEntity;
@@ -35,7 +37,38 @@ public class GameGiftGalleryAdapter extends RecyclerView.Adapter")) {
+ content = concernEntity.getContent().replaceAll("
", " ");
+ } else {
+ content = concernEntity.getContent();
+ }
+
String giftCode = null;
viewHolder.imgLayout.removeAllViews();
- viewHolder.content.setText(Html.fromHtml(concernEntity.getName() + "-" + PlatformUtils.getInstance(context)
- .getPlatformName(concernEntity.getPlatform()) + " (" + concernEntity.getContent() + ")" ));
+ viewHolder.content.setText(concernEntity.getName() + "-" + PlatformUtils.getInstance(context)
+ .getPlatformName(concernEntity.getPlatform()) + " (" + content + ")" );
viewHolder.comment.setVisibility(View.GONE);
viewHolder.share.setVisibility(View.GONE);
viewHolder.link.setImageResource(R.drawable.gift_icon);
for (GiftStatusEntity giftStatusEntity : giftStatusList) {
if (giftStatusEntity.getId().equals(concernEntity.getId())) {
+
+ if ("finish".equals(giftStatusEntity.getStatus())) {
+ viewHolder.read.setText("已结束");
+ } else {
+ viewHolder.read.setText(Html.fromHtml("" + "点击领取" + ""));
+ }
+
for (GiftInfo info : giftInfo) {
if (info.getGiftId().equals(concernEntity.getId())) {
viewHolder.read.setText("已领取");
@@ -556,17 +570,6 @@ public class News1FragmentAdapter extends RecyclerView.Adapter" + "点击领取" + ""));
- }
- break;
}
}
@@ -666,6 +669,9 @@ public class News1FragmentAdapter extends RecyclerView.Adapter) concernEntity.getImg());
intent.putExtras(bundle);
context.startActivity(intent);
@@ -675,6 +681,9 @@ public class News1FragmentAdapter extends RecyclerView.Adapter
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file