基本完成首页专题、专题详情、分类详情的曝光统计需求 http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/253

This commit is contained in:
chenjuntao
2018-06-20 17:22:40 +08:00
parent 3e285a4466
commit 875c0b8c16
53 changed files with 1377 additions and 229 deletions

View File

@ -3,6 +3,7 @@ package com.gh.common.util;
import android.content.Context;
import android.graphics.Color;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.ArrayMap;
import android.support.v7.widget.RecyclerView;
@ -11,6 +12,8 @@ import android.view.View;
import android.widget.TextView;
import com.gh.common.constant.Config;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.exposure.ExposureUtils;
import com.gh.common.view.DownloadDialog;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.DownloadManagerActivity;
@ -315,20 +318,22 @@ public class DownloadItemUtils {
final String entrance,
final String location) {
setOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, null);
}
public static void setOnClickListener(final Context context,
final TextView downloadBtn,
final GameEntity gameEntity,
final int position,
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
final String entrance,
final String location,
final ExposureEvent traceEvent) {
if (gameEntity.getApk().size() == 1) {
downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location);
}
});
downloadBtn.setOnClickListener(v -> onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent));
} else {
downloadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location);
}
});
downloadBtn.setOnClickListener(v -> DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location, traceEvent));
}
}
@ -340,31 +345,32 @@ public class DownloadItemUtils {
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
final String entrance,
final String location) {
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, null);
}
public static void onNormalClick(final Context context,
final TextView downloadBtn,
final GameEntity gameEntity,
final int position,
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
final String entrance,
final String location,
@Nullable final ExposureEvent traceEvent) {
String str = downloadBtn.getText().toString();
switch (str) {
case "下载":
if (NetworkUtils.isWifiConnected(context)) {
download(context, gameEntity, downloadBtn, entrance, location);
download(context, gameEntity, downloadBtn, entrance, location, traceEvent);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
download(context, gameEntity, downloadBtn, entrance, location);
}
});
DialogUtils.showDownloadDialog(context, () -> download(context, gameEntity, downloadBtn, entrance, location, traceEvent));
}
break;
case "插件化":
if (NetworkUtils.isWifiConnected(context)) {
plugin(context, gameEntity, downloadBtn, entrance, location);
plugin(context, gameEntity, downloadBtn, entrance, location, traceEvent);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
plugin(context, gameEntity, downloadBtn, entrance, location);
}
});
DialogUtils.showDownloadDialog(context, () -> plugin(context, gameEntity, downloadBtn, entrance, location, traceEvent));
}
break;
case "安装":
@ -381,14 +387,9 @@ public class DownloadItemUtils {
break;
case "更新":
if (NetworkUtils.isWifiConnected(context)) {
update(context, gameEntity, entrance, location);
update(context, gameEntity, entrance, location, traceEvent);
} else {
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
update(context, gameEntity, entrance, location);
}
});
DialogUtils.showDownloadDialog(context, () -> update(context, gameEntity, entrance, location, traceEvent));
}
break;
}
@ -399,12 +400,15 @@ public class DownloadItemUtils {
GameEntity gameEntity,
TextView downloadBtn,
String entrance,
String location) {
String location,
@Nullable ExposureEvent traceEvent) {
String msg = FileUtils.isCanDownload(context, gameEntity.getApk().get(0).getSize());
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), entrance, "下载开始");
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location);
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.DOWNLOAD);
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location, downloadExposureEvent);
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
downloadBtn.setText(R.string.downloading);
@ -419,12 +423,14 @@ public class DownloadItemUtils {
//插件化
private static void plugin(Context context, GameEntity gameEntity, TextView downloadBtn, String entrance,
String location) {
String location, @Nullable ExposureEvent traceEvent) {
String msg = FileUtils.isCanDownload(context, gameEntity.getApk().get(0).getSize());
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), entrance, "下载开始");
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location);
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.PLUGIN_DOWNLOAD);
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, downloadExposureEvent);
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
downloadBtn.setText(R.string.downloading);
@ -458,9 +464,10 @@ public class DownloadItemUtils {
}
//更新
private static void update(Context context, GameEntity gameEntity, String entrance, String location) {
private static void update(Context context, GameEntity gameEntity, String entrance, String location, @Nullable ExposureEvent traceEvent) {
DataUtils.onGameUpdateEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), "下载开始");
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location);
ExposureEvent downloadExposureEvent = ExposureUtils.INSTANCE.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.UPDATE);
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location, downloadExposureEvent);
}
}