protected void updateCommentCount(int talkID, String commentsUri) throws JSONException { JIRest rest = new JIRest(TalkDetail.this); int result = rest.getJSONFullURI(commentsUri); if (result == JIRest.OK) { JSONObject fullResponse = rest.getJSONResult(); JSONArray json = fullResponse.getJSONArray("talks"); if (json.length() != 1) { // error, we were expecting a single talk } DataHelper dh = DataHelper.getInstance(); JSONObject thisTalk = json.getJSONObject(0); dh.insertTalk(talkID, thisTalk); this.talkJSON = thisTalk; buttonCommentCount(this.talkJSON.optInt("comment_count")); } }
public class BaseEvent { private int id; private String appId; private Context mContext; private String eventType; private String imei; private String ip; private String model; private String orderId; private String osVersion; private String payAmount; private String time; private String basicContent; private String clientId; private String netType; public BaseEvent(Context context, String eventType, String orderId, String payAmount) { mContext = context; } private DataHelper dataHelper = DataHelper.getInstance(mContext); public String getAppId() { return dataHelper.getAppId(); } public String getClientId() { return dataHelper.getClientId(); } public String getCurrentTime() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); } public String getEventType() { return eventType; } public int getId() { return id; } public String getImei() { return dataHelper.getImei(); } public String getIp() { return dataHelper.getIp(); } public String getBasicContent() { return basicContent; } public JSONObject getJsonContent() { JSONObject jsonContent = new JSONObject(); try { jsonContent.put("platform", Constants.OS_TYPE); jsonContent.put("cid", getClientId()); jsonContent.put("appId", getAppId()); jsonContent.put("imei", getImei()); jsonContent.put("ip", getIp()); jsonContent.put("mobile_type", getModel()); jsonContent.put("os", getOsVersion()); jsonContent.put("order_id", getOrderId()); jsonContent.put("order_price", getPayAmount()); jsonContent.put("net_type", getNetType(mContext)); } catch (Exception e) { e.printStackTrace(); System.out.println("封装jsonContent出错"); } return jsonContent; } public String getModel() { return dataHelper.getModel(); } public String getNetType(Context context) { return dataHelper.getNetType(context); } public String getOrderId() { return orderId; } public String getOsVersion() { return dataHelper.getOsVersion(); } public String getPayAmount() { return payAmount; } public String getTime() { return time; } public void setAppId(String appId) { this.appId = appId; } public void setClientId(String clientId) { this.clientId = clientId; } public void setEventType(String eventType) { this.eventType = eventType; } public void setId(int id) { this.id = id; } public void setImei(String imei) { this.imei = imei; } public void setIp(String ip) { this.ip = ip; } public void setJsonContent(String basicContent) { this.basicContent = basicContent; } public void setModel(String model) { this.model = model; } public void setNetType(String netType) { this.netType = netType; } public void setOrderId(String orderId) { this.orderId = orderId; } public void setOsVersion(String osVersion) { this.osVersion = osVersion; } public void setPayAmount(String payAmount) { this.payAmount = payAmount; } public void setTime(String time) { this.time = time; } }