List of usage examples for android.net NetworkUtils.CancelResponse toString
public String toString()
From source file:org.creativecommons.thelist.fragments.MyListFragment.java
public void performPhotoUpload() { //Set upload count int uploadCount = mSharedPref.getUploadCount(); mSharedPref.setUploadCount(uploadCount + 1); //mUploadText.setText("Uploading " + mItemToBeUploaded.getItemName() + ""); mUploadProgressBarContainer.setVisibility(View.VISIBLE); //Hide progress bar if it takes too much time to upload new Handler().postDelayed(new Runnable() { @Override/* w w w. ja v a2 s .co m*/ public void run() { if (mUploadProgressBarContainer.getVisibility() == View.VISIBLE) { mUploadProgressBarContainer.setVisibility(View.GONE); } } }, 3000); Uploader uploader = new Uploader(mContext); uploader.uploadPhoto(mItemToBeUploaded, mMediaUri, new NetworkUtils.UploadResponse() { @Override public void onSuccess() { Log.d(TAG, "uploadPhoto > onSuccess"); //TODO: add upload notification bar (below actionbar) displayUserItems(); mUploadProgressBarContainer.setVisibility(View.GONE); mItemToBeUploaded = null; //Show snackbar confirmation //TODO: check if we actually need to disable fab showPhotoUploadSnackbar("Photo Uploaded", "dismiss", new ActionClickListener() { @Override public void onActionClicked(Snackbar snackbar) { mFab.setEnabled(false); snackbar.dismiss(); new Handler().postDelayed(new Runnable() { @Override public void run() { mFab.show(); mFab.setEnabled(true); } }, 500); } }); } //onSuccess @Override public void onFail() { Log.d(TAG, "uploadPhoto > onFail"); //TODO: add upload notification bar (below actionbar) new Handler().postDelayed(new Runnable() { @Override public void run() { mUploadProgressBarContainer.setVisibility(View.GONE); displayUserItems(); } }, 500); //Show snackbar confirmation showPhotoUploadSnackbar("Upload failed", "retry", new ActionClickListener() { @Override public void onActionClicked(Snackbar snackbar) { performPhotoUpload(); } }); } //onFail @Override public void onCancelled(NetworkUtils.CancelResponse response) { Log.v(TAG, "uploadPhoto > onCancelled: " + response.toString()); mUploadProgressBarContainer.setVisibility(View.GONE); switch (response) { case NETWORK_ERROR: mMessageHelper.networkFailMessage(); break; case FILESIZE_ERROR: mMessageHelper.photoUploadSizeFailMessage(); break; } } }); }