X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/ed89b915ae968ceb10a3a29cc732733246e7cb6a..106a2324e113d997db71f00a63ecda3ad828f098:/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java diff --git a/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java b/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java index 54d78fd6..9a4a9749 100644 --- a/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java +++ b/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java @@ -29,14 +29,18 @@ import android.content.UriMatcher; import android.database.Cursor; import android.database.MatrixCursor; import android.net.Uri; +import android.os.Handler; +import android.os.Looper; import android.provider.BaseColumns; import android.support.annotation.Nullable; +import android.widget.Toast; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.GetRemoteShareesOperation; +import com.owncloud.android.utils.ErrorMessageAdapter; import org.json.JSONException; import org.json.JSONObject; @@ -136,6 +140,8 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { // Get JSonObjects from response names.add((JSONObject) o); } + } else { + showErrorMessage(result); } /// convert the responses from the OC server to the expected format @@ -194,4 +200,30 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { return 0; } + /** + * Show error message + * + * @param result Result with the failure information. + */ + public void showErrorMessage(final RemoteOperationResult result) { + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(new Runnable() { + @Override + public void run() { + // The Toast must be shown in the main thread to grant that will be hidden correctly; otherwise + // the thread may die before, an exception will occur, and the message will be left on the screen + // until the app dies + Toast.makeText( + getContext().getApplicationContext(), + ErrorMessageAdapter.getErrorCauseMessage( + result, + null, + getContext().getResources() + ), + Toast.LENGTH_SHORT + ).show(); + } + }); + } + }