diff --git a/app/src/main/java/com/gh/common/util/DetailDownloadUtils.java b/app/src/main/java/com/gh/common/util/DetailDownloadUtils.java index 107c17b31b..8ba6f550cf 100644 --- a/app/src/main/java/com/gh/common/util/DetailDownloadUtils.java +++ b/app/src/main/java/com/gh/common/util/DetailDownloadUtils.java @@ -96,12 +96,16 @@ public class DetailDownloadUtils { } } else { String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity); - if ("插件化".equals(status)) { - viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_plugin_style); - } else if ("打开".equals(status)) { - viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_launch_style); - } else { - viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_download_style); + switch (status) { + case "插件化": + viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_plugin_style); + break; + case "打开": + viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_launch_style); + break; + default: + viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_download_style); + break; } if (viewHolder.isNewsDetail) { diff --git a/app/src/main/java/com/gh/common/util/GameUtils.java b/app/src/main/java/com/gh/common/util/GameUtils.java index 015ddaa9dc..35db4fa26b 100644 --- a/app/src/main/java/com/gh/common/util/GameUtils.java +++ b/app/src/main/java/com/gh/common/util/GameUtils.java @@ -2,6 +2,7 @@ package com.gh.common.util; import android.content.Context; import android.graphics.Color; +import android.text.TextUtils; import android.widget.TextView; import com.gh.download.DownloadEntity; @@ -82,7 +83,9 @@ public class GameUtils { } if (PackageManager.isInstalled(apkEntity.getPackageName())) { gh_id = PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_id"); - if (!PackageUtils.isSignature(context, apkEntity.getPackageName())) { // TODO 外层判断插件化逻辑与多平台弹窗不一致 + if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0 + && !TextUtils.isEmpty(apkEntity.getGhVersion()) + && !PackageUtils.isSignature(context, apkEntity.getPackageName())) { pluginCount++; } else if (gh_id == null || gh_id.equals(gameEntity.getId())) { installCount++; diff --git a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java index f9af3a1082..d40386ea8e 100644 --- a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java @@ -7,38 +7,32 @@ import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.support.design.widget.AppBarLayout; import android.support.v4.app.Fragment; -import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.text.TextUtils; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.BaseActivity; import com.gh.base.adapter.FragmentAdapter; -import com.gh.common.constant.Config; import com.gh.common.util.ApkActiveUtils; import com.gh.common.util.ConcernUtils; import com.gh.common.util.DataCollectionUtils; import com.gh.common.util.DataUtils; +import com.gh.common.util.DetailDownloadUtils; import com.gh.common.util.DialogUtils; import com.gh.common.util.EntranceUtils; -import com.gh.common.util.FileUtils; -import com.gh.common.util.GameUtils; import com.gh.common.util.ImageUtils; -import com.gh.common.util.NetworkUtils; -import com.gh.common.util.PackageUtils; import com.gh.common.util.ShareUtils; import com.gh.common.util.Utils; -import com.gh.common.view.DownloadDialog; import com.gh.download.DataWatcher; import com.gh.download.DownloadEntity; import com.gh.download.DownloadManager; +import com.gh.gamecenter.adapter.viewholder.DetailViewHolder; import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.GameDetailEntity; import com.gh.gamecenter.entity.GameEntity; @@ -49,7 +43,6 @@ import com.gh.gamecenter.eventbus.EBReuse; import com.gh.gamecenter.gamedetail.FuliFragment; import com.gh.gamecenter.gamedetail.XinXiFragment; import com.gh.gamecenter.manager.ConcernManager; -import com.gh.gamecenter.manager.PackageManager; import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; import com.jakewharton.rxbinding.view.RxView; @@ -106,14 +99,6 @@ public class GameDetailActivity extends BaseActivity { TextView mTanBarXinXiTv; @BindView(R.id.gamedetail_share) ImageView mShareIv; - @BindView(R.id.detail_ll_bottom) - LinearLayout mDownloadBottom; - @BindView(R.id.detail_tv_download) - TextView mDownloadTv; - @BindView(R.id.detail_tv_per) - TextView mDownloadPer; - @BindView(R.id.detail_pb_progressbar) - ProgressBar mDownloadPb; @BindView(R.id.gamedetail_appbar) AppBarLayout mAppBarLayout; @@ -127,6 +112,7 @@ public class GameDetailActivity extends BaseActivity { private String title; // 页面标题 private String shareCode; private boolean mIsTouchScreen = false; + private DataWatcher dataWatcher = new DataWatcher() { @Override public void onDataChanged(DownloadEntity downloadEntity) { @@ -136,13 +122,19 @@ public class GameDetailActivity extends BaseActivity { if (!"pause".equals(DownloadManager.getInstance(GameDetailActivity.this). getStatus(downloadEntity.getUrl()))) { mDownloadEntity = downloadEntity; - invalidate(); + DetailDownloadUtils.detailInvalidate(getDetailViewHolder()); } } } } }; + private DetailViewHolder getDetailViewHolder() { + // 每次获取需要重新创建, 防止数据刷新 + return new DetailViewHolder(mContentView, mGameEntity, mDownloadEntity, downloadOffText, downloadAddWord, + false, mEntrance, name, title); // 下载按钮ViewHolder + } + /** * 启动游戏详情页面 */ @@ -270,7 +262,7 @@ public class GameDetailActivity extends BaseActivity { if (mGameEntity != null && mGameEntity.getApk() != null && mGameEntity.getApk().size() == 1) { - initDownload(true); + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), true); } DownloadManager.getInstance(this).addObserver(dataWatcher); } @@ -424,7 +416,7 @@ public class GameDetailActivity extends BaseActivity { mViewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), list)); initGameDetailTop(); - initDownload(true); + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), true); if (!mConcernManager.isConcern(mGameId)) { mTanBarXinXiTv.performClick(); @@ -473,7 +465,7 @@ public class GameDetailActivity extends BaseActivity { && mGameEntity.getApk().size() == 1) { String url = mGameEntity.getApk().get(0).getUrl(); if (url.equals(status.getUrl())) { - initDownload(false); + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), false); } } } @@ -488,7 +480,7 @@ public class GameDetailActivity extends BaseActivity { String packageName = apkEntity.getPackageName(); if (packageName.equals(busFour.getPackageName())) { ApkActiveUtils.filterHideApk(mGameEntity); - initDownload(false); + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), false); } } } @@ -506,34 +498,7 @@ public class GameDetailActivity extends BaseActivity { , R.id.detail_tv_per, R.id.gamedetail_tabbar_xinxi_tv , R.id.gamedetail_tabbar_fuli_tv, R.id.gamedetail_share}) public void onClick(View v) { - if (v == mDownloadTv) { - if (mGameEntity != null && !mGameEntity.getApk().isEmpty()) { - if (mGameEntity.getApk().size() == 1) { - if (NetworkUtils.isWifiConnected(this)) { - download(); - } else { - DialogUtils.showDownloadDialog(this, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - download(); - } - }); - } - } else { - DownloadDialog.getInstance(this).showPopupWindow(v, mGameEntity, mEntrance, name + ":" + title); - } - } else { - toast("稍等片刻~!游戏正在上传中..."); - } - } else if (v == mDownloadPb || v == mDownloadPer) { - String str = mDownloadPer.getText().toString(); - if ("下载中".equals(str)) { - Intent intent = DownloadManagerActivity.getDownloadMangerIntent(this, mGameEntity.getApk().get(0).getUrl(), mEntrance + "+(" + name + "[" + title + "])"); - startActivity(intent); - } else if ("安装".equals(str)) { - PackageUtils.launchSetup(this, mDownloadEntity.getPath()); - } - } else if (v == mTanBarFuLiTv) { + if (v == mTanBarFuLiTv) { mViewPager.setCurrentItem(0); } else if (v == mTanBarXinXiTv) { mViewPager.setCurrentItem(1); @@ -567,174 +532,4 @@ public class GameDetailActivity extends BaseActivity { } } - private void download() { - String str = mDownloadTv.getText().toString(); - if (str.contains("启动")) { - DataUtils.onGameLaunchEvent(this, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), name); - - PackageUtils.launchApplicationByPackageName(this, mGameEntity.getApk().get(0).getPackageName()); - } else { - String method; - if (str.contains("更新")) { - method = "更新"; - } else if (str.contains("插件化")) { - method = "插件化"; - } else { - method = "下载"; - } - ApkEntity apkEntity = mGameEntity.getApk().get(0); - String msg = FileUtils.isCanDownload(this, apkEntity.getSize()); - if (TextUtils.isEmpty(msg)) { - DataUtils.onGameDownloadEvent(this, mGameEntity.getName(), apkEntity.getPlatform(), mEntrance, "下载开始"); - - DownloadManager.createDownload(this, apkEntity, mGameEntity, method, mEntrance, name + ":" + title); - - mDownloadTv.setVisibility(View.GONE); - mDownloadPb.setVisibility(View.VISIBLE); - mDownloadPer.setVisibility(View.VISIBLE); - mDownloadPb.setProgress(0); - mDownloadPer.setText("0.0%"); - - DownloadManager.getInstance(GameDetailActivity.this).putStatus(apkEntity.getUrl(), "downloading"); - } else { - toast(msg); - } - } - } - - private void invalidate() { - mDownloadPb.setProgress((int) (mDownloadEntity.getPercent() * 10)); - mDownloadPer.setTextColor(0xFFFFFFFF); - switch (mDownloadEntity.getStatus()) { - case downloading: - case pause: - case timeout: - case neterror: - case waiting: - mDownloadPer.setText("下载中"); - break; - case done: - mDownloadPer.setText("安装"); - if (mDownloadEntity.isPluggable() - && PackageManager.isInstalled(mDownloadEntity.getPackageName())) { - mDownloadPb.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progressbar_plugin_radius_style)); - } else { - mDownloadPb.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progressbar_normal_radius_style)); - } - break; - case cancel: - case hijack: - case notfound: - initDownload(false); - break; - default: - break; - } - } - - protected void initDownload(boolean isCheck) { - if (Config.isShow(this)) { - mDownloadBottom.setVisibility(View.VISIBLE); - } else { - mDownloadBottom.setVisibility(View.GONE); - } - if (mGameEntity != null && "光环助手".equals(mGameEntity.getName())) { - mDownloadBottom.setVisibility(View.GONE); - } else if (mGameEntity == null || mGameEntity.getApk().isEmpty()) { - mDownloadTv.setVisibility(View.VISIBLE); - mDownloadPb.setVisibility(View.GONE); - mDownloadPer.setVisibility(View.GONE); - if (TextUtils.isEmpty(downloadOffText)) { - mDownloadTv.setText("暂无下载"); - } else { - mDownloadTv.setText(downloadOffText); - } - mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_pause_style); - mDownloadTv.setTextColor(0xFF999999); - mDownloadTv.setClickable(false); - } else { - mDownloadTv.setVisibility(View.VISIBLE); - mDownloadPb.setVisibility(View.GONE); - mDownloadPer.setVisibility(View.GONE); - boolean isInstalled = false; - if (mGameEntity.getApk() != null && mGameEntity.getApk().size() == 1 - && PackageManager.isInstalled(mGameEntity.getApk().get(0).getPackageName())) { - isInstalled = true; - } - if (isInstalled) { - if (PackageManager.isCanUpdate(mGameEntity.getId(), mGameEntity.getApk().get(0).getPackageName())) { - if (TextUtils.isEmpty(downloadAddWord)) { - mDownloadTv.setBackgroundResource( - R.drawable.game_item_btn_download_style); - mDownloadTv.setText(String.format("更新《%s》", - mGameEntity.getName())); - } else { - mDownloadTv.setBackgroundResource( - R.drawable.game_item_btn_download_style); - mDownloadTv.setText(String.format("更新《%s》%s", - mGameEntity.getName(), downloadAddWord)); - } - } else { - if (mGameEntity.getTag() != null && mGameEntity.getTag().size() != 0 - && !TextUtils.isEmpty(mGameEntity.getApk().get(0).getGhVersion()) - && !PackageUtils.isSignature(this, mGameEntity.getApk().get(0).getPackageName())) { - if (TextUtils.isEmpty(downloadAddWord)) { - mDownloadTv.setBackgroundResource( - R.drawable.game_item_btn_plugin_style); - mDownloadTv.setText(String.format("插件化《%s》", - mGameEntity.getName())); - } else { - mDownloadTv.setBackgroundResource( - R.drawable.game_item_btn_plugin_style); - mDownloadTv.setText(String.format("插件化《%s》%s", - mGameEntity.getName(), downloadAddWord)); - } - } else { - if (TextUtils.isEmpty(downloadAddWord)) { - mDownloadTv.setBackgroundResource( - R.drawable.game_item_btn_launch_style); - mDownloadTv.setText(String.format("启动《%s》", - mGameEntity.getName())); - } else { - mDownloadTv.setBackgroundResource( - R.drawable.game_item_btn_launch_style); - mDownloadTv.setText(String.format("启动《%s》%s", - mGameEntity.getName(), downloadAddWord)); - } - } - } - } else { - String status = GameUtils.getDownloadBtnText(this, mGameEntity); - if ("插件化".equals(status)) { - mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_plugin_style); - } else if ("打开".equals(status)) { - mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_launch_style); - } else { - mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_download_style); - } - - if (TextUtils.isEmpty(downloadAddWord)) { - mDownloadTv.setText(String.format(status + "《%s》", - mGameEntity.getName())); - } else { - mDownloadTv.setText(String.format(status + "《%s》%s", - mGameEntity.getName(), downloadAddWord)); - } - } - } - if (isCheck && mGameEntity != null - && mGameEntity.getApk() != null - && mGameEntity.getApk().size() == 1) { - String url = mGameEntity.getApk().get(0).getUrl(); - DownloadEntity downloadEntity = DownloadManager.getInstance(getApplicationContext()).get(url); - if (downloadEntity != null) { - mDownloadEntity = downloadEntity; - mDownloadTv.setVisibility(View.GONE); - mDownloadPb.setVisibility(View.VISIBLE); - mDownloadPer.setVisibility(View.VISIBLE); - invalidate(); - } - } - } - } diff --git a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java index 4ffcb1e53e..10880ed6c2 100644 --- a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java @@ -7,20 +7,31 @@ import android.os.Handler; import android.os.Message; import android.support.annotation.NonNull; import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; -import com.gh.base.BaseDetailActivity; +import com.gh.base.BaseActivity; import com.gh.common.util.ApkActiveUtils; +import com.gh.common.util.DetailDownloadUtils; import com.gh.common.util.EntranceUtils; import com.gh.common.util.LibaoUtils; import com.gh.common.util.TokenUtils; import com.gh.common.util.Utils; import com.gh.common.view.VerticalItemDecoration; +import com.gh.download.DataWatcher; +import com.gh.download.DownloadEntity; +import com.gh.download.DownloadManager; import com.gh.gamecenter.adapter.LibaoDetailAdapter; +import com.gh.gamecenter.adapter.viewholder.DetailViewHolder; import com.gh.gamecenter.db.LibaoDao; +import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.LibaoEntity; +import com.gh.gamecenter.eventbus.EBDownloadStatus; +import com.gh.gamecenter.eventbus.EBPackage; import com.gh.gamecenter.eventbus.EBUISwitch; import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; @@ -31,20 +42,43 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.Calendar; import java.util.Date; +import butterknife.BindView; import retrofit2.HttpException; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; +import static com.gh.gamecenter.R.id.reuse_tv_none_data; + /** * Created by khy on 2016/12/13. */ -public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDetailAdapter.OnCodeScrollListener { +public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdapter.OnCodeScrollListener { + + @BindView(R.id.libaodetail_rv_show) + RecyclerView mLibaoDetailRv; + @BindView(R.id.reuse_ll_loading) + LinearLayout mLlLoading; + @BindView(R.id.reuse_no_connection) + LinearLayout mNoConnection; + @BindView(reuse_tv_none_data) + TextView mNoneDataTv; + @BindView(R.id.reuse_none_data) + LinearLayout mNoneData; + @BindView(R.id.detail_tv_download) + TextView mDownloadTv; private LibaoDetailAdapter mAdapter; private LibaoEntity mLibaoEntity; + private DownloadEntity mDownloadEntity; + private GameEntity mGameEntity; private boolean mIsScroll; + + private String mName; + private String mTitle; + protected String mDownloadAddWord; + protected String mDownloadOffText; private Handler handler = new Handler() { @Override @@ -74,6 +108,29 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta } }; + private DataWatcher dataWatcher = new DataWatcher() { + @Override + public void onDataChanged(DownloadEntity downloadEntity) { + if (mGameEntity != null && mGameEntity.getApk().size() == 1) { + String url = mGameEntity.getApk().get(0).getUrl(); + if (url.equals(downloadEntity.getUrl())) { + if (!"pause".equals(DownloadManager.getInstance(LibaoDetailActivity.this). + getStatus(downloadEntity.getUrl()))) { + mDownloadEntity = downloadEntity; + DetailDownloadUtils.detailInvalidate(getDetailViewHolder()); + } + } + } + } + }; + + + private DetailViewHolder getDetailViewHolder() { + // 每次获取需要重新创建, 防止数据刷新 + return new DetailViewHolder(mContentView, mGameEntity, mDownloadEntity, mDownloadOffText, mDownloadAddWord, + false, mEntrance, mName, mTitle); // 下载按钮ViewHolder + } + @NonNull public static Intent getIntent(Context context, LibaoEntity libaoEntity, String entrance) { Intent intent = new Intent(context, LibaoDetailActivity.class); @@ -100,34 +157,31 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - actionbar_tv_title.setText("礼包详情"); - + initTitle("礼包详情"); if (savedInstanceState != null) { mLibaoEntity = savedInstanceState.getParcelable(LibaoDetailActivity.class.getSimpleName()); } else { mLibaoEntity = getIntent().getParcelableExtra(LibaoDetailActivity.class.getSimpleName()); } - name = "礼包详情"; - - iv_share.setVisibility(View.GONE); + mName = "礼包详情"; mIsScroll = true; - mAdapter = new LibaoDetailAdapter(this, this, this, mLibaoEntity, detail_tv_download, mEntrance); - detail_rv_show.setLayoutManager(new LinearLayoutManager(this) { + mAdapter = new LibaoDetailAdapter(this, this, this, mLibaoEntity, mDownloadTv, mEntrance); + mLibaoDetailRv.setLayoutManager(new LinearLayoutManager(this) { @Override public boolean canScrollVertically() { return mIsScroll; } }); - detail_rv_show.addItemDecoration(new VerticalItemDecoration(this, 8, true)); - detail_rv_show.setAdapter(mAdapter); + mLibaoDetailRv.addItemDecoration(new VerticalItemDecoration(this, 8, true)); + mLibaoDetailRv.setAdapter(mAdapter); - reuse_no_connection.setOnClickListener(new View.OnClickListener() { + mNoConnection.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - reuse_no_connection.setVisibility(View.GONE); - reuse_ll_loading.setVisibility(View.VISIBLE); + mNoConnection.setVisibility(View.GONE); + mLlLoading.setVisibility(View.VISIBLE); handler.postDelayed(new Runnable() { @Override public void run() { @@ -147,9 +201,32 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta } } + @Override + protected void onPause() { + super.onPause(); + DownloadManager.getInstance(this).removeObserver(dataWatcher); + } + + @Override + protected void onResume() { + super.onResume(); + if (mGameEntity != null + && mGameEntity.getApk() != null + && mGameEntity.getApk().size() == 1) { + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), true); + } + DownloadManager.getInstance(this).addObserver(dataWatcher); + } + + @Override + protected int getLayoutId() { + return R.layout.activity_libaodetail; + + } + private void init() { if (mLibaoEntity != null && mLibaoEntity.getGame() != null && mLibaoEntity.getGame().getId() != null) { - title = mLibaoEntity.getName(); + mTitle = mLibaoEntity.getName(); getGameDigest(); String status = mLibaoEntity.getStatus(); String beforeStatus = mLibaoEntity.getBeforeStatus(); @@ -191,22 +268,21 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta @Override public void onResponse(GameEntity response) { ApkActiveUtils.filterHideApk(response); - gameEntity = response; + mGameEntity = response; - downloadAddWord = gameEntity.getDownloadAddWord(); - downloadOffText = gameEntity.getDownloadOffText(); - initDownload(true); + mDownloadAddWord = mGameEntity.getDownloadAddWord(); + mDownloadOffText = mGameEntity.getDownloadOffText(); + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), true); mAdapter.addLibaoDetail(); } @Override public void onFailure(HttpException 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); + mLibaoDetailRv.setVisibility(View.GONE); + mLlLoading.setVisibility(View.GONE); + mLibaoDetailRv.setPadding(0, 0, 0, 0); + mNoConnection.setVisibility(View.VISIBLE); } }); } @@ -224,29 +300,27 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta @Override public void loadDone() { - if (reuse_ll_loading != null) { - reuse_ll_loading.setVisibility(View.GONE); - detail_rv_show.setVisibility(View.VISIBLE); + if (mLlLoading != null) { + mLlLoading.setVisibility(View.GONE); + mLibaoDetailRv.setVisibility(View.VISIBLE); } } @Override public void loadError() { - 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); + mLibaoDetailRv.setVisibility(View.GONE); + mLlLoading.setVisibility(View.GONE); + mLibaoDetailRv.setPadding(0, 0, 0, 0); + mNoConnection.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); + mLibaoDetailRv.setVisibility(View.GONE); + mLlLoading.setVisibility(View.GONE); + mLibaoDetailRv.setPadding(0, 0, 0, 0); + mNoneDataTv.setText("天了噜~页面不见了"); + mNoneData.setVisibility(View.VISIBLE); } // 领取/淘号失败,根据返回的时间重新倒数 @@ -256,4 +330,34 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta handler.sendEmptyMessageDelayed(1, swith.getPosition()); } } + + // 接收下载被删除消息 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEvent(EBDownloadStatus status) { + if ("delete".equals(status.getStatus()) + && mGameEntity != null + && mGameEntity.getApk() != null + && mGameEntity.getApk().size() == 1) { + String url = mGameEntity.getApk().get(0).getUrl(); + if (url.equals(status.getUrl())) { + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), false); + } + } + } + + // 接受安装、卸载消息 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(EBPackage busFour) { + if (mGameEntity != null + && mGameEntity.getApk() != null + && mGameEntity.getApk().size() > 0) { + for (ApkEntity apkEntity : mGameEntity.getApk()) { + String packageName = apkEntity.getPackageName(); + if (packageName.equals(busFour.getPackageName())) { + ApkActiveUtils.filterHideApk(mGameEntity); + DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), false); + } + } + } + } } diff --git a/app/src/main/res/layout/activity_libaodetail.xml b/app/src/main/res/layout/activity_libaodetail.xml new file mode 100644 index 0000000000..44d1da9250 --- /dev/null +++ b/app/src/main/res/layout/activity_libaodetail.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file