6
6
import android .view .KeyEvent ;
7
7
import android .view .Menu ;
8
8
import android .view .MenuItem ;
9
+ import android .view .View ;
9
10
import android .view .Window ;
10
11
import android .view .WindowManager ;
11
12
12
13
import androidx .annotation .NonNull ;
14
+ import androidx .appcompat .widget .Toolbar ;
15
+ import androidx .coordinatorlayout .widget .CoordinatorLayout ;
13
16
import androidx .fragment .app .Fragment ;
14
17
18
+ import com .google .android .material .appbar .AppBarLayout ;
19
+ import com .google .android .material .appbar .CollapsingToolbarLayout ;
15
20
import com .r0adkll .slidr .Slidr ;
16
21
17
22
import org .greenrobot .eventbus .EventBus ;
20
25
import javax .inject .Inject ;
21
26
import javax .inject .Named ;
22
27
28
+ import butterknife .BindView ;
29
+ import butterknife .ButterKnife ;
23
30
import ml .docilealligator .infinityforreddit .ActivityToolbarInterface ;
24
31
import ml .docilealligator .infinityforreddit .FragmentCommunicator ;
25
32
import ml .docilealligator .infinityforreddit .Infinity ;
28
35
import ml .docilealligator .infinityforreddit .SortTypeSelectionCallback ;
29
36
import ml .docilealligator .infinityforreddit .bottomsheetfragments .PostLayoutBottomSheetFragment ;
30
37
import ml .docilealligator .infinityforreddit .customtheme .CustomThemeWrapper ;
31
- import ml .docilealligator .infinityforreddit .databinding .ActivityAccountPostsBinding ;
32
38
import ml .docilealligator .infinityforreddit .events .ChangeNSFWEvent ;
33
39
import ml .docilealligator .infinityforreddit .events .SwitchAccountEvent ;
34
40
import ml .docilealligator .infinityforreddit .fragments .PostFragment ;
@@ -42,6 +48,14 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
42
48
43
49
private static final String FRAGMENT_OUT_STATE = "FOS" ;
44
50
51
+ @ BindView (R .id .coordinator_layout_account_posts_activity )
52
+ CoordinatorLayout coordinatorLayout ;
53
+ @ BindView (R .id .appbar_layout_account_posts_activity )
54
+ AppBarLayout appBarLayout ;
55
+ @ BindView (R .id .collapsing_toolbar_layout_account_posts_activity )
56
+ CollapsingToolbarLayout collapsingToolbarLayout ;
57
+ @ BindView (R .id .toolbar_account_posts_activity )
58
+ Toolbar toolbar ;
45
59
@ Inject
46
60
@ Named ("default" )
47
61
SharedPreferences mSharedPreferences ;
@@ -58,16 +72,16 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
58
72
private String mUserWhere ;
59
73
private Fragment mFragment ;
60
74
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment ;
61
- private ActivityAccountPostsBinding binding ;
62
75
63
76
@ Override
64
77
protected void onCreate (Bundle savedInstanceState ) {
65
78
((Infinity ) getApplication ()).getAppComponent ().inject (this );
66
79
67
80
super .onCreate (savedInstanceState );
68
81
69
- binding = ActivityAccountPostsBinding .inflate (getLayoutInflater ());
70
- setContentView (binding .getRoot ());
82
+ setContentView (R .layout .activity_account_posts );
83
+
84
+ ButterKnife .bind (this );
71
85
72
86
EventBus .getDefault ().register (this );
73
87
@@ -81,7 +95,7 @@ protected void onCreate(Bundle savedInstanceState) {
81
95
Window window = getWindow ();
82
96
83
97
if (isChangeStatusBarIconColor ()) {
84
- addOnOffsetChangedListener (binding . accountPostsAppbarLayout );
98
+ addOnOffsetChangedListener (appBarLayout );
85
99
}
86
100
87
101
if (isImmersiveInterface ()) {
@@ -90,24 +104,24 @@ protected void onCreate(Bundle savedInstanceState) {
90
104
} else {
91
105
window .setFlags (WindowManager .LayoutParams .FLAG_LAYOUT_NO_LIMITS , WindowManager .LayoutParams .FLAG_LAYOUT_NO_LIMITS );
92
106
}
93
- adjustToolbar (binding . accountPostsToolbar );
107
+ adjustToolbar (toolbar );
94
108
}
95
109
}
96
110
97
111
mUserWhere = getIntent ().getExtras ().getString (EXTRA_USER_WHERE );
98
112
if (mUserWhere .equals (PostPagingSource .USER_WHERE_UPVOTED )) {
99
- binding . accountPostsToolbar .setTitle (R .string .upvoted );
113
+ toolbar .setTitle (R .string .upvoted );
100
114
} else if (mUserWhere .equals (PostPagingSource .USER_WHERE_DOWNVOTED )) {
101
- binding . accountPostsToolbar .setTitle (R .string .downvoted );
115
+ toolbar .setTitle (R .string .downvoted );
102
116
} else if (mUserWhere .equals (PostPagingSource .USER_WHERE_HIDDEN )) {
103
- binding . accountPostsToolbar .setTitle (R .string .hidden );
117
+ toolbar .setTitle (R .string .hidden );
104
118
} else if (mUserWhere .equals (PostPagingSource .USER_WHERE_GILDED )) {
105
- binding . accountPostsToolbar .setTitle (R .string .gilded );
119
+ toolbar .setTitle (R .string .gilded );
106
120
}
107
121
108
- setSupportActionBar (binding . accountPostsToolbar );
122
+ setSupportActionBar (toolbar );
109
123
getSupportActionBar ().setDisplayHomeAsUpEnabled (true );
110
- setToolbarGoToTop (binding . accountPostsToolbar );
124
+ setToolbarGoToTop (toolbar );
111
125
112
126
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment ();
113
127
@@ -116,9 +130,7 @@ protected void onCreate(Bundle savedInstanceState) {
116
130
117
131
if (savedInstanceState != null ) {
118
132
mFragment = getSupportFragmentManager ().getFragment (savedInstanceState , FRAGMENT_OUT_STATE );
119
- getSupportFragmentManager ().beginTransaction ()
120
- .replace (binding .accountPostsFrameLayout .getId (), mFragment )
121
- .commit ();
133
+ getSupportFragmentManager ().beginTransaction ().replace (R .id .frame_layout_account_posts_activity , mFragment ).commit ();
122
134
} else {
123
135
initializeFragment ();
124
136
}
@@ -145,10 +157,8 @@ protected CustomThemeWrapper getCustomThemeWrapper() {
145
157
146
158
@ Override
147
159
protected void applyCustomTheme () {
148
- binding .accountPostsCoordinatorLayout .setBackgroundColor (mCustomThemeWrapper .getBackgroundColor ());
149
- applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme (
150
- binding .accountPostsAppbarLayout , binding .accountPostsCollapsingToolbarLayout ,
151
- binding .accountPostsToolbar );
160
+ coordinatorLayout .setBackgroundColor (mCustomThemeWrapper .getBackgroundColor ());
161
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme (appBarLayout , collapsingToolbarLayout , toolbar );
152
162
}
153
163
154
164
private void initializeFragment () {
@@ -161,9 +171,7 @@ private void initializeFragment() {
161
171
bundle .putString (PostFragment .EXTRA_ACCOUNT_NAME , mAccountName );
162
172
bundle .putBoolean (PostFragment .EXTRA_DISABLE_READ_POSTS , true );
163
173
mFragment .setArguments (bundle );
164
- getSupportFragmentManager ().beginTransaction ()
165
- .replace (binding .accountPostsFrameLayout .getId (), mFragment )
166
- .commit ();
174
+ getSupportFragmentManager ().beginTransaction ().replace (R .id .frame_layout_account_posts_activity , mFragment ).commit ();
167
175
}
168
176
169
177
@ Override
0 commit comments