@Override public void showSoftKeyboard(final boolean show) { view.getHandler().post(new Runnable() { public void run() { InputMethodManager manager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (show) { manager.showSoftInput(view, 0); } else { manager.hideSoftInputFromWindow(view.getWindowToken(), 0); } } }); } }
@Override public void showErrorDialog(String message) { final String finalMsg = message; final String finalTitle = "Error in application"; final Context context = JmeAndroidSystem.getView().getContext(); view.getHandler().post(new Runnable() { @Override public void run() { AlertDialog dialog = new AlertDialog.Builder(context) .setTitle(finalTitle).setMessage(finalMsg).create(); dialog.show(); } }); }
@Override public void onClick(View v) { Drawable background = v.getBackground(); long delay = 0; if(background != null) { if (background instanceof RippleDrawable) delay = ((RippleDrawable) background).getClickDelayTime(); else if (background instanceof ToolbarRippleDrawable) delay = ((ToolbarRippleDrawable) background).getClickDelayTime(); } if(delay > 0 && v.getHandler() != null) { if(!mClickScheduled){ mClickScheduled = true; v.getHandler().postDelayed(new ClickRunnable(v), delay); } } else dispatchClickEvent(v); }
view.getHandler().post(new Runnable() { @Override public void run() {
private void scheduleButAlsoReschedule(final View v){ v.getHandler().removeCallbacksAndMessages(null); v.getHandler().postDelayed(new Runnable(){ @Override public void run() { // do something here, Note: this is UI-thread }}, DISMISS_DELAY); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // TODO Auto-generated method stub super.onViewCreated(view, savedInstanceState); view.getHandler().postDelayed(new Runnable(){ @Override public void run() { getActivity().getSupportFragmentManager().beginTransaction().remove(PreviewFragment.this).commit(); }}, 5000); }
if (view.getHandler() != null) view.getHandler().post(myRunnable);
@Override public void onAnimationEnd(Animation animation) { animation.setAnimationListener(null); final Displayable oldView = this.oldView.get(); final Animator animator = this.animator.get(); if (oldView != null && animator != null) { // Make sure to post actions on UI thread oldView.getView().getHandler().post(new Runnable() { public void run() { animator.clearAnimation(); oldView.destroy(); animator.setAnimation(); } }); } }
@Override public void run() { //Adrian: after screen rotation it might take some time to attach the view to the window //Wait up to 3 seconds for this to happen. int i = 0; while (localView.getHandler() == null && i < 10) { i++; try { Thread.sleep(300); } catch (InterruptedException e) { } } if (localView.getHandler() == null) { Log.d("DrawStats", "no Handler found - stopping to update view"); return; } boolean success = localView.post(new Runnable() { @Override public void run() { tv.setText(s); Log.d("DrawStats", "setText actually called: " + s); } }); Log.d("DrawStats", "updateText: " + s + " success: " + success); } });
@Override public void run() { //Adrian: after screen rotation it might take some time to attach the view to the window //Wait up to 3 seconds for this to happen. int i = 0; while (localView.getHandler() == null && i < 10) { i++; try { Thread.sleep(300); } catch (InterruptedException e) { } } if (localView.getHandler() == null) { Log.d("DrawStats", "no Handler found - stopping to update view"); return; } boolean success = localView.post(new Runnable() { @Override public void run() { tv.setText(s); Log.d("DrawStats", "setText actually called: " + s); } }); Log.d("DrawStats", "updateText: " + s + " success: " + success); } });
@Override public Handler getUIHandler(){ if( mHandler != null ){ return mHandler; } mHandler = mBinder.getUiHandler(); if( mHandler != null ){ return mHandler; } mHandler = mRapidView.getView().getHandler(); return mHandler; }
final Handler handler = view != null ? view.getHandler() : null; if (handler != null) { handler.postDelayed(this, TIMEOUT); final Handler handler = view != null ? view.getHandler() : null; if (handler != null) { added.set(true);
private void assignRunnable(final View view, final Runnable runnable, final int delay) { if (view.getHandler() == null) { // View is not ready, postpone assignment this.getView().postDelayed(new Runnable() { @Override public void run() { assignRunnable(view, runnable, delay); } }, 100); //Abort return; } //View is ready, assign the runnable view.postDelayed(runnable, delay); }
private void showKeyboard(View v) { InputMethodManager imm = (InputMethodManager) mLauncher.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { boolean success = false; if (v != null) { View focused = v.findFocus(); success = imm.showSoftInput(focused, InputMethodManager.SHOW_FORCED, new ResultReceiver(focused.getHandler()) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { super.onReceiveResult(resultCode, resultData); mIsKeyboardShowing = (resultCode == InputMethodManager.RESULT_UNCHANGED_SHOWN) || (resultCode == InputMethodManager.RESULT_SHOWN); } }); } else { Log.d(TAG, "showKeyboard: no focused view"); } if (!success) { imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS); mIsKeyboardShowing = true; } } else { Log.d(TAG, "showKeyboard: no soft input service"); } }