Skip to content

Commit

Permalink
Pull request #476: Aboldyrev MM-5789 asyncs
Browse files Browse the repository at this point in the history
Merge in MML/infobip-mobile-messaging-android from aboldyrev-MM-5789-asyncs to master

Squashed commit of the following:

commit f88e4dbc2eb531c7b2daf9bd9dfe59faf57d1661
Merge: 5a9a74df 9e4f1ac
Author: Alexander Boldyrev <[email protected]>
Date:   Wed Jan 29 11:50:59 2025 +0300

    Merge branch 'master' into aboldyrev-MM-5789-asyncs

commit 5a9a74df4df55f5f8f6699118e6d79e8d2132d0a
Author: Alexander Boldyrev <[email protected]>
Date:   Wed Jan 29 11:49:30 2025 +0300

    mmasync updated

commit dc826e1876ae92d2796a961070a1be7d16bf76b0
Author: Alexander Boldyrev <[email protected]>
Date:   Thu Dec 26 20:35:53 2024 +0300

    cleaning up

commit 2d45540b0dfb08adf6d9af5c4ffa04d753391136
Merge: 98c1b4e2 6e56ea5
Author: Alexander Boldyrev <[email protected]>
Date:   Thu Dec 26 18:14:34 2024 +0300

    Merge branch 'refs/heads/master' into aboldyrev-MM-5789-asyncs

commit 98c1b4e2e161b9d371fd8c8904cf967e005d3e09
Author: Alexander Boldyrev <[email protected]>
Date:   Thu Dec 26 18:09:32 2024 +0300

    asynctask moved to SDK level
  • Loading branch information
alboldy-ib committed Feb 6, 2025
1 parent 0570e9b commit b35b3d9
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.provider.MediaStore;
import android.provider.OpenableColumns;

import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
import org.infobip.mobile.messaging.mobileapi.InternalSdkError;
import org.infobip.mobile.messaging.mobileapi.common.MMAsyncTask;
import org.infobip.mobile.messaging.util.DateTimeUtil;
import org.infobip.mobile.messaging.util.SoftwareInformation;

Expand All @@ -32,7 +32,7 @@ public class InAppChatAttachmentHelper {
public static final String MIME_TYPE_IMAGE_JPEG = "image/jpeg";

public static void makeAttachment(final FragmentActivity context, final Intent data, final Uri capturedMediaStoreUri, final InAppChatAttachmentHelper.InAppChatAttachmentHelperListener listener) {
AsyncTask.execute(() -> {
MMAsyncTask.execute(() -> {
try {
//From media store Uri we need to get real Uri of the file
Uri capturedMediaRealUri = getUriFromMediaStoreURI(capturedMediaStoreUri, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Build;
import android.security.NetworkSecurityPolicy;

import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
import org.infobip.mobile.messaging.mobileapi.common.MMAsyncTask;

import java.io.InputStream;
import java.net.URL;
Expand All @@ -15,7 +15,7 @@
* @author sslavin
* @since 12/04/2018.
*/
public abstract class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
public abstract class DownloadImageTask extends MMAsyncTask<String, Void, Bitmap> {

private final static int MAX_DOWNLOAD_ATTEMPTS = 3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
Expand Down Expand Up @@ -37,6 +36,7 @@
import org.infobip.mobile.messaging.interactive.inapp.InAppWebViewMessage;
import org.infobip.mobile.messaging.interactive.inapp.InAppWebViewMessage.InAppWebViewPosition;
import org.infobip.mobile.messaging.logging.MobileMessagingLogger;
import org.infobip.mobile.messaging.mobileapi.common.MMAsyncTask;
import org.infobip.mobile.messaging.platform.AndroidBroadcaster;
import org.infobip.mobile.messaging.platform.Time;
import org.infobip.mobile.messaging.util.PreferenceHelper;
Expand Down Expand Up @@ -548,7 +548,7 @@ private static void logWebViewError(int errorCode) {
}

@SuppressLint("StaticFieldLeak")
public class ConnectionTimeoutHandler extends AsyncTask<Void, Void, String> {
public class ConnectionTimeoutHandler extends MMAsyncTask<Void, Void, String> {

private static final String PAGE_LOADED = "PAGE_LOADED";
private static final String CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public void before() {

/**
* Executed on background thread as a last step before running the main block
*
* @return return true to skip execution, in this case only the {@link IMAsyncTask#cancelled(Object[])} will be called.
*/
public boolean shouldCancel() {
Expand Down Expand Up @@ -67,6 +68,7 @@ public void error(IN[] ins, Throwable error) {

/**
* Executed on UI thread if execution was cancelled ({@link IMAsyncTask#shouldCancel()} returned `true`).
*
* @param ins input parameters
*/
public void cancelled(IN[] ins) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.infobip.mobile.messaging.mobileapi.common;

import android.annotation.SuppressLint;
import android.os.AsyncTask;

import androidx.annotation.NonNull;

import org.infobip.mobile.messaging.api.support.ApiBackendExceptionWithContent;
Expand Down Expand Up @@ -40,7 +40,7 @@ public abstract class MAsyncTask<IN, OUT> extends IMAsyncTask<IN, OUT> {
}};

@SuppressLint("StaticFieldLeak")
private final AsyncTask<IN, Void, ResultWrapper<IN, OUT>> asyncTask = new AsyncTask<IN, Void, ResultWrapper<IN, OUT>>() {
private final MMAsyncTask<IN, Void, ResultWrapper<IN, OUT>> MMAsyncTask = new MMAsyncTask<IN, Void, ResultWrapper<IN, OUT>>() {
@Override
protected void onPreExecute() {
before();
Expand Down Expand Up @@ -87,7 +87,7 @@ protected void onPostExecute(ResultWrapper<IN, OUT> resultWrapper) {
*/
@SuppressWarnings({"unused", "unchecked"})
public void execute(IN... ins) {
asyncTask.execute(ins);
MMAsyncTask.execute(ins);
}

/**
Expand All @@ -98,7 +98,7 @@ public void execute(IN... ins) {
*/
@SuppressWarnings({"unused", "unchecked"})
public void execute(Executor executor, IN... ins) {
asyncTask.executeOnExecutor(executor, ins);
MMAsyncTask.executeOnExecutor(executor, ins);
}

// region private methods
Expand Down
Loading

0 comments on commit b35b3d9

Please sign in to comment.