Exemplo n.º 1
0
  private void doJson() {
    try {
      Log.i("json", detail);
      JSONArray arr = new JSONArray(detail);
      JSONArray main = arr.getJSONArray(0);

      tvSender.setText(main.getString(4));
      tvSendTime.setText(HttpConstant.convertTime(main.getLong(7)));
      tvMsg.setText(main.getString(1));
      tvLoc.setText(main.getString(6));
      alert_id = main.getInt(2);
      Picasso.with(this).load(HttpConstant.BAIDUFACE + main.getString(5)).into(ivFace);

      for (int i = 1; i < arr.length(); i++) {
        LostBean lb = new LostBean();
        JSONArray lost = arr.getJSONArray(i);
        lb.title = lost.optString(0);
        lb.description = lost.optString(1);
        lb.alert_id = lost.optString(2);
        lb.from_user_id = lost.optString(3);
        lb.uname = lost.optString(4);
        lb.uface = lost.optString(5);
        lb.position = lost.optString(6);
        lb.time = lost.optLong(7);
        lostList.add(lb);
      }
      adapter.notifyDataSetChanged();
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
 /**
  * Returns the last time the cache was refreshed.
  *
  * @param cacheType Cache type.
  * @param cacheKey Cache key.
  * @return Last update time of the cache.
  */
 public long getLastCacheUpdateTime(String cacheType, String cacheKey) {
   try {
     if (cacheType == null
         || cacheKey == null
         || Constants.EMPTY_STRING.equals(cacheType)
         || Constants.EMPTY_STRING.equals(cacheKey)) {
       return 0;
     }
     final String soupName = cacheType + cacheKey;
     if (!doesCacheExist(soupName)) {
       return 0;
     }
     final String smartSql =
         "SELECT {"
             + soupName
             + ":"
             + String.format(CACHE_TIME_KEY, cacheKey)
             + "} FROM {"
             + soupName
             + "}";
     final QuerySpec querySpec = QuerySpec.buildSmartQuerySpec(smartSql, 1);
     final JSONArray results = smartStore.query(querySpec, 0);
     if (results != null && results.length() > 0) {
       final JSONArray array = results.optJSONArray(0);
       if (array != null && array.length() > 0) {
         return array.optLong(0);
       }
     }
   } catch (IllegalStateException e) {
     Log.e(TAG, "IllegalStateException occurred while attempting to read last cached time", e);
   } catch (JSONException e) {
     Log.e(TAG, "JSONException occurred while attempting to read last cached time", e);
   } catch (SmartStoreException e) {
     Log.e(TAG, "SmartStoreException occurred while attempting to read last cached time", e);
   }
   return 0;
 }
Exemplo n.º 3
0
 public long optLong(int index) {
   return baseArgs.optLong(index);
 }