예제 #1
0
 @Override
 public void run() {
   String url = SERVER_URL_TEST;
   String params = getParams(ACTION_TAB, true);
   boolean isSucceed = false;
   if (params != null) {
     CustomerHttpClient client = new CustomerHttpClient(mContext);
     String[] res = client.post(url, params);
     if (isExit) {
       synchronized (syncTabObject) {
         downTabThread = null;
         return;
       }
     }
     if (res != null) {
       String content = res[0];
       Log.v("downloadtab", "content = " + content);
       JSONObject json = null;
       try {
         json = new JSONObject(content);
         int retCode = json.getInt("retcode");
         if (retCode == 0) {
           String configUrl = json.getString("tablist");
           json = new JSONObject(configUrl);
           tabInfo.clear();
           for (Iterator iter = json.keys(); iter.hasNext(); ) {
             String key = (String) iter.next();
             JSONObject tmJson = (JSONObject) json.get(key);
             Map<String, String> map = new HashMap<String, String>();
             map.put("tabid", tmJson.getString("tabid"));
             map.put("enname", tmJson.getString("enname"));
             map.put("cnname", tmJson.getString("cnname"));
             map.put("twname", tmJson.getString("twname"));
             map.put("id", key);
             tabInfo.add(map);
           }
           Collections.sort(tabInfo, new ByStringValue());
           isSucceed = true;
         }
       } catch (JSONException e) {
         e.printStackTrace();
       }
     }
   }
   if (isSucceed) {
     downloadTabFinish();
   }
   synchronized (syncTabObject) {
     downTabThread = null;
     return;
   }
 }
예제 #2
0
 @Override
 public void run() {
   // TODO Auto-generated method stub
   mHandler.removeCallbacks(UploadRun);
   if (enable_Statistics_LOG) {
     Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=UploadRun" + "\n--上传线程");
   }
   // 判断是否联网
   if (!IsHaveInternet(mContext)) {
     if (enable_Statistics_LOG)
       Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=UploadRun" + "\n--没有线程");
     exitThread();
     if (enable_Statistics_LOG)
       Log.v(
           "UICenter - StatisticsNew",
           LOG_TAG
               + "\n=UploadRun"
               + "\n--没有网退出线程"
               + "---------------------exitThread--------------------");
     return;
   } else {
     String params = getLogInformation();
     if (params != null) {
       CustomerHttpClient client = new CustomerHttpClient(mContext);
       String[] res = client.post(LOG_URL_TEST, params);
       if (res != null) {
         String content = res[0];
         JSONObject json = null;
         try {
           json = new JSONObject(content);
           int retCode = json.getInt("retcode");
           if (retCode == 0) {
             delAllData();
             clearErrTimeAndCount();
             recordSuccessTime();
             if (enable_Statistics_LOG)
               Log.v(
                   "UICenter - StatisticsNew",
                   LOG_TAG
                       + "\n=UploadRun"
                       + "\n--上传成功 =============ok===================="
                       + "\n--params    = "
                       + params);
           } else {
             isUseLog = false;
             int errcount = getErrTimes();
             recordErrCount(++errcount);
             recordErrTime();
             if (enable_Statistics_LOG)
               Log.v(
                   "UICenter - StatisticsNew",
                   LOG_TAG
                       + "\n=UploadRun"
                       + "\n--上传失败=============not ok===================="
                       + "\n--params    = "
                       + params
                       + "\n--retCode    ="
                       + retCode);
           }
         } catch (JSONException e) {
           isUseLog = false;
           int errcount = getErrTimes();
           recordErrCount(++errcount);
           recordErrTime();
           if (enable_Statistics_LOG)
             Log.v(
                 "UICenter - StatisticsNew",
                 LOG_TAG
                     + "\n=UploadRun"
                     + "\n--上传失败=============not ok===================="
                     + "\n--params    = "
                     + params);
           e.printStackTrace();
         }
       } else {
         isUseLog = false;
         int errcount = getErrTimes();
         recordErrCount(++errcount);
         recordErrTime();
         if (enable_Statistics_LOG)
           Log.v(
               "UICenter - StatisticsNew",
               LOG_TAG
                   + "\n=UploadRun"
                   + "\n--上传失败=============not ok===================="
                   + "\n--params    = "
                   + params
                   + "\n--res      ="
                   + res);
       }
     }
     if (enable_Statistics_LOG)
       Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=UploadRun" + "\n--关闭上传线程");
     exitThread();
   }
 }
예제 #3
0
 @Override
 public void run() {
   String url = SERVER_URL_TEST;
   String params = getParams(ACTION_LIST, true);
   boolean isSucceed = false;
   if (params != null) {
     CustomerHttpClient client = new CustomerHttpClient(mContext);
     String[] res = client.post(url, params);
     if (isExit) {
       synchronized (syncObject) {
         downListThread = null;
         return;
       }
     }
     if (res != null) {
       String content = res[0];
       Log.v("downloadlist", "content = " + content);
       //					Tools.writelogTosd( content );
       JSONObject json = null;
       try {
         json = new JSONObject(content);
         int retCode = json.getInt("retcode");
         if (retCode == 0) {
           String configUrl = json.getString("reslist");
           json = new JSONObject(configUrl);
           for (Iterator iter = json.keys(); iter.hasNext(); ) {
             String key = (String) iter.next();
             JSONObject tmJson = (JSONObject) json.get(key);
             ListInfo listInfo = new ListInfo();
             for (Iterator mIterator = tmJson.keys(); mIterator.hasNext(); ) {
               String mKey = (String) mIterator.next();
               if (mKey.equals("tabid")) {
                 listInfo.setTabid(tmJson.get(mKey).toString());
               } else if (mKey.equals("enname")) {
                 listInfo.setEnname(tmJson.get(mKey).toString());
               } else if (mKey.equals("cnname")) {
                 listInfo.setCnname(tmJson.get(mKey).toString());
               } else if (mKey.equals("twname")) {
                 listInfo.setTwname(tmJson.get(mKey).toString());
               } else if (mKey.equals("typeid")) {
                 listInfo.setTypeid(tmJson.get(mKey).toString());
               } else {
                 JSONObject jsObj = (JSONObject) tmJson.get(mKey);
                 ItemInfo itemInfo = new ItemInfo();
                 itemInfo.setIndex(mKey);
                 System.out.println(
                     "mKey = " + mKey + " jsObj.getString() = " + jsObj.getString("cnname"));
                 itemInfo.setResid(jsObj.getString("resid"));
                 itemInfo.setEnname(jsObj.getString("enname"));
                 itemInfo.setCnname(jsObj.getString("cnname"));
                 // itemInfo.setTwname(jsObj.getString("twname"));
                 itemInfo.setResurl(jsObj.getString("resurl"));
                 itemInfo.setPackname(jsObj.getString("packname"));
                 itemInfo.setSize(jsObj.getString("size"));
                 itemInfo.setAuthor(jsObj.getString("author"));
                 itemInfo.setAboutchinese(jsObj.getString("aboutchinese"));
                 itemInfo.setVersion(jsObj.getString("version"));
                 itemInfo.setVersionname(jsObj.getString("versionname"));
                 itemInfo.setAboutenglish(jsObj.getString("aboutenglish"));
                 itemInfo.setPrice(jsObj.getString("price"));
                 itemInfo.setPricedetail(jsObj.getString("pricedetail"));
                 itemInfo.setPricePoint(jsObj.getString("pricepoint"));
                 itemInfo.setIcon(jsObj.getString("icon"));
                 itemInfo.setThumbimg(jsObj.getString("thumbimg"));
                 try {
                   itemInfo.setEnginepackname(jsObj.getString("enginepackname"));
                   itemInfo.setEngineurl(jsObj.getString("engineurl"));
                   itemInfo.setEnginesize(jsObj.getString("enginesize"));
                 } catch (JSONException e) {
                   itemInfo.setEnginepackname(null);
                   itemInfo.setEngineurl(null);
                   itemInfo.setEnginesize(null);
                 }
                 try {
                   itemInfo.setEnginedesc(jsObj.getString("enginedesc"));
                 } catch (JSONException e) {
                   itemInfo.setEnginedesc(null);
                 }
                 try {
                   itemInfo.setThirdparty(jsObj.getString("thirdparty"));
                 } catch (JSONException e) {
                   itemInfo.setThirdparty(null);
                 }
                 try {
                   JSONArray preview = jsObj.getJSONArray("previewlist");
                   String[] pre = new String[preview.length()];
                   for (int k = 0; k < preview.length(); k++) {
                     pre[k] = preview.getString(k);
                   }
                   itemInfo.setPreviewlist(pre);
                 } catch (JSONException e) {
                   itemInfo.setPreviewlist(new String[] {itemInfo.getThumbimg()});
                 }
                 listInfo.getItemList().add(itemInfo);
               }
             }
             info.add(listInfo);
           }
           isSucceed = true;
         }
       } catch (JSONException e) {
         e.printStackTrace();
       }
     }
   }
   if (isSucceed) {
     downloadListFinish();
   }
   synchronized (syncObject) {
     downListThread = null;
     return;
   }
 }