Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
This commit is contained in:
@ -122,7 +122,6 @@ android {
|
||||
dimension "nonsense"
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "COMMENT_HOST", "\"${COMMENT_HOST}\""
|
||||
buildConfigField "String", "DATA_HOST", "\"${DATA_HOST}\""
|
||||
|
||||
buildConfigField "String", "UMENG_APPKEY", "\"${UMENG_APPKEY}\""
|
||||
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${UMENG_MESSAGE_SECRET}\""
|
||||
@ -140,7 +139,6 @@ android {
|
||||
|
||||
buildConfigField "String", "API_HOST", "\"${DEV_API_HOST}\""
|
||||
buildConfigField "String", "COMMENT_HOST", "\"${DEV_COMMENT_HOST}\""
|
||||
buildConfigField "String", "DATA_HOST", "\"${DEV_DATA_HOST}\""
|
||||
|
||||
buildConfigField "String", "UMENG_APPKEY", "\"${DEBUG_UMENG_APPKEY}\""
|
||||
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${DEBUG_UMENG_MESSAGE_SECRET}\""
|
||||
|
||||
@ -31,7 +31,6 @@ public class Config {
|
||||
|
||||
public static final String API_HOST = BuildConfig.API_HOST;
|
||||
public static final String COMMENT_HOST = BuildConfig.COMMENT_HOST;
|
||||
public static final String DATA_HOST = BuildConfig.DATA_HOST;
|
||||
|
||||
/**
|
||||
* 需要配置的请使用{@link PreferenceManager#getDefaultSharedPreferences(Context)}
|
||||
|
||||
@ -9,8 +9,6 @@ import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -169,24 +167,4 @@ public class DataCollectionUtils {
|
||||
map.put("type", args[2]);
|
||||
DataCollectionManager.onEvent(context, "concern", map);
|
||||
}
|
||||
|
||||
//上传推荐位数据
|
||||
public static void uploadPosition(Context context, String... args) {
|
||||
if (args.length < 3) {
|
||||
return;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("page", args[0]);
|
||||
map.put("location", args[1]);
|
||||
map.put("name", args[2]);
|
||||
DataCollectionManager.onEvent(context, "position", map);
|
||||
}
|
||||
|
||||
//上传应用列表
|
||||
public static void uploadAppList(Context context, JSONArray applist) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("applist", applist);
|
||||
DataCollectionManager.onEvent(context, "applist", map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,8 +2,7 @@ package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.common.loghub.LoghubUtils;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
@ -14,12 +13,6 @@ import org.json.JSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/12/8.
|
||||
* 日志上传工具类
|
||||
@ -68,12 +61,7 @@ public class DataLogUtils {
|
||||
params.put("time", String.valueOf(Utils.getTime(context)));
|
||||
params.put("content", new JSONObject(map).toString());
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
new JSONObject(params).toString());
|
||||
RetrofitManager.getInstance(context).getData().postLog(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>());
|
||||
LoghubUtils.log(new JSONObject(params), "common", true);
|
||||
}
|
||||
|
||||
// 网络错误
|
||||
|
||||
@ -46,7 +46,7 @@ public class NewsUtils {
|
||||
* 统计阅读量
|
||||
*/
|
||||
public static void statNewsViews(Context context, String news_id) {
|
||||
RetrofitManager.getInstance(context).getData().postNewsViews(news_id)
|
||||
RetrofitManager.getInstance(context).getApi().postArticleVisit(news_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>());
|
||||
|
||||
@ -130,7 +130,9 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
|
||||
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location,
|
||||
@Nullable ExposureEvent traceEvent) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
|
||||
// todo 后续修正
|
||||
if (true) {
|
||||
com.gh.download.dialog.DownloadDialog.showDownloadDialog(mContext, gameEntity);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.im.ImManager;
|
||||
import com.gh.common.loghub.LoghubUtils;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.util.ActivationHelper;
|
||||
import com.gh.common.util.ClassUtils;
|
||||
@ -87,6 +88,7 @@ import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.AppManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.tencent.bugly.beta.tinker.TinkerManager;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.umeng.message.PushAgent;
|
||||
@ -799,17 +801,20 @@ public class MainActivity extends BaseActivity {
|
||||
// 发送应用变更前都检查一下是否需要把所有应用都上传
|
||||
PackageRepository.checkAndUploadAppList();
|
||||
|
||||
JSONObject packageObject = PackageUtils.getAppBasicInfoByPackageName(packageName);
|
||||
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"),
|
||||
packageObject.toString());
|
||||
|
||||
// 更新已安装游戏
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.postNewlyInstalledApp(HaloApp.getInstance().getGid(), requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new EmptyResponse<>());
|
||||
JSONObject packageObject = PackageUtils.getAppBasicInfoByPackageName(packageName);
|
||||
JSONObject dataObject = new JSONObject();
|
||||
JSONObject wrapperObject = new JSONObject();
|
||||
try {
|
||||
dataObject.put("type", "POST");
|
||||
dataObject.put("device_id", HaloApp.getInstance().getGid());
|
||||
dataObject.put("app", packageObject);
|
||||
dataObject.put("time", Utils.getTime(getApplicationContext()));
|
||||
wrapperObject.put("content", dataObject.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true);
|
||||
|
||||
if (!TextUtils.isEmpty(gameId) && UserManager.getInstance().isLoggedIn()) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@ -836,11 +841,18 @@ public class MainActivity extends BaseActivity {
|
||||
PackageRepository.checkAndUploadAppList();
|
||||
|
||||
// 删除已安装游戏
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.deleteInstalledApp(HaloApp.getInstance().getGid(), packageName)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new EmptyResponse<>());
|
||||
JSONObject dataObject = new JSONObject();
|
||||
JSONObject wrapperObject = new JSONObject();
|
||||
try {
|
||||
dataObject.put("type", "DELETE");
|
||||
dataObject.put("device_id", HaloApp.getInstance().getGid());
|
||||
dataObject.put("package", packageName);
|
||||
dataObject.put("time", Utils.getTime(getApplicationContext()));
|
||||
wrapperObject.put("content", dataObject.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true);
|
||||
}
|
||||
|
||||
// 接收登录和登出更新事件统计的 Meta
|
||||
|
||||
@ -496,7 +496,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
|
||||
private void statNewsViews(final String news_id) {
|
||||
RetrofitManager.getInstance(mContext).getData().postNewsViews(news_id)
|
||||
RetrofitManager.getInstance(mContext).getApi().postArticleVisit(news_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
|
||||
@ -219,7 +219,7 @@ public class ArticleAdapter extends ListAdapter<NewsEntity> {
|
||||
|
||||
// 统计新闻阅读量
|
||||
public void statNewsViews(final NewsEntity newsEntity, final int position) {
|
||||
RetrofitManager.getInstance(mContext).getData().postNewsViews(newsEntity.getId())
|
||||
RetrofitManager.getInstance(mContext).getApi().postArticleVisit(newsEntity.getId())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.collection;
|
||||
import android.app.Application;
|
||||
|
||||
import com.gh.common.history.HistoryDatabase;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.gamecenter.baselist.ListViewModel;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.ViewsEntity;
|
||||
@ -45,7 +46,10 @@ public class ArticleViewModel extends ListViewModel<NewsEntity, NewsEntity> {
|
||||
if (builder.length() > 0) {
|
||||
builder.deleteCharAt(builder.length() - 1);
|
||||
String ids = builder.toString();
|
||||
mNewsViewsRepository.getNewsViews(RetrofitManager.getInstance(getApplication()).getData().getNewsViews(ids));
|
||||
mNewsViewsRepository.getNewsViews(RetrofitManager
|
||||
.getInstance(getApplication())
|
||||
.getApi()
|
||||
.getArticlesVisits(UrlFilterUtils.getFilterQuery("article_ids", ids)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -365,7 +365,6 @@ class GameFragmentAdapter(context: Context,
|
||||
entity.type == "column" -> {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.link, entity.text, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (data + 1).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (data + 1).toString(), entity.name)
|
||||
}
|
||||
entity.type == "game" -> GameDetailActivity.startGameDetailActivity(mContext, entity.link, "(推荐入口)")
|
||||
entity.type == EntranceUtils.HOST_COMMUNITY -> DirectUtils.directToCommunity(mContext, CommunityEntity(entity.link!!, entity.text!!))
|
||||
@ -466,8 +465,8 @@ class GameFragmentAdapter(context: Context,
|
||||
}
|
||||
|
||||
holder.binding.game = gameEntity
|
||||
holder.binding.subjectTag = subjectData?.tag
|
||||
holder.initServerType(gameEntity!!)
|
||||
holder.binding.subjectTag = subjectData.tag
|
||||
holder.initServerType(gameEntity)
|
||||
holder.binding.executePendingBindings()
|
||||
|
||||
itemData.exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
|
||||
@ -19,6 +19,7 @@ import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.NumberUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.NewsDigestViewHolder;
|
||||
@ -232,8 +233,8 @@ class ConcernAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}, new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(String s) {
|
||||
RetrofitManager.getInstance(mContext).getData()
|
||||
.getNewsViews(s)
|
||||
RetrofitManager.getInstance(mContext).getApi()
|
||||
.getArticlesVisits(UrlFilterUtils.getFilterQuery("article_ids", s))
|
||||
.map((Function<List<ViewsEntity>, String>) list1 -> {
|
||||
for (ViewsEntity viewsEntity : list1) {
|
||||
for (ConcernEntity concernEntity : concernList) {
|
||||
@ -458,7 +459,7 @@ class ConcernAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
// 统计新闻阅读量
|
||||
public void statNewsViews(final ConcernEntity concernEntity, final int position) {
|
||||
RetrofitManager.getInstance(mContext).getData().postNewsViews(concernEntity.getId())
|
||||
RetrofitManager.getInstance(mContext).getApi().postArticleVisit(concernEntity.getId())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
|
||||
@ -167,7 +167,7 @@ class InfoAdapter extends ListAdapter<NewsEntity> {
|
||||
|
||||
// 统计新闻阅读量
|
||||
public void statNewsViews(final NewsEntity newsEntity, final int position) {
|
||||
RetrofitManager.getInstance(mContext).getData().postNewsViews(newsEntity.getId())
|
||||
RetrofitManager.getInstance(mContext).getApi().postArticleVisit(newsEntity.getId())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
|
||||
@ -57,7 +57,10 @@ public class InfoViewModel extends ListViewModel<NewsEntity, NewsEntity> {
|
||||
if (builder.length() > 0) {
|
||||
builder.deleteCharAt(builder.length() - 1);
|
||||
String ids = builder.toString();
|
||||
mNewsViewsRepository.getNewsViews(RetrofitManager.getInstance(getApplication()).getData().getNewsViews(ids));
|
||||
mNewsViewsRepository.getNewsViews(RetrofitManager
|
||||
.getInstance(getApplication())
|
||||
.getApi()
|
||||
.getArticlesVisits(UrlFilterUtils.getFilterQuery("article_ids", ids)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,16 +75,5 @@ public class InfoWrapperFragment extends BaseFragment_TabLayout {
|
||||
public void onPageSelected(int position) {
|
||||
MtaHelper.onEvent("我的光环_新", "资讯中心", mTabTitleList.get(position) + "Tab");
|
||||
EventBus.getDefault().post(new EBUISwitch(EB_NEWSFRAGMENT_TAG, position));
|
||||
switch (position) {
|
||||
case 0:
|
||||
DataCollectionUtils.uploadPosition(getActivity(), "资讯", "1", "资讯");
|
||||
break;
|
||||
case 1:
|
||||
DataCollectionUtils.uploadPosition(getActivity(), "资讯", "2", "攻略");
|
||||
break;
|
||||
case 2:
|
||||
DataCollectionUtils.uploadPosition(getActivity(), "资讯", "3", "原创");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package com.gh.gamecenter.info;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -145,7 +147,7 @@ class OriginalAdapter extends ListAdapter<NewsEntity> {
|
||||
}
|
||||
|
||||
public void statNewsViews(final NewsEntity newsEntity, final int position) {
|
||||
RetrofitManager.getInstance(mContext).getData().postNewsViews(newsEntity.getId())
|
||||
RetrofitManager.getInstance(mContext).getApi().postArticleVisit(newsEntity.getId())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
|
||||
@ -58,7 +58,10 @@ public class OriginalViewModel extends ListViewModel<NewsEntity, NewsEntity> {
|
||||
if (builder.length() > 0) {
|
||||
builder.deleteCharAt(builder.length() - 1);
|
||||
String ids = builder.toString();
|
||||
mNewsViewsRepository.getNewsViews(RetrofitManager.getInstance(getApplication()).getData().getNewsViews(ids));
|
||||
mNewsViewsRepository.getNewsViews(RetrofitManager
|
||||
.getInstance(getApplication())
|
||||
.getApi()
|
||||
.getArticlesVisits(UrlFilterUtils.getFilterQuery("article_ids", ids)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
package com.gh.gamecenter.manager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.gh.common.loghub.LoghubUtils;
|
||||
import com.gh.common.util.Installation;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.db.DataCollectionDao;
|
||||
import com.gh.gamecenter.db.info.DataCollectionInfo;
|
||||
import com.gh.gamecenter.retrofit.JSONObjectResponse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -24,13 +22,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
|
||||
public class DataCollectionManager {
|
||||
|
||||
private static DataCollectionManager mInstance;
|
||||
@ -65,24 +56,17 @@ public class DataCollectionManager {
|
||||
map.put("user", user);
|
||||
map.put("device_id", Util_System_Phone_State.getDeviceId(mContext));
|
||||
map.put("channel", channel);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("type", type);
|
||||
params.put("data", new JSONObject(map).toString());
|
||||
params.put("updateOn", Utils.getTime(HaloApp.getInstance().getApplication()));
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
new JSONObject(params).toString());
|
||||
RetrofitManager.getInstance(mContext).getData().postRealData(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
if ("applist".equals(type)) {
|
||||
PreferenceManager.getDefaultSharedPreferences(mContext)
|
||||
.edit().putLong("last_upload_applist_time", Utils.getTime(mContext)).apply();
|
||||
}
|
||||
}
|
||||
});
|
||||
Map<String, Object> paramsWrapper = new HashMap<>();
|
||||
paramsWrapper.put("topic", type);
|
||||
paramsWrapper.put("content", new JSONObject(params));
|
||||
paramsWrapper.put("time", Utils.getTime(HaloApp.getInstance().getApplication()));
|
||||
|
||||
LoghubUtils.log(new JSONObject(paramsWrapper), "collection", true);
|
||||
}
|
||||
|
||||
public static DataCollectionManager getInstance(Context context) {
|
||||
@ -136,13 +120,13 @@ public class DataCollectionManager {
|
||||
}
|
||||
isUploading = true;
|
||||
|
||||
final List<String> ids = new ArrayList<>();
|
||||
|
||||
String version = PackageUtils.getVersionName();
|
||||
String user = Installation.getUUID(mContext);
|
||||
String channel = HaloApp.getInstance().getChannel();
|
||||
|
||||
HashMap<String, JSONArray> map = new HashMap<>();
|
||||
// Pair first: database id ,second: type
|
||||
HashMap<Pair<String, String>, JSONArray> map = new HashMap<>();
|
||||
DataCollectionInfo dataCollectionEntity;
|
||||
String type;
|
||||
JSONArray jsonArray;
|
||||
@ -155,7 +139,7 @@ public class DataCollectionManager {
|
||||
jsonArray = map.get(type);
|
||||
if (jsonArray == null) {
|
||||
jsonArray = new JSONArray();
|
||||
map.put(type, jsonArray);
|
||||
map.put(new Pair<>(dataCollectionEntity.getId(), type), jsonArray);
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject(
|
||||
dataCollectionEntity.getData());
|
||||
@ -164,50 +148,28 @@ public class DataCollectionManager {
|
||||
jsonObject.put("device_id", Util_System_Phone_State.getDeviceId(mContext));
|
||||
jsonObject.put("channel", channel);
|
||||
jsonArray.put(jsonObject.toString());
|
||||
|
||||
ids.add(dataCollectionEntity.getId());
|
||||
}
|
||||
|
||||
if (!isForce && ids.size() < 20) {
|
||||
if (!isForce && map.size() < 20) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Object> params = new ArrayList<>();
|
||||
for (String key : map.keySet()) {
|
||||
for (Pair<String, String> pair : map.keySet()) {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("type", key);
|
||||
hashMap.put("data", map.get(key));
|
||||
JSONObject jsonObject = new JSONObject(hashMap);
|
||||
params.add(jsonObject);
|
||||
hashMap.put("type", pair.second);
|
||||
hashMap.put("data", map.get(pair));
|
||||
hashMap.put("updateOn", Utils.getTime(HaloApp.getInstance().getApplication()));
|
||||
|
||||
Map<String, Object> paramsWrapper = new HashMap<>();
|
||||
paramsWrapper.put("topic", pair.second);
|
||||
paramsWrapper.put("content", new JSONObject(hashMap));
|
||||
paramsWrapper.put("time", Utils.getTime(HaloApp.getInstance().getApplication()));
|
||||
|
||||
// 提交到LogHub模块后就等于上传完成了,后续无论上传成功还是失败都按照LogHub的策略处理
|
||||
LoghubUtils.log(new JSONObject(paramsWrapper), "collection", true);
|
||||
dao.delete(pair.first);
|
||||
}
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
new JSONArray(params).toString());
|
||||
RetrofitManager.getInstance(mContext).getData().postData(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
isUploading = false;
|
||||
|
||||
if (response.length() != 0) {
|
||||
try {
|
||||
if ("success".equals(response.getString("status"))) {
|
||||
// 上传成功,删除本地数据
|
||||
dao.delete(ids);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
isUploading = false;
|
||||
}
|
||||
});
|
||||
isUploading = false;
|
||||
}
|
||||
|
||||
public static void upsert(Context context, String type, Map<String, Object> map) {
|
||||
@ -277,7 +239,7 @@ public class DataCollectionManager {
|
||||
|
||||
public static void onEvent(Context context, String type, Map<String, Object> map) {
|
||||
map.put("createdOn", Utils.getTime(context));
|
||||
if ("news".equals(type) || "download".equals(type) || "search".equals(type) || "position".equals(type) || "applist".equals(type)) {
|
||||
if ("news".equals(type) || "download".equals(type) || "search".equals(type)) {
|
||||
DataCollectionManager.getInstance(context).realTimeUpload(type, map);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.gamecenter.retrofit.ObservableUtil;
|
||||
import com.gh.gamecenter.retrofit.OkHttpCache;
|
||||
|
||||
@ -82,7 +83,7 @@ public class VisitManager {
|
||||
}
|
||||
|
||||
public void addUrl(String ids) {
|
||||
String url = StringUtils.buildString(Config.DATA_HOST, "v1d46/news/", ids, "/visit");
|
||||
String url = StringUtils.buildString(Config.API_HOST, "articles/visits?filter=" + UrlFilterUtils.getFilterQuery("article_ids", ids));
|
||||
if (!urlList.contains(url)) {
|
||||
urlList.add(url);
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import com.gh.common.util.PermissionHelper;
|
||||
import com.gh.common.util.PostCommentUtils;
|
||||
import com.gh.common.util.TextHelper;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.MessageDetailAdapter;
|
||||
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
|
||||
@ -242,8 +243,8 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa
|
||||
}
|
||||
|
||||
private void getNewsViews() {
|
||||
RetrofitManager.getInstance(getContext()).getData()
|
||||
.getNewsViews(newsId)
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.getArticlesVisits(UrlFilterUtils.getFilterQuery("article_ids", newsId))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<List<ViewsEntity>>() {
|
||||
|
||||
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.preference.PreferenceManager
|
||||
import android.text.TextUtils
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.common.loghub.LoghubUtils
|
||||
import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
@ -13,6 +14,7 @@ import com.gh.gamecenter.entity.GameInstall
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import com.gh.gamecenter.manager.FilterManager
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository.gameInstalled
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository.gameUpdate
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
@ -20,6 +22,7 @@ import com.gh.gamecenter.retrofit.ObservableUtil
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Util_System_Phone_State
|
||||
import com.lightgame.utils.Utils
|
||||
import com.tencent.bugly.beta.tinker.TinkerManager.getApplication
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@ -27,6 +30,8 @@ import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
|
||||
/**
|
||||
@ -122,30 +127,28 @@ object PackageRepository {
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun uploadAppList() {
|
||||
// 检查是否符合应用上报周期, 用的不同 SP 不冲突
|
||||
val time = mSharedPreferences.getLong(LAST_UPLOAD_APPLIST_TIME, 0)
|
||||
// 检查是否符合应用上报周期
|
||||
val lastUploadTime = SPUtils.getLong(LAST_UPLOAD_APPLIST_TIME, 0)
|
||||
|
||||
// 上传到 data 后台一周一个周期
|
||||
if (Utils.getTime(mApplication) - time >= 604800L) {
|
||||
DataCollectionUtils.uploadAppList(mApplication, PackageUtils.getAppList(mApplication))
|
||||
}
|
||||
|
||||
// 上传到 api 后台一天一个周期
|
||||
if (Utils.getTime(mApplication) - lastUploadTime >= (3600 * 24)) {
|
||||
|
||||
val appList = PackageUtils.getAppList(mApplication)
|
||||
|
||||
val requestBody = RequestBody.create(MediaType.parse("application/json"),
|
||||
appList.toString())
|
||||
|
||||
RetrofitManager.getInstance(mApplication).api.putInstalledApps(HaloApp.getInstance().gid, requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
SPUtils.setLong(LAST_UPLOAD_APPLIST_TIME, System.currentTimeMillis() / 1000)
|
||||
}
|
||||
})
|
||||
val dataObject = JSONObject()
|
||||
val wrapperObject = JSONObject()
|
||||
try {
|
||||
dataObject.put("type", "PUT")
|
||||
dataObject.put("device_id", HaloApp.getInstance().gid)
|
||||
dataObject.put("app", appList)
|
||||
dataObject.put("imei", Util_System_Phone_State.getImei(HaloApp.getInstance().application))
|
||||
dataObject.put("user_id", UserManager.getInstance().userId)
|
||||
dataObject.put("time", Utils.getTime(HaloApp.getInstance().application))
|
||||
wrapperObject.put("content", dataObject.toString())
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true)
|
||||
SPUtils.setLong(LAST_UPLOAD_APPLIST_TIME, System.currentTimeMillis() / 1000)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import com.chuckerteam.chucker.api.RetentionManager;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.gamecenter.Injection;
|
||||
import com.gh.gamecenter.retrofit.service.ApiService;
|
||||
import com.gh.gamecenter.retrofit.service.DataService;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -32,7 +31,6 @@ public class RetrofitManager {
|
||||
private static final byte[] LOCK = new byte[0];
|
||||
private ApiService mApiService;
|
||||
private ApiService mUploadApiService;
|
||||
private DataService mDataService;
|
||||
|
||||
public static <T> T provideService(OkHttpClient client, String url, Class<T> serviceCls) {
|
||||
return new Retrofit.Builder()
|
||||
@ -45,7 +43,6 @@ public class RetrofitManager {
|
||||
private RetrofitManager(Context context) {
|
||||
OkHttpClient okHttpNormalConfig = getOkHttpConfig(context, NORMAL_CONN_TIME_OUT, NORMAL_READ_TIME_OUT);
|
||||
mApiService = provideService(okHttpNormalConfig, Config.API_HOST, ApiService.class);
|
||||
mDataService = provideService(okHttpNormalConfig, Config.DATA_HOST, DataService.class);
|
||||
mUploadApiService = provideService(getOkHttpConfig(context, UPLOAD_TIME_OUT, UPLOAD_TIME_OUT), Config.API_HOST, ApiService.class);
|
||||
}
|
||||
|
||||
@ -82,9 +79,4 @@ public class RetrofitManager {
|
||||
public ApiService getUploadApi() {
|
||||
return mUploadApiService;
|
||||
}
|
||||
|
||||
public DataService getData() {
|
||||
return mDataService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@ import com.gh.gamecenter.entity.VersionVoteEntity;
|
||||
import com.gh.gamecenter.entity.VideoDraftEntity;
|
||||
import com.gh.gamecenter.entity.VideoEntity;
|
||||
import com.gh.gamecenter.entity.VideoTagEntity;
|
||||
import com.gh.gamecenter.entity.ViewsEntity;
|
||||
import com.gh.gamecenter.entity.VoteEntity;
|
||||
import com.gh.gamecenter.entity.WelcomeDialogEntity;
|
||||
import com.gh.gamecenter.gamedetail.entity.NewGameDetailEntity;
|
||||
@ -1781,31 +1782,6 @@ public interface ApiService {
|
||||
Observable<RatingComment> getGameComment(@Path("game_id") String gameId,
|
||||
@Path("comment_id") String commitId);
|
||||
|
||||
|
||||
/**
|
||||
* 本设备新增了一个应用
|
||||
*
|
||||
* @param deviceId gid
|
||||
*/
|
||||
@POST("devices/{device_id}/applications")
|
||||
Single<ResponseBody> postNewlyInstalledApp(@Path("device_id") String deviceId, @Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 本设备删除了一个应用
|
||||
*
|
||||
* @param deviceId gid
|
||||
*/
|
||||
@DELETE("devices/{device_id}/applications/{package_name}")
|
||||
Single<ResponseBody> deleteInstalledApp(@Path("device_id") String deviceId, @Path("package_name") String packageName);
|
||||
|
||||
/**
|
||||
* 将本机所有已安装应用(除系统应用外)提交给后台
|
||||
*
|
||||
* @param deviceId gid
|
||||
*/
|
||||
@PUT("devices/{device_id}/applications")
|
||||
Single<ResponseBody> putInstalledApps(@Path("device_id") String deviceId, @Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 新建游戏预约
|
||||
*/
|
||||
@ -2322,4 +2298,16 @@ public interface ApiService {
|
||||
*/
|
||||
@GET("games/filter_detail_tags")
|
||||
Observable<ArrayList<String>> getFilterDetailTags();
|
||||
|
||||
/**
|
||||
* 获取新闻阅读量
|
||||
*/
|
||||
@GET("articles/visits")
|
||||
Observable<List<ViewsEntity>> getArticlesVisits(@Query("filter") String filter);
|
||||
|
||||
/**
|
||||
* 统计新闻阅读量
|
||||
*/
|
||||
@POST("articles/{article_id}:stat_visit")
|
||||
Observable<ResponseBody> postArticleVisit(@Path("article_id") String articleId);
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package com.gh.gamecenter.retrofit.service;
|
||||
|
||||
import com.gh.gamecenter.entity.ViewsEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Path;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/11/9.
|
||||
* data.ghzs666.com
|
||||
*/
|
||||
public interface DataService {
|
||||
|
||||
/**
|
||||
* 获取新闻阅读量
|
||||
*/
|
||||
@GET("v1d46/news/{ids}/visit")
|
||||
Observable<List<ViewsEntity>> getNewsViews(@Path("ids") String ids);
|
||||
|
||||
/**
|
||||
* 统计新闻阅读量
|
||||
*/
|
||||
@POST("news/stat")
|
||||
Observable<ResponseBody> postNewsViews(@Query("news_id") String news_id);
|
||||
|
||||
/**
|
||||
* 上传log
|
||||
*/
|
||||
@Headers({"Content-Type: application/json", "Accept: application/json"})
|
||||
@POST("api/v1d0/log")
|
||||
Observable<ResponseBody> postLog(@Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 上传实时数据
|
||||
*/
|
||||
@Headers({"Content-Type: application/json", "Accept: application/json"})
|
||||
@POST("collection/upload2")
|
||||
Observable<ResponseBody> postRealData(@Body RequestBody body);
|
||||
|
||||
/**
|
||||
* 上传数据
|
||||
*/
|
||||
@Headers({"Content-Type: application/json", "Accept: application/json"})
|
||||
@POST("collection/upload")
|
||||
Observable<ResponseBody> postData(@Body RequestBody body);
|
||||
|
||||
}
|
||||
@ -46,11 +46,9 @@ BUGLY_APPID=d5de44c594
|
||||
# hosts
|
||||
DEV_API_HOST=https\://dev.api.ghzs666.com/v4d0d0/
|
||||
DEV_COMMENT_HOST=https\://dev.api.ghzs666.com/v4d0d0/
|
||||
DEV_DATA_HOST=https\://data.ghzs.com/
|
||||
|
||||
API_HOST=https\://api.ghzs.com/v4d0d0/
|
||||
COMMENT_HOST=https\://api.ghzs.com/v4d0d0/
|
||||
DATA_HOST=https\://data.ghzs.com/
|
||||
|
||||
# 请不要手动改动下面的值,除非你明确需要以某个apk作为基准包,需要打包请以scripts/tinker*.sh为准
|
||||
TINKER_ENABLE=
|
||||
|
||||
Reference in New Issue
Block a user