List of usage examples for android.os Looper myLooper
public static @Nullable Looper myLooper()
From source file:de.qspool.clementineremote.backend.ClementineService.java
private void intteruptThread() { if (mPlayerThread != null) { mPlayerThread.interrupt();/*from w ww .jav a2 s . c o m*/ } if (App.mClementineConnection != null && mPlayerThread.isAlive()) { App.mClementineConnection.mHandler.post(new Runnable() { @Override public void run() { Looper.myLooper().quit(); } }); } }
From source file:com.example.login1.http.AsyncHttpResponseHandler.java
/** * Creates a new AsyncHttpResponseHandler *//*from w w w .j av a2s . c o m*/ public AsyncHttpResponseHandler(Looper looper) { this.looper = looper == null ? Looper.myLooper() : looper; // Use asynchronous mode by default. setUseSynchronousMode(false); }
From source file:com.applivery.applvsdklib.ui.views.update.MustUpdateViewImpl.java
public Looper getLooper() { if (Looper.myLooper() == Looper.getMainLooper()) { return Looper.myLooper(); } else {//w w w . j a v a2s .c om return Looper.getMainLooper(); } }
From source file:io.flutter.plugins.localauth.AuthenticationHelper.java
@Override public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result) { updateFingerprintDialog(DialogState.SUCCESS, (String) call.argument("fingerprintSuccess")); new Handler(Looper.myLooper()).postDelayed(new Runnable() { @Override//from ww w . j av a2s . c o m public void run() { stop(true); } }, DISMISS_AFTER_MS); }
From source file:com.autonavi.gxdtaojin.toolbox.volley.Request.java
/** * Notifies the request queue that this request has finished (successfully or with error). * <p>/*from w w w . jav a2s . c o m*/ * Also dumps all events from this request's event log; for debugging. * </p> */ void finish(final String tag) { if (mRequestQueue != null) { mRequestQueue.finish(this); } if (MarkerLog.ENABLED) { final long threadId = Thread.currentThread().getId(); if (Looper.myLooper() != Looper.getMainLooper()) { // If we finish marking off of the main thread, we need to // actually do it on the main thread to ensure correct ordering. Handler mainThread = new Handler(Looper.getMainLooper()); mainThread.post(new Runnable() { @Override public void run() { mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } }); return; } mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } else { long requestTime = SystemClock.elapsedRealtime() - mRequestBirthTime; if (requestTime >= SLOW_REQUEST_THRESHOLD_MS) { VolleyLog.d("%d ms: %s", requestTime, this.toString()); } } }
From source file:net.frakbot.FWeather.util.LocationHelper.java
/** * Bootstraps the appropriate location modules *//*from ww w. j a v a 2s. c o m*/ private void bootstrapLocationHelper() { FLog.d(TAG, "Bootstrapping location provider. Using Play Services: " + hasPlayServices); if (hasPlayServices) { mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); mLocationClientListener = new LocationClientListener(); mLocationManagerListener = new LocationManagerListener(); // Create an instance of GoogleAPIClient. if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(mContext) .addConnectionCallbacks(mLocationClientListener) .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() { @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } }).addApi(LocationServices.API).build(); } mGoogleApiClient.connect(); } else { mLocationManagerListener = new LocationManagerListener(); mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); final Criteria criteria = getDefaultCriteria(); final String provider = mLocationManager.getBestProvider(criteria, true); if (TextUtils.isEmpty(provider)) { FLog.w(mContext, TAG, "No provider available, unable to bootstrap location"); return; } // Setup the listener FLog.v(TAG, "Requesting a single update to the system LocationManager..."); if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } mLocationManager.requestLocationUpdates(provider, getMinUpdateInterval(), 0, mLocationManagerListener, Looper.myLooper()); } // At this point, either mLocationClient or mLocationManager are doing their initialization stuff }
From source file:com.facebook.AccessTokenManager.java
void refreshCurrentAccessToken() { if (Looper.getMainLooper().equals(Looper.myLooper())) { refreshCurrentAccessTokenImpl(); } else {/*from w w w .jav a2s.c o m*/ Handler mainHandler = new Handler(Looper.getMainLooper()); mainHandler.post(new Runnable() { @Override public void run() { refreshCurrentAccessTokenImpl(); } }); } }
From source file:ai.eve.volley.Request.java
/** * Notifies the request queue that this request has finished (successfully * or with error)./*from w ww .java 2s . com*/ * * <p> * Also dumps all events from this request's event log; for debugging. * </p> */ public void finish(final String tag) { if (mRequestQueue != null) { mRequestQueue.finish(this); } if (MarkerLog.ENABLED) { final long threadId = Thread.currentThread().getId(); if (Looper.myLooper() != Looper.getMainLooper()) { // If we finish marking off of the main thread, we need to // actually do it on the main thread to ensure correct ordering. Handler mainThread = new Handler(Looper.getMainLooper()); mainThread.post(new Runnable() { @Override public void run() { mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } }); return; } mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } else { long requestTime = SystemClock.elapsedRealtime() - mRequestBirthTime; if (requestTime >= SLOW_REQUEST_THRESHOLD_MS) { NetroidLog.d("%d ms: %s", requestTime, this.toString()); } } }
From source file:com.facebook.AccessTokenManager.java
void refreshCurrentAccessToken(final AccessToken.AccessTokenRefreshCallback callback) { if (Looper.getMainLooper().equals(Looper.myLooper())) { refreshCurrentAccessTokenImpl(callback); } else {/* ww w .j a v a 2 s .c o m*/ Handler mainHandler = new Handler(Looper.getMainLooper()); mainHandler.post(new Runnable() { @Override public void run() { refreshCurrentAccessTokenImpl(callback); } }); } }
From source file:com.spoiledmilk.ibikecph.login.LoginSplashActivity.java
private void login(final String accessToken) { new Thread(new Runnable() { @Override/*from w w w .java 2 s . c o m*/ public void run() { Looper.myLooper(); Looper.prepare(); showProgressDialog(); LOG.d("facebook login fb token = " + accessToken); Message message = HTTPAccountHandler.performFacebookLogin(accessToken); handler.sendMessage(message); dismissProgressDialog(); } }).start(); }