mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
add toast messages when exceptions were thrown
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
59ccc19ebe
commit
c1f55aa02e
@ -856,9 +856,13 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
filesToShare.add(intent.getData().toString());
|
filesToShare.add(intent.getData().toString());
|
||||||
}
|
}
|
||||||
if (filesToShare.isEmpty() && textToPaste.isEmpty()) {
|
if (filesToShare.isEmpty() && textToPaste.isEmpty()) {
|
||||||
|
Toast.makeText(context, context.getResources().getString(R.string.nc_common_error_sorry),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
Log.e(TAG, "failed to get data from intent");
|
Log.e(TAG, "failed to get data from intent");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Toast.makeText(context, context.getResources().getString(R.string.nc_common_error_sorry),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
Log.e(TAG, "Something went wrong when extracting data from intent");
|
Log.e(TAG, "Something went wrong when extracting data from intent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -867,6 +871,8 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
|
|
||||||
private void upload() {
|
private void upload() {
|
||||||
if (selectedConversation == null) {
|
if (selectedConversation == null) {
|
||||||
|
Toast.makeText(context, context.getResources().getString(R.string.nc_common_error_sorry),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
Log.e(TAG, "not able to upload any files because conversation was null.");
|
Log.e(TAG, "not able to upload any files because conversation was null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import android.content.Context
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.core.content.PermissionChecker
|
import androidx.core.content.PermissionChecker
|
||||||
import androidx.work.Data
|
import androidx.work.Data
|
||||||
import androidx.work.OneTimeWorkRequest
|
import androidx.work.OneTimeWorkRequest
|
||||||
@ -33,6 +34,7 @@ import androidx.work.Worker
|
|||||||
import androidx.work.WorkerParameters
|
import androidx.work.WorkerParameters
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.api.NcApi
|
import com.nextcloud.talk.api.NcApi
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||||
import com.nextcloud.talk.models.database.UserEntity
|
import com.nextcloud.talk.models.database.UserEntity
|
||||||
@ -101,9 +103,13 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||||||
uploadFile(currentUser, ncTargetpath, filename, roomToken, requestBody, sourcefileUri)
|
uploadFile(currentUser, ncTargetpath, filename, roomToken, requestBody, sourcefileUri)
|
||||||
}
|
}
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
|
Toast.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e)
|
Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e)
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
|
Toast.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e)
|
Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e)
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
}
|
}
|
||||||
@ -118,6 +124,8 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||||||
while (input.read(buf) != -1)
|
while (input.read(buf) != -1)
|
||||||
requestBody = RequestBody.create("application/octet-stream".toMediaTypeOrNull(), buf)
|
requestBody = RequestBody.create("application/octet-stream".toMediaTypeOrNull(), buf)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Toast.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
Log.e(javaClass.simpleName, "failed to create RequestBody for $sourcefileUri", e)
|
Log.e(javaClass.simpleName, "failed to create RequestBody for $sourcefileUri", e)
|
||||||
}
|
}
|
||||||
return requestBody
|
return requestBody
|
||||||
@ -146,6 +154,8 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
|
Toast.makeText(context, context.resources.getString(R.string.nc_common_error_sorry), Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
Log.e(TAG, "failed to upload file $filename")
|
Log.e(TAG, "failed to upload file $filename")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
458
|
457
|
Loading…
Reference in New Issue
Block a user