From: David A. Velasco Date: Tue, 17 Nov 2015 08:51:13 +0000 (+0100) Subject: Added error messages on view for sharees searching X-Git-Tag: oc-android-1.9^2~7 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/538af7d36b9163451eba8d5882b990ec391510a6?ds=inline;hp=--cc Added error messages on view for sharees searching --- 538af7d36b9163451eba8d5882b990ec391510a6 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(); + } + }); + } + }