diff --git a/app/src/main/java/com/gh/base/BaseDetailActivity.java b/app/src/main/java/com/gh/base/BaseDetailActivity.java index aaef438017..d57dd29b0e 100644 --- a/app/src/main/java/com/gh/base/BaseDetailActivity.java +++ b/app/src/main/java/com/gh/base/BaseDetailActivity.java @@ -48,6 +48,8 @@ public abstract class BaseDetailActivity extends BaseActivity implements View.On protected TextView detail_tv_per; protected LinearLayout reuse_ll_loading; protected LinearLayout reuse_no_connection; + protected LinearLayout reuse_none_data; + protected TextView reuse_tv_none_data; protected ImageView iv_share; protected GameEntity gameEntity; @@ -113,6 +115,8 @@ public abstract class BaseDetailActivity extends BaseActivity implements View.On detail_tv_per = (TextView) findViewById(R.id.detail_tv_per); reuse_ll_loading = (LinearLayout) findViewById(R.id.reuse_ll_loading); reuse_no_connection = (LinearLayout) findViewById(R.id.reuse_no_connection); + reuse_none_data = (LinearLayout) findViewById(R.id.reuse_none_data); + reuse_tv_none_data = (TextView) findViewById(R.id.reuse_tv_none_data); detail_ll_bottom.setOnClickListener(this); detail_tv_download.setOnClickListener(this); 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 bd2bc1ed0c..7309a8591f 100644 --- a/app/src/main/java/com/gh/common/util/DialogUtils.java +++ b/app/src/main/java/com/gh/common/util/DialogUtils.java @@ -88,6 +88,32 @@ public class DialogUtils { dialog.show(); } + public static void showHintDialog(Context context, String title, CharSequence msg, String confirm) { + final Dialog dialog = new Dialog(context); + + View view = View.inflate(context, R.layout.common_hintdialog, null); + + TextView hintdialog_title = (TextView) view.findViewById(R.id.hintdialog_title); + hintdialog_title.setText(title); + + // 内容 + TextView hintdialog_content = (TextView) view.findViewById(R.id.hintdialog_content); + hintdialog_content.setText(msg); + + TextView hintdialog_confirm = (TextView) view.findViewById(R.id.hintdialog_confirm); + + hintdialog_confirm.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialog.cancel(); + } + }); + + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + dialog.setContentView(view); + dialog.show(); + } + public static void showHijackDialog(final Context context) { showWarningDialog(context, "警告", "您当前网络环境异常,下载地址已被替换(网络劫持),请更换网络环境进行下载。", new ConfiremListener() { @@ -138,8 +164,8 @@ public class DialogUtils { public static void showCancelDialog(Context context, final ConfiremListener listener) { Spanned content = Html.fromHtml("取消关注游戏后,您将无法及时收到游戏" + - "攻略、" + - "资讯等最新动态提醒。"); + "攻略、" + + "资讯等最新动态提醒。"); showWarningDialog(context, "取消关注", content, "暂不取消", "确定取消", listener, null); } 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 5ed1504233..fecf308f80 100644 --- a/app/src/main/java/com/gh/common/util/GiftUtils.java +++ b/app/src/main/java/com/gh/common/util/GiftUtils.java @@ -1,11 +1,17 @@ package com.gh.common.util; +import android.content.ClipboardManager; import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageInfo; import android.text.TextUtils; import android.view.View; import android.widget.TextView; +import com.gh.base.AppController; +import com.gh.gamecenter.GiftDetailActivity; import com.gh.gamecenter.R; +import com.gh.gamecenter.adapter.GiftDetailAdapter; import com.gh.gamecenter.db.GiftDao; import com.gh.gamecenter.db.info.GiftInfo; import com.gh.gamecenter.entity.GiftEntity; @@ -18,11 +24,9 @@ import com.gh.gamecenter.retrofit.RetrofitManager; import org.json.JSONException; import org.json.JSONObject; -import java.io.IOException; import java.util.List; import de.greenrobot.event.EventBus; -import okhttp3.ResponseBody; import retrofit2.adapter.rxjava.HttpException; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; @@ -53,11 +57,12 @@ public class GiftUtils { } //初始化存号箱 获取存号箱所有礼包 - public static void getCunHaoXiang(final Context context, final PostGiftListener listener) { - getCunHaoXiang(context, true, listener); + public static void getCunHaoXiang(final Context context, final GiftDao giftDao) { + getCunHaoXiang(context, true, giftDao); } - private static void getCunHaoXiang(final Context context, final boolean isCheck, final PostGiftListener listener) { + private static void getCunHaoXiang(final Context context, final boolean isCheck, final GiftDao giftDao) { + new Thread(new Runnable() { @Override public void run() { @@ -68,7 +73,14 @@ public class GiftUtils { @Override public void onResponse(List response) { super.onResponse(response); - listener.postSucced(response); + for (GiftEntity giftEntity : response) { + giftDao.add(new GiftInfo(giftEntity.getGiftId(), giftEntity.getContent(), giftEntity.getIcon() + , giftEntity.getName(),giftEntity.getPlatform(), giftEntity.getGiftStatus() + , giftEntity.getGame().getId(), giftEntity.getGame().getName(), giftEntity.getCode() + , giftEntity.getAvailable(), giftEntity.getTotal())); + } + + EventBus.getDefault().post(new EBReuse("giftChanged")); } @Override @@ -77,12 +89,10 @@ public class GiftUtils { if (e instanceof HttpException) { HttpException exception = (HttpException) e; if (exception.code() == 401) { - getCunHaoXiang(context, false, listener); + getCunHaoXiang(context, false, giftDao); return; } } - - listener.postFailed(e); } }); @@ -103,15 +113,11 @@ public class GiftUtils { RetrofitManager.getApi().postGiftLing(TokenUtils.getToken(context, isCheck), giftId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Response() { + .subscribe(new JSONObjectResponse() { @Override - public void onResponse(ResponseBody response) { + public void onResponse(JSONObject response) { super.onResponse(response); - try { - listener.postSucced(response.string().toString()); - } catch (IOException e) { - e.printStackTrace(); - } + listener.postSucced(response); } @Override @@ -124,7 +130,6 @@ public class GiftUtils { return; } } - listener.postFailed(e); } }); @@ -140,6 +145,7 @@ public class GiftUtils { private static void postGiftTao(final Context context, final String giftId, final boolean isCheck , final PostGiftListener listener) { + new Thread(new Runnable() { @Override public void run() { @@ -196,7 +202,9 @@ public class GiftUtils { void postFailed(Throwable error); } - public static void initGiftBtn(final TextView giftBtn, final GiftEntity giftEntity, final GiftDao giftDao) { + public static void initGiftBtn(final TextView giftBtn, final GiftEntity giftEntity, final GiftDao giftDao, + final boolean isInstallRequired, final GiftDetailAdapter adapter) { + switch (giftEntity.getGiftStatus()) { case "coming": giftBtn.setText("未开始"); @@ -221,6 +229,11 @@ public class GiftUtils { case "check": giftBtn.setText("查看"); giftBtn.setBackgroundResource(R.drawable.textview_blue_style); + break; + case "copy": + giftBtn.setText("复制"); + giftBtn.setBackgroundResource(R.drawable.textview_blue_style); + break; default: giftBtn.setBackgroundResource(R.drawable.textview_cancel_style); giftBtn.setText("异常"); @@ -229,20 +242,34 @@ public class GiftUtils { giftBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - switch (giftEntity.getGiftStatus()) { - case "coming": + + if (isInstallRequired && !isAppInstalled(giftBtn.getContext(), giftEntity.getPackageName())) { + DialogUtils.showHintDialog(giftBtn.getContext(), "条件不符" + , "请检查是否符合领取条件:安装游戏" + giftEntity.getGame().getName() + + PlatformUtils.getInstance(giftBtn.getContext()) + .getPlatformName(giftEntity.getPlatform()) + "版", "知道了"); + return; + } + + switch (giftBtn.getText().toString()) { + case "未开始": Utils.toast(giftBtn.getContext(), "还没到开始领取时间"); break; - case "ling": + case "查看": + AppController.put("giftEntity", giftEntity); + Intent intent = new Intent(giftBtn.getContext(), GiftDetailActivity.class); + giftBtn.getContext().startActivity(intent); + break; + case "领取": postGiftLing(giftBtn.getContext(), giftEntity.getId(), new PostGiftListener() { @Override public void postSucced(Object response) { JSONObject responseBody = (JSONObject) response; + Utils.log("postGiftLing=====" + responseBody); String giftCode = null; try { - JSONObject jsonObject = new JSONObject(responseBody.toString()); - giftCode = jsonObject.getString("code"); + giftCode = responseBody.getString("code"); } catch (JSONException e) { e.printStackTrace(); } @@ -254,10 +281,14 @@ public class GiftUtils { Utils.toast(giftBtn.getContext(), "领取成功"); giftDao.add(new GiftInfo(giftEntity.getId(), giftEntity.getContent(), giftEntity.getIcon() - , giftEntity.getName(),giftEntity.getPlatform(), "tao" - , giftEntity.getGame().getId(), giftEntity.getGame().getName(), giftCode)); + , 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"); + adapter.initGiftDao(); + adapter.notifyDataSetChanged(); } @Override @@ -270,18 +301,23 @@ public class GiftUtils { try { JSONObject errorJson = new JSONObject(exception.response().errorBody().string()); String detail = errorJson.getString("detail"); + if ("coming".equals(detail)) { - Utils.toast(giftBtn.getContext(), "礼包未开抢"); + Utils.toast(giftBtn.getContext(), "礼包领取时间未开始"); } else if ("finish".equals(detail)) { - Utils.toast(giftBtn.getContext(), "礼包已结束"); + Utils.toast(giftBtn.getContext(), "礼包领取时间已结束"); } else if ("fetched".equals(detail)) { - Utils.toast(giftBtn.getContext(), "用户已领过或淘过该礼包"); - } else if ("try tao".equals(detail)) { - Utils.toast(giftBtn.getContext(), "礼包当前为淘号状态"); - } else if ("used up".equals(detail)){ - Utils.toast(giftBtn.getContext(), "礼包已被领光,未达淘号状态"); + Utils.toast(giftBtn.getContext(), "你已领过这个礼包了"); + 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(), "礼包已领光" + , "手速不够快,礼包已经被抢光了,十分抱歉", "知道了"); } else if ("maintaining".equals(detail)) { - Utils.toast(giftBtn.getContext(), "服务端正在修改礼包"); + Utils.toast(giftBtn.getContext(), "网络状态异常,请稍后再试"); + } else { + Utils.toast(giftBtn.getContext(), "操作失败"); } } catch (Exception ex) { ex.printStackTrace(); @@ -290,28 +326,109 @@ public class GiftUtils { return; } } - + Utils.toast(giftBtn.getContext(), "网络异常"); } }); break; - case "tao": + case "淘号": postGiftTao(giftBtn.getContext(), giftEntity.getId(), new PostGiftListener() { @Override public void postSucced(Object response) { + JSONObject responseBody = (JSONObject) response; + Utils.log("postGiftTao=====" + responseBody); + String giftCode = null; + try { + giftCode = responseBody.getString("code"); + } catch (JSONException e) { + e.printStackTrace(); + } + + if (TextUtils.isEmpty(giftCode)) { + Utils.toast(giftBtn.getContext(), "淘号异常"); + return; + } + + 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"); + adapter.initGiftDao(); + adapter.notifyDataSetChanged(); } @Override public void postFailed(Throwable error) { + Utils.log("---" + error.toString()); + + if (error instanceof HttpException) { + HttpException exception = (HttpException) error; + if (exception.code() == 403) { + try { + JSONObject errorJson = new JSONObject(exception.response().errorBody().string()); + String detail = errorJson.getString("detail"); + + if ("coming".equals(detail)) { + Utils.toast(giftBtn.getContext(), "礼包领取时间未开始"); + } else if ("finish".equals(detail)) { + Utils.toast(giftBtn.getContext(), "礼包领取时间已结束"); + } else if ("fetched".equals(detail)) { + Utils.toast(giftBtn.getContext(), "你已领过这个礼包了"); + 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(), "礼包已领光" + , "手速不够快,礼包已经被抢光了,十分抱歉", "知道了"); + } else if ("maintaining".equals(detail)) { + Utils.toast(giftBtn.getContext(), "网络状态异常,请稍后再试"); + } else if ("fail to compete".equals(detail)) { + Utils.toast(giftBtn.getContext(), "淘号失败,稍后重试"); + } else { + Utils.toast(giftBtn.getContext(), "操作失败"); + } + } catch (Exception ex) { + ex.printStackTrace(); + Utils.toast(giftBtn.getContext(),"礼包处理异常"); + } + return; + } + } Utils.toast(giftBtn.getContext(), "网络异常"); - Utils.log(error.toString()); } }); - break; } } }); } + + public static boolean isAppInstalled(Context context, String packageName) { + final android.content.pm.PackageManager packageManager = context.getPackageManager(); + List pinfo = packageManager.getInstalledPackages(0); + if (pinfo != null) { + for (int i = 0; i < pinfo.size(); i++) { + String pn = pinfo.get(i).packageName; + if (pn.equals(packageName)) { + return true; + } + } + } + return false; + } + + + //复制文字 + public static void copyLink(String copyContent, Context context) { + ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); + cmb.setText(copyContent); + + Utils.toast(context,copyContent + "复制成功"); + } } diff --git a/app/src/main/java/com/gh/gamecenter/GiftDetailActivity.java b/app/src/main/java/com/gh/gamecenter/GiftDetailActivity.java index e55a2a88e5..94a2f2a4a3 100644 --- a/app/src/main/java/com/gh/gamecenter/GiftDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/GiftDetailActivity.java @@ -7,6 +7,7 @@ import android.view.View; import com.gh.base.AppController; import com.gh.base.BaseDetailActivity; import com.gh.gamecenter.adapter.GiftDetailAdapter; +import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.GiftEntity; import com.gh.gamecenter.retrofit.Response; @@ -24,10 +25,17 @@ public class GiftDetailActivity extends BaseDetailActivity { private GiftEntity mGiftEntity; + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + AppController.put("giftEntity", mAdapter.getGiftEntity()); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - name = "礼包详情"; + actionbar_tv_title.setText("礼包详情"); + title = "礼包详情"; mGiftEntity = (GiftEntity) AppController.get("giftEntity", true); @@ -49,7 +57,7 @@ public class GiftDetailActivity extends BaseDetailActivity { handler.postDelayed(new Runnable() { @Override public void run() { - mAdapter.addGiftDetail(); + getGameDigest(); } }, 1000); } @@ -65,19 +73,28 @@ public class GiftDetailActivity extends BaseDetailActivity { @Override public void onResponse(GameEntity response) { gameEntity = response; - title = gameEntity.getName(); - actionbar_tv_title.setText(gameEntity.getName()); - mAdapter.addGiftDetail(); entrance = "礼包详情"; //TODO downloadAddWord = gameEntity.getDownloadAddWord(); downloadOffText = gameEntity.getDownloadOffText(); initDownload(true); + + for (ApkEntity apkEntity : gameEntity.getApk()) { + if (mGiftEntity.getPlatform().equals(apkEntity.getPlatform())) { + mGiftEntity.setPackageName(apkEntity.getPackageName()); + } + } + + mAdapter.addGiftDetail(); } @Override public void onFailure(Throwable e) { + detail_rv_show.setVisibility(View.GONE); + reuse_ll_loading.setVisibility(View.GONE); + detail_ll_bottom.setVisibility(View.GONE); + detail_rv_show.setPadding(0, 0, 0, 0); reuse_no_connection.setVisibility(View.VISIBLE); } }); @@ -99,4 +116,14 @@ public class GiftDetailActivity extends BaseDetailActivity { detail_rv_show.setPadding(0, 0, 0, 0); reuse_no_connection.setVisibility(View.VISIBLE); } + + @Override + public void loadEmpty() { + detail_rv_show.setVisibility(View.GONE); + reuse_ll_loading.setVisibility(View.GONE); + detail_ll_bottom.setVisibility(View.GONE); + detail_rv_show.setPadding(0, 0, 0, 0); + reuse_tv_none_data.setText("天了噜~页面不见了"); + reuse_none_data.setVisibility(View.VISIBLE); + } } diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index 8b51142b91..eaaaa0910c 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -31,7 +31,9 @@ import com.gh.common.util.DataLogUtils; import com.gh.common.util.DataUtils; import com.gh.common.util.DialogUtils; import com.gh.common.util.FileUtils; -import com.gh.common.util.GameUtils; +import com.gh.common.util.GiftUtils; +import com.gh.common.util.MD5Utils; +import com.gh.common.util.NetworkUtils; import com.gh.common.util.PackageUtils; import com.gh.common.util.PlatformUtils; import com.gh.common.util.RandomUtils; @@ -41,6 +43,7 @@ import com.gh.download.DataWatcher; import com.gh.download.DownloadEntity; import com.gh.download.DownloadManager; import com.gh.download.DownloadStatus; +import com.gh.gamecenter.db.GiftDao; import com.gh.gamecenter.db.info.ConcernInfo; import com.gh.gamecenter.db.info.GameInfo; import com.gh.gamecenter.entity.ApkEntity; @@ -362,6 +365,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene UpdateManager.getInstance(this).checkUpdate(true); } if (isNewFirstLaunch) { + initCunHaoXiang(); getPluginUpdate(); // sp.edit().putBoolean("isNewFirstLaunchV" + PackageUtils.getVersion(getApplicationContext()), false).apply(); } @@ -395,6 +399,11 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene Log.e("TD_CHANNEL_ID", (String) PackageUtils.getMetaData(this, getPackageName(), "TD_CHANNEL_ID")); } + private void initCunHaoXiang() { + GiftDao giftDao = new GiftDao(this); + GiftUtils.getCunHaoXiang(this, giftDao); + } + // 初始化关注 private void initConcern() { RetrofitManager.getApi().getConcern(TokenUtils.getDeviceId(MainActivity.this)) diff --git a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java index f599080184..fb034771d9 100644 --- a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java @@ -470,7 +470,8 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { - if (commentNum != -1 && commentNum != adapter.getConcernEntity().getCommentnum()) { + if (commentNum != -1 && adapter.getConcernEntity() != null + && commentNum != adapter.getConcernEntity().getCommentnum()) { Intent intent= new Intent(); intent.putExtra("commentNum", adapter.getConcernEntity().getCommentnum()); setResult(1001, intent); 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 f6ec9a70b3..66ce597f41 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java @@ -5,25 +5,33 @@ import android.graphics.Color; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.text.Spanned; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import com.gh.common.util.DialogUtils; import com.gh.common.util.DisplayUtils; +import com.gh.common.util.GiftUtils; +import com.gh.common.util.PackageUtils; import com.gh.common.util.PlatformUtils; +import com.gh.common.util.Utils; import com.gh.gamecenter.GiftDetailActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.adapter.viewholder.GiftDetailTopViewHolder; +import com.gh.gamecenter.db.GiftDao; +import com.gh.gamecenter.db.info.GiftInfo; import com.gh.gamecenter.entity.GiftDetailEntity; import com.gh.gamecenter.entity.GiftEntity; +import com.gh.gamecenter.entity.GiftStatusEntity; import com.gh.gamecenter.gamedetail.GameDetailNewsViewHolder; import com.gh.gamecenter.listener.OnCallBackListener; import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; import java.text.SimpleDateFormat; -import java.util.Locale; +import java.util.List; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; @@ -40,10 +48,18 @@ public class GiftDetailAdapter extends RecyclerView.Adapter mGiftInfos; + public GiftDetailAdapter(GiftDetailActivity giftDetailActivity, GiftEntity giftEntity) { this.mContext = giftDetailActivity; this.mCallBackListener = giftDetailActivity; this.mGiftEntity = giftEntity; + + mGiftDao = new GiftDao(mContext); + mGiftInfos = mGiftDao.getAll(); + } public void addGiftDetail() { @@ -63,7 +79,7 @@ public class GiftDetailAdapter extends RecyclerView.Adapter已安装 " + mGiftEntity.getGame().getName() + + Spanned content = Html.fromHtml("领取条件:" + "安装游戏: " + mGiftEntity.getGame().getName() + PlatformUtils.getInstance(mContext) - .getPlatformName(mGiftEntity.getPlatform()) + ""); - textView.setText("领取条件:" + content); + .getPlatformName(mGiftEntity.getPlatform()) + "版"); + textView.setText(content); holder.gamedetail_item_news_list.addView(textView); } + if (mGiftDetailEntity.getTime() != null) { - SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); - format.applyPattern("yyyy年MM月dd日"); - String start = format.format(mGiftDetailEntity.getTime().getStart()); - String end = format.format(mGiftDetailEntity.getTime().getEnd()); + SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日"); + String start = format.format((mGiftDetailEntity.getTime().getStart() * 1000)); + String end = format.format((mGiftDetailEntity.getTime().getEnd() * 1000)); TextView tvTime = new TextView(mContext); tvTime.setTextColor(Color.parseColor("#717171")); - tvTime.setText("领取时间:" + start + "-" + end); + tvTime.setText("领取时间:" + start + " - " + end); holder.gamedetail_item_news_list.addView(tvTime); } } else if (mGiftDetailEntity.getDes() != null && position == getItemCount() -1) { holder.gamedetail_item_news_title.setText("使用说明"); TextView desTv = new TextView(mContext); desTv.setTextColor(Color.parseColor("#717171")); - desTv.setText(mGiftDetailEntity.getDes()); + desTv.setText(Html.fromHtml(mGiftDetailEntity.getDes())); holder.gamedetail_item_news_list.addView(desTv); } } @@ -160,11 +176,102 @@ public class GiftDetailAdapter extends RecyclerView.Adapter" + count + "%" + ""); + } else if ("tao".equals(mGiftEntity.getGiftStatus())) { + content = Html.fromHtml("剩余:" + "" + count + "%" + ""); + } else if ("used_up".equals(mGiftEntity.getGiftStatus())) { + content = Html.fromHtml("剩余:0% "); + } + + //已领取或已淘号 + for (final GiftInfo giftInfo : mGiftInfos) { + if (giftInfo.getGiftId().equals(mGiftEntity.getId())) { + holder.giftCopyBtn.setText("复制"); + holder.giftCopyBtn.setBackgroundResource(R.drawable.textview_blue_style); + holder.giftCopyBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mGiftDetailEntity.getInstallRequired()) { + DialogUtils.showWarningDialog(mContext, "复制成功", "礼包码:" + giftInfo.getGiftCode() + + "\n请尽快使用,礼包码将于60分钟后进入淘号池" + , "关闭", "启动游戏" + , new DialogUtils.ConfiremListener() { + @Override + public void onConfirem() { + if (GiftUtils.isAppInstalled(mContext, mGiftEntity.getPackageName())) { + PackageUtils.launchApplicationByPackageName(mContext, mGiftEntity.getPackageName()); + } else { + Utils.toast(mContext, "请安装游戏:" + mGiftEntity.getGame().getName() + + PlatformUtils.getInstance(mContext).getPlatformName(mGiftEntity.getPlatform()) + "版"); + } + + } + }, null); + } + GiftUtils.copyLink(giftInfo.getGiftCode(), mContext); + } + }); + + Spanned giftCode; + if ("ling".equals(giftInfo.getGiftStatus())) { + giftCode = Html.fromHtml("已领取:" + "" +giftInfo.getGiftCode()+ ""); + if (count == 0) { + content = Html.fromHtml("剩余:" + "" + count + "%" + ""); + } else { + content = Html.fromHtml("剩余:" + "" + count + "%" + ""); + } + } else { + giftCode = Html.fromHtml("已淘号:" + "" +giftInfo.getGiftCode()+ ""); + content = Html.fromHtml("剩余:" + count + "%" ); + } + holder.giftCode.setVisibility(View.VISIBLE); + holder.giftCode.setText(giftCode); + holder.giftDes.setText(content); + return; + } + } + + holder.giftDes.setText(content); + + if (mGiftEntity.getGiftStatus() != null && mGiftDetailEntity != null) { + GiftUtils.initGiftBtn(holder.giftCopyBtn, mGiftEntity, mGiftDao, mGiftDetailEntity.getInstallRequired(), this); + } + + // 判断按钮状态是否为空(礼包详情进入),重新获取 + if (TextUtils.isEmpty(content)) { + GiftUtils.getGiftStatus(mGiftEntity.getId(), new GiftUtils.PostGiftListener() { + @Override + public void postSucced(Object response) { + List statusList = (List) response; + if (statusList.size() == 0) return; + mGiftEntity.setGiftStatus(statusList.get(0).getStatus()); + mGiftEntity.setAvailable(statusList.get(0).getAvailable()); + mGiftEntity.setTotal(statusList.get(0).getTotal()); + notifyItemChanged(0); + } + + @Override + public void postFailed(Throwable error) { + + } + }); + } } - public GiftDetailEntity getGiftDetailEntity() { - return mGiftDetailEntity; + public GiftEntity getGiftEntity() { + return mGiftEntity; } + //初始化获取数据库的列表 + public void initGiftDao() { + mGiftDao = new GiftDao(mContext); + mGiftInfos = mGiftDao.getAll(); + } } diff --git a/app/src/main/java/com/gh/gamecenter/db/info/GiftInfo.java b/app/src/main/java/com/gh/gamecenter/db/info/GiftInfo.java index cbdfcc32ff..fe7c4f616d 100644 --- a/app/src/main/java/com/gh/gamecenter/db/info/GiftInfo.java +++ b/app/src/main/java/com/gh/gamecenter/db/info/GiftInfo.java @@ -39,6 +39,28 @@ public class GiftInfo implements Serializable { @DatabaseField(columnName = "giftCode") private String giftCode; + @DatabaseField(columnName = "available") + private int available; + + @DatabaseField(columnName = "total") + private int total; + + public int getAvailable() { + return available; + } + + public void setAvailable(int available) { + this.available = available; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + public String getGiftCode() { return giftCode; } @@ -111,9 +133,8 @@ public class GiftInfo implements Serializable { this.gameName = gameName; } - public GiftInfo(String giftId, String content, String icon, String name, String platform, String giftStatus - , String gameId, String gameName, String giftCode) { + , String gameId, String gameName, String giftCode, int available, int total) { this.giftId = giftId; this.content = content; this.icon = icon; @@ -123,6 +144,8 @@ public class GiftInfo implements Serializable { this.gameId = gameId; this.gameName = gameName; this.giftCode = giftCode; + this.available = available; + this.total = total; } public GiftInfo() { @@ -141,6 +164,8 @@ public class GiftInfo implements Serializable { ", gameId='" + gameId + '\'' + ", gameName='" + gameName + '\'' + ", giftCode='" + giftCode + '\'' + + ", available='" + available + '\'' + + ", total='" + total + '\'' + '}'; } } diff --git a/app/src/main/java/com/gh/gamecenter/entity/ConcernEntity.java b/app/src/main/java/com/gh/gamecenter/entity/ConcernEntity.java index 9064aa8f3c..a5b147414c 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/ConcernEntity.java +++ b/app/src/main/java/com/gh/gamecenter/entity/ConcernEntity.java @@ -37,6 +37,47 @@ public class ConcernEntity { private int itemHeight; + private String type; + + @SerializedName("game_id") + private String gameId; + + private String platform; + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getGameId() { + return gameId; + } + + public void setGameId(String gameId) { + this.gameId = gameId; + } + + public String getPlatform() { + return platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + public int getItemHeight() { return itemHeight; } diff --git a/app/src/main/java/com/gh/gamecenter/entity/GiftDetailEntity.java b/app/src/main/java/com/gh/gamecenter/entity/GiftDetailEntity.java index 2eb232559a..80cc0a8b33 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GiftDetailEntity.java +++ b/app/src/main/java/com/gh/gamecenter/entity/GiftDetailEntity.java @@ -51,23 +51,23 @@ public class GiftDetailEntity { public class GiftDetailTimeEntity { - private int end; + private long end; - private int start; + private long start; - public void setEnd(int end) { + public void setEnd(long end) { this.end = end; } - public int getEnd() { + public long getEnd() { return end; } - public void setStart(int start) { + public void setStart(long start) { this.start = start; } - public int getStart() { + public long getStart() { return start; } } diff --git a/app/src/main/java/com/gh/gamecenter/entity/GiftEntity.java b/app/src/main/java/com/gh/gamecenter/entity/GiftEntity.java index 02e848c663..0c3db70df1 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GiftEntity.java +++ b/app/src/main/java/com/gh/gamecenter/entity/GiftEntity.java @@ -10,6 +10,9 @@ public class GiftEntity { @SerializedName("_id") private String Id; + @SerializedName("libao_id") + private String giftId; + private String content; private GiftGameEntity game; @@ -20,8 +23,57 @@ public class GiftEntity { private String platform; + @SerializedName("type") private String giftStatus; + private String code; + + private int available; + + private int total; + + private String packageName; + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public int getAvailable() { + return available; + } + + public void setAvailable(int available) { + this.available = available; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public String getGiftId() { + return giftId; + } + + public void setGiftId(String giftId) { + this.giftId = giftId; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + public String getGiftStatus() { return giftStatus; } @@ -78,14 +130,18 @@ public class GiftEntity { return platform; } - public GiftEntity(String id, String content, GiftGameEntity game, String icon, String name - , String platform, String giftStatus) { + public GiftEntity(String id, String giftId, String content, GiftGameEntity game, String icon, String name + , String platform, String giftStatus, String code, int available, int total) { Id = id; + this.giftId = giftId; this.content = content; this.game = game; this.icon = icon; this.name = name; this.platform = platform; this.giftStatus = giftStatus; + this.code = code; + this.available = available; + this.total = total; } } diff --git a/app/src/main/java/com/gh/gamecenter/entity/GiftStatusEntity.java b/app/src/main/java/com/gh/gamecenter/entity/GiftStatusEntity.java index 4d586c5d4f..5ae3867c74 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GiftStatusEntity.java +++ b/app/src/main/java/com/gh/gamecenter/entity/GiftStatusEntity.java @@ -12,6 +12,26 @@ public class GiftStatusEntity { private String status; + private int available; + + private int total; + + public int getAvailable() { + return available; + } + + public void setAvailable(int available) { + this.available = available; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + public String getId() { return id; } diff --git a/app/src/main/java/com/gh/gamecenter/gift/Gift1Fragment.java b/app/src/main/java/com/gh/gamecenter/gift/Gift1Fragment.java index 531bd99c3e..6189e4b790 100644 --- a/app/src/main/java/com/gh/gamecenter/gift/Gift1Fragment.java +++ b/app/src/main/java/com/gh/gamecenter/gift/Gift1Fragment.java @@ -1,5 +1,6 @@ package com.gh.gamecenter.gift; +import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.widget.SwipeRefreshLayout; @@ -76,6 +77,15 @@ public class Gift1Fragment extends BaseFragment implements SwipeRefreshLayout.On }); } + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == 0x123 && adapter.getSkipPosition() != -1) { + // 更新对应位置 + adapter.notifyItemChanged(adapter.getSkipPosition()); + adapter.setSkipPosition(-1); + } + } + @Override public void onRefresh() { handler.postDelayed(runnable, 1000); @@ -108,9 +118,9 @@ public class Gift1Fragment extends BaseFragment implements SwipeRefreshLayout.On public void loadEmpty() { mRefreshLayout.setRefreshing(false); mLoadingLayout.setVisibility(View.GONE); - mRecyclerView.setVisibility(View.GONE); +// mRecyclerView.setVisibility(View.GONE); mEmptyLayout.setVisibility(View.VISIBLE); - mRefreshLayout.setEnabled(false); +// mRefreshLayout.setEnabled(false); if (mIsSearch) { mEmptyTv.setText("sorry,没找到相关礼包"); @@ -121,6 +131,9 @@ public class Gift1Fragment extends BaseFragment implements SwipeRefreshLayout.On @Override public void search(boolean isSearch, String searchKey) { //搜索回调 + if (mEmptyLayout.getVisibility() == View.VISIBLE) { + mEmptyLayout.setVisibility(View.GONE); + } mIsSearch = isSearch; mSearckKey = searchKey; changeAdapter(false); diff --git a/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java index 5ec857c206..de1cbc1ff4 100644 --- a/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java @@ -19,6 +19,7 @@ import com.gh.gamecenter.adapter.viewholder.FooterViewHolder; import com.gh.gamecenter.adapter.viewholder.GameNewsSearchViewHolder; import com.gh.gamecenter.adapter.viewholder.GiftNormalViewHolder; import com.gh.gamecenter.db.GiftDao; +import com.gh.gamecenter.db.info.GiftInfo; import com.gh.gamecenter.entity.GiftEntity; import com.gh.gamecenter.entity.GiftStatusEntity; import com.gh.gamecenter.listener.OnCallBackListener; @@ -37,7 +38,9 @@ import rx.schedulers.Schedulers; * Created by khy on 2016/12/12. */ public class Gift1FragmentAdapter extends RecyclerView.Adapter { + private Context mContext; + private Gift1Fragment gift1Fragment; private OnCallBackListener mCallBackListener; private OnSearchCallBackListener mSearchListener; @@ -48,6 +51,8 @@ public class Gift1FragmentAdapter extends RecyclerView.Adapter> giftApi; + final Observable> giftApi; if (isSearch) { giftApi = RetrofitManager.getApi().getSearchGift(mSerchKey, offset); } else { @@ -108,12 +116,16 @@ public class Gift1FragmentAdapter extends RecyclerView.Adapter) response) { - if (giftEntity.getId().equals(giftStatusEntity.getId())) { - giftEntity.setGiftStatus(giftStatusEntity.getStatus()); + List statusList = (List) response; + + 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"); } } } + + for (GiftEntity giftEntity : mGiftList) { + for (GiftStatusEntity giftStatusEntity : statusList) { + if (giftEntity.getId().equals(giftStatusEntity.getId())) { + giftEntity.setGiftStatus(giftStatusEntity.getStatus()); + giftEntity.setAvailable(giftStatusEntity.getAvailable()); + giftEntity.setTotal(giftStatusEntity.getTotal()); + } + } + } + notifyDataSetChanged(); } @@ -166,7 +192,7 @@ public class Gift1FragmentAdapter extends RecyclerView.Adapter")) { + content = giftEntity.getContent().replaceAll("
", " "); + } else { + content = giftEntity.getContent(); + } + holder.giftDes.setText(content); + if (giftEntity.getGiftStatus() != null) { - GiftUtils.initGiftBtn(holder.giftBtnStatus, giftEntity, mGiftDao); + GiftUtils.initGiftBtn(holder.giftBtnStatus, giftEntity, mGiftDao, false, null); + holder.giftBtnStatus.setClickable(false); + String tv = holder.giftBtnStatus.getText().toString(); + if ("已结束".equals(tv) || "已领光".equals(tv)) { + holder.giftBtnStatus.setClickable(true); + } } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + skipPosition = position; AppController.put("giftEntity", giftEntity); Intent intent = new Intent(mContext, GiftDetailActivity.class); - mContext.startActivity(intent); + gift1Fragment.startActivityForResult(intent, 0x123); } }); } @@ -293,6 +335,14 @@ public class Gift1FragmentAdapter extends RecyclerView.Adapter { + private Context mContext; + private Gift2Fragment gift2Fragment; private OnCallBackListener mCallBackListener; private List mGiftList; + private List gameIdList; private boolean isLoading; private boolean isOver; private boolean isNetworkError; + private String key; private String ids; - private List gameIdList; + + private int skipPosition; + private GiftDao mGiftDao; + public Gift2FragmentAdapter(Gift2Fragment gift2Fragment) { this.mContext = gift2Fragment.getContext(); + this.gift2Fragment = gift2Fragment; this.mCallBackListener = gift2Fragment; mGiftList = new ArrayList<>(); @@ -72,6 +82,8 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter() { @@ -167,7 +181,10 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter response) { super.onResponse(response); mGiftList.addAll(response); - mCallBackListener.loadDone(); + isLoading = false; if (response.size() < 20) { isOver = true; @@ -219,7 +236,9 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter statusList = (List) response; + + 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"); + } + } + } + for (GiftEntity giftEntity : mGiftList) { - for (GiftStatusEntity giftStatusEntity : (List) response) { + for (GiftStatusEntity giftStatusEntity : statusList) { if (giftEntity.getId().equals(giftStatusEntity.getId())) { giftEntity.setGiftStatus(giftStatusEntity.getStatus()); + giftEntity.setAvailable(giftStatusEntity.getAvailable()); + giftEntity.setTotal(giftStatusEntity.getTotal()); } } } @@ -345,22 +377,37 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter")) { + content = giftEntity.getContent().replaceAll("
", " "); + } else { + content = giftEntity.getContent(); + } + holder.giftDes.setText(content); if (giftEntity.getGiftStatus() != null) { - GiftUtils.initGiftBtn(holder.giftBtnStatus, giftEntity, mGiftDao); + GiftUtils.initGiftBtn(holder.giftBtnStatus, giftEntity, mGiftDao, false, null); + holder.giftBtnStatus.setClickable(false); + String tv = holder.giftBtnStatus.getText().toString(); + if ("已结束".equals(tv) || "已领光".equals(tv)) { + holder.giftBtnStatus.setClickable(true); + } } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + skipPosition = position; AppController.put("giftEntity", giftEntity); Intent intent = new Intent(mContext, GiftDetailActivity.class); - mContext.startActivity(intent); + gift2Fragment.startActivityForResult(intent, 0x123); } }); } @@ -384,4 +431,12 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter { + private Context mContext; - private List mGiftList; - private GiftDao mGiftDao; + private OnCallBackListener mCallBackListener; + private List mGiftList; + + private GiftDao mGiftDao; public Gift3FragmentAdapter(Gift3Fragment gift3Fragment) { this.mContext = gift3Fragment.getContext(); + this.mCallBackListener = gift3Fragment; mGiftList = new ArrayList<>(); @@ -42,16 +50,26 @@ public class Gift3FragmentAdapter extends RecyclerView.Adapter giftInfos = mGiftDao.getAll(); + if (giftInfos == null) { + mCallBackListener.loadEmpty(); return; } - for (int i = 0; i < giftInfos.size(); i++) { + + for (int i = 0; i < giftInfos.size(); i++) { // 数据转换 GiftInfo giftInfo = giftInfos.get(i); GiftGameEntity giftGameEntity = new GiftGameEntity(giftInfo.getGameId(), giftInfo.getGameName()); - GiftEntity giftEntity = new GiftEntity(giftInfo.getGiftId(), giftInfo.getContent(), giftGameEntity, giftInfo.getIcon() - , giftInfo.getName(), giftInfo.getPlatform() ,giftInfo.getGiftStatus()); + GiftEntity giftEntity = new GiftEntity(giftInfo.getGiftId(), giftInfo.getGiftId(), giftInfo.getContent() + , giftGameEntity, giftInfo.getIcon(), giftInfo.getName(), giftInfo.getPlatform() + , giftInfo.getGiftStatus(), giftInfo.getGiftCode(), giftInfo.getAvailable(), giftInfo.getTotal()); mGiftList.add(i,giftEntity); } + + if (mGiftList.size() == 0) { + mCallBackListener.loadEmpty(); + } else { + mCallBackListener.loadDone(); + } notifyDataSetChanged(); } @@ -67,11 +85,27 @@ public class Gift3FragmentAdapter extends RecyclerView.Adapter" +giftEntity.getCode()+ ""); + } else { + content = Html.fromHtml("已淘号:" + "" +giftEntity.getCode()+ ""); + } + viewHolder.giftDes.setText(content); + + viewHolder.giftBtnStatus.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + GiftUtils.copyLink(giftEntity.getCode(), mContext); + } + }); } holder.itemView.setOnClickListener(new View.OnClickListener() { @@ -82,6 +116,9 @@ public class Gift3FragmentAdapter extends RecyclerView.Adapter concernList; private List gameIdList; + private List giftStatusList; + + private List giftInfo; + private GiftDao giftDao; private String key; private String ids; @@ -95,6 +109,7 @@ public class News1FragmentAdapter extends RecyclerView.Adapter(); gameIdList = new ArrayList<>(); + giftStatusList = new ArrayList<>(); itemCount = 0; skipPosition = -1; @@ -103,6 +118,9 @@ public class News1FragmentAdapter extends RecyclerView.Adapter response) { + StringBuilder builder = new StringBuilder(); + for (int i = 0, size = response.size(); i < size; i++) { + if ("libao".equals(response.get(i).getType())){ + 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) { + giftStatusList = (List) response; + notifyDataSetChanged(); + } + + @Override + public void postFailed(Throwable error) { + + } + }); + } + + // 去除重复数据 private static List removeDuplicateData(List sourceList, List rawList) { if (sourceList == null || sourceList.isEmpty() @@ -492,6 +541,63 @@ public class News1FragmentAdapter extends RecyclerView.Adapter" + "点击领取" + "")); + } + break; + } + } + + final String finalGiftCode = giftCode; + viewHolder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + for (GiftStatusEntity giftStatusEntity : giftStatusList) { + if (concernEntity.getId().equals(giftStatusEntity.getId())) { + GiftEntity giftEntity = new GiftEntity(concernEntity.getId(), concernEntity.getId() + , concernEntity.getContent(), new GiftGameEntity(concernEntity.getGameId() + , concernEntity.getGameName()), concernEntity.getGameIcon(), concernEntity.getName() + , concernEntity.getPlatform(), giftStatusEntity.getStatus(), finalGiftCode + , giftStatusEntity.getAvailable(), giftStatusEntity.getTotal()); + AppController.put("giftEntity", giftEntity); + } + } + skipPosition = viewHolder.getPosition(); + Intent intent = new Intent(context, GiftDetailActivity.class); + fragment.startActivityForResult(intent, 0x122); + } + }); + return; + } + + viewHolder.comment.setVisibility(View.VISIBLE); + viewHolder.share.setVisibility(View.VISIBLE); + if (concernEntity.getBrief() != null) { viewHolder.content.setText(Html.fromHtml(concernEntity.getBrief())); viewHolder.content.setMaxLines(100); @@ -640,6 +746,12 @@ public class News1FragmentAdapter extends RecyclerView.Adapter> getGift(@Query("offset") int offset); //获取礼包列表数据 @GET("libao?limit=20") - Observable> getSearchGift(@Query("search") String searchKey, @Query("offset") int offset); //搜索礼包列表数据 + Observable> getSearchGift(@Query("keyword") String searchKey, @Query("offset") int offset); //搜索礼包列表数据 @GET("libao/{gift_Id}/detail") Observable getGiftDetail(@Path("gift_Id") String giftId); //获取礼包详情数据 diff --git a/app/src/main/res/drawable-hdpi/gift_icon.png b/app/src/main/res/drawable-hdpi/gift_icon.png new file mode 100644 index 0000000000..cbc7bde911 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/gift_icon.png differ diff --git a/app/src/main/res/layout/activity_detail.xml b/app/src/main/res/layout/activity_detail.xml index 2c7489ecfa..8339deab7e 100644 --- a/app/src/main/res/layout/activity_detail.xml +++ b/app/src/main/res/layout/activity_detail.xml @@ -70,6 +70,7 @@ android:layout_centerInParent="true"/> + diff --git a/app/src/main/res/layout/common_hintdialog.xml b/app/src/main/res/layout/common_hintdialog.xml new file mode 100644 index 0000000000..7f44c82857 --- /dev/null +++ b/app/src/main/res/layout/common_hintdialog.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_gift3.xml b/app/src/main/res/layout/fragment_gift3.xml index eae2178f2c..c1d9f53de3 100644 --- a/app/src/main/res/layout/fragment_gift3.xml +++ b/app/src/main/res/layout/fragment_gift3.xml @@ -21,7 +21,6 @@ android:layout_centerInParent="true" android:background="@color/theme" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/gift_item_search.xml b/app/src/main/res/layout/gift_item_search.xml new file mode 100644 index 0000000000..70ac8a5f93 --- /dev/null +++ b/app/src/main/res/layout/gift_item_search.xml @@ -0,0 +1,35 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/giftdetail_item_top.xml b/app/src/main/res/layout/giftdetail_item_top.xml index 52488113f8..91bf63d214 100644 --- a/app/src/main/res/layout/giftdetail_item_top.xml +++ b/app/src/main/res/layout/giftdetail_item_top.xml @@ -46,8 +46,7 @@ android:layout_height="wrap_content" android:textColor="@color/title" android:textSize="16sp" - android:singleLine="true" - android:text="暖床萌萌大礼包"/> + android:singleLine="true" /> + android:singleLine="true" /> + android:singleLine="true" /> @@ -78,6 +75,7 @@ android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginLeft="10dp" + android:gravity="center" android:textColor="@android:color/white"/> @@ -97,4 +95,4 @@ - \ No newline at end of file +