Methods Summary |
---|
private static native void | closeAsynchronousDialog(java.lang.String res)Native callback method
|
public static void | closeDialog(java.lang.String res)Static method that GearsNativeDialog calls to set the
dialog's result
mResults = res;
|
private android.content.Intent | createIntent(java.lang.String type, java.lang.String arguments)Utility function to build the intent calling the
dialog activity
Intent intent = new Intent();
intent.setClassName(DIALOG_PACKAGE, DIALOG_CLASS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("dialogArguments", arguments);
intent.putExtra("dialogType", type);
return intent;
|
public void | showAsyncDialog(android.content.Context context, java.lang.String type, java.lang.String arguments)Opens a native dialog asynchronously
The dialog is an activity (GearsNativeDialog) provided by the
Browser.
mAsynchronousDialog = true;
Intent intent = createIntent(type, arguments);
context.startActivity(intent);
|
public java.lang.String | showDialog(android.content.Context context, java.lang.String file, java.lang.String arguments)Opens a native dialog synchronously and waits for its completion.
The dialog is an activity (GearsNativeDialog) provided by the Browser
that we call via startActivity(). Contrary to a normal activity though,
we need to block until it returns. To do so, we define a static lock
object in this class, which GearsNativeDialog can unlock once done
try {
mAsynchronousDialog = false;
mLock.lock();
File path = new File(file);
String fileName = path.getName();
String type = fileName.substring(0, fileName.indexOf(".html"));
Intent intent = createIntent(type, arguments);
mResults = null;
context.startActivity(intent);
mDialogFinished.await();
} catch (InterruptedException e) {
Log.e(TAG, "exception e: " + e);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "exception e: " + e);
} finally {
mLock.unlock();
}
return mResults;
|
public static void | signalFinishedDialog()Static method that GearsNativeDialog calls to unlock us
if (!mAsynchronousDialog) {
mLock.lock();
mDialogFinished.signal();
mLock.unlock();
} else {
// we call the native callback
closeAsynchronousDialog(mResults);
}
|