本文整理汇总了Java中android.os.Looper.prepare方法的典型用法代码示例。如果您正苦于以下问题:Java Looper.prepare方法的具体用法?Java Looper.prepare怎么用?Java Looper.prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Looper
的用法示例。
在下文中一共展示了Looper.prepare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import android.os.Looper; //导入方法依赖的package包/类
@Before
public void setup() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
Context context = InstrumentationRegistry.getTargetContext();
manager = new BrickDataManager(MAX_SPANS);
View parentView = mock(View.class);
manager.setRecyclerView(context, new RecyclerView(context), GridLayoutManager.VERTICAL, false, parentView);
brickTestHelper = new BrickTestHelper(context);
manager.addLast(brickTestHelper.generateBrick());
manager.addLast(brickTestHelper.generateBrick());
manager.addLast(brickTestHelper.generateBrick());
manager.addLast(brickTestHelper.generateBrick());
footerBehavior = mock(StickyFooterBehavior.class);
manager.addBehavior(footerBehavior);
headerBehavior = mock(StickyHeaderBehavior.class);
manager.addBehavior(headerBehavior);
observer = new BrickTestHelper.TestAdapterDataObserver();
manager.getBrickRecyclerAdapter().registerAdapterDataObserver(observer);
}
示例2: run
import android.os.Looper; //导入方法依赖的package包/类
public void run(){
// There are minimum OS version requirements
if(versionCheck()){
// Reference: http://developer.android.com/reference/android/os/Process.html#THREAD_PRIORITY_BACKGROUND
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
// We are running a Looper to allow the Cordova CallbackContext to be passed within the Thread as a message.
if(Looper.myLooper() == null){
_telephonyManager = (TelephonyManager) _cordova.getActivity().getSystemService(Context.TELEPHONY_SERVICE);
Looper.prepare();
startLocation();
Looper.loop();
}
}
else {
Log.e(TAG, ErrorMessages.CELL_DATA_MIN_VERSION().message);
sendCallback(PluginResult.Status.ERROR,
JSONHelper.errorJSON(CELLINFO_PROVIDER, ErrorMessages.CELL_DATA_MIN_VERSION()));
}
}
示例3: run
import android.os.Looper; //导入方法依赖的package包/类
/**
* Thread entry point.
* <p>
* The thread should not be started until the Surface associated with the SurfaceHolder
* has been created. That way we don't have to wait for a separate "surface created"
* message to arrive.
*/
@Override
public void run() {
Looper.prepare();
mHandler = new RenderHandler(this);
mEglCore = new EglCore(null, 0);
synchronized (mStartLock) {
mReady = true;
mStartLock.notify(); // signal waitUntilReady()
}
Looper.loop();
Log.d(TAG, "looper quit");
releaseGl();
mEglCore.release();
synchronized (mStartLock) {
mReady = false;
}
}
示例4: run
import android.os.Looper; //导入方法依赖的package包/类
public void run(){
// Reference: http://developer.android.com/reference/android/os/Process.html#THREAD_PRIORITY_BACKGROUND
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
// We are running a Looper to allow the Cordova CallbackContext to be passed within the Thread as a message.
if(Looper.myLooper() == null){
_locationManager = (LocationManager) _cordova.getActivity().getSystemService(Context.LOCATION_SERVICE);
Looper.prepare();
startLocation();
Looper.loop();
}
}
示例5: run
import android.os.Looper; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
handler = new DecodeHandler(activity, hints);
handlerInitLatch.countDown();
Looper.loop();
}
示例6: restartGame
import android.os.Looper; //导入方法依赖的package包/类
@Override
protected void restartGame() {
super.restartGame();
if (Looper.myLooper() == null) {
Looper.prepare();
}
Point dimens = new Point(gameView.getWidth(), gameView.getHeight());
onSurfaceChanged(getSurfaceHolder(), format, dimens.x, dimens.y);
}
示例7: prepareTest
import android.os.Looper; //导入方法依赖的package包/类
@Override
public void prepareTest() {
Looper.prepare();
try {
Constructor<?> constructor = subscriberClass.getConstructor(PerfTestOtto.class);
for (int i = 0; i < params.getSubscriberCount(); i++) {
Object subscriber = constructor.newInstance(this);
subscribers.add(subscriber);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例8: removeAllCookiesV21
import android.os.Looper; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void removeAllCookiesV21() {
final CookieManager cookieManager = CookieManager.getInstance();
Looper looper = Looper.myLooper();
boolean prepared = false;
if (looper == null) {
Looper.prepare();
prepared = true;
}
// requires a looper
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean value) {
Thread thread = new Thread() {
@Override
public void run() {
// is synchronous, run in background
cookieManager.flush();
}
};
thread.start();
}
});
if (prepared) {
looper = Looper.myLooper();
if (looper != null) {
looper.quit();
}
}
}
示例9: run
import android.os.Looper; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
handler = new Handler();
syncLatch.countDown();
Looper.loop();
}
示例10: run
import android.os.Looper; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
handler = new DecodeHandler(activity, hints);
handlerInitLatch.countDown();
Looper.loop();
}
示例11: run
import android.os.Looper; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
mHandler = new DecodeHandler(mActivity);
mHandlerInitLatch.countDown();
Looper.loop();
}
示例12: start
import android.os.Looper; //导入方法依赖的package包/类
public static Thread start(final Actionable actionable) {
Thread t=new Thread(new Runnable(){
public void run() {
actionable.doInThread();
Looper.prepare();
actionable.callback();
Looper.loop();
}
});
t.start();
return t;
}
示例13: run
import android.os.Looper; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
handler = new DecodeHandler(barcodeReaderView, hints);
handlerInitLatch.countDown();
Looper.loop();
}
示例14: setup
import android.os.Looper; //导入方法依赖的package包/类
@Before
public void setup() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
context = InstrumentationRegistry.getTargetContext();
recyclerView = mock(RecyclerView.class);
adapter = mock(BrickRecyclerAdapter.class);
view = mock(View.class);
dataManager = mock(BrickDataManager.class);
when(dataManager.getBrickRecyclerAdapter()).thenReturn(adapter);
when(adapter.getRecyclerView()).thenReturn(recyclerView);
itemView = new TextView(context);
((TextView) itemView).setText(TEST);
itemView.measure(MOCK_VIEW_SIZE, MOCK_VIEW_SIZE);
stickyViewHolder = new BrickViewHolder(itemView);
stickyHolderContainer = spy((ViewGroup) LayoutInflater.from(context).inflate(R.layout.vertical_header, new LinearLayout(context), false));
stickyHolderContainer.layout(0, 0, MOCK_VIEW_SIZE, MOCK_VIEW_SIZE);
stickyHolderContainer.setLayoutParams(new ViewGroup.LayoutParams(MOCK_VIEW_SIZE, MOCK_VIEW_SIZE));
View header = spy((ViewGroup) LayoutInflater.from(context).inflate(R.layout.text_brick, new LinearLayout(context), false));
header.layout(0, 0, MOCK_VIEW_SIZE, MOCK_VIEW_SIZE);
header.setLayoutParams(new ViewGroup.LayoutParams(MOCK_VIEW_SIZE, MOCK_VIEW_SIZE));
stickyHolderLayout = ((ViewGroup) stickyHolderContainer.findViewById(R.id.header_sticky_layout));
stickyHolderLayout.addView(header);
headerBehavior = spy(new TestStickyHeaderBehavior(dataManager, stickyHolderContainer));
headerBehavior.swapStickyView(stickyViewHolder);
headerBehavior.translateStickyView();
headerBehavior.setStickyBackgroundColor(Color.WHITE);
}
示例15: initializeLooper
import android.os.Looper; //导入方法依赖的package包/类
private Looper initializeLooper() {
Looper looper = Looper.myLooper();
if (looper == null) {
Looper.prepare();
}
return Looper.myLooper();
}