Skip to content

Commit daf37d1

Browse files
author
Ariel
committed
init
0 parents  commit daf37d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1110
-0
lines changed

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'com.neenbedankt.android-apt'
3+
apply plugin: 'me.tatarka.retrolambda'
4+
apply plugin: 'realm-android'
5+
6+
android {
7+
compileSdkVersion 25
8+
buildToolsVersion "25.0.0"
9+
defaultConfig {
10+
applicationId "demoapp.dapulse.com.dapulsedemoapp"
11+
minSdkVersion 15
12+
targetSdkVersion 25
13+
versionCode 1
14+
versionName "1.0"
15+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
24+
compileOptions {
25+
sourceCompatibility JavaVersion.VERSION_1_8
26+
targetCompatibility JavaVersion.VERSION_1_8
27+
}
28+
}
29+
30+
31+
32+
dependencies {
33+
compile fileTree(dir: 'libs', include: ['*.jar'])
34+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
35+
exclude group: 'com.android.support', module: 'support-annotations'
36+
})
37+
38+
compile 'com.android.support:appcompat-v7:25.1.1'
39+
compile "com.android.support:recyclerview-v7:25.1.1"
40+
41+
compile 'com.squareup.retrofit:retrofit:1.9.0'
42+
compile 'io.reactivex:rxandroid:1.0.1'
43+
compile 'com.squareup.picasso:picasso:2.5.2'
44+
testCompile 'junit:junit:4.12'
45+
46+
compile 'com.jakewharton:butterknife:8.5.1'
47+
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
48+
49+
// Butter Knife
50+
compile 'com.jakewharton:butterknife:8.4.0'
51+
apt 'com.jakewharton:butterknife-compiler:8.4.0'
52+
53+
// Dagger 2
54+
apt 'com.google.dagger:dagger-compiler:2.8'
55+
compile 'com.google.dagger:dagger:2.8'
56+
provided 'javax.annotation:jsr250-api:1.0'
57+
58+
//retro lambada
59+
retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.3.0'
60+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/ofertour/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package demoapp.dapulse.com.dapulsedemoapp;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("demoapp.dapulse.com.dapulsedemoapp", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="demoapp.dapulse.com.dapulsedemoapp">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:name=".DemoApp"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name=".MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
<activity android:name=".features.employees.EmployeeActivity"></activity>
22+
</application>
23+
24+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package demoapp.dapulse.com.dapulsedemoapp;
2+
3+
import android.app.Application;
4+
5+
import demoapp.dapulse.com.dapulsedemoapp.dagger.ApplicationComponent;
6+
import demoapp.dapulse.com.dapulsedemoapp.dagger.ApplicationModule;
7+
import demoapp.dapulse.com.dapulsedemoapp.dagger.DaggerApplicationComponent;
8+
import demoapp.dapulse.com.dapulsedemoapp.dagger.NetworkModule;
9+
import io.realm.Realm;
10+
11+
/**
12+
* Created by ofertour on 06/02/2017.
13+
*/
14+
15+
public class DemoApp extends Application{
16+
17+
18+
private ApplicationComponent mAppComponent;
19+
20+
@Override
21+
public void onCreate() {
22+
super.onCreate();
23+
mAppComponent = DaggerApplicationComponent.builder()
24+
.applicationModule(new ApplicationModule(this))
25+
.networkModule(new NetworkModule("https://dapulse-mobile-test.herokuapp.com/"))
26+
.build();
27+
28+
Realm.init(this);
29+
}
30+
31+
public ApplicationComponent getAppComponent() {
32+
return mAppComponent;
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package demoapp.dapulse.com.dapulsedemoapp;
2+
3+
import android.content.Intent;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
7+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.EmployeeActivity;
8+
9+
public class MainActivity extends AppCompatActivity {
10+
11+
12+
13+
14+
@Override
15+
protected void onCreate(Bundle savedInstanceState) {
16+
super.onCreate(savedInstanceState);
17+
setContentView(R.layout.activity_main);
18+
19+
startActivity(new Intent(this, EmployeeActivity.class));
20+
finish();
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package demoapp.dapulse.com.dapulsedemoapp.dagger;
2+
import java.lang.annotation.Retention;
3+
import javax.inject.Scope;
4+
5+
@Scope
6+
public @interface ActivityScope {
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package demoapp.dapulse.com.dapulsedemoapp.dagger;
2+
3+
import android.content.SharedPreferences;
4+
import android.support.v7.app.AppCompatActivity;
5+
6+
import javax.inject.Singleton;
7+
8+
import dagger.Component;
9+
10+
@Singleton
11+
@Component(modules={ApplicationModule.class, NetworkModule.class})
12+
public interface ApplicationComponent {
13+
ServerApi getServerApi();
14+
SharedPreferences getPrefs();
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package demoapp.dapulse.com.dapulsedemoapp.dagger;
2+
3+
4+
import android.content.Context;
5+
import android.content.SharedPreferences;
6+
import android.preference.PreferenceManager;
7+
8+
import javax.inject.Named;
9+
import javax.inject.Singleton;
10+
11+
import dagger.Module;
12+
import dagger.Provides;
13+
14+
15+
@Module
16+
public final class ApplicationModule {
17+
private final Context context;
18+
19+
public ApplicationModule(Context context) {
20+
this.context = context;
21+
}
22+
23+
@Provides @Named("application")
24+
@Singleton
25+
Context provideApplicationContext() {
26+
return context;
27+
}
28+
29+
@Provides
30+
@Singleton
31+
SharedPreferences providePrefs() {
32+
return PreferenceManager.getDefaultSharedPreferences(context);
33+
}
34+
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package demoapp.dapulse.com.dapulsedemoapp.dagger;
2+
3+
import dagger.Component;
4+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.base.BaseEmployeeActivity;
5+
6+
@ActivityScope
7+
@Component(dependencies = ApplicationComponent.class, modules = {EmployeesModule.class})
8+
public interface EmployeesComponent {
9+
void inject(BaseEmployeeActivity activity);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package demoapp.dapulse.com.dapulsedemoapp.dagger;
2+
3+
import android.content.Context;
4+
import android.content.SharedPreferences;
5+
import android.support.v7.app.AppCompatActivity;
6+
7+
import javax.inject.Named;
8+
9+
import dagger.Module;
10+
import dagger.Provides;
11+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.EmployeeInteractor;
12+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.EmployeePresenter;
13+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.EmployeesVIP;
14+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.repo.EmployeeRepo;
15+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.repo.RealmEmployeeConverter;
16+
17+
@Module
18+
public class EmployeesModule {
19+
private final AppCompatActivity activity;
20+
21+
public EmployeesModule(AppCompatActivity activity) {
22+
this.activity = activity;
23+
}
24+
25+
@Provides @Named("activity")
26+
@ActivityScope
27+
Context provideActivityContext() {
28+
return activity;
29+
}
30+
31+
@Provides
32+
@ActivityScope
33+
EmployeesVIP.Interactor provideInteractor(ServerApi serverApi, EmployeesVIP.Repository repository) {
34+
return new EmployeeInteractor(serverApi, repository);
35+
}
36+
37+
@Provides
38+
@ActivityScope
39+
EmployeesVIP.Repository provideRepo(RealmEmployeeConverter converter, SharedPreferences prefs) {
40+
return new EmployeeRepo(prefs, converter);
41+
}
42+
43+
44+
45+
@Provides
46+
@ActivityScope
47+
EmployeePresenter providePresenter(EmployeesVIP.Interactor interactor) {
48+
return new EmployeePresenter(interactor);
49+
}
50+
51+
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package demoapp.dapulse.com.dapulsedemoapp.dagger;
2+
3+
import com.google.gson.Gson;
4+
5+
import javax.inject.Singleton;
6+
7+
import dagger.Module;
8+
import dagger.Provides;
9+
import demoapp.dapulse.com.dapulsedemoapp.BuildConfig;
10+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.EmployeesVIP;
11+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.repo.EmployeeRepo;
12+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.repo.RealmEmployeeConverter;
13+
import retrofit.RestAdapter;
14+
import retrofit.converter.GsonConverter;
15+
16+
@Module
17+
public class NetworkModule {
18+
19+
private final String mBaseUrl;
20+
21+
public NetworkModule(String baseUrl) {
22+
mBaseUrl = baseUrl;
23+
}
24+
25+
@Provides @Singleton
26+
public RestAdapter provideRestAdapter() {
27+
return new RestAdapter.Builder()
28+
.setEndpoint(mBaseUrl)
29+
.setConverter(new GsonConverter(new Gson()))
30+
.setLogLevel((BuildConfig.DEBUG ?
31+
RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE))
32+
.build();
33+
}
34+
35+
@Provides @Singleton
36+
public ServerApi provideAPIService(RestAdapter restAdapter) {
37+
return restAdapter.create(ServerApi.class);
38+
}
39+
40+
41+
42+
@Provides @Singleton
43+
RealmEmployeeConverter provideConverter() {
44+
return new RealmEmployeeConverter();
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package demoapp.dapulse.com.dapulsedemoapp.dagger;
2+
3+
import demoapp.dapulse.com.dapulsedemoapp.features.employees.models.EmployeeResponse;
4+
import retrofit.http.GET;
5+
import rx.Observable;
6+
7+
/**
8+
* Created by ofertour on 01/02/2017.
9+
*/
10+
public interface ServerApi {
11+
12+
@GET("/")
13+
Observable<EmployeeResponse> getEmployees();
14+
}

0 commit comments

Comments
 (0)