This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PerActivity | |
@Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) | |
public interface ActivityComponent { | |
void inject(MainActivity mainActivity); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Component(modules = ApplicationModule.class) | |
public interface ApplicationComponent { | |
void inject(DemoApplication demoApplication); | |
@ApplicationContext | |
Context getContext(); | |
Application getApplication(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class ActivityModule { | |
private Activity mActivity; | |
public ActivityModule(Activity activity) { | |
mActivity = activity; | |
} | |
@Provides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class ApplicationModule { | |
private final Application mApplication; | |
public ApplicationModule(Application app) { | |
mApplication = app; | |
} | |
@Provides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
public class DataManager { | |
private Context mContext; | |
private DbHelper mDbHelper; | |
private SharedPrefsHelper mSharedPrefsHelper; | |
@Inject | |
public DataManager(@ApplicationContext Context context, | |
DbHelper dbHelper, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User { | |
private Long id; | |
private String name; | |
private String address; | |
private String createdAt; | |
private String updatedAt; | |
public User() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
public class DbHelper extends SQLiteOpenHelper { | |
//USER TABLE | |
public static final String USER_TABLE_NAME = "users"; | |
public static final String USER_COLUMN_USER_ID = "id"; | |
public static final String USER_COLUMN_USER_NAME = "usr_name"; | |
public static final String USER_COLUMN_USER_ADDRESS = "usr_add"; | |
public static final String USER_COLUMN_USER_CREATED_AT = "created_at"; | |
public static final String USER_COLUMN_USER_UPDATED_AT = "updated_at"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
compile "com.google.dagger:dagger:2.8" | |
annotationProcessor "com.google.dagger:dagger-compiler:2.8" | |
provided 'javax.annotation:jsr250-api:1.0' | |
compile 'javax.inject:javax.inject:1' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private InfinitePlaceHolderView mLoadMoreView; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
mLoadMoreView = (InfinitePlaceHolderView)findViewById(R.id.loadMoreView); | |
setupView(); |