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


Java Looper.prepare方法代碼示例

本文整理匯總了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);
}
 
開發者ID:wayfair,項目名稱:brickkit-android,代碼行數:26,代碼來源:BrickDataManagerTest.java

示例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()));
        }
    }
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:22,代碼來源:CellLocationController.java

示例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;
    }
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:28,代碼來源:HardwareScalerActivity.java

示例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();
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:13,代碼來源:GPSController.java

示例5: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
  Looper.prepare();
  handler = new DecodeHandler(activity, hints);
  handlerInitLatch.countDown();
  Looper.loop();
}
 
開發者ID:TommyLemon,項目名稱:APIJSON-Android-RxJava,代碼行數:8,代碼來源:DecodeThread.java

示例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);
}
 
開發者ID:StringMon,項目名稱:homescreenarcade,代碼行數:11,代碼來源:MazeManWallpaper.java

示例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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:PerfTestOtto.java

示例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();
        }
    }
}
 
開發者ID:fivef,項目名稱:add_to_evernote_note,代碼行數:34,代碼來源:EvernoteUtil.java

示例9: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
    Looper.prepare();
    handler = new Handler();
    syncLatch.countDown();
    Looper.loop();
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:8,代碼來源:DispatchQueue.java

示例10: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
    Looper.prepare();
    handler = new DecodeHandler(activity, hints);
    handlerInitLatch.countDown();
    Looper.loop();
}
 
開發者ID:CardInfoLink,項目名稱:QRScanner,代碼行數:8,代碼來源:DecodeThread.java

示例11: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
    Looper.prepare();
    mHandler = new DecodeHandler(mActivity);
    mHandlerInitLatch.countDown();
    Looper.loop();
}
 
開發者ID:simplezhli,項目名稱:Tesseract-OCR-Scanner,代碼行數:8,代碼來源:DecodeThread.java

示例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;
 }
 
開發者ID:TIIEHenry,項目名稱:TIIEHenry-Android-SDK,代碼行數:13,代碼來源:Task.java

示例13: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
    Looper.prepare();
    handler = new DecodeHandler(barcodeReaderView, hints);
    handlerInitLatch.countDown();
    Looper.loop();
}
 
開發者ID:CoderChoy,項目名稱:BarcodeReaderView,代碼行數:8,代碼來源:DecodeThread.java

示例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);
}
 
開發者ID:wayfair,項目名稱:brickkit-android,代碼行數:38,代碼來源:StickyHeaderBehaviorTest.java

示例15: initializeLooper

import android.os.Looper; //導入方法依賴的package包/類
private Looper initializeLooper() {
  Looper looper = Looper.myLooper();

  if (looper == null) {
    Looper.prepare();
  }

  return Looper.myLooper();
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:10,代碼來源:TelephonyServiceState.java


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