コード例 #1
0
 /** 加载入口 */
 public void loadEntry() {
   boolean sentry = false;
   if (null == Profile.instance().region && 0 != currentRegionId) {
     currentRegionId = 0;
     sentry = true;
   } else if (null != Profile.instance().region
       && Profile.instance().region.id != currentRegionId) {
     currentRegionId = Profile.instance().region.id;
     sentry = true;
   }
   if (null == Me.instance && null != currentUserId) {
     currentUserId = null;
     sentry = true;
   } else if (null != Me.instance && !Me.instance.id.equals(currentUserId)) {
     currentUserId = Me.instance.id;
     sentry = true;
   }
   if (sentry) {
     if (null == Me.instance) {
       browser.loadUrl(Networking.fetchURL("HomePage", "", currentRegionId));
     } else {
       browser.loadUrl(Networking.fetchURL("HomePage", Me.instance.token, currentRegionId));
     }
   }
 }
コード例 #2
0
ファイル: User.java プロジェクト: sovranliu/priest-android
 /**
  * 获取头像位图
  *
  * @return 头像位图
  */
 public <T> void photo(T tatget, ITargetEventable<T, Bitmap> event) {
   if (Text.isBlank(photo)) {
     event.on(tatget, null);
     return;
   }
   Networking.doImage("image", tatget, event, photo);
 }
コード例 #3
0
 /** 加载版本准备升级 */
 private void loadVersion() {
   Networking.doCommand(
       "readVersion",
       new CommonResponse<String>() {
         @Override
         public void onFinished(String content) {
           if (Response.CODE_SUCCESS != code()) {
             return;
           }
           JSONObject resultObject = JSONObject.convert(content);
           if (((JSONNumber) resultObject.get("code")).intValue() <= 0) {
             return;
           }
           JSONObject result = (JSONObject) resultObject.get("data");
           String version = ((JSONString) (result.get("appVersion"))).getValue();
           String url = ((JSONString) (result.get("downloadUrl"))).getValue();
           Version current = Version.fetchVersion(Program.application);
           Version server = Version.build(version);
           if (null == server) {
             return;
           }
           if (current.compareTo(server) >= 0) {
             return;
           }
           Intent intent = new Intent(HomeActivity.this.getActivity(), BrowserActivity.class);
           intent.putExtra("url", url);
           HomeActivity.this.startActivity(intent);
         }
       });
 }
コード例 #4
0
ファイル: User.java プロジェクト: sovranliu/priest-android
 /**
  * 获取头像位图
  *
  * @return 头像位图
  */
 public Bitmap photo() {
   if (Text.isBlank(photo)) {
     return null;
   }
   File file = new File(Networking.cache + Networking.parseFileNameWithURL(photo));
   if (file.exists()) {
     return GraphicsHelper.makeCycleImage(GraphicsHelper.decodeFile(file), 200, 200);
   }
   return null;
 }
コード例 #5
0
 /** 加载资讯列表 */
 private void loadNews() {
   Networking.doCommand(
       "news",
       new CommonResponse<String>(page) {
         @Override
         public void onFinished(String content) {
           if (Response.CODE_SUCCESS != code()) {
             Toast.makeText(HomeActivity.this.getActivity(), "加载资讯失败", Toast.LENGTH_LONG).show();
             return;
           }
           JSONObject resultObject = JSONObject.convert(content);
           if (((JSONNumber) resultObject.get("code")).intValue() <= 0) {
             Toast.makeText(
                     HomeActivity.this.getActivity(),
                     ((JSONString) resultObject.get("msg")).getValue(),
                     Toast.LENGTH_LONG)
                 .show();
             return;
           }
           JSONArray result = (JSONArray) resultObject.get("data");
           int thisPage = (Integer) this.tag;
           if (page != thisPage) {
             return;
           }
           if (0 == result.size()) {
             return;
           }
           for (IJSON item : result) {
             JSONObject newJSONObject = (JSONObject) item;
             HashMap<String, Object> newsMap = new HashMap<String, Object>();
             String photoURL = "";
             if (null != newJSONObject.get("imageUrl")) {
               photoURL = ((JSONString) newJSONObject.get("imageUrl")).getValue();
             }
             String photoName = Storage.getImageName(photoURL);
             newsMap.put("photo", photoName);
             newsMap.put("title", ((JSONString) newJSONObject.get("title")).getValue());
             newsMap.put("publisher", ((JSONString) newJSONObject.get("publisher")).getValue());
             newsMap.put("date", ((JSONString) newJSONObject.get("date")).getValue());
             newsMap.put("url", ((JSONString) newJSONObject.get("url")).getValue());
             newsList.add(newsMap);
             if (Text.isBlank(photoURL)) {
               continue;
             }
             // 加载图片
             Networking.doImage(
                 "image",
                 new ImageResponse(photoName, newsList.size() - 1) {
                   @Override
                   public void onFinished(Bitmap content) {
                     HashMap<String, Object> map = newsList.get((Integer) tag);
                     map.put("photo", content);
                     ListView listview =
                         (ListView)
                             HomeActivity.this.getActivity().findViewById(R.id.home_list_news);
                     SimpleAdapter adapter =
                         (SimpleAdapter)
                             ((HeaderViewListAdapter) listview.getAdapter()).getWrappedAdapter();
                     adapter.notifyDataSetChanged();
                   }
                 },
                 photoURL);
           }
           ListView listview =
               (ListView) HomeActivity.this.getActivity().findViewById(R.id.home_list_news);
           SimpleAdapter adapter =
               (SimpleAdapter) ((HeaderViewListAdapter) listview.getAdapter()).getWrappedAdapter();
           adapter.notifyDataSetChanged();
           page = thisPage + 1;
         }
       },
       page);
 }