Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #46 from blackberry-webworks/next-back-customAsk

Pull Req: Next back custom ask
  • Loading branch information...
commit e491ea158bb6431992f88f481b9fa583a43e3424 2 parents bd49e27 + 53cedc8
@dmateescu dmateescu authored
View
17 api/dialog/src/main/java/blackberry/ui/dialog/CustomAskAsyncFunction.java
@@ -37,28 +37,25 @@
public Object execute( Object thiz, Object[] args ) throws Exception {
String message;
String[] buttons;
- int[] values;
- //the default value of the default choice. The developer cannot change it.
+ // the default value of the default choice. The developer cannot change it.
final int defaultChoice = 0;
- //callback function
+ // callback function
ScriptableFunction callback = (ScriptableFunction) args[ 2 ];
- //the default value of the global status. The developer cannot change it.
- final boolean global = false;
+ // the default value of the global status. The developer cannot change it.
+ final boolean global = false;
// message
message = (String) args[ 0 ];
// choices & values
Scriptable stringArray = (Scriptable) args[ 1 ];
int count = stringArray.getElementCount();
buttons = new String[ count ];
- values = new int[ count ];
for( int i = 0; i < count; i++ ) {
buttons[ i ] = stringArray.getElement( i ).toString();
- values[ i ] = i;
}
- Runnable dr = DialogRunnableFactory.getCustomAskRunnable(message, buttons, values, defaultChoice, global, callback);
+ Runnable dr = DialogRunnableFactory.getCustomAskRunnable( message, buttons, defaultChoice, global, callback );
// queue
- UiApplication.getUiApplication().invokeLater(dr);
+ UiApplication.getUiApplication().invokeLater( dr );
// return value
return Scriptable.UNDEFINED;
}
@@ -75,7 +72,7 @@ public Object execute( Object thiz, Object[] args ) throws Exception {
fs.addParam( Scriptable.class, true );
// callback
fs.addParam( ScriptableFunction.class, true );
- // filler
+ // filler
fs.addParam( Object.class, false );
return new FunctionSignature[] { fs };
}
View
21 api/dialog/src/main/java/blackberry/ui/dialog/DialogRunnableFactory.java
@@ -82,9 +82,9 @@ public static Runnable getSelectRunnable(boolean allowMultiple, String[] labels,
* @param callback the callback function
* @return the Runnable responsible for opening the dialog
*/
- public static Runnable getCustomAskRunnable(String message, String[] buttons, int[] values, int defaultChoice, boolean global /* style, false */, ScriptableFunction callback) {
- Dialog d = new Dialog( message, buttons, values, defaultChoice, null /* bitmap */, global ? Dialog.GLOBAL_STATUS : 0 /* style */);
- return new DialogAsyncRunnable(d, callback);
+ public static Runnable getCustomAskRunnable(String message, String[] buttons, int defaultChoice, boolean global /* style, false */, ScriptableFunction callback) {
+ Dialog d = new Dialog( message, buttons, null, defaultChoice, null /* bitmap */, global ? Dialog.GLOBAL_STATUS : 0 /* style */);
+ return new DialogAsyncRunnable( d, callback );
}
/**
@@ -177,20 +177,19 @@ public void run() {
_callback = callback;
}
-
/**
* Run the dialog.
*
* @see java.lang.Runnable#run()
*/
- public void run() {
- _dialogValue = new Integer(_dialog.doModal());
- //get object's string as all ecma primitives will return a valid string representation of themselves
- Object retVal = _dialogValue.toString();
+ public void run() {
+ _dialogValue = new Integer( _dialog.doModal() );
+ // get object's string as all ecma primitives will return a valid string representation of themselves
+ Object retVal = _dialogValue.toString();
try {
- _callback.invoke(null, new Object[] { retVal });
- } catch (Exception e) {
- throw new RuntimeException("Invoke callback failed: " + e.getMessage());
+ _callback.invoke( null, new Object[] { retVal } );
+ } catch( Exception e ) {
+ throw new RuntimeException( "Invoke callback failed: " + e.getMessage() );
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.