Conflicts:
	PushSDK/build/intermediates/bundles/debug/classes.jar
	PushSDK/build/intermediates/bundles/release/classes.jar
	PushSDK/build/intermediates/incremental/mergeAssets/androidTest/debug/merger.xml
	PushSDK/build/intermediates/incremental/mergeAssets/debug/merger.xml
	PushSDK/build/intermediates/incremental/mergeAssets/release/merger.xml
	PushSDK/build/intermediates/incremental/mergeResourcesandroidTest/debug/merger.xml
	PushSDK/build/intermediates/incremental/packageResourcesdebug/merger.xml
	PushSDK/build/intermediates/incremental/packageResourcesrelease/merger.xml
	PushSDK/build/intermediates/mockable-android-22.jar
	PushSDK/build/intermediates/res/resources-debug-androidTest.ap_
	PushSDK/build/outputs/aar/PushSDK-debug.aar
	PushSDK/build/outputs/aar/PushSDK-release.aar
This commit is contained in:
huangzhuanghua
2016-12-26 16:13:24 +08:00
21 changed files with 549 additions and 67 deletions

View File

@ -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手机安装游戏时请选择“" +
"<font color=\"#ff0000\">继续安装</font>" +
"”(请记住不要选择“官方推荐”或“软件商店安装”)");
// 内容
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);

View File

@ -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<List<GiftEntity>>(){
@Override
public void onResponse(List<GiftEntity> 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 + " 复制成功");
}
}

View File

@ -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; // 通知无法手动清除

View File

@ -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<EncodeHintType, Object> 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;
}
}

View File

@ -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());

View File

@ -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();
}

View File

@ -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) {

View File

@ -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<String> 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){

View File

@ -146,8 +146,8 @@ public class GiftDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
if (mGiftDetailEntity.getInstallRequired()) {
TextView textView = new TextView(mContext);
textView.setTextColor(Color.parseColor("#717171"));
Spanned content = Html.fromHtml("领取条件:" + "<font color=\"#06D0A8\">安装游戏: " +
mGiftEntity.getGame().getName() + PlatformUtils.getInstance(mContext)
Spanned content = Html.fromHtml("领取条件:" + "<font color=\"#06D0A8\">安装" +
mGiftEntity.getGame().getName() + "" + PlatformUtils.getInstance(mContext)
.getPlatformName(mGiftEntity.getPlatform()) + "版</font>");
textView.setText(content);
holder.gamedetail_item_news_list.addView(textView);
@ -185,7 +185,7 @@ public class GiftDetailAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else if ("ling".equals(mGiftEntity.getGiftStatus())) {
content = Html.fromHtml("剩余:" + "<font color=\"#06D0A8\">" + count + "%" + "</font>");
} else if ("tao".equals(mGiftEntity.getGiftStatus())) {
content = Html.fromHtml("剩余:" + "<font color=\"#ffb13c\">" + count + "%" + "</font>");
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<RecyclerView.ViewHol
@Override
public void onClick(View v) {
if (mGiftDetailEntity.getInstallRequired()) {
DialogUtils.showWarningDialog(mContext, "复制成功", "礼包码:" + giftInfo.getGiftCode() +
"\n请尽快使用礼包码将于60分钟后进入淘号池"
String msg;
if ("ling".equals(giftInfo.getGiftStatus())) {
msg = "礼包码:" + giftInfo.getGiftCode() +
"\n请尽快使用礼包码将于60分钟后进入淘号池";
} else {
msg = "礼包码:" + giftInfo.getGiftCode() +
"\n淘号礼包不保证可用请尽快进入游戏尝试兑换";
}
DialogUtils.showWarningDialog(mContext, "复制成功", msg
, "关闭", "启动游戏"
, new DialogUtils.ConfiremListener() {
@Override

View File

@ -385,6 +385,9 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
bundle.putString("gameName", mConcernEntity.getGameName());
bundle.putString("gameIconUrl", mConcernEntity.getGameIcon());
bundle.putString("shareContent", shareContent);
if (mConcernEntity.getLink() == null){
bundle.putString("newsId", mConcernEntity.getId());
}
bundle.putStringArrayList("shareArrImg", (ArrayList<String>) mConcernEntity.getImg());
intent.putExtras(bundle);
mContext.startActivity(intent);
@ -394,6 +397,9 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
bundle.putString("gameName", mConcernEntity.getGameName());
bundle.putString("gameIconUrl", mConcernEntity.getGameIcon());
bundle.putString("shareContent", shareContent);
if (mConcernEntity.getLink() == null){
bundle.putString("newsId", mConcernEntity.getId());
}
intent.putExtras(bundle);
mContext.startActivity(intent);
}

View File

@ -21,16 +21,20 @@ import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.GiftUtils;
import com.gh.common.util.NewsUtils;
import com.gh.common.view.HorizontalItemDecoration;
import com.gh.gamecenter.GameDetailActivity;
import com.gh.gamecenter.GameNewsActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.changeskin.ChangeSkinUtils;
import com.gh.gamecenter.db.GiftDao;
import com.gh.gamecenter.db.info.GiftInfo;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameDetailEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GiftEntity;
import com.gh.gamecenter.entity.GiftStatusEntity;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.entity.ServerEntity;
import com.gh.gamecenter.entity.TagEntity;
@ -145,8 +149,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
public void onResponse(List<GiftEntity> 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<GiftEntity> 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<GiftStatusEntity> statusList = (List<GiftStatusEntity>) 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())

View File

@ -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<RecyclerView.Vi
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
GameGiftGalleryViewHolder viewHolder = (GameGiftGalleryViewHolder) holder;
viewHolder.giftName.setText(mGiftList.get(position).getName());
GiftEntity giftEntity = mGiftList.get(position);
viewHolder.giftName.setText(giftEntity.getName());
Utils.log("========z=" + giftEntity.getGiftStatus());
if (giftEntity.getGiftStatus() == null) return;
switch (giftEntity.getGiftStatus()) {
case "coming":
viewHolder.giftBtn.setText("未开始");
viewHolder.giftBtn.setBackgroundColor(Color.parseColor("#00B7FA"));
break;
case "ling":
viewHolder.giftBtn.setText("领取");
viewHolder.giftBtn.setBackgroundColor(Color.parseColor("#06D0A8"));
break;
case "tao":
viewHolder.giftBtn.setText("淘号");
viewHolder.giftBtn.setBackgroundColor(Color.parseColor("#ffb13c"));
break;
case "used_up":
viewHolder.giftBtn.setText("已领光");
viewHolder.giftBtn.setBackgroundColor(Color.parseColor("#DCDCDC"));
break;
case "linged":
viewHolder.giftBtn.setText("已领取");
viewHolder.giftBtn.setBackgroundColor(Color.parseColor("#00B7FA"));
break;
case "taoed":
viewHolder.giftBtn.setText("已淘号");
viewHolder.giftBtn.setBackgroundColor(Color.parseColor("#00B7FA"));
break;
}
viewHolder.giftBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -44,6 +77,10 @@ public class GameGiftGalleryAdapter extends RecyclerView.Adapter<RecyclerView.Vi
mContext.startActivity(intent);
}
});
if ("used_up".equals(giftEntity.getGiftStatus())) {
viewHolder.giftBtn.setClickable(false);
}
}
@Override

View File

@ -123,7 +123,7 @@ public class Gift1Fragment extends BaseFragment implements SwipeRefreshLayout.On
// mRefreshLayout.setEnabled(false);
if (mIsSearch) {
mEmptyTv.setText("sorry,没找到相关礼包");
mEmptyTv.setText("很抱歉,没找到相关礼包");
} else {
mEmptyTv.setText("这里还没有东西哦");
}

View File

@ -7,6 +7,7 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import com.gh.base.AppController;
import com.gh.common.constant.ItemViewType;
@ -151,7 +152,11 @@ public class Gift1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
for (GiftInfo giftInfo : mGiftDao.getAll()) {
for (int i = 0; i < statusList.size(); i++) {
if (giftInfo.getGiftId().equals(statusList.get(i).getId())) {
statusList.get(i).setStatus("check");
if ("ling".equals(giftInfo.getGiftStatus())) {
statusList.get(i).setStatus("linged");
} else {
statusList.get(i).setStatus("taoed");
}
}
}
}
@ -271,6 +276,9 @@ public class Gift1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
} else { // 返回
mSearchListener.search(false, key);
}
InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(gift1Fragment.getActivity().getWindow().getDecorView().getWindowToken(), 0);
}
});
}

View File

@ -7,10 +7,12 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.gh.base.AppController;
import com.gh.common.constant.ItemViewType;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.GiftUtils;
import com.gh.common.util.MD5Utils;
import com.gh.common.util.PlatformUtils;
@ -269,7 +271,11 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
for (GiftInfo giftInfo : mGiftDao.getAll()) {
for (int i = 0; i < statusList.size(); i++) {
if (giftInfo.getGiftId().equals(statusList.get(i).getId())) {
statusList.get(i).setStatus("check");
if ("ling".equals(giftInfo.getGiftStatus())) {
statusList.get(i).setStatus("linged");
} else {
statusList.get(i).setStatus("taoed");
}
}
}
}
@ -364,6 +370,11 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
}
private void initSkipCommentViewHolder(NewsDetailCommentViewHolder holder) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, DisplayUtils.dip2px(mContext, 5), 0, 0);
holder.itemView.setLayoutParams(params);
holder.commentTv.setText("管理我的关注");
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -8,8 +8,10 @@ import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.gh.base.AppController;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.GiftUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.gamecenter.GiftDetailActivity;
@ -82,6 +84,19 @@ public class Gift3FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
GiftNormalViewHolder viewHolder = (GiftNormalViewHolder)holder;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
int left = (int) mContext.getResources().getDimension(R.dimen.cardview_mar_left);
if (position == 0 || position == getItemCount() -1) {
if (position == 0) {
params.setMargins(left, DisplayUtils.dip2px(mContext, 5),left,0);
} else {
params.setMargins(left, 0, left, DisplayUtils.dip2px(mContext, 5));
}
} else {
params.setMargins(left, 0, left, 0);
}
viewHolder.itemView.setLayoutParams(params);
final GiftEntity giftEntity = mGiftList.get(position );
viewHolder.giftName.setText(giftEntity.getName());

View File

@ -539,16 +539,30 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
NewsUtils.setNewsPublishOn(viewHolder.time, concernEntity.getTime());
if ("libao".equals(concernEntity.getType())) {
String content ;
if (concernEntity.getContent().contains("<br/>")) {
content = concernEntity.getContent().replaceAll("<br/>", " ");
} 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("<font color=\"#00B7FA\">" + "点击领取" + "</font>"));
}
for (GiftInfo info : giftInfo) {
if (info.getGiftId().equals(concernEntity.getId())) {
viewHolder.read.setText("已领取");
@ -556,17 +570,6 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
break;
}
}
if ("已领取".equals(viewHolder.read.getText().toString())) {
break;
}
if ("finish".equals(giftStatusEntity.getStatus())) {
viewHolder.read.setText("已结束");
} else {
viewHolder.read.setText(Html.fromHtml("<font color=\"#00B7FA\">" + "点击领取" + "</font>"));
}
break;
}
}
@ -666,6 +669,9 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
bundle.putString("gameName", concernEntity.getGameName());
bundle.putString("gameIconUrl", concernEntity.getGameIcon());
bundle.putString("shareContent", shareContent);
if (concernEntity.getLink() == null){
bundle.putString("newsId", concernEntity.getId());
}
bundle.putStringArrayList("shareArrImg", (ArrayList<String>) concernEntity.getImg());
intent.putExtras(bundle);
context.startActivity(intent);
@ -675,6 +681,9 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
bundle.putString("gameName", concernEntity.getGameName());
bundle.putString("gameIconUrl", concernEntity.getGameIcon());
bundle.putString("shareContent", shareContent);
if (concernEntity.getLink() == null){
bundle.putString("newsId", concernEntity.getId());
}
intent.putExtras(bundle);
context.startActivity(intent);
}