Skip to content

Commit 1c6c032

Browse files
committed
Moving injection to super classes
1 parent 293e881 commit 1c6c032

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapActivity.java

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.actionbarsherlock.app.SherlockActivity;
88
import com.actionbarsherlock.view.MenuItem;
9+
import com.donnfelker.android.bootstrap.BootstrapApplication;
910

1011
import butterknife.Views;
1112

@@ -18,6 +19,9 @@ public abstract class BootstrapActivity extends SherlockActivity {
1819
public void setContentView(int layoutResId) {
1920
super.setContentView(layoutResId);
2021

22+
23+
BootstrapApplication.getInstance().inject(this);
24+
2125
// Used to inject views with the Butterknife library
2226
Views.inject(this);
2327
}

app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapFragmentActivity.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.donnfelker.android.bootstrap.ui;
22

3+
import android.os.Bundle;
4+
35
import com.actionbarsherlock.app.SherlockFragmentActivity;
46
import com.donnfelker.android.bootstrap.BootstrapApplication;
57

@@ -9,7 +11,18 @@
911
* Base class for all Bootstrap Activities that need fragments.
1012
*/
1113
public class BootstrapFragmentActivity extends SherlockFragmentActivity {
14+
@Override
15+
protected void onCreate(Bundle savedInstanceState) {
16+
super.onCreate(savedInstanceState);
17+
18+
BootstrapApplication.getInstance().inject(this);
19+
}
20+
21+
@Override
22+
public void setContentView(int layoutResId) {
23+
super.setContentView(layoutResId);
1224

13-
// Handle any super class related items here.
25+
Views.inject(this);
26+
}
1427

1528
}

app/src/main/java/com/donnfelker/android/bootstrap/ui/BootstrapTimerActivity.java

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ protected void onCreate(Bundle savedInstanceState) {
3939

4040
setContentView(R.layout.bootstrap_timer);
4141

42-
BootstrapApplication.getInstance().inject(this);
43-
44-
Views.inject(this);
45-
4642
setTitle(R.string.timer);
4743

4844
start.setOnClickListener(this);

app/src/main/java/com/donnfelker/android/bootstrap/ui/CarouselActivity.java

-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ protected void onCreate(Bundle savedInstanceState) {
3636
super.onCreate(savedInstanceState);
3737
setContentView(R.layout.carousel_view);
3838

39-
Views.inject(this);
40-
BootstrapApplication.getInstance().inject(this);
41-
4239
pager.setAdapter(new BootstrapPagerAdapter(getResources(), getSupportFragmentManager()));
4340

4441
indicator.setViewPager(pager);

app/src/main/java/com/donnfelker/android/bootstrap/ui/UserActivity.java

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ protected void onCreate(Bundle savedInstanceState) {
2929

3030
setContentView(R.layout.user_view);
3131

32-
BootstrapApplication.getInstance().inject(this);
33-
3432
if(getIntent() != null && getIntent().getExtras() != null) {
3533
user = (User) getIntent().getExtras().getSerializable(USER);
3634
}

0 commit comments

Comments
 (0)