Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 500d7e6

Browse files
author
Sabari
committed
dagger dependency injection base added.
1 parent ac154c6 commit 500d7e6

File tree

18 files changed

+179
-95
lines changed

18 files changed

+179
-95
lines changed

‎app/src/androidTest/java/com/nathansdev/stack/ExampleInstrumentedTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.junit.Test;
88
import org.junit.runner.RunWith;
99

10-
import static org.junit.Assert.*;
10+
import static org.junit.Assert.assertEquals;
1111

1212
/**
1313
* Instrumented test, which will execute on an Android device.
Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
package com.nathansdev.stack.base;
22

3-
import android.app.Fragment;
43
import android.os.Bundle;
54
import android.support.annotation.Nullable;
65
import android.support.annotation.StringRes;
6+
import android.support.v4.app.Fragment;
77
import android.support.v7.app.AppCompatActivity;
88

99
import javax.inject.Inject;
1010

1111
import dagger.android.AndroidInjection;
1212
import dagger.android.AndroidInjector;
1313
import dagger.android.DispatchingAndroidInjector;
14-
import dagger.android.HasFragmentInjector;
15-
import timber.log.Timber;
14+
import dagger.android.support.HasSupportFragmentInjector;
1615

1716
/**
1817
* Base activity class for other activities.
1918
*/
20-
21-
public abstract class BaseActivity extends AppCompatActivity implements HasFragmentInjector, MvpView {
19+
public abstract class BaseActivity extends AppCompatActivity implements HasSupportFragmentInjector, MvpView {
2220

2321
@Inject
2422
DispatchingAndroidInjector<Fragment> fragmentInjector;
@@ -30,7 +28,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3028
}
3129

3230
@Override
33-
public AndroidInjector<Fragment> fragmentInjector() {
31+
public AndroidInjector<Fragment> supportFragmentInjector() {
3432
return fragmentInjector;
3533
}
3634

@@ -64,36 +62,11 @@ public void showMessage(String message) {
6462

6563
}
6664

67-
@Override
68-
public boolean isNetworkConnected() {
69-
return false;
70-
}
71-
72-
@Override
73-
public void openActivityOnTokenExpire() {
74-
75-
}
76-
7765
/**
7866
* Hide soft keyboard.
7967
*/
8068
public void hideKeyboard() {
8169

8270
}
83-
84-
@Override
85-
public void showSessionExpired() {
86-
87-
}
88-
89-
@Override
90-
public boolean isSessionExpired() {
91-
return false;
92-
}
93-
94-
@Override
95-
public void onServerDownError(int errorCode) {
96-
Timber.d("server down error");
97-
}
9871
}
9972

‎app/src/main/java/com/nathansdev/stack/base/BaseFragment.java‎

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package com.nathansdev.stack.base;
22

33
import android.app.Activity;
4-
import android.app.Fragment;
54
import android.content.Context;
65
import android.os.Build;
76
import android.os.Bundle;
87
import android.support.annotation.Nullable;
98
import android.support.annotation.StringRes;
9+
import android.support.v4.app.Fragment;
1010
import android.view.View;
1111

1212
import butterknife.Unbinder;
13-
import dagger.android.AndroidInjection;
13+
import dagger.android.support.AndroidSupportInjection;
1414

1515
/**
1616
* Base fragment class that any fragment can extends.
@@ -32,7 +32,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
3232
@Override
3333
public void onAttach(Activity activity) {
3434
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
35-
AndroidInjection.inject(this);
35+
AndroidSupportInjection.inject(this);
3636
}
3737
if (activity instanceof BaseActivity) {
3838
this.mActivity = (BaseActivity) activity;
@@ -43,7 +43,7 @@ public void onAttach(Activity activity) {
4343
@Override
4444
public void onAttach(Context context) {
4545
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
46-
AndroidInjection.inject(this);
46+
AndroidSupportInjection.inject(this);
4747
}
4848
if (context instanceof BaseActivity) {
4949
this.mActivity = (BaseActivity) context;
@@ -104,36 +104,11 @@ public void showMessage(String message) {
104104

105105
}
106106

107-
@Override
108-
public boolean isNetworkConnected() {
109-
return false;
110-
}
111-
112107
@Override
113108
public void hideKeyboard() {
114109

115110
}
116111

117-
@Override
118-
public void openActivityOnTokenExpire() {
119-
120-
}
121-
122-
@Override
123-
public boolean isSessionExpired() {
124-
return false;
125-
}
126-
127-
@Override
128-
public void showSessionExpired() {
129-
130-
}
131-
132-
@Override
133-
public void onServerDownError(int errorCode) {
134-
mActivity.onServerDownError(errorCode);
135-
}
136-
137112
protected abstract void setUpView(View view);
138113

139114
public void setViewUnbinder(Unbinder unbinder) {

‎app/src/main/java/com/nathansdev/stack/base/BasePresenter.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ public void onDetach() {
2323
mMvpView = null;
2424
}
2525

26-
@Override
27-
public void setUserAsLoggedOut() {
28-
29-
}
30-
3126
private boolean isViewAttached() {
3227
return mMvpView != null;
3328
}

‎app/src/main/java/com/nathansdev/stack/base/MvpPresenter.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@ public interface MvpPresenter<V extends MvpView> {
99
void onAttach(V mvpView);
1010

1111
void onDetach();
12-
13-
//void handleApiError(ANError error);
14-
15-
void setUserAsLoggedOut();
1612
}

‎app/src/main/java/com/nathansdev/stack/base/MvpView.java‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,4 @@ public interface MvpView {
2323
void showMessage(@StringRes int resId);
2424

2525
void hideKeyboard();
26-
27-
boolean isNetworkConnected();
28-
29-
void showSessionExpired();
30-
31-
boolean isSessionExpired();
32-
33-
void onServerDownError(int errorCode);
34-
3526
}

‎app/src/main/java/com/nathansdev/stack/di/AppComponent.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
import dagger.BindsInstance;
1010
import dagger.Component;
11-
import dagger.android.AndroidInjectionModule;
11+
import dagger.android.support.AndroidSupportInjectionModule;
1212

1313
/**
1414
* App component interface.
1515
*/
1616

1717
@Singleton
18-
@Component(modules = {AndroidInjectionModule.class, AppModule.class, ActivityBuilderModule.class})
18+
@Component(modules = {AndroidSupportInjectionModule.class, AppModule.class, ActivityBuilderModule.class})
1919
public interface AppComponent {
2020

2121
/**
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,71 @@
11
package com.nathansdev.stack.home;
22

33
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.design.widget.AppBarLayout;
6+
import android.support.v4.view.ViewPager;
47
import android.support.v7.app.AppCompatActivity;
8+
import android.support.v7.widget.Toolbar;
9+
import android.widget.TableLayout;
510

611
import com.nathansdev.stack.R;
12+
import com.nathansdev.stack.rxevent.RxEventBus;
13+
14+
import javax.inject.Inject;
15+
16+
import butterknife.BindView;
17+
import butterknife.ButterKnife;
18+
import io.reactivex.disposables.CompositeDisposable;
719

820
public class HomeActivity extends AppCompatActivity {
921

22+
// injection
23+
@Inject
24+
RxEventBus eventBus;
25+
@BindView(R.id.viewpager)
26+
ViewPager viewPager;
27+
@BindView(R.id.app_bar)
28+
AppBarLayout appBarLayout;
29+
@BindView(R.id.toolbar)
30+
Toolbar toolbar;
31+
@BindView(R.id.tabs)
32+
TableLayout tableLayout;
33+
34+
private final CompositeDisposable disposables = new CompositeDisposable();
35+
1036
@Override
1137
protected void onCreate(Bundle savedInstanceState) {
1238
super.onCreate(savedInstanceState);
1339
setContentView(R.layout.activity_home);
40+
ButterKnife.bind(this);
41+
setUpSubscription();
42+
setUpViewPager();
43+
addFragmentsToContainer();
44+
}
45+
46+
private void setUpSubscription() {
47+
}
48+
49+
private void addFragmentsToContainer() {
50+
51+
}
52+
53+
private void setUpViewPager() {
54+
55+
}
56+
57+
@Override
58+
protected void onResume() {
59+
super.onResume();
60+
}
61+
62+
@Override
63+
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
64+
super.onPostCreate(savedInstanceState);
65+
}
66+
67+
@Override
68+
protected void onDestroy() {
69+
super.onDestroy();
1470
}
1571
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.nathansdev.stack.home;
2+
3+
import android.support.v4.app.Fragment;
4+
import android.support.v4.app.FragmentManager;
5+
import android.support.v4.app.FragmentStatePagerAdapter;
6+
7+
public class HomePagerAdapter extends FragmentStatePagerAdapter {
8+
public HomePagerAdapter(FragmentManager fm) {
9+
super(fm);
10+
}
11+
12+
@Override
13+
public Fragment getItem(int i) {
14+
return null;
15+
}
16+
17+
@Override
18+
public int getCount() {
19+
return 0;
20+
}
21+
}
Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
3+
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
34
xmlns:app="http://schemas.android.com/apk/res-auto"
4-
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
6-
android:layout_height="match_parent"
7-
tools:context=".home.HomeActivity">
6+
android:layout_height="match_parent">
87

9-
<TextView
10-
android:layout_width="wrap_content"
8+
<android.support.design.widget.AppBarLayout
9+
android:layout_width="match_parent"
1110
android:layout_height="wrap_content"
12-
android:text="Hello World!"
13-
app:layout_constraintBottom_toBottomOf="parent"
14-
app:layout_constraintLeft_toLeftOf="parent"
15-
app:layout_constraintRight_toRightOf="parent"
16-
app:layout_constraintTop_toTopOf="parent" />
11+
android:id="@+id/app_bar"
12+
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
13+
14+
<android.support.v7.widget.Toolbar
15+
android:id="@+id/toolbar"
16+
android:layout_width="match_parent"
17+
android:layout_height="?attr/actionBarSize"
18+
android:background="?attr/colorPrimary"
19+
app:layout_scrollFlags="scroll|enterAlways"
20+
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
21+
22+
<android.support.design.widget.TabLayout
23+
android:id="@+id/tabs"
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
app:tabGravity="fill"
27+
app:tabMode="fixed" />
28+
</android.support.design.widget.AppBarLayout>
1729

18-
</android.support.constraint.ConstraintLayout>
30+
<android.support.v4.view.ViewPager
31+
android:id="@+id/viewpager"
32+
android:layout_width="match_parent"
33+
android:layout_height="match_parent"
34+
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
35+
</android.support.design.widget.CoordinatorLayout>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /