添加首页轮播图数据统计
This commit is contained in:
@ -10,15 +10,26 @@ import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.TokenUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
import com.gh.gamecenter.NewsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.SubjectActivity;
|
||||
import com.gh.gamecenter.entity.SlideEntity;
|
||||
import com.gh.gamecenter.volley.extended.StringExtendedRequest;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -70,22 +81,17 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View view, ViewGroup container) {
|
||||
ViewHolder holder;
|
||||
if (view == null) {
|
||||
holder = new ViewHolder();
|
||||
view = holder.imageView = new SimpleDraweeView(context);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) view.getTag();
|
||||
view = new SimpleDraweeView(context);
|
||||
}
|
||||
|
||||
final SlideEntity slideEntity = slideList.get(getPosition(position));
|
||||
|
||||
ImageUtils.getInstance().display(context.getResources(), holder.imageView,
|
||||
ImageUtils.getInstance().display(context.getResources(), (SimpleDraweeView) view,
|
||||
slideEntity.getImage(), R.drawable.preload);
|
||||
// indicator.setPosition(slideList.size(), getPosition(position));
|
||||
|
||||
holder.imageView.setOnClickListener(new View.OnClickListener() {
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@ -94,15 +100,27 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
kv.put("位置", getPosition(position) + 1);
|
||||
DataUtils.onEvent(context, "点击", "游戏-插件-滚动图", kv);
|
||||
|
||||
// 首页轮播图数据统计
|
||||
statLunbotuData(getPosition(position));
|
||||
|
||||
if ("game".equals(slideEntity.getType())) {
|
||||
GameUtils.startGameDetailActivity(context, slideEntity.getLink(), "(游戏-插件:滚动图)");
|
||||
String entrance = "(游戏-插件:滚动图["
|
||||
+ slideEntity.getName()
|
||||
+ "=" + slideEntity.getType()
|
||||
+ "=" + (getPosition(position) + 1)
|
||||
+ "])";
|
||||
GameUtils.startGameDetailActivity(context, slideEntity.getLink(), entrance);
|
||||
} else if ("news".equals(slideEntity.getType())) {
|
||||
// 统计阅读量
|
||||
NewsUtils.statNewsViews(slideEntity.getLink());
|
||||
|
||||
Intent intent = new Intent(context, NewsDetailActivity.class);
|
||||
intent.putExtra("newsId", slideEntity.getLink());
|
||||
intent.putExtra("entrance", "(游戏-插件:滚动图)");
|
||||
intent.putExtra("entrance", "(游戏-插件:滚动图["
|
||||
+ slideEntity.getName()
|
||||
+ "=" + slideEntity.getType()
|
||||
+ "=" + (getPosition(position) + 1)
|
||||
+ "])");
|
||||
context.startActivity(intent);
|
||||
} else if ("column".equals(slideEntity.getType())) {
|
||||
Intent intent = new Intent(context, SubjectActivity.class);
|
||||
@ -117,8 +135,33 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
return view;
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
SimpleDraweeView imageView;
|
||||
// 首页轮播图数据统计
|
||||
public void statLunbotuData(int position) {
|
||||
SlideEntity slideEntity = slideList.get(position);
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("location", String.valueOf(position + 1));
|
||||
map.put("type", slideEntity.getType());
|
||||
map.put("title", slideEntity.getName());
|
||||
map.put("form", "click");
|
||||
|
||||
String version = PackageUtils.getVersion(context);
|
||||
String user = DeviceUtils.getDeviceID(context);
|
||||
String channel = (String) PackageUtils.getMetaData(context, context.getPackageName(), "TD_CHANNEL_ID");
|
||||
map.put("version", version);
|
||||
map.put("user", user);
|
||||
map.put("device_id", TokenUtils.getDeviceId(context));
|
||||
map.put("channel", channel);
|
||||
String url = Config.DATA_HOST + "api/v1d0/log";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("topic", "lunbotu");
|
||||
params.put("source", "GH-ASSIST-Client");
|
||||
params.put("time", String.valueOf(Utils.getTime(context)));
|
||||
params.put("content", new JSONObject(map).toString());
|
||||
StringExtendedRequest request = new StringExtendedRequest(Request.Method.POST, url, null, null);
|
||||
request.setParams(params);
|
||||
request.setShouldCache(false);
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,4 +179,5 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
this.isInfiniteLoop = isInfiniteLoop;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user