Skip to content

Commit

Permalink
Accept IPlugin for result callback when starting activities for result.
Browse files Browse the repository at this point in the history
  • Loading branch information
brycecurtis committed Jul 7, 2011
1 parent 9d1e736 commit 0a7a77e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions framework/src/com/phonegap/DroidGap.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import android.widget.LinearLayout;

import com.phonegap.api.PhonegapActivity;
import com.phonegap.api.Plugin;
import com.phonegap.api.IPlugin;
import com.phonegap.api.PluginManager;

/**
Expand Down Expand Up @@ -140,7 +140,7 @@ public class DroidGap extends PhonegapActivity {
private String baseUrl = null;

// Plugin to call when activity result is received
protected Plugin activityResultCallback = null;
protected IPlugin activityResultCallback = null;
protected boolean activityResultKeepRunning;

// Flag indicates that a loadUrl timeout occurred
Expand Down Expand Up @@ -1288,7 +1288,7 @@ public void startActivityForResult(Intent intent, int requestCode) throws Runtim
* @param intent The intent to start
* @param requestCode The request code that is passed to callback to identify the activity
*/
public void startActivityForResult(Plugin command, Intent intent, int requestCode) {
public void startActivityForResult(IPlugin command, Intent intent, int requestCode) {
this.activityResultCallback = command;
this.activityResultKeepRunning = this.keepRunning;

Expand All @@ -1313,14 +1313,14 @@ public void startActivityForResult(Plugin command, Intent intent, int requestCod
*/
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
Plugin callback = this.activityResultCallback;
IPlugin callback = this.activityResultCallback;
if (callback != null) {
callback.onActivityResult(requestCode, resultCode, intent);
}
}

@Override
public void setActivityResultCallback(Plugin plugin) {
public void setActivityResultCallback(IPlugin plugin) {
this.activityResultCallback = plugin;
}

Expand Down
5 changes: 5 additions & 0 deletions framework/src/com/phonegap/api/IPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public interface IPlugin {
*/
void onResume(boolean multitasking);

/**
* Called when the activity receives a new intent.
*/
void onNewIntent(Intent intent);

/**
* The final call you receive before your activity is destroyed.
*/
Expand Down
4 changes: 2 additions & 2 deletions framework/src/com/phonegap/api/PhonegapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public abstract class PhonegapActivity extends Activity {
* @param intent The intent to start
* @param requestCode The request code that is passed to callback to identify the activity
*/
abstract public void startActivityForResult(Plugin command, Intent intent, int requestCode);
abstract public void startActivityForResult(IPlugin command, Intent intent, int requestCode);

/**
* Set the plugin to be called when a sub-activity exits.
*
* @param plugin The plugin on which onActivityResult is to be called
*/
abstract public void setActivityResultCallback(Plugin plugin);
abstract public void setActivityResultCallback(IPlugin plugin);
}

0 comments on commit 0a7a77e

Please sign in to comment.