Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10a8935e authored by Michael Jurka's avatar Michael Jurka Committed by Android (Google) Code Review
Browse files

Merge "Use AsyncTasks instead of creating new threads" into jb-ub-now-jolly-elf

parents a50d3430 4346746e
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.res.Resources;
import android.graphics.PointF;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.TransitionDrawable;
import android.graphics.drawable.TransitionDrawable;
import android.os.AsyncTask;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.View;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewConfiguration;
@@ -334,11 +335,12 @@ public class DeleteDropTarget extends ButtonDropTarget {
            if (appWidgetHost != null) {
            if (appWidgetHost != null) {
                // Deleting an app widget ID is a void call but writes to disk before returning
                // Deleting an app widget ID is a void call but writes to disk before returning
                // to the caller...
                // to the caller...
                new Thread("deleteAppWidgetId") {
                new AsyncTask<Void, Void, Void>() {
                    public void run() {
                    public Void doInBackground(Void ... args) {
                        appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
                        appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
                        return null;
                    }
                    }
                }.start();
                }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
            }
            }
        }
        }
        if (wasWaitingForUninstall && !mWaitingForUninstall) {
        if (wasWaitingForUninstall && !mWaitingForUninstall) {
+16 −14
Original line number Original line Diff line number Diff line
@@ -584,12 +584,12 @@ public class Launcher extends Activity
            mIconCache.flush();
            mIconCache.flush();


            final LocaleConfiguration localeConfiguration = sLocaleConfiguration;
            final LocaleConfiguration localeConfiguration = sLocaleConfiguration;
            new Thread("WriteLocaleConfiguration") {
            new AsyncTask<Void, Void, Void>() {
                @Override
                public Void doInBackground(Void ... args) {
                public void run() {
                    writeConfiguration(Launcher.this, localeConfiguration);
                    writeConfiguration(Launcher.this, localeConfiguration);
                    return null;
                }
                }
            }.start();
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
        }
        }
    }
    }


@@ -1489,11 +1489,12 @@ public class Launcher extends Activity
            if (appWidgetId != -1) {
            if (appWidgetId != -1) {
                // Deleting an app widget ID is a void call but writes to disk before returning
                // Deleting an app widget ID is a void call but writes to disk before returning
                // to the caller...
                // to the caller...
                new Thread("deleteAppWidgetId") {
                new AsyncTask<Void, Void, Void>() {
                    public void run() {
                    public Void doInBackground(Void ... args) {
                        mAppWidgetHost.deleteAppWidgetId(appWidgetId);
                        mAppWidgetHost.deleteAppWidgetId(appWidgetId);
                        return null;
                    }
                    }
                }.start();
                }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
            }
            }
            showOutOfSpaceMessage(isHotseatLayout(layout));
            showOutOfSpaceMessage(isHotseatLayout(layout));
            return;
            return;
@@ -4271,13 +4272,14 @@ public class Launcher extends Activity
                public void run() {
                public void run() {
                    cling.cleanup();
                    cling.cleanup();
                    // We should update the shared preferences on a background thread
                    // We should update the shared preferences on a background thread
                    new Thread("dismissClingThread") {
                    new AsyncTask<Void, Void, Void>() {
                        public void run() {
                        public Void doInBackground(Void ... args) {
                            SharedPreferences.Editor editor = mSharedPrefs.edit();
                            SharedPreferences.Editor editor = mSharedPrefs.edit();
                            editor.putBoolean(flag, true);
                            editor.putBoolean(flag, true);
                            editor.commit();
                            editor.commit();
                            return null;
                        }
                        }
                    }.start();
                    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
                    if (postAnimationCb != null) {
                    if (postAnimationCb != null) {
                        postAnimationCb.run();
                        postAnimationCb.run();
                    }
                    }
@@ -4567,9 +4569,8 @@ public class Launcher extends Activity


    public void dumpLogsToLocalData() {
    public void dumpLogsToLocalData() {
        if (DEBUG_DUMP_LOG) {
        if (DEBUG_DUMP_LOG) {
            new Thread("DumpLogsToLocalData") {
            new AsyncTask<Void, Void, Void>() {
                @Override
                public Void doInBackground(Void ... args) {
                public void run() {
                    boolean success = false;
                    boolean success = false;
                    sDateStamp.setTime(sRunStart);
                    sDateStamp.setTime(sRunStart);
                    String FILENAME = sDateStamp.getMonth() + "-"
                    String FILENAME = sDateStamp.getMonth() + "-"
@@ -4607,8 +4608,9 @@ public class Launcher extends Activity
                    } catch (IOException e) {
                    } catch (IOException e) {
                        e.printStackTrace();
                        e.printStackTrace();
                    }
                    }
                    return null;
                }
                }
            }.start();
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
        }
        }
    }
    }
}
}
+5 −4
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;


@@ -39,12 +40,12 @@ public class PreloadReceiver extends BroadcastReceiver {
            if (LOGD) {
            if (LOGD) {
                Log.d(TAG, "workspace name: " + name + " id: " + workspaceResId);
                Log.d(TAG, "workspace name: " + name + " id: " + workspaceResId);
            }
            }
            new Thread(new Runnable() {
            new AsyncTask<Void, Void, Void>() {
                @Override
                public Void doInBackground(Void ... args) {
                public void run() {
                    provider.loadDefaultFavoritesIfNecessary(workspaceResId);
                    provider.loadDefaultFavoritesIfNecessary(workspaceResId);
                    return null;
                }
                }
            }).start();
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
        }
        }
    }
    }
}
}
+4 −3
Original line number Original line Diff line number Diff line
@@ -786,14 +786,15 @@ public class WallpaperCropActivity extends Activity {
            final WallpaperManager wallpaperManager) {
            final WallpaperManager wallpaperManager) {
        final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
        final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);


        new Thread("suggestWallpaperDimension") {
        new AsyncTask<Void, Void, Void>() {
            public void run() {
            public Void doInBackground(Void ... args) {
                // If we have saved a wallpaper width/height, use that instead
                // If we have saved a wallpaper width/height, use that instead
                int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, defaultWallpaperSize.x);
                int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, defaultWallpaperSize.x);
                int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, defaultWallpaperSize.y);
                int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, defaultWallpaperSize.y);
                wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
                wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
                return null;
            }
            }
        }.start();
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
    }
    }


    protected static RectF getMaxCropRect(
    protected static RectF getMaxCropRect(