解决final int position导致的bug
This commit is contained in:
@ -49,13 +49,11 @@ public class DataCollectionManager {
|
||||
}
|
||||
|
||||
// 添加事件
|
||||
public static void onEvent(Context context, DataCollectionInfo entity,
|
||||
boolean isUpload) {
|
||||
public static void onEvent(Context context, DataCollectionInfo entity, boolean isUpload) {
|
||||
DataCollectionManager.getInstance(context).add(entity, isUpload);
|
||||
}
|
||||
|
||||
public static void onEvent(Context context, String type, String data,
|
||||
boolean isUpload) {
|
||||
public static void onEvent(Context context, String type, String data, boolean isUpload) {
|
||||
String id = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
DataCollectionInfo entity = new DataCollectionInfo();
|
||||
entity.setId(id);
|
||||
@ -72,13 +70,11 @@ public class DataCollectionManager {
|
||||
onEvent(context, type, new JSONObject(map).toString(), true);
|
||||
}
|
||||
|
||||
public static void onEvent(Context context, String type,
|
||||
Map<String, Object> map, boolean isUpload) {
|
||||
public static void onEvent(Context context, String type, Map<String, Object> map, boolean isUpload) {
|
||||
onEvent(context, type, new JSONObject(map).toString(), isUpload);
|
||||
}
|
||||
|
||||
public static void upsert(Context context, String type,
|
||||
Map<String, Object> map) {
|
||||
public static void upsert(Context context, String type, Map<String, Object> map) {
|
||||
String id = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
DataCollectionInfo entity = new DataCollectionInfo();
|
||||
entity.setId(id);
|
||||
@ -88,14 +84,14 @@ public class DataCollectionManager {
|
||||
}
|
||||
|
||||
public void upsert(DataCollectionInfo entity, String type) {
|
||||
List<DataCollectionInfo> list = dao.findByType("user");
|
||||
List<DataCollectionInfo> list = dao.findByType(type);
|
||||
if (list == null || list.isEmpty()) {
|
||||
dao.add(entity);
|
||||
} else {
|
||||
entity.setId(list.get(0).getId());
|
||||
dao.update(entity);
|
||||
if (list.size() > 1) {
|
||||
List<String> ids = new ArrayList<String>();
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (int i = 1, size = list.size(); i < size; i++) {
|
||||
ids.add(list.get(i).getId());
|
||||
}
|
||||
@ -133,7 +129,7 @@ public class DataCollectionManager {
|
||||
map.put("version", version);
|
||||
map.put("user", user);
|
||||
map.put("channel", channel);
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("type", type);
|
||||
params.put("data", new JSONObject(map).toString());
|
||||
String url = "http://data.ghzhushou.com/collection/upload2";
|
||||
@ -156,6 +152,7 @@ public class DataCollectionManager {
|
||||
}
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
AppController.addToRequestQueue(request, DataCollectionManager.class);
|
||||
}
|
||||
|
||||
@ -165,9 +162,9 @@ public class DataCollectionManager {
|
||||
public void statClickData() {
|
||||
List<DataCollectionInfo> list = dao.getClickData();
|
||||
if (!list.isEmpty()) {
|
||||
List<String> ids = new ArrayList<String>();
|
||||
List<String> ids = new ArrayList<>();
|
||||
DataCollectionInfo dataCollectionEntity;
|
||||
List<Object> data = new ArrayList<Object>();
|
||||
List<Object> data = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
dataCollectionEntity = list.get(i);
|
||||
@ -177,7 +174,7 @@ public class DataCollectionManager {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("data", data);
|
||||
map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
onEvent(mContext, "click", map);
|
||||
@ -208,14 +205,14 @@ public class DataCollectionManager {
|
||||
isUploading = true;
|
||||
String url = "http://data.ghzhushou.com/collection/upload";
|
||||
|
||||
final List<String> ids = new ArrayList<String>();
|
||||
final List<String> ids = new ArrayList<>();
|
||||
|
||||
String version = PackageUtils.getVersion(mContext);
|
||||
String user = DeviceUtils.getDeviceID(mContext);
|
||||
String channel = (String) PackageUtils.getMetaData(mContext,
|
||||
mContext.getPackageName(), "TD_CHANNEL_ID");
|
||||
|
||||
HashMap<String, JSONArray> map = new HashMap<String, JSONArray>();
|
||||
HashMap<String, JSONArray> map = new HashMap<>();
|
||||
DataCollectionInfo dataCollectionEntity;
|
||||
String type;
|
||||
JSONArray jsonArray;
|
||||
@ -244,9 +241,9 @@ public class DataCollectionManager {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Object> params = new ArrayList<Object>();
|
||||
ArrayList<Object> params = new ArrayList<>();
|
||||
for (String key : map.keySet()) {
|
||||
HashMap<String, Object> hashMap = new HashMap<String, Object>();
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("type", key);
|
||||
hashMap.put("data", map.get(key));
|
||||
JSONObject jsonObject = new JSONObject(hashMap);
|
||||
|
||||
Reference in New Issue
Block a user