当前位置: 首页>>代码示例>>Java>>正文


Java Handler.post方法代码示例

本文整理汇总了Java中android.os.Handler.post方法的典型用法代码示例。如果您正苦于以下问题:Java Handler.post方法的具体用法?Java Handler.post怎么用?Java Handler.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Handler的用法示例。


在下文中一共展示了Handler.post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.os.Handler; //导入方法依赖的package包/类
@Override
protected void init(final String initialCommand) {
    Handler uiHandler = new Handler(mContext.getMainLooper());
    uiHandler.post(new Runnable() {
        @Override
        public void run() {
            TermSettings settings = new TermSettings(mContext.getResources(), PreferenceManager.getDefaultSharedPreferences(mContext));
            try {
                mTermSession = new MyShellTermSession(settings, initialCommand);
                mTermSession.initializeEmulator(1024, 40);
            } catch (IOException e) {
                mInitException = new UncheckedIOException(e);
            }
        }
    });
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:17,代码来源:Shell.java

示例2: getStringCallback

import android.os.Handler; //导入方法依赖的package包/类
private WebSocket.StringCallback getStringCallback() {
    return new WebSocket.StringCallback(){
        public void onStringAvailable(String s){
            try {
                final JSONObject row = new JSONObject(s);
                Runnable dispatchState = new Runnable() {
                    @Override
                    public void run() {
                        processData(row);
                    }
                };
                Handler mainHandler = new Handler(context.getMainLooper());
                mainHandler.post(dispatchState);
            } catch (JSONException e) {}
        }
    };
}
 
开发者ID:mervinderuiter,项目名称:home-assistant-android,代码行数:18,代码来源:HassEntities.java

示例3: ExecutorDelivery

import android.os.Handler; //导入方法依赖的package包/类
/**
 * Creates a new response delivery interface.
 * @param handler {@link Handler} to post responses on
 */
public ExecutorDelivery(final Handler handler) {
    // Make an Executor that just wraps the handler.
    mResponsePoster = new Executor() {
        @Override
        public void execute(Runnable command) {
            handler.post(command);
        }
    };
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:14,代码来源:ExecutorDelivery.java

示例4: runMainHanlder

import android.os.Handler; //导入方法依赖的package包/类
private void runMainHanlder(final Camera.Size previewSize) {
    Handler mainHanlder = new Handler(Looper.getMainLooper());
    mainHanlder.post(new Runnable() {
        @Override
        public void run() {
            adjustViewSize(previewSize);
        }
    });
}
 
开发者ID:ThinkKeep,项目名称:EvilsLive,代码行数:10,代码来源:CameraOld.java

示例5: runTask

import android.os.Handler; //导入方法依赖的package包/类
static void runTask(Runnable r, boolean sync, Handler handler, ImageLoaderEngine engine) {
    if (sync) {
        r.run();
    } else if (handler == null) {
        engine.fireCallback(r);
    } else {
        handler.post(r);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:LoadAndDisplayImageTask.java

示例6: runUI

import android.os.Handler; //导入方法依赖的package包/类
public void runUI(@NonNull Runnable runnable) {
    if (Looper.myLooper() == Looper.getMainLooper()) {
        runnable.run();
        return;
    }
    Handler handler = ensureUiHandlerNotNull();
    try {
        handler.post(runnable);
    } catch (Exception e) {
        BoxingLog.d("update UI task fail. " + e.getMessage());
    }
}
 
开发者ID:Bilibili,项目名称:boxing,代码行数:13,代码来源:BoxingExecutor.java

示例7: setProgressFromAnotherThread

import android.os.Handler; //导入方法依赖的package包/类
public void setProgressFromAnotherThread(final int progress) {
    if (mProgress != progress) {
        mProgress = progress;
        // For some unknown reason, setProgress just does not work from a separate
        // thread, although the code in ProgressBar looks like it should. Thus, we
        // resort to a runnable posted to the handler of the view.
        final Handler handler = getHandler();
        // It's possible to come here before this view has been laid out. If so,
        // just ignore the call - it will be updated again later.
        if (null == handler) return;
        handler.post(this);
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:14,代码来源:DictionaryDownloadProgressBar.java

示例8: DownloadStatusDeliveryImpl

import android.os.Handler; //导入方法依赖的package包/类
public DownloadStatusDeliveryImpl(final Handler handler) {
    this.mDownloadStatusPoster = new Executor() {
        public void execute(Runnable command) {
            handler.post(command);
        }
    };
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:DownloadStatusDeliveryImpl.java

示例9: notifyListeners

import android.os.Handler; //导入方法依赖的package包/类
private void notifyListeners(int why, int deviceId) {
    // the state of some device has changed
    if (!mListeners.isEmpty()) {
        // yes... this will cause an object to get created... hopefully
        // it won't happen very often
        for (InputDeviceListener listener : mListeners.keySet()) {
            Handler handler = mListeners.get(listener);
            DeviceEvent odc = DeviceEvent.getDeviceEvent(why, deviceId, listener);
            handler.post(odc);
        }
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:13,代码来源:InputManagerV9.java

示例10: openIME

import android.os.Handler; //导入方法依赖的package包/类
public void openIME(final EditText v) {
    final boolean focus = v.requestFocus();
    if (v.hasFocus()) {
        final Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                InputMethodManager mgr = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                boolean result = mgr.showSoftInput(v, InputMethodManager.SHOW_FORCED);
                log.debug("openIME " + focus + " " + result);
            }
        });
    }
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:15,代码来源:BaseActivity.java

示例11: addPersonDataBool

import android.os.Handler; //导入方法依赖的package包/类
@ReactMethod
public void addPersonDataBool(final Boolean bool, final String key, final Promise promise)
{
	if (!_initialised)
	{
		promise.reject(APPTENTIVE, "Apptentive is not initialised");
		return;
	}
	if (bool == null)
	{
		promise.reject(APPTENTIVE, "Your bool is empty");
		return;
	}
	if (key == null || key.isEmpty())
	{
		promise.reject(APPTENTIVE, "Your key is empty");
		return;
	}

	Handler handler = new Handler(_application.getMainLooper());
	Runnable runnable = new Runnable()
	{
		@Override
		public void run()
		{
			Apptentive.addCustomPersonData(key, bool);
			promise.resolve(true);
		}
	};
	handler.post(runnable);
}
 
开发者ID:erikpoort,项目名称:react-native-apptentive-module,代码行数:32,代码来源:RNApptentiveModule.java

示例12: jumpPoint

import android.os.Handler; //导入方法依赖的package包/类
/**
 * marker点击时跳动一下
 */
public void jumpPoint(final Marker marker) {
    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    //获取地图投影坐标转换器
    Projection proj = amap.getProjection();
    final LatLng markerLatlng = marker.getPosition();
    Point markerPoint = proj.toScreenLocation(markerLatlng);
    markerPoint.offset(0, -50);
    final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
    final long duration = 500;

    final Interpolator interpolator = new BounceInterpolator();
    handler.post(new Runnable() {
        @Override
        public void run() {
            long elapsed = SystemClock.uptimeMillis() - start;
            float t = interpolator.getInterpolation((float) elapsed
                    / duration);
            double lng = t * markerLatlng.longitude + (1 - t)
                    * startLatLng.longitude;
            double lat = t * markerLatlng.latitude + (1 - t)
                    * startLatLng.latitude;
            marker.setPosition(new LatLng(lat, lng));
            if (t < 1.0) {
                handler.postDelayed(this, 16);
            }
        }
    });
}
 
开发者ID:Vicent9920,项目名称:MyMap,代码行数:33,代码来源:PiclocationActivity.java

示例13: record

import android.os.Handler; //导入方法依赖的package包/类
public void record(final HttpCall httpCall) throws IOException {
  Handler handler = new Handler(context.getMainLooper());
  handler.post(new Runnable() {
    @Override
    public void run() {
      AndroidSnooper.this.snooperRepo.save(HttpCallRecord.from(httpCall));
    }
  });
}
 
开发者ID:jainsahab,项目名称:AndroidSnooper,代码行数:10,代码来源:AndroidSnooper.java

示例14: addDeviceDataNumber

import android.os.Handler; //导入方法依赖的package包/类
@ReactMethod
public void addDeviceDataNumber(final Number number, final String key, final Promise promise)
{
	if (!_initialised)
	{
		promise.reject(APPTENTIVE, "Apptentive is not initialised");
		return;
	}
	if (number == null)
	{
		promise.reject(APPTENTIVE, "Your number is empty");
		return;
	}
	if (key == null || key.isEmpty())
	{
		promise.reject(APPTENTIVE, "Your key is empty");
		return;
	}

	Handler handler = new Handler(_application.getMainLooper());
	Runnable runnable = new Runnable()
	{
		@Override
		public void run()
		{
			Apptentive.addCustomDeviceData(key, number);
			promise.resolve(true);
		}
	};
	handler.post(runnable);
}
 
开发者ID:erikpoort,项目名称:react-native-apptentive-module,代码行数:32,代码来源:RNApptentiveModule.java

示例15: update

import android.os.Handler; //导入方法依赖的package包/类
/**
 * Update mobile map package with latest version
 */
@Override public void update() {
  //Check for valid credentials

  final String credentialString;
  try {
    credentialString = mCredentialCryptographer.decrypt();
    if (credentialString != null && credentialString.length() > 0 ){
      Log.i(TAG,"Downloading with cached credentials");

      // Rehydrate the credential cache from the decrypted file
      AuthenticationManager.CredentialCache.restoreFromJson(credentialString);

      //Kick off a thread to handle mobile map package download
      final Handler handler = new Handler() ;
      handler.post(new Runnable() {
        @Override public void run() {
          // Download map book
          downloadMapbook();
        }
      });
    }else{
      // If credentials are null, we'll prompt user for credentials
      Log.i(TAG,"Credential cache cannot be reconstituted from null credentials, so asking using to provide credentials...");
      signIn();
    }
  } catch (Exception e) {
    Log.e(TAG, e.getClass().getSimpleName() + " " + e.getMessage());
    if (e.getCause() != null){
      Log.e(TAG, e.getCause().getMessage());
    }
  }


}
 
开发者ID:Esri,项目名称:mapbook-android,代码行数:38,代码来源:DownloadPresenter.java


注:本文中的android.os.Handler.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。