Java Code Examples for org.appcelerator.titanium.util.TiUIHelper#runUiDelayedIfBlock()

The following examples show how to use org.appcelerator.titanium.util.TiUIHelper#runUiDelayedIfBlock() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiPickerProxy.java    From TiDialogs with MIT License 6 votes vote down vote up
@Override
protected void handleShow(KrollDict options) {
	super.handleShow(options);
	// If there's a lock on the UI message queue, there's a good chance
	// we're in the middle of activity stack transitions. An alert
	// dialog should occur above the "topmost" activity, so if activity
	// stack transitions are occurring, try to give them a chance to
	// "settle"
	// before determining which Activity should be the context for the
	// AlertDialog.
	TiUIHelper.runUiDelayedIfBlock(new Runnable() {
		@Override
		public void run() {
			MultiPicker d = (MultiPicker) getOrCreateView();
			d.show();
		}
	});
}
 
Example 2
Source File: Manager.java    From TiCrouton with MIT License 5 votes vote down vote up
/**
  * Removes the {@link Crouton}'s view after it's display
  * durationInMilliseconds.
  *
  * @param crouton
  *     The {@link Crouton} added to a {@link ViewGroup} and should be
  *     removed.
  */
 protected void removeCrouton(Crouton crouton) {
   View croutonView = crouton.getView();
   ViewGroup croutonParentView = (ViewGroup) croutonView.getParent();

if (null != croutonParentView) {
	final View mCroutonView = croutonView;
	final ViewGroup mCroutonParentView = croutonParentView;
	final Crouton mCrouton = crouton;
	TiUIHelper.runUiDelayedIfBlock(new Runnable() {
		@Override
		public void run() {
			mCroutonView.startAnimation(mCrouton.getOutAnimation());
			// Remove the Crouton from the queue.
			Crouton removed = croutonQueue.poll();

			// Remove the crouton from the view's parent.
			mCroutonParentView.removeView(mCroutonView);
			if (null != removed) {
				removed.detachActivity();
				removed.detachViewGroup();
				if (null != removed.getLifecycleCallback()) {
					removed.getLifecycleCallback().onRemoved();
				}
				removed.detachLifecycleCallback();
				removed.fireEvent("finish");
			}

			// Send a message to display the next crouton but delay it
			// by the out
			// animation duration to make sure it finishes
			sendMessageDelayed(mCrouton, Messages.DISPLAY_CROUTON,
					mCrouton.getOutAnimation().getDuration());
		}
	});
}
 }
 
Example 3
Source File: TicroutonModule.java    From TiCrouton with MIT License 5 votes vote down vote up
@Kroll.method
public void showText(final String text, final int style)
{
	Log.d(TAG, "showText called");
	TiUIHelper.runUiDelayedIfBlock(new Runnable() {
 			@Override
 			public void run() {
 				Crouton.showText(TiApplication.getInstance().getCurrentActivity(), text, getStyle(style));
 			}
 		});
	
}
 
Example 4
Source File: TimePickerProxy.java    From TiDialogs with MIT License 5 votes vote down vote up
@Override
protected void handleShow(KrollDict options) {
	super.handleShow(options);
	TiUIHelper.runUiDelayedIfBlock(new Runnable() {
		@Override
		public void run() {
			BasicDatePicker d = (BasicDatePicker) getOrCreateView();
			d.show();
		}
	});
}
 
Example 5
Source File: DatePickerProxy.java    From TiDialogs with MIT License 5 votes vote down vote up
@Override
protected void handleShow(KrollDict options) {
	super.handleShow(options);
	TiUIHelper.runUiDelayedIfBlock(new Runnable() {
		@Override
		public void run() {
			BasicDatePicker d = (BasicDatePicker) getOrCreateView();
			d.show();
		}
	});
}
 
Example 6
Source File: TicroutonModule.java    From TiCrouton with MIT License 4 votes vote down vote up
@Kroll.method
public void show(KrollDict args)
{
	Log.d(TAG, "show called");
	
	final Crouton crouton;
	
	Activity activity;
	String text = "";
	Style style = null;
	Builder config = new Configuration.Builder();
	
	if (args.containsKey(TiC.PROPERTY_ACTIVITY)){
		ActivityProxy activityProxy = (ActivityProxy) args.get(TiC.PROPERTY_ACTIVITY);
		activity = activityProxy.getActivity();
       }else{
       	activity = TiApplication.getInstance().getCurrentActivity();
       }
	
	if (args.containsKey(TiC.PROPERTY_TEXT)){
           text = TiConvert.toString(args.get(TiC.PROPERTY_TEXT));
       }
	
	if (args.containsKey(TiC.PROPERTY_STYLE)){
           style = getStyle(TiConvert.toInt(args.get(TiC.PROPERTY_STYLE)));
       }
	
	if (args.containsKey(TiC.PROPERTY_COLOR)){
		
		String color = (String) args.get(TiC.PROPERTY_COLOR);
		
		style = new Style.Builder()
			.setBackgroundColorValue(TiConvert.toColor(color))
			.build();
	}
	
	if (style == null){
		style = Style.INFO;
	}
	
	crouton = Crouton.makeText(activity, text, style);
	
	if (args.containsKey(TiC.PROPERTY_DURATION)){
		config.setDuration(TiConvert.toInt(args.get(TiC.PROPERTY_DURATION)));
		crouton.setConfiguration(config.build());
	}
	
	TiUIHelper.runUiDelayedIfBlock(new Runnable() {
 			@Override
 			public void run() {
 				crouton.show();
 			}
 		});
	
}