-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
92 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
48 changes: 48 additions & 0 deletions
48
core/src/main/java/com/lzh/router/replugin/core/RouterBridgeReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.lzh.router.replugin.core; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.net.Uri; | ||
|
||
import com.lzh.nonview.router.Router; | ||
import com.lzh.nonview.router.extras.RouteBundleExtras; | ||
|
||
/** | ||
* @author haoge on 2018/2/24. | ||
*/ | ||
public class RouterBridgeReceiver extends BroadcastReceiver { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
Uri uri = intent.getParcelableExtra("uri"); | ||
RouteBundleExtras extras = intent.getParcelableExtra("extras"); | ||
Router.resume(uri, extras).open(context); | ||
} | ||
|
||
public static void registerSelf(Context context, String alias, boolean isHost) { | ||
String action = obtainAction(alias, isHost); | ||
|
||
IntentFilter filter = new IntentFilter(action); | ||
context.registerReceiver(new RouterBridgeReceiver(), filter); | ||
} | ||
|
||
public static void start(Context context, String alias, boolean isHost, Uri uri, RouteBundleExtras extras) { | ||
String action = obtainAction(alias, isHost); | ||
|
||
Intent intent = new Intent(action); | ||
intent.putExtra("uri", uri); | ||
intent.putExtra("extras", extras); | ||
context.sendBroadcast(intent); | ||
} | ||
|
||
private static String obtainAction(String alias, boolean isHost) { | ||
String action; | ||
if (isHost) { | ||
action = "com.RePlugin.Router.Host"; | ||
} else { | ||
action = "com.RePlugin.Router.Plugin." + alias; | ||
} | ||
return action; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters