Example usage for android.os Looper loop

List of usage examples for android.os Looper loop

Introduction

In this page you can find the example usage for android.os Looper loop.

Prototype

public static void loop() 

Source Link

Document

Run the message queue in this thread.

Usage

From source file:Main.java

public static void openToast(Context context, String str) {
    //Looper.prepare();
    Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
    Looper.loop();
}

From source file:Main.java

static public void showToast(Context context, String msg) {
    Looper.prepare();
    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    Looper.loop();
}

From source file:Main.java

public static void showToastOnMainThread(Context context, String msg) {
    Looper.prepare();
    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    Looper.loop();
}

From source file:Main.java

public static Handler getApplicationHandler(Runnable runnable) {
    if (mApplicationHandler == null) {
        Looper.prepare();/*from   w w  w .  ja v  a2 s  .c  o  m*/
        mApplicationHandler = new Handler(Looper.getMainLooper());
        Looper.loop();
    }
    return mApplicationHandler;
}

From source file:Main.java

public static void showToast(final String toast, final Context context) {
    new Thread(new Runnable() {

        @Override//from   w w  w.  j  ava2  s . com
        public void run() {
            Looper.prepare();
            //                Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
            Looper.loop();
        }
    }).start();
}

From source file:Main.java

public static void showToast(final String toast, final Context context) {
    new Thread(new Runnable() {

        @Override//from  w  w w  .  j  av  a  2 s  . co  m
        public void run() {
            Looper.prepare();
            Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
            Looper.loop();
        }
    }).start();
}

From source file:cc.metapro.openct.utils.CrashHandler.java

@Override
public void uncaughtException(Thread thread, final Throwable ex) {
    if (ContextCompat.checkSelfPermission(mContext,
            Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
        try {//from ww  w . j a va  2 s .c o m
            dumpExceptionToSDCard(ex);
            if (mDefaultHandler != null) {
                mDefaultHandler.uncaughtException(thread, ex);
            }
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Looper.prepare();
                    Toast.makeText(mContext, R.string.crash_pop, Toast.LENGTH_LONG).show();
                    Looper.loop();
                }
            }).start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.onecase.chatroom.service.DataLayerService.java

private void startSendThread() {
    Thread t = new Thread() {
        @Override/*w ww  .ja  v a2 s  .com*/
        public void run() {
            Looper.prepare();
            sendDataHandler = new OCHandler(Looper.myLooper());
            Looper.loop();
        }
    };
    t.setPriority(Thread.MIN_PRIORITY);
    t.start();
    while (sendDataHandler == null)
        ;
}

From source file:com.open.file.manager.CutCopyService.java

/**
 * Proceed to cut/copy file(s) if there is no duplicate(s)
 *//*from   w  ww .j a  v a  2s .c  o  m*/
private void performCutCopy() {
    FileCopyNode current;
    while (currentfileind < tree.children.size()) {
        try {
            current = tree.children.get(currentfileind);
            if (current.duplicate != null && duplicates == null) {
                String waitingdup = getResources().getString(R.string.waitingduplicate);
                cutcopynotification.contentView.setTextViewText(R.id.progresstext, waitingdup);
                cutcopymanager.notify(id, cutcopynotification);
                Looper.loop();
            }
            performOperation(tree.children.get(currentfileind));
            currentfileind++;
        } catch (Exception e) {
            notifyError(R.string.unknownerror);
            e.printStackTrace();
        }
        currentfileind++;
    }
    finish();
}

From source file:com.wang.mygallery.ui.GalleryViewPagerFragment.java

private void loadBitmap() {
    new Thread(new Runnable() {
        @Override//from ww  w.  j a v a  2s .c  om
        public void run() {
            Looper.prepare();
            try {
                bitmap = Glide.with(GalleryViewPagerFragment.this).load(picUrl).asBitmap().into(-1, -1).get();
                galleryHandler.obtainMessage(WHAT_LOAD_SUCCESS).sendToTarget();
            } catch (Exception e) {
                e.printStackTrace();
                galleryHandler.obtainMessage(WHAT_LOAD_FAILED).sendToTarget();
            }

            Looper.loop();
        }
    }).start();
}