-
Notifications
You must be signed in to change notification settings - Fork 7
/
MainActivity.java
70 lines (58 loc) · 2.15 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.zhuinden.flowless_dispatcher_sample;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import com.zhuinden.flowless_dispatcher_sample.extracted.ExampleDispatcher;
import butterknife.BindView;
import butterknife.ButterKnife;
import flowless.Flow;
import flowless.preset.SingleRootDispatcher;
public class MainActivity
extends AppCompatActivity {
@BindView(R.id.main_root)
ViewGroup root;
SingleRootDispatcher flowDispatcher;
@Override
protected void attachBaseContext(Context newBase) {
flowDispatcher = new ExampleDispatcher();
newBase = Flow.configure(newBase, this) //
.defaultKey(FirstKey.create()) //
.dispatcher(flowDispatcher) //
.install(); //
flowDispatcher.setBaseContext(this);
super.attachBaseContext(newBase);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
flowDispatcher.getRootHolder().setRoot(root);
}
@Override
public void onBackPressed() {
boolean didGoBack = flowDispatcher.onBackPressed();
if(didGoBack) {
return;
}
super.onBackPressed();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
flowDispatcher.preSaveViewState();
super.onSaveInstanceState(outState);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
flowDispatcher.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
flowDispatcher.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}