Skip to content

Commit 4996bfc

Browse files
author
Hussein Aladeen
committed
feat(samples): Add sample library to demonstrate multi module deep linking
1 parent c2c6343 commit 4996bfc

File tree

13 files changed

+126
-12
lines changed

13 files changed

+126
-12
lines changed

sample-library/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

sample-library/build.gradle

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'checkstyle'
3+
apply from: "../extra/checkstyle/checkstyle_android_library.gradle"
4+
5+
android {
6+
compileSdkVersion compileSdk
7+
buildToolsVersion buildTools
8+
9+
defaultConfig {
10+
minSdkVersion minSdk
11+
targetSdkVersion targetSdk
12+
}
13+
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt')
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
25+
compile project(':flowr')
26+
annotationProcessor project(':flowr-compiler')
27+
28+
compile libraries.appCompat
29+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.fueled.flowr.sample.library">
3+
4+
<application/>
5+
6+
</manifest>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.fueled.flowr.sample.library;
2+
3+
import com.fueled.flowr.annotations.DeepLinkHandler;
4+
5+
/**
6+
* Created by [email protected] on 05/06/2017.
7+
* Copyright (c) 2017 Fueled. All rights reserved.
8+
*/
9+
@DeepLinkHandler
10+
public class LibraryDeepLinkHandler {
11+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.fueled.flowr.sample.library;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.view.LayoutInflater;
6+
import android.view.View;
7+
import android.view.ViewGroup;
8+
9+
import com.fueled.flowr.AbstractFlowrFragment;
10+
import com.fueled.flowr.annotations.DeepLink;
11+
12+
/**
13+
* Created by [email protected] on 05/06/2017.
14+
* Copyright (c) 2017 Fueled. All rights reserved.
15+
*/
16+
@DeepLink("/hello")
17+
public class LinkFragment extends AbstractFlowrFragment {
18+
19+
@Nullable
20+
@Override
21+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
22+
@Nullable Bundle savedInstanceState) {
23+
return inflater.inflate(R.layout.fragment_link, container, false);
24+
}
25+
26+
@Override
27+
public String getTitle() {
28+
return "Sample Library Link Fragment";
29+
}
30+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<TextView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="#FFFFFF"
7+
android:clickable="true"
8+
android:gravity="center"
9+
android:text="@string/hello_world"
10+
android:textSize="18sp"
11+
android:textStyle="bold"/>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<resources>
2+
<string name="app_name">sample-library</string>
3+
<string name="hello_world">Hello, World!</string>
4+
</resources>

sample/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ dependencies {
3232
compile fileTree(dir: 'libs', include: ['*.jar'])
3333

3434
compile project(':flowr')
35-
3635
annotationProcessor project(':flowr-compiler')
3736

37+
compile project(':sample-library')
38+
3839
compile libraries.appCompat
3940
compile libraries.designSupport
4041

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public int getLayoutId() {
2424
protected void setupView(View view) {
2525
binding = DataBindingUtil.bind(view);
2626
binding.homeOpenViewButton.setOnClickListener(this);
27+
binding.homeOpenLinkButton.setOnClickListener(this);
2728
}
2829

2930
@Override
@@ -38,12 +39,22 @@ public NavigationIconType getNavigationIconType() {
3839

3940
@Override
4041
public void onClick(View view) {
41-
displayViewFragment();
42+
if (getId() == R.id.home_open_view_button) {
43+
displayViewFragment();
44+
} else {
45+
displayLinkFragment();
46+
}
4247
}
4348

4449
private void displayViewFragment() {
4550
getFlowr().open("/m/From%20HomeFragment")
46-
.setCustomTransactionAnimation(android.R.anim.fade_in, android.R.anim.fade_out, android.R.anim.slide_in_left, android.R.anim.slide_out_right)
51+
.setCustomTransactionAnimation(android.R.anim.fade_in, android.R.anim.fade_out,
52+
android.R.anim.slide_in_left, android.R.anim.slide_out_right)
53+
.displayFragment();
54+
}
55+
56+
private void displayLinkFragment() {
57+
getFlowr().open("/hello")
4758
.displayFragment();
4859
}
4960
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.fueled.flowr.sample.core.AbstractFragment;
1919
import com.fueled.flowr.sample.core.FragmentResultPublisherImpl;
2020
import com.fueled.flowr.sample.databinding.ActivityMainBinding;
21-
21+
import com.fueled.flowr.sample.library.LibraryDeepLinkHandlerImpl;
2222

2323
public class MainActivity extends AbstractActivity implements ToolbarHandler, DrawerHandler {
2424

@@ -50,7 +50,8 @@ public Flowr getFlowr() {
5050
flowr = new Flowr(R.id.main_container, this, this, this,
5151
FragmentResultPublisherImpl.getInstance());
5252

53-
flowr.setDeepLinkHandlers(new MainDeepLinkHandlerImpl());
53+
flowr.setDeepLinkHandlers(new MainDeepLinkHandlerImpl(),
54+
new LibraryDeepLinkHandlerImpl());
5455
}
5556

5657
return flowr;

0 commit comments

Comments
 (0)