Added handler for FileHasNoContent exception, some clean up

This commit is contained in:
Daniel Haß 2014-03-03 09:35:05 +01:00
parent 7f384e7346
commit 9843bafafd

View File

@ -219,27 +219,34 @@ public class ImportKeysListFragment extends ListFragment implements
} else { } else {
setListShownNoAnimation(true); setListShownNoAnimation(true);
} }
Exception error = data.getError();
switch (loader.getId()) { switch (loader.getId()) {
case LOADER_ID_BYTES: case LOADER_ID_BYTES:
error = data.getError();
if(error instanceof ImportKeysListLoader.FileHasNoContent) {
AppMsg.makeText(getActivity(), R.string.error_import_file_no_content,
AppMsg.STYLE_ALERT).show();
}
break; break;
case LOADER_ID_SERVER_QUERY: case LOADER_ID_SERVER_QUERY:
Exception error = data.getError(); if(error == null) {
if(error == null){
AppMsg.makeText( AppMsg.makeText(
getActivity(), getResources().getQuantityString(R.plurals.keys_found, getActivity(), getResources().getQuantityString(R.plurals.keys_found,
mAdapter.getCount(), mAdapter.getCount()), mAdapter.getCount(), mAdapter.getCount()),
AppMsg.STYLE_INFO AppMsg.STYLE_INFO
).show(); ).show();
} else if(error instanceof KeyServer.InsufficientQuery){ } else if(error instanceof KeyServer.InsufficientQuery) {
AppMsg.makeText(getActivity(), R.string.error_keyserver_insufficient_query, AppMsg.makeText(getActivity(), R.string.error_keyserver_insufficient_query,
AppMsg.STYLE_ALERT).show(); AppMsg.STYLE_ALERT).show();
}else if(error instanceof KeyServer.QueryException){ } else if(error instanceof KeyServer.QueryException) {
AppMsg.makeText(getActivity(), R.string.error_keyserver_query, AppMsg.makeText(getActivity(), R.string.error_keyserver_query,
AppMsg.STYLE_ALERT).show(); AppMsg.STYLE_ALERT).show();
}else if(error instanceof KeyServer.TooManyResponses){ } else if(error instanceof KeyServer.TooManyResponses) {
AppMsg.makeText(getActivity(), R.string.error_keyserver_too_many_responses, AppMsg.makeText(getActivity(), R.string.error_keyserver_too_many_responses,
AppMsg.STYLE_ALERT).show(); AppMsg.STYLE_ALERT).show();
} }