コード例 #1
0
  // json数据解析映射到bean
  private void jsonToBean(String responseString) {
    Gson gson = new Gson();
    newsDetail = gson.fromJson(responseString, NewsDetail.class);
    final ImageLoader imageloader = ImageLoader.getInstance();
    DisplayImageOptions options =
        new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).build();
    if (listEntity.getPhoto() != null) {
      if (listEntity.getTime().substring(2, 4).equals("15")) {
        imageloader.displayImage(
            Constants.BASE_PICURL + "2015/" + listEntity.getPhoto(), iv_toolBar, options);
      } else if (listEntity.getTime().substring(2, 4).equals("16")) {
        imageloader.displayImage(
            Constants.BASE_PICURL + "2016/" + listEntity.getPhoto(), iv_toolBar, options);
      }

    } else {
      imageloader.displayImage("drawable://" + R.drawable.banner_01, iv_toolBar, options);
    }
    textView_newsDetail.setText(newsDetail.getArticle().getContent());
    collapsingToolbarLayout.setTitle(newsDetail.getArticle().getTitle());
  }
コード例 #2
0
  // 初始化数据
  private void initData() {
    listEntity = (NewsList.ItemsEntity.ListEntity) getIntent().getSerializableExtra("entity");
    if (HttpUtil.isNetworkConnected(this)) {
      HttpUtil.get(
          Constants.NEWS_DETAIL + listEntity.getId(),
          new TextHttpResponseHandler() {
            @Override
            public void onFailure(
                int statusCode, Header[] headers, String responseString, Throwable throwable) {}

            @Override
            public void onSuccess(int statusCode, Header[] headers, String responseString) {
              jsonToBean(responseString);
            }
          });
    }
  }