當前位置: 首頁>>代碼示例>>Java>>正文


Java Looper.getMainLooper方法代碼示例

本文整理匯總了Java中android.os.Looper.getMainLooper方法的典型用法代碼示例。如果您正苦於以下問題:Java Looper.getMainLooper方法的具體用法?Java Looper.getMainLooper怎麽用?Java Looper.getMainLooper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Looper的用法示例。


在下文中一共展示了Looper.getMainLooper方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clearImageDiskCache

import android.os.Looper; //導入方法依賴的package包/類
/**
 * 清除圖片磁盤緩存
 */
public void clearImageDiskCache(final Context context) {
    try {
        if (Looper.myLooper() == Looper.getMainLooper()) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Glide.get(context).clearDiskCache();
                }
            }).start();
        } else {
            Glide.get(context).clearDiskCache();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:20,代碼來源:GlideCathUtil.java

示例2: notifyChanged

import android.os.Looper; //導入方法依賴的package包/類
private void notifyChanged(final String key) {
    if (Looper.myLooper() == Looper.getMainLooper()) {
        for (OnSharedPreferenceChangeListener listener : listeners) {
            if (listener != null) {
                listener.onSharedPreferenceChanged(AccountPreferences.this, key);
            }
        }
    } else {
        mainHandler.post(new Runnable() {
            @Override
            public void run() {
                notifyChanged(key);
            }
        });
    }
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:17,代碼來源:AccountPreferences.java

示例3: getThreadPool

import android.os.Looper; //導入方法依賴的package包/類
/**
     * 獲取單例的線程池對象
     *
     * @return
     */
    public static ThreadUtil.ThreadPool getThreadPool() {
        if (mThreadPool == null) {
            synchronized (ThreadUtil.class) {
                if (mThreadPool == null) {
                    // cpu個數
                    int cpuNum = Runtime.getRuntime().availableProcessors();
                     int count = cpuNum * 2 + 1;
//                    int count = 15;
                    System.out.println("cpu個數:" + cpuNum);
                    mThreadPool = new ThreadPool(count, count, 0L);
                    mHandler = new Handler(Looper.getMainLooper());
                }
            }
        }

        return mThreadPool;
    }
 
開發者ID:DyncKathline,項目名稱:LiveGiftLayout,代碼行數:23,代碼來源:ThreadUtil.java

示例4: AndroidInflaterHandler

import android.os.Looper; //導入方法依賴的package包/類
public AndroidInflaterHandler(int threads, int priority) {
    mMainHandlerFallback = new android.os.Handler(Looper.getMainLooper());
    mLoopers = new LooperThread[8];
    for (int i = 0; i < mLoopers.length; ++i) {
        mLoopers[i] = new LooperThread("AndroidInflaterHandler " + i, priority);
        mLoopers[i].start();
    }

}
 
開發者ID:worldiety,項目名稱:homunculus,代碼行數:10,代碼來源:AndroidInflaterHandler.java

示例5: Loopers

import android.os.Looper; //導入方法依賴的package包/類
public Loopers(Timers timers) {
    mTimers = timers;
    if (Looper.myLooper() == Looper.getMainLooper()) {
        waitWhenIdle = true;
    }
    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            Looper l = Looper.myLooper();
            if (l != null && shouldQuitLooper())
                l.quit();
            return true;
        }
    });
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:16,代碼來源:Loopers.java

示例6: init

import android.os.Looper; //導入方法依賴的package包/類
@Before
public void init() throws NoSuchFieldException, IllegalAccessException {
    injectMobileEngageConfig();
    IamWebViewProvider.webView = null;

    provider = new IamWebViewProvider();
    listener = mock(MessageLoadedListener.class);

    handler = new Handler(Looper.getMainLooper());
    latch = new CountDownLatch(1);
    dummyJsBridge = new IamJsBridge(mock(IamDialog.class), mock(InAppMessageHandlerProvider.class), mock(ButtonClickedRepository.class), "123", mock(Handler.class));
}
 
開發者ID:emartech,項目名稱:android-mobile-engage-sdk,代碼行數:13,代碼來源:IamWebViewProviderTest.java

示例7: refreshCurrentAccessToken

import android.os.Looper; //導入方法依賴的package包/類
void refreshCurrentAccessToken() {
    if (Looper.getMainLooper().equals(Looper.myLooper())) {
        refreshCurrentAccessTokenImpl();
    } else {
        Handler mainHandler = new Handler(Looper.getMainLooper());
        mainHandler.post(new Runnable() {
            @Override
            public void run() {
                refreshCurrentAccessTokenImpl();
            }
        });
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:14,代碼來源:AccessTokenManager.java

示例8: onRefresh

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void onRefresh() {
    if (CellTracker.OCID_API_KEY != null && !CellTracker.OCID_API_KEY.equals("NA")) {
        Request request = createOpenCellIdApiCall();
        okHttpClient.newCall(request).enqueue(getOpenCellIdResponseCallback());
    } else {
        Handler refresh = new Handler(Looper.getMainLooper());
        refresh.post(new Runnable() {
            public void run() {
                Helpers.sendMsg(getActivity(), getString(R.string.no_opencellid_key_detected));
                swipeRefreshLayout.setRefreshing(false);
            }
        });
    }
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:16,代碼來源:DeviceFragment.java

示例9: onCreate

import android.os.Looper; //導入方法依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final Toolbar toolbar = findById(this, R.id.toolbar);
        setSupportActionBar(toolbar);

        // Inject pragmatically
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.container, PlaceholderFragment.getInstance())
                .commit();


        final Handler handler = new Handler(Looper.getMainLooper());
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
//                toolbar.setTitle("Calligraphy Added");
                toolbar.setSubtitle("Added subtitle");
            }
        }, 1000);

        handler.postDelayed(new Runnable() {
            @Override public void run() {
                toolbar.setTitle(null);
                toolbar.setSubtitle("Added subtitle");
            }
        }, 2000);

        handler.postDelayed(new Runnable() {
            @Override public void run() {
                toolbar.setTitle("Calligraphy added back");
                toolbar.setSubtitle("Added subtitle");
            }
        }, 3000);
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:38,代碼來源:MainActivity.java

示例10: showMsg

import android.os.Looper; //導入方法依賴的package包/類
private void showMsg(final String msg) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
        }
    });
    Log.e(TAG, msg);
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:11,代碼來源:MyContentProvider1.java

示例11: runOnMainThread

import android.os.Looper; //導入方法依賴的package包/類
public static void runOnMainThread(Runnable r) {
    if (Looper.myLooper() == Looper.getMainLooper()) {
        r.run();
    }
    else {
        scheduleOnMainThread(r);
    }
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:9,代碼來源:ActivityUtil.java

示例12: OcrDetectorProcessor

import android.os.Looper; //導入方法依賴的package包/類
public OcrDetectorProcessor(GraphicOverlay<GraphicOverlay.Graphic> ocrGraphicOverlay,
                            Container maskViewContainer,
                            PreferenceManager preferenceManager,
                            SearchResultHandler searchResultHandler,
                            TextClassifierProvider textClassifierProvider) {
    mOcrGraphicOverlay = ocrGraphicOverlay;
    mMaskViewContainer = maskViewContainer;
    mPreferenceManager = preferenceManager;
    mSearchResultHandler = searchResultHandler;
    mPinBitmap = BitmapFactory.decodeResource(mOcrGraphicOverlay.getResources(), R.drawable.pin);
    mMainHandler = new Handler(Looper.getMainLooper());
    mCurrentStatus = null;
    mTextClassifierProvider = textClassifierProvider;
    sendOnStatusChanged(Status.OFF);
}
 
開發者ID:dvdciri,項目名稱:DeepImagePreview-Project,代碼行數:16,代碼來源:OcrDetectorProcessor.java

示例13: ThreadHandler

import android.os.Looper; //導入方法依賴的package包/類
private ThreadHandler() {
    super(Looper.getMainLooper());
    sparseArray = new SparseArray<>();
}
 
開發者ID:tohodog,項目名稱:QSHttp,代碼行數:5,代碼來源:ThreadHandler.java

示例14: isOnMainThread

import android.os.Looper; //導入方法依賴的package包/類
/**
 * @return {@code true} if called on the main thread, {@code false} otherwise.
 */
private static boolean isOnMainThread() {
    return Looper.myLooper() == Looper.getMainLooper();
}
 
開發者ID:Tenor-Inc,項目名稱:tenor-android-core,代碼行數:7,代碼來源:AaidClient.java

示例15: checkMainThread

import android.os.Looper; //導入方法依賴的package包/類
private boolean checkMainThread() {
  return Looper.myLooper() == Looper.getMainLooper();
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:4,代碼來源:WXBridgeManager.java


注:本文中的android.os.Looper.getMainLooper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。