推荐入口增加跳转类型

This commit is contained in:
kehaoyuan
2018-06-26 17:28:30 +08:00
parent d17ad6a497
commit 2da4182ee1
8 changed files with 100 additions and 88 deletions

View File

@ -306,39 +306,40 @@ public class BindingAdapters {
}
// 显示下载过程状态
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
if (gameEntity.getApk().size() == 1 && downloadEntity != null) {
progressBar.setProgress((int) (downloadEntity.getPercent() * 10));
switch (downloadEntity.getStatus()) {
case downloading:
case pause:
case timeout:
case neterror:
case waiting:
progressBar.setText(R.string.downloading);
if (downloadEntity.isPluggable() && PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
} else {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
}
break;
case done:
progressBar.setText(R.string.install);
if (downloadEntity.isPluggable()
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
} else {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
}
break;
case cancel:
case hijack:
case notfound:
break;
default:
break;
if (gameEntity.getApk().size() == 1) {
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
if (downloadEntity != null) {
progressBar.setProgress((int) (downloadEntity.getPercent() * 10));
switch (downloadEntity.getStatus()) {
case downloading:
case pause:
case timeout:
case neterror:
case waiting:
progressBar.setText(R.string.downloading);
if (downloadEntity.isPluggable() && PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
} else {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
}
break;
case done:
progressBar.setText(R.string.install);
if (downloadEntity.isPluggable()
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
} else {
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
}
break;
case cancel:
case hijack:
case notfound:
break;
default:
break;
}
}
}
// 点击事件
@ -379,14 +380,19 @@ public class BindingAdapters {
break;
case INSTALL_PLUGIN:
case INSTALL_NORMAL:
if (downloadEntity != null)
PackageUtils.launchSetup(v.getContext(), downloadEntity.getPath());
if (gameEntity.getApk().size() == 1) {
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
if (downloadEntity != null) {
PackageUtils.launchSetup(v.getContext(), downloadEntity.getPath());
}
}
}
});
}
// 开始下载
private static void download(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent) {
private static void download(DownloadProgressBar progressBar, GameEntity
gameEntity, ExposureEvent traceEvent) {
String str = progressBar.getText();
String method;
if (str.contains("更新")) {
@ -419,7 +425,8 @@ public class BindingAdapters {
}
@BindingAdapter({"gameLabelList", "subjectTag"})
public static void setGameLabelList(LinearLayout layout, GameEntity gameEntity, String subjectTag) {
public static void setGameLabelList(LinearLayout layout, GameEntity gameEntity, String
subjectTag) {
if (gameEntity == null) return;
if (gameEntity.getTest() != null) {
View testView = LayoutInflater.from(layout.getContext()).inflate(R.layout.game_test_label, null);

View File

@ -9,24 +9,24 @@ import kotlinx.android.parcel.Parcelize
*/
@Parcelize
data class SubjectRecommendEntity(@SerializedName("column_id")
var columnId: String? = null,
data class SubjectRecommendEntity(
var link: String? = null,
@SerializedName("name_normal")
var nameNormal: String? = null,
@SerializedName("name_normal")
var nameNormal: String? = null,
@SerializedName("column_name")
var columnName: String? = null,
@SerializedName("column_name")
var columnName: String? = null,
var icon: String? = null,
var icon: String? = null,
var name: String? = null,
var name: String? = null,
var type: String? = null,
var type: String? = null,
var order: Boolean = false,
var order: Boolean = false,
var display: Display = Display()) : Parcelable
var display: Display = Display()) : Parcelable
@Parcelize
data class Display(var slide: Boolean = true,

View File

@ -17,6 +17,7 @@ import com.gh.gamecenter.databinding.FragmentGameBinding
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.eventbus.EBReuse
import com.gh.gamecenter.game.data.GameItemData
import com.gh.gamecenter.normal.NormalFragment
import com.halo.assistant.HaloApp
@ -147,4 +148,11 @@ class GameFragment : NormalFragment() {
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(reuse: EBReuse) {
if ("Refresh" == reuse.type) {
mListAdapter?.notifyDataSetChanged()
}
}
}

View File

@ -210,11 +210,13 @@ class GameFragmentAdapter(context: Context, model: GameViewModel, var blockName:
if (entity.type == "block") {
mContext.startActivity(BlockActivity.getIntent(mContext, entity))
} else if (entity.type == "category") {
mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.columnId!!, entity.name!!))
} else {
SubjectActivity.startSubjectActivity(mContext, entity.columnId, entity.columnName, entity.order
mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.link!!, entity.name!!))
} else if (entity.type == "column") {
SubjectActivity.startSubjectActivity(mContext, entity.link, entity.columnName, entity.order
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (data + 1).toString(), "]", ")"))
DataCollectionUtils.uploadPosition(mContext, "游戏", (data + 1).toString(), entity.name)
} else if (entity.type == "game") {
GameDetailActivity.startGameDetailActivity(mContext, entity.link, "(推荐入口)")
}
}
} else if (v.id == R.id.home_subject_failure) {
@ -241,11 +243,13 @@ class GameFragmentAdapter(context: Context, model: GameViewModel, var blockName:
if (entity.type == "block") {
mContext.startActivity(BlockActivity.getIntent(mContext, entity))
} else if (entity.type == "category") {
mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.columnId!!, entity.name!!))
} else {
SubjectActivity.startSubjectActivity(mContext, entity.columnId, entity.columnName, entity.order
mContext.startActivity(CategoryDirectoryActivity.getIntent(mContext, entity.link!!, entity.name!!))
} else if (entity.type == "column") {
SubjectActivity.startSubjectActivity(mContext, entity.link, entity.columnName, entity.order
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (5).toString(), "]", ")"))
DataCollectionUtils.uploadPosition(mContext, "游戏", (5).toString(), entity.name)
} else if (entity.type == "game") {
GameDetailActivity.startGameDetailActivity(mContext, entity.link, "(推荐入口)")
}
}
} else {

View File

@ -119,7 +119,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
if (initData) getSubjectDigest(initData)
return
}
val observable = if (blockData == null) mApi.slide else mApi.getBlockSlides(blockData?.columnId)
val observable = if (blockData == null) mApi.slide else mApi.getBlockSlides(blockData?.link)
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<List<SlideEntity>>() {
@ -140,7 +140,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
if (initData) getSubjectList(initData)
return
}
val observable = if (blockData == null) mApi.subjectDigest else mApi.getBlockRecommends(blockData?.columnId)
val observable = if (blockData == null) mApi.subjectDigest else mApi.getBlockRecommends(blockData?.link)
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<List<SubjectRecommendEntity>>() {
@ -169,7 +169,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
mIsLoading = true
if (initData) mSubjectPage = 1
val observable = if (blockData == null) mApi.getColumn(mSubjectPage) else mApi.getBlockColumns(blockData?.columnId, mSubjectPage)
val observable = if (blockData == null) mApi.getColumn(mSubjectPage) else mApi.getBlockColumns(blockData?.link, mSubjectPage)
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<List<SubjectEntity>>() {

View File

@ -49,13 +49,13 @@ public class AskQuestionsRecommendsAdapter extends ListAdapter<AnswerEntity> {
} else {
mSubjectEntity = new ArrayList<>(subjectEntity);
}
notifyDataSetChanged();
notifyItemChanged(0);
}
@Override
protected void setListData(List<AnswerEntity> updateData) {
mEntityList = new ArrayList<>(updateData);
notifyDataSetChanged();
notifyItemRangeChanged(1, updateData.size());
}
@Override

View File

@ -105,7 +105,7 @@ public class AskQuestionsRecommendsFragment extends ListFragment<AnswerEntity, A
AskLogUtils.communityRefresh(getContext(), integer);
break;
case -1:
toast("获取失败,请检查网络设置");
toast("获取失败,请检查网络设置");
break;
default:
mRefreshHint.setText("成功获取" + integer + "条内容");
@ -206,7 +206,7 @@ public class AskQuestionsRecommendsFragment extends ListFragment<AnswerEntity, A
case R.id.ask_recommends_item_refresh:
scrollToTop();
refreshLayout.autoRefresh();
onRefresh();
// onRefresh();
break;
}