コード例 #1
0
  @Override
  public void onBlocksLoaded(Response response) {
    Logger.v("Response code:", "Response Code: " + response.getResponseCode() + response.getBody());
    try {

      Gson gson = new Gson();

      if (response.getResponseCode() == 200) {
        BlocksList blocksList = gson.fromJson(response.getBody(), BlocksList.class);
        mBlocks = blocksList.getBlocks();
        BlocksAdapter blocksAdapter = new BlocksAdapter(mBlocks, this);
        mRecyclerView.setAdapter(blocksAdapter);
        mRecyclerView.setVisibility(View.VISIBLE);
        mProgressWheel.setVisibility(View.GONE);
        mConnectionContainer.setVisibility(View.GONE);
        mFragmentLoader.onFragmentLoaded();
      } else {
        onBlocksLoadFailed(response);
      }

    } catch (Exception e) {
      e.printStackTrace();
      couldNotLoadBlocks();
    }
  }
コード例 #2
0
 @Override
 public void onBlocksLoadFailed(Response response) {
   Logger.v("Response code:", "Response Code: " + response.getResponseCode() + response.getBody());
   if (response.getResponseCode() == 0) {
     onNoInternet();
   } else {
     couldNotLoadBlocks();
   }
 }