package com.android.launcher3.util;

import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

import com.android.launcher3.Launcher;
import com.android.launcher3.manager.LauncherManager;

public class UIExecutor {

    public static Handler uiHandler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 200) {
                Intent home = new Intent(LauncherManager.getContext(), Launcher.class);
                home.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                home.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                LauncherManager.getContext().startActivity(home);
            }
        }
    };


    public static void postRunable(Runnable runnable) {
        uiHandler.post(runnable);
//        Looper.prepare();
    }

    public static void postRunableDelay(Runnable runnable, long millsTime) {
        uiHandler.postDelayed(runnable, millsTime);
//        Looper.prepare();
    }
}
