Skip to content

Commit 7764c87

Browse files
author
Hussein Aladeen
committed
chore(docs): Update documentations to include deep linking setup
1 parent aec8b64 commit 7764c87

File tree

2 files changed

+61
-13
lines changed

2 files changed

+61
-13
lines changed

README.md

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,68 @@ public class TestFragment extends Fragment implement FlowrFragment
235235
String url = getArguments().getString(Flowr.DEEP_LINK_URL,"");
236236
String id = getArguments().getString("id","");
237237
```
238-
To trigger the deep linking handling, simply call `open(Intent, Fragment))`
238+
239+
### Deep Linking Setup:
240+
241+
To generate your deep link handler you will need to annotate at least one class with the `@DeepLinkHandler` annotation. The name of the class annotated with the `@DeepLinkHandler` annotation would then be used as the name of the generated handler class with "Impl" appended at the end.
239242
240243
```java
241-
getFlowr()
242-
.open(getIntent(), HomeFragment.class)
243-
.skipBackStack(true)
244-
.displayFragment();
244+
/** This will generate a MainDeepLinkHandlerImpl class */
245+
@DeepLinkHandler
246+
public class MainDeepLinkHandler {
247+
}
248+
```
249+
250+
However it is also possible to specify a custom name for the generated class by passing the desired class name as a string argument to the `@DeepLinkHandler` annotation.
251+
252+
```java
253+
/** This will generate a MyDeepLinkHandler class */
254+
@DeepLinkHandler("MyDeepLinkHandler")
255+
public class MainActivity extends AbstractActivity {
256+
}
257+
```
258+
259+
If you have fragments across multiple modules, you will need to add the `@DeepLinkHandler` annotation to at least one class in each module.
260+
261+
```java
262+
/** This will generate a LibraryDeepLinkHandlerImpl class */
263+
@DeepLinkHandler
264+
public class LibraryDeepLinkHandler {
265+
}
266+
```
267+
268+
Provide the list of generated deep link handlers to your flowr instance.
269+
270+
```java
271+
public class MainActivity extends AbstractActivity {
272+
273+
private Flowr flowr;
274+
275+
public void getFlowr() {
276+
if (flowr == null) {
277+
flowr = new Flowr(...);
278+
flowr.setDeepLinkHandlers(new MainDeepLinkHandlerImpl(), new LibraryDeepLinkHandlerImpl());
279+
}
280+
281+
return flowr;
282+
}
283+
}
284+
```
285+
286+
Finally to trigger the deep linking handling, simply call `open(Intent, Fragment))` from your `Activity#onCreate(Bundle)` method.
287+
288+
```java
289+
public class MainActivity extends AbstractActivity {
290+
291+
@Override
292+
protected void onCreate(Bundle savedInstanceState) {
293+
...
294+
getFlowr()
295+
.open(getIntent(), HomeFragment.class)
296+
.skipBackStack(true)
297+
.displayFragment();
298+
}
299+
}
245300
```
246301
247302
Additionally you can access a Fragment via the link attached to it:
@@ -261,13 +316,6 @@ getFlowr()
261316
.displayFragment();
262317
```
263318
264-
But don't forget to add those lines to your proguard config:
265-
266-
```
267-
-keep public class * implements com.fueled.flowr.internal.FlowrConfig
268-
-keep public class * implements com.fueled.flowr.internal.FlowrDeepLinkHandler
269-
```
270-
271319
# License
272320
273321
Copyright 2016 Fueled

sample/src/main/java/com/fueled/flowr/sample/HomeFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public NavigationIconType getNavigationIconType() {
3939

4040
@Override
4141
public void onClick(View view) {
42-
if (getId() == R.id.home_open_view_button) {
42+
if (view.getId() == R.id.home_open_view_button) {
4343
displayViewFragment();
4444
} else {
4545
displayLinkFragment();

0 commit comments

Comments
 (0)