-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IntentHandler to start or handle Intents (#13)
* Added IntentHandler to start or handle Intents Closed #11 * Added setIntentHandler guide for README * Fixed a code style issue
- Loading branch information
Showing
7 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
library/src/main/java/me/drakeet/floo/DefaultIntentHandler.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,16 @@ | ||
package me.drakeet.floo; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* @author drakeet | ||
*/ | ||
public class DefaultIntentHandler implements IntentHandler { | ||
|
||
@Override | ||
public void onIntentCreated(@NonNull Context context, @NonNull Intent intent) { | ||
context.startActivity(intent); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package me.drakeet.floo; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* @author drakeet | ||
*/ | ||
public interface IntentHandler { | ||
|
||
/** | ||
* Called immediately after intent has created on {@link Floo#start()}. | ||
* | ||
* @param context The context. | ||
* @param intent The intent. | ||
*/ | ||
void onIntentCreated(@NonNull Context context, @NonNull Intent intent); | ||
} |
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,21 @@ | ||
package me.drakeet.floo; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
/** | ||
* @author drakeet | ||
*/ | ||
public final class Preconditions { | ||
|
||
@NonNull | ||
@SuppressWarnings("ConstantConditions") | ||
public static <T> T checkNotNull(@NonNull final T object) { | ||
if (object == null) { | ||
throw new NullPointerException(); | ||
} | ||
return object; | ||
} | ||
|
||
|
||
private Preconditions() {} | ||
} |