mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
extract upload failed text calculation to separate method
This commit is contained in:
parent
af60d91e9a
commit
e4e07c28fb
1 changed files with 76 additions and 88 deletions
|
@ -26,6 +26,7 @@ import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -413,61 +414,52 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPLOAD_FAILED:
|
case UPLOAD_FAILED:
|
||||||
switch (upload.getLastResult()) {
|
status = getUploadFailedStatusText(upload.getLastResult());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
status = "Uncontrolled status: " + upload.getUploadStatus().toString();
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private String getUploadFailedStatusText(UploadResult result) {
|
||||||
|
String status;
|
||||||
|
switch (result) {
|
||||||
case CREDENTIAL_ERROR:
|
case CREDENTIAL_ERROR:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_credentials_error);
|
||||||
R.string.uploads_view_upload_status_failed_credentials_error
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case FOLDER_ERROR:
|
case FOLDER_ERROR:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_folder_error);
|
||||||
R.string.uploads_view_upload_status_failed_folder_error
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case FILE_NOT_FOUND:
|
case FILE_NOT_FOUND:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_localfile_error);
|
||||||
R.string.uploads_view_upload_status_failed_localfile_error
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case FILE_ERROR:
|
case FILE_ERROR:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_file_error);
|
||||||
R.string.uploads_view_upload_status_failed_file_error
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case PRIVILEDGES_ERROR:
|
case PRIVILEDGES_ERROR:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_permission_error);
|
||||||
R.string.uploads_view_upload_status_failed_permission_error
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case NETWORK_CONNECTION:
|
case NETWORK_CONNECTION:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_failed_connection_error);
|
||||||
R.string.uploads_view_upload_status_failed_connection_error
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case DELAYED_FOR_WIFI:
|
case DELAYED_FOR_WIFI:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_waiting_for_wifi);
|
||||||
R.string.uploads_view_upload_status_waiting_for_wifi
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case DELAYED_FOR_CHARGING:
|
case DELAYED_FOR_CHARGING:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_waiting_for_charging);
|
||||||
R.string.uploads_view_upload_status_waiting_for_charging);
|
|
||||||
break;
|
break;
|
||||||
case CONFLICT_ERROR:
|
case CONFLICT_ERROR:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_conflict);
|
||||||
R.string.uploads_view_upload_status_conflict
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case SERVICE_INTERRUPTED:
|
case SERVICE_INTERRUPTED:
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_service_interrupted);
|
||||||
R.string.uploads_view_upload_status_service_interrupted
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case CANCELLED:
|
case CANCELLED:
|
||||||
// should not get here ; cancelled uploads should be wiped out
|
// should not get here ; cancelled uploads should be wiped out
|
||||||
status = mParentActivity.getString(
|
status = mParentActivity.getString(R.string.uploads_view_upload_status_cancelled);
|
||||||
R.string.uploads_view_upload_status_cancelled
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case UPLOADED:
|
case UPLOADED:
|
||||||
// should not get here ; status should be UPLOAD_SUCCESS
|
// should not get here ; status should be UPLOAD_SUCCESS
|
||||||
|
@ -496,23 +488,19 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
status = "New fail result but no description for the user";
|
status = "New fail result but no description for the user";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
status = "Uncontrolled status: " + upload.getUploadStatus().toString();
|
|
||||||
}
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SectionedViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
@NonNull
|
||||||
|
public SectionedViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
if (viewType == VIEW_TYPE_HEADER) {
|
if (viewType == VIEW_TYPE_HEADER) {
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.upload_list_header, parent, false);
|
return new HeaderViewHolder(
|
||||||
return new HeaderViewHolder(v);
|
LayoutInflater.from(parent.getContext()).inflate(R.layout.upload_list_header, parent, false));
|
||||||
} else {
|
} else {
|
||||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.upload_list_item, parent, false);
|
return new ItemViewHolder(
|
||||||
return new ItemViewHolder(v);
|
LayoutInflater.from(parent.getContext()).inflate(R.layout.upload_list_item, parent, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue