当前位置: 首页>>代码示例>>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;未经允许,请勿转载。