Created
January 8, 2018 16:09
-
-
Save nazmulidris/23ff62a72315575f9d70c340dbc49a53 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public class MyIntentBuilder{ | |
| public static MyIntentBuilder getInstance(Context context) { | |
| return new MyIntentBuilder(context); | |
| } | |
| public MyIntentBuilder(Context context) { | |
| this.mContext = context; | |
| } | |
| public MyIntentBuilder setMessage(String message) { | |
| this.mMessage = message; | |
| return this; | |
| } | |
| public MyIntentBuilder setCommand(@Command int command) { | |
| this.mCommandId = command; | |
| return this; | |
| } | |
| public Intent build() { | |
| Assert.assertNotNull("Context can not be null!", mContext); | |
| Intent intent = new Intent(mContext, MyTileService.class); | |
| if (mCommandId != Command.INVALID) { | |
| intent.putExtra(KEY_COMMAND, mCommandId); | |
| } | |
| if (mMessage != null) { | |
| intent.putExtra(KEY_MESSAGE, mMessage); | |
| } | |
| return intent; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment