Skip to content

Commit 7f16db7

Browse files
Merge pull request #75 from Omega-R/feature/fragment_builder
Feature/fragment builder
2 parents bb27e48 + 4c408f0 commit 7f16db7

23 files changed

Lines changed: 986 additions & 98 deletions

File tree

README.md

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ allprojects {
1919
**Step 2.** Add the dependency
2020
```
2121
dependencies {
22-
compile 'com.github.Omega-R.OmegaIntentBuilder:core:1.0.9'
22+
compile 'com.github.Omega-R.OmegaIntentBuilder:core:1.1.0'
2323
// For extras
24-
compile 'com.github.Omega-R.OmegaIntentBuilder:annotations:1.0.9'
25-
annotationProcessor 'com.github.Omega-R.OmegaIntentBuilder:processor:1.0.9'
24+
compile 'com.github.Omega-R.OmegaIntentBuilder:annotations:1.1.0'
25+
annotationProcessor 'com.github.Omega-R.OmegaIntentBuilder:processor:1.1.0'
2626
}
2727
```
2828
# Usage
@@ -205,7 +205,9 @@ OmegaIntentBuilder.from(this)
205205
.startActivityForResult(request_code)
206206
```
207207

208-
**Extras**
208+
# Extras
209+
210+
**Activity**
209211
```
210212
@OmegaActivity
211213
public class ExampleActivity extends Activity {
@@ -243,7 +245,7 @@ public class Model {
243245

244246
```
245247
AppOmegaIntentBuilder.from(this)
246-
.appActivity()
248+
.appActivities()
247249
.exampleActivity()
248250
.parameter_name("Omega-R")
249251
.title("https://omega-r.com/")
@@ -252,6 +254,63 @@ AppOmegaIntentBuilder.from(this)
252254
.startActivity();
253255
```
254256

257+
**Fragment**
258+
259+
```
260+
@OmegaFragment
261+
public class FirstFragment extends BaseFragment {
262+
263+
@OmegaExtra
264+
String value;
265+
266+
@Override
267+
public void onCreate(Bundle savedInstanceState) {
268+
super.onCreate(savedInstanceState);
269+
AppOmegaFragmentBuilder.inject(this);
270+
}
271+
```
272+
273+
```
274+
AppOmegaFragmentBuilder.firstFragment()
275+
.value("First fragment")
276+
.createFragment();
277+
```
278+
279+
**Service**
280+
```
281+
@OmegaService
282+
public class TestService extends IntentService {
283+
284+
private static final String TAG = TestService.class.getSimpleName();
285+
286+
@OmegaExtra
287+
String value;
288+
289+
@OmegaExtraModel(prefix = "model")
290+
Model model = new Model();
291+
292+
public TestService() {
293+
super(TAG);
294+
}
295+
296+
@Override
297+
protected void onHandleIntent(@Nullable Intent intent) {
298+
AppOmegaIntentBuilder.inject(this, intent);
299+
Log.d(TAG, value);
300+
Log.d(TAG, model.getUrl());
301+
}
302+
}
303+
```
304+
305+
```
306+
AppOmegaIntentBuilder.from(context)
307+
.appServices()
308+
.testService()
309+
.value("Great library")
310+
.modelVar2("Omega-R")
311+
.startService();
312+
```
313+
255314
# License
256315
```
257316
The MIT License
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package omega.com.annotations;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
@Target({ElementType.TYPE})
9+
@Retention(RetentionPolicy.RUNTIME)
10+
public @interface OmegaFragment {
11+
12+
}

core/src/main/java/com/omega_r/libs/omegaintentbuilder/OmegaIntentBuilder.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ open class OmegaIntentBuilder(private val context: Context) {
3838
* @param phoneNumber String for calling
3939
* @return CallIntentBuilder for creating call Intent
4040
*/
41-
fun call(phoneNumber: String): CallIntentBuilder {
41+
@JvmOverloads
42+
fun call(phoneNumber: String = ""): CallIntentBuilder {
4243
return CallIntentBuilder(context, phoneNumber)
4344
}
4445

core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/CallIntentBuilder.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ class CallIntentBuilder (private val context: Context,
3131

3232
init {
3333
phoneNumber = phoneNumber.replace(regex, "")
34-
if (phoneNumber.isEmpty()) {
35-
throw IllegalStateException("Empty phone number")
36-
}
3734
}
3835

3936
fun type(callType: CallTypes): CallIntentBuilder {

0 commit comments

Comments
 (0)