Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

Commit

Permalink
maintenance & improvements (#5)
Browse files Browse the repository at this point in the history
* [update] fix contracts & maybe pattern

* [delete] AGER Contract - renamed to RAGEContract

* [add] flavor dimensions
[update] library versions

* [update] readme update
  • Loading branch information
aqidd authored Dec 19, 2017
1 parent c7d249c commit 7ff0b15
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 24 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Libraries used :
* Hawk `com.orhanobut:hawk:2.0.1`
* Android Libraries ( `appcompat`, `design support`, `data binding`, etc )
* Sosoito Loading Layout `com.github.flipboxstudio:sosoito:v1.0.3`
* Data Binding Validator `com.github.Ilhasoft:data-binding-validator:0.6.4`
* Data Binding Validator `com.github.Ilhasoft:data-binding-validator:1.1.0`
* Rx Java 2 + Rx Android `io.reactivex.rxjava2:rxandroid:2.0.1` & `io.reactivex.rxjava2:rxjava:2.1.2`

--
Expand Down Expand Up @@ -59,6 +59,9 @@ Setup included :
* Utilities classes
* Camera Utils : Get image from camera / gallery
* Calendar Utils : Parse & display Calendar object into various format
* Product Flavors
* Flavor dimensions : using flavor dimensions enable app to combine multiple flavors ( currently using 1 dimension, env / environment )
* Product Flavors : `dev` for development variables and `prod` for production environment variables

--
![screenshots](https://puu.sh/v7Um1/e36c48b42f.png "Screenshots")
Expand All @@ -79,4 +82,5 @@ Setup included :
- [x] Camera utils
- [x] RecyclerView sample
- [x] ViewPager sample
- [x] Product Flavors
- [ ] Any suggestion?
39 changes: 29 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileSdkVersion 27
buildToolsVersion '26.0.2'

defaultConfig {
applicationId "id.co.flipbox.mvvmstarter"
minSdkVersion 18
targetSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

buildConfigField 'String', 'BASE_URL', '"https://jsonplaceholder.typicode.com"'
}

flavorDimensions "env"
productFlavors {
dev { // development environment
dimension "env"
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
buildConfigField 'String', 'BASE_URL', '"https://jsonplaceholder.typicode.com"'
resValue "string", "app_name", "MVVM Starter Dev"
}
prod { //production environment
dimension "env"
buildConfigField 'String', 'BASE_URL', '"https://jsonplaceholder.typicode.com"'
resValue "string", "app_name", "MVVM Starter"
}
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -31,22 +50,22 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
//marshmallow & up permission
compile 'pub.devrel:easypermissions:0.4.3'
compile 'pub.devrel:easypermissions:1.0.1'
//loader
compile 'com.github.flipboxstudio:sosoito:v1.0.3'

//validator
compile 'com.github.Ilhasoft:data-binding-validator:0.6.4'
compile 'com.github.Ilhasoft:data-binding-validator:1.0.0'
//network-related libraries
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import java.util.ArrayList;
import java.util.List;

import id.co.flipbox.mvvmstarter.data.local.contracts.AGERContract;
import id.co.flipbox.mvvmstarter.data.local.contracts.CacheContract;
import id.co.flipbox.mvvmstarter.data.local.contracts.RAGEContract;
import id.co.flipbox.mvvmstarter.models.User;
import id.co.flipbox.mvvmstarter.utils.constants.K;
import io.reactivex.Maybe;
Expand All @@ -16,27 +16,28 @@
* Created by bukhoriaqid on 5/27/17.
*/

public class UserStorage implements AGERContract<User, Integer>, CacheContract
public class UserStorage implements RAGEContract<User, Integer>, CacheContract
{
@Override
public boolean isCacheValid ()
{
// TODO: 7/28/17 define your own cache validity
return true;
return false;
}


@Override
public Maybe<List<User>> getList ()
{
List<User> users = isCacheValid() ? Hawk.get(K.USER_LIST, new ArrayList<User>()) : null;
return Maybe.just(users).subscribeOn(Schedulers.io());
return users == null ? Maybe.<List<User>>empty() : Maybe.just(users).subscribeOn(Schedulers.io());
}

@Override
public Maybe<User> get (Integer id)
{
return Maybe.just(isCacheValid() ? Hawk.get(String.format(K.USER_DETAIL, id), new User(0, "", "")) : null);
User user = isCacheValid() ? Hawk.get(String.format(K.USER_DETAIL, id), new User(0, "", "")) : null;
return user == null ? Maybe.<User>empty() : Maybe.just(user).subscribeOn(Schedulers.io());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Created by bukhoriaqid on 5/27/17.
*/

public interface AGERContract<T, U>
public interface RAGEContract<T, U>
{
Maybe<List<T>> getList ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

public interface CRUDContract<T, U>
{
Maybe<List<User>> getList ();
Maybe<List<T>> getList ();

void create (T obj);

Maybe<User> read (U id);
Maybe<T> read (U id);

void update (T obj, U id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.IOException;

import id.co.flipbox.mvvmstarter.BuildConfig;
import id.co.flipbox.mvvmstarter.data.DataManager;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
Expand All @@ -21,7 +22,7 @@
public class RetrofitServiceFactory
{
// TODO: define your own base url
private static final String BASE_URL = "https://jsonplaceholder.typicode.com";
private static final String BASE_URL = BuildConfig.BASE_URL;
private static final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
private static final Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(new DataTypeAdapterFactory()).create();
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="app_name">MVVM Starter</string>
<string name="email_label">Email</string>
<string name="password_label">Password</string>
<string name="sign_in_label">Sign In</string>
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -16,6 +17,7 @@ allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Mar 25 17:57:37 WIB 2017
#Mon Dec 11 22:03:04 WIB 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 comments on commit 7ff0b15

Please sign in to comment.