├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── universetelecom
│ │ └── mvvm_users
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── universetelecom
│ │ │ └── mvvm_users
│ │ │ ├── app
│ │ │ └── AppController.java
│ │ │ ├── model
│ │ │ ├── Location.java
│ │ │ ├── Login.java
│ │ │ ├── Name.java
│ │ │ ├── Picture.java
│ │ │ ├── User.java
│ │ │ └── UserResponse.java
│ │ │ ├── network
│ │ │ ├── ApiFactory.java
│ │ │ └── UsersService.java
│ │ │ ├── utils
│ │ │ └── Constant.java
│ │ │ ├── view
│ │ │ ├── activity
│ │ │ │ ├── UserDetailActivity.java
│ │ │ │ └── UsersActivity.java
│ │ │ └── adapter
│ │ │ │ └── UserAdapter.java
│ │ │ └── viewModel
│ │ │ ├── ItemUserViewModel.java
│ │ │ ├── UserDetailViewModel.java
│ │ │ └── UserViewModel.java
│ └── res
│ │ ├── drawable-hdpi
│ │ ├── ic_action.png
│ │ └── ic_action_github.png
│ │ ├── drawable-mdpi
│ │ ├── ic_action.png
│ │ └── ic_action_github.png
│ │ ├── drawable-xhdpi
│ │ ├── ic_action.png
│ │ └── ic_action_github.png
│ │ ├── drawable-xxhdpi
│ │ ├── ic_action.png
│ │ └── ic_action_github.png
│ │ ├── drawable
│ │ ├── ic_account_circle_24dp.xml
│ │ ├── ic_add_24dp.xml
│ │ ├── ic_business_24dp.xml
│ │ ├── ic_call_24dp.xml
│ │ ├── ic_email_24dp.xml
│ │ ├── ic_menu_camera.xml
│ │ ├── ic_menu_gallery.xml
│ │ ├── ic_menu_manage.xml
│ │ ├── ic_menu_send.xml
│ │ ├── ic_menu_share.xml
│ │ ├── ic_menu_slideshow.xml
│ │ ├── ic_person_24dp.xml
│ │ ├── ic_thumb_up_24dp.xml
│ │ └── ic_whatshot_24dp.xml
│ │ ├── layout
│ │ ├── activity_user_detail.xml
│ │ ├── activity_users.xml
│ │ └── item_user.xml
│ │ ├── menu
│ │ └── main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── universetelecom
│ └── mvvm_users
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | dataBinding.enabled = true
5 | compileSdkVersion 25
6 | buildToolsVersion "26.0.0"
7 | defaultConfig {
8 | applicationId "com.universetelecom.mvvm_users"
9 | minSdkVersion 15
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | dexOptions {
23 | javaMaxHeapSize "2g"
24 | }
25 | dataBinding {
26 | enabled = true
27 | }
28 | }
29 |
30 | dependencies {
31 | compile fileTree(dir: 'libs', include: ['*.jar'])
32 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
33 | exclude group: 'com.android.support', module: 'support-annotations'
34 | })
35 |
36 |
37 | compile 'com.android.support:appcompat-v7:25.3.1'
38 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
39 | compile 'com.android.support:cardview-v7:25.3.1'
40 | compile 'com.android.support:design:25.3.1'
41 | compile 'com.android.support:recyclerview-v7:25.3.1'
42 | compile 'com.google.code.gson:gson:2.7'
43 | compile 'com.squareup.retrofit2:retrofit:2.2.0'
44 | compile 'com.squareup.retrofit2:converter-gson:2.2.0'
45 | compile 'com.squareup.retrofit2:converter-scalars:2.2.0'
46 | compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
47 | compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
48 | compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
49 | compile 'io.reactivex.rxjava2:rxjava:2.0.5'
50 | compile 'de.hdodenhof:circleimageview:2.1.0'
51 | compile 'com.github.bumptech.glide:glide:3.7.0'
52 | compile 'com.android.support:support-v4:25.3.1'
53 | testCompile 'junit:junit:4.12'
54 | testCompile 'org.mockito:mockito-core:2.+'
55 | testCompile 'org.robolectric:robolectric:3.3.2'
56 | }
57 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/me/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 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/universetelecom/mvvm_users/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users;
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 Testing documentation
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("com.universetelecom.mvvm_users", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/app/AppController.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.app;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import com.universetelecom.mvvm_users.network.ApiFactory;
7 | import com.universetelecom.mvvm_users.network.UsersService;
8 |
9 | import io.reactivex.Scheduler;
10 | import io.reactivex.schedulers.Schedulers;
11 |
12 | /**
13 | * Created by Ahmad Shubita on 8/1/17.
14 | */
15 |
16 | public class AppController extends Application {
17 |
18 | private UsersService usersService;
19 | private Scheduler scheduler;
20 |
21 | private static AppController get(Context context) {
22 | return (AppController) context.getApplicationContext();
23 | }
24 |
25 | public static AppController create(Context context) {
26 | return AppController.get(context);
27 | }
28 |
29 | public UsersService getUserService() {
30 | if (usersService == null) {
31 | usersService = ApiFactory.create();
32 | }
33 |
34 | return usersService;
35 | }
36 |
37 | public Scheduler subscribeScheduler() {
38 | if (scheduler == null) {
39 | scheduler = Schedulers.io();
40 | }
41 |
42 | return scheduler;
43 | }
44 |
45 | public void setUserService(UsersService usersService) {
46 | this.usersService = usersService;
47 | }
48 |
49 | public void setScheduler(Scheduler scheduler) {
50 | this.scheduler = scheduler;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/model/Location.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Created by me on 7/25/17.
9 | */
10 |
11 | public class Location implements Serializable {
12 |
13 | @SerializedName("street") public String street;
14 |
15 | @SerializedName("city") public String city;
16 |
17 | @SerializedName("state") public String state;
18 |
19 | @SerializedName("postcode") public String postcode;
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/model/Login.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Created by me on 7/25/17.
9 | */
10 |
11 | public class Login implements Serializable {
12 |
13 | @SerializedName("username") public String username;
14 |
15 | @SerializedName("password") public String password;
16 |
17 | @SerializedName("salt") public String salt;
18 |
19 | @SerializedName("md5") public String md5;
20 |
21 | @SerializedName("sha1") public String sha1;
22 |
23 | @SerializedName("sha256") public String sha256;
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/model/Name.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Created by Ahmad Shubita on 7/25/17.
9 | */
10 |
11 | public class Name implements Serializable {
12 |
13 | @SerializedName("title") public String title;
14 |
15 | @SerializedName("first") public String first;
16 |
17 | @SerializedName("last") public String last;
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/model/Picture.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Created by Ahmad Shubita on 7/25/17.
9 | */
10 |
11 | public class Picture implements Serializable {
12 |
13 | @SerializedName("large") public String large;
14 |
15 | @SerializedName("medium") public String medium;
16 |
17 | @SerializedName("thumbnail") public String thumbnail;
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/model/User.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Created by Ahmad Shubita on 8/1/17.
9 | */
10 |
11 | public class User implements Serializable {
12 |
13 | @SerializedName("gender") public String gender;
14 |
15 | @SerializedName("name") public Name name;
16 |
17 | @SerializedName("location") public Location location;
18 |
19 | @SerializedName("email") public String email;
20 |
21 | @SerializedName("login") public Login login;
22 |
23 | @SerializedName("phone") public String phone;
24 |
25 | @SerializedName("cell") public String cell;
26 |
27 | @SerializedName("picture") public Picture picture;
28 |
29 | public String fullName;
30 |
31 | public boolean hasEmail() {return email != null && !email.isEmpty();}
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/model/UserResponse.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.model;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by me on 8/1/17.
9 | */
10 |
11 | public class UserResponse {
12 |
13 | @SerializedName("results") private List userList;
14 |
15 | public List getPeopleList () { return userList;}
16 |
17 | public void setPeopleList(List mUserList) { this.userList = mUserList ;}
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/network/ApiFactory.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.network;
2 |
3 | import retrofit2.Retrofit;
4 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
5 | import retrofit2.converter.gson.GsonConverterFactory;
6 |
7 | import static com.universetelecom.mvvm_users.utils.Constant.BASE_URL;
8 |
9 | /**
10 | * Created by Ahmad Shubita on 8/1/17.
11 | */
12 |
13 | public class ApiFactory {
14 |
15 | public static UsersService create() {
16 | Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL)
17 | .addConverterFactory(GsonConverterFactory.create())
18 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
19 | .build();
20 | return retrofit.create(UsersService.class);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/network/UsersService.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.network;
2 |
3 | import com.universetelecom.mvvm_users.model.UserResponse;
4 |
5 | import io.reactivex.Observable;
6 | import retrofit2.http.GET;
7 | import retrofit2.http.Url;
8 |
9 | /**
10 | * Created by Ahmad Shubita on 8/1/17.
11 | */
12 |
13 | public interface UsersService {
14 |
15 | @GET
16 | Observable fetchUsers(@Url String url);
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/utils/Constant.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.utils;
2 |
3 | /**
4 | * Created by Ahmad Shubita on 8/1/17.
5 | */
6 |
7 | public interface Constant {
8 |
9 | public final String BASE_URL = "http://api.randomuser.me/";
10 | public final String RANDOM_USER_URL = "http://api.randomuser.me/?results=10&nat=en";
11 | public final String PROJECT_URL = "https://github.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-";
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/view/activity/UserDetailActivity.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.view.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.databinding.DataBindingUtil;
6 | import android.os.Bundle;
7 | import android.support.v7.app.ActionBar;
8 | import android.support.v7.app.AppCompatActivity;
9 |
10 | import com.universetelecom.mvvm_users.R;
11 | import com.universetelecom.mvvm_users.databinding.ActivityUserDetailBinding;
12 | import com.universetelecom.mvvm_users.model.User;
13 | import com.universetelecom.mvvm_users.viewModel.UserDetailViewModel;
14 |
15 | public class UserDetailActivity extends AppCompatActivity {
16 |
17 |
18 | private static final String EXTRA_USER = "EXTRA_USER";
19 |
20 | private ActivityUserDetailBinding activityUserDetailBinding;
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | activityUserDetailBinding = DataBindingUtil.setContentView(this, R.layout.activity_user_detail);
26 | setSupportActionBar(activityUserDetailBinding.toolbar);
27 | displayHomeAsUpEnabled();
28 | getExtrasFromIntent();
29 | }
30 |
31 | private void displayHomeAsUpEnabled() {
32 |
33 | ActionBar actionBar = getSupportActionBar();
34 | if(actionBar != null) {
35 | actionBar.setDisplayHomeAsUpEnabled(true);
36 | }
37 | }
38 |
39 | public static Intent fillDetail(Context context, User user) {
40 | Intent intent = new Intent(context, UserDetailActivity.class);
41 | intent.putExtra(EXTRA_USER, user);
42 | return intent;
43 | }
44 |
45 | private void getExtrasFromIntent(){
46 | User user = (User) getIntent().getSerializableExtra(EXTRA_USER);
47 | UserDetailViewModel userDetailViewModel = new UserDetailViewModel(user);
48 | activityUserDetailBinding.setUserDetailViewModel(userDetailViewModel);
49 | setTitle(user.name.title + "." + user.name.first + " " + user.name.last);
50 | }
51 |
52 |
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/view/activity/UsersActivity.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.view.activity;
2 |
3 | import android.content.Intent;
4 | import android.databinding.DataBindingUtil;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 |
13 | import com.universetelecom.mvvm_users.R;
14 | import com.universetelecom.mvvm_users.databinding.ActivityUsersBinding;
15 | import com.universetelecom.mvvm_users.utils.Constant;
16 | import com.universetelecom.mvvm_users.view.adapter.UserAdapter;
17 | import com.universetelecom.mvvm_users.viewModel.UserViewModel;
18 |
19 | import java.util.Observable;
20 | import java.util.Observer;
21 |
22 | public class UsersActivity extends AppCompatActivity implements Observer {
23 |
24 | private ActivityUsersBinding userActivityBinding;
25 | private UserViewModel userViewModel;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | initDataBinding();
31 | setSupportActionBar(userActivityBinding.toolbar);
32 | setUpListOfUsersView(userActivityBinding.listUser);
33 | setUpObserver(userViewModel);
34 | }
35 |
36 | private void initDataBinding() {
37 | userActivityBinding = DataBindingUtil.setContentView(this, R.layout.activity_users);
38 | userViewModel = new UserViewModel(this);
39 | userActivityBinding.setUserViewModel(userViewModel);
40 | }
41 |
42 | // set up the list of user with recycler view
43 | private void setUpListOfUsersView(RecyclerView listUser) {
44 | UserAdapter userAdapter = new UserAdapter();
45 | listUser.setAdapter(userAdapter);
46 | listUser.setLayoutManager(new LinearLayoutManager(this));
47 | }
48 |
49 | public void setUpObserver(Observable observable) {
50 | observable.addObserver(this);
51 | }
52 |
53 |
54 | @Override
55 | public void update(Observable o, Object arg) {
56 | if(o instanceof UserViewModel) {
57 | UserAdapter userAdapter = (UserAdapter) userActivityBinding.listUser.getAdapter();
58 | UserViewModel userViewModel = (UserViewModel) o;
59 | userAdapter.setUserList(userViewModel.getUserList());
60 | }
61 | }
62 |
63 | private void startActivityActionView() {
64 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constant.PROJECT_URL)));
65 | }
66 |
67 | @Override public boolean onCreateOptionsMenu(Menu menu) {
68 | getMenuInflater().inflate(R.menu.main, menu);
69 | return true;
70 | }
71 |
72 | @Override public boolean onOptionsItemSelected(MenuItem item) {
73 | if (item.getItemId() == R.id.menu_github) {
74 | startActivityActionView();
75 | return true;
76 | }
77 | return super.onOptionsItemSelected(item);
78 | }
79 |
80 |
81 |
82 |
83 | @Override protected void onDestroy() {
84 | super.onDestroy();
85 | userViewModel.reset();
86 | }
87 |
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/view/adapter/UserAdapter.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.view.adapter;
2 |
3 | import android.databinding.DataBindingUtil;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.ViewGroup;
7 |
8 | import com.universetelecom.mvvm_users.R;
9 | import com.universetelecom.mvvm_users.databinding.ItemUserBinding;
10 | import com.universetelecom.mvvm_users.model.User;
11 | import com.universetelecom.mvvm_users.viewModel.ItemUserViewModel;
12 |
13 | import java.util.Collections;
14 | import java.util.List;
15 |
16 | /**
17 | * Created by Ahmad Shubita on 8/04/17.
18 | */
19 |
20 | public class UserAdapter extends RecyclerView.Adapter {
21 |
22 | private List userList;
23 |
24 | public UserAdapter() {this.userList = Collections.emptyList();}
25 |
26 | @Override
27 | public UserAdapterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
28 |
29 | ItemUserBinding itemUserBinding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_user ,parent, false);
30 | return new UserAdapterViewHolder(itemUserBinding);
31 | }
32 |
33 | @Override
34 | public void onBindViewHolder(UserAdapterViewHolder holder, int position) {
35 | holder.bindUser(userList.get(position));
36 |
37 | }
38 |
39 | @Override
40 | public int getItemCount() {
41 | return userList.size();
42 | }
43 |
44 | public void setUserList(List userList) {
45 | this.userList = userList;
46 | notifyDataSetChanged();
47 | }
48 |
49 | public static class UserAdapterViewHolder extends RecyclerView.ViewHolder {
50 |
51 | ItemUserBinding mItemUserBinding;
52 |
53 | public UserAdapterViewHolder(ItemUserBinding itemUserBinding) {
54 | super(itemUserBinding.itemPeople);
55 | this.mItemUserBinding = itemUserBinding;
56 | }
57 |
58 | void bindUser(User user){
59 | if(mItemUserBinding.getUserViewModel() == null){
60 | mItemUserBinding.setUserViewModel(new ItemUserViewModel(user, itemView.getContext()));
61 | }else {
62 | mItemUserBinding.getUserViewModel().setUser(user);
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/viewModel/ItemUserViewModel.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.viewModel;
2 |
3 | import android.content.Context;
4 | import android.databinding.BaseObservable;
5 | import android.databinding.BindingAdapter;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import com.bumptech.glide.Glide;
10 | import com.universetelecom.mvvm_users.model.User;
11 | import com.universetelecom.mvvm_users.view.activity.UserDetailActivity;
12 |
13 | /**
14 | * Created by Ahmad Shubita on 8/4/17.
15 | */
16 |
17 | public class ItemUserViewModel extends BaseObservable {
18 |
19 | private User user;
20 | private Context context;
21 |
22 | public ItemUserViewModel(User user, Context context){
23 | this.user = user;
24 | this.context = context;
25 | }
26 |
27 | public String getProfileThumb() {
28 | return user.picture.medium;
29 | }
30 |
31 | // Loading Image using Glide Library.
32 | @BindingAdapter("imageUrl") public static void setImageUrl(ImageView imageView, String url){
33 | Glide.with(imageView.getContext()).load(url).into(imageView);
34 | }
35 |
36 | public String getCell() { return user.cell; }
37 |
38 | public String getEmail() { return user.email; }
39 |
40 | public String getFullName() {
41 |
42 | user.fullName = user.name.title + "." + user.name.first + " " + user.name.last;
43 |
44 | return user.fullName;
45 |
46 | }
47 |
48 | public void onItemClick(View v){
49 | context.startActivity(UserDetailActivity.fillDetail(v.getContext(), user));
50 | }
51 |
52 | public void setUser(User user) {
53 | this.user = user;
54 | notifyChange();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/viewModel/UserDetailViewModel.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.viewModel;
2 |
3 |
4 | import android.databinding.BindingAdapter;
5 | import android.view.View;
6 | import android.widget.ImageView;
7 |
8 | import com.bumptech.glide.Glide;
9 | import com.universetelecom.mvvm_users.model.User;
10 |
11 | import java.util.Observable;
12 |
13 | /**
14 | * Created by Ahmad Shubita on 8/04/17.
15 | */
16 | /*
17 | ** This Class as ViewModel to exposes streams of data relevant to the View (UserDetailActivity).
18 | */
19 |
20 | public class UserDetailViewModel extends Observable {
21 |
22 | private User user;
23 |
24 | public UserDetailViewModel(User user) {this.user = user;}
25 |
26 | public String getFullUserName(){
27 | user.fullName = user.name.title + "." + user.name.first + " " + user.name.last ;
28 | return user.fullName;
29 | }
30 |
31 | public String getUserName(){return user.login.username;}
32 |
33 | public String getEmail() { return user.email; }
34 |
35 | public int getEmailVisibility() {return user.hasEmail() ? View.VISIBLE : View.GONE ;}
36 |
37 | public String getCell() { return user.cell; }
38 |
39 | public String getProfileThumb() { return user.picture.large ;}
40 |
41 | public String getAddress() {
42 | return user.location.street
43 | + " "
44 | + user.location.city
45 | + " "
46 | + user.location.state;
47 | }
48 |
49 | public String getGender() { return user.gender;}
50 |
51 | @BindingAdapter({"imageUrl"})
52 | public static void loadImage(ImageView view, String imageUrl){
53 | Glide.with(view.getContext()).load(imageUrl).into(view);
54 | }
55 |
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/universetelecom/mvvm_users/viewModel/UserViewModel.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users.viewModel;
2 |
3 | import android.content.Context;
4 | import android.databinding.ObservableField;
5 | import android.databinding.ObservableInt;
6 | import android.support.annotation.NonNull;
7 | import android.view.View;
8 |
9 | import com.universetelecom.mvvm_users.R;
10 | import com.universetelecom.mvvm_users.app.AppController;
11 | import com.universetelecom.mvvm_users.model.User;
12 | import com.universetelecom.mvvm_users.model.UserResponse;
13 | import com.universetelecom.mvvm_users.network.UsersService;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 | import java.util.Observable;
18 |
19 | import io.reactivex.android.schedulers.AndroidSchedulers;
20 | import io.reactivex.disposables.CompositeDisposable;
21 | import io.reactivex.disposables.Disposable;
22 | import io.reactivex.functions.Consumer;
23 |
24 | import static com.universetelecom.mvvm_users.utils.Constant.RANDOM_USER_URL;
25 |
26 | /**
27 | * Created by Ahmad Shubita on 8/1/17.
28 | */
29 |
30 | public class UserViewModel extends Observable {
31 |
32 | public ObservableInt progressBar;
33 | public ObservableInt userRecycler;
34 | public ObservableInt userLabel;
35 | public ObservableField messageLabel;
36 |
37 | private List userList;
38 | private Context context;
39 | private CompositeDisposable compositeDisposable = new CompositeDisposable();
40 |
41 | public UserViewModel(@NonNull Context context) {
42 | this.context = context;
43 | this.userList = new ArrayList<>();
44 | progressBar = new ObservableInt(View.GONE);
45 | userRecycler = new ObservableInt(View.GONE);
46 | userLabel = new ObservableInt(View.VISIBLE);
47 | messageLabel = new ObservableField<>(context.getString(R.string.default_message_loading_users));
48 | }
49 |
50 | public void onClickFabToLoad(View view) {
51 | initializeViews();
52 | fetchUsersList();
53 | }
54 |
55 | //It is "public" to show an example of test
56 | public void initializeViews() {
57 | userLabel.set(View.GONE);
58 | userRecycler.set(View.GONE);
59 | progressBar.set(View.VISIBLE);
60 | }
61 |
62 | private void fetchUsersList() {
63 |
64 | AppController appController = AppController.create(context);
65 | UsersService usersService = appController.getUserService();
66 |
67 | Disposable disposable = usersService.fetchUsers(RANDOM_USER_URL)
68 | .subscribeOn(appController.subscribeScheduler())
69 | .observeOn(AndroidSchedulers.mainThread())
70 | .subscribe(new Consumer() {
71 | @Override public void accept(UserResponse userResponse) throws Exception {
72 | updateUserDataList(userResponse.getPeopleList());
73 | progressBar.set(View.GONE);
74 | userLabel.set(View.GONE);
75 | userRecycler.set(View.VISIBLE);
76 | }
77 | }, new Consumer() {
78 | @Override public void accept(Throwable throwable) throws Exception {
79 | messageLabel.set(context.getString(R.string.error_message_loading_users));
80 | progressBar.set(View.GONE);
81 | userLabel.set(View.VISIBLE);
82 | userRecycler.set(View.GONE);
83 | }
84 | });
85 |
86 | compositeDisposable.add(disposable);
87 | }
88 |
89 | private void updateUserDataList(List peoples) {
90 | userList.addAll(peoples);
91 | setChanged();
92 | notifyObservers();
93 | }
94 |
95 | public List getUserList() {
96 | return userList;
97 | }
98 |
99 | private void unSubscribeFromObservable() {
100 | if (compositeDisposable != null && !compositeDisposable.isDisposed()) {
101 | compositeDisposable.dispose();
102 | }
103 | }
104 |
105 | public void reset() {
106 | unSubscribeFromObservable();
107 | compositeDisposable = null;
108 | context = null;
109 | }
110 | }
111 |
112 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-hdpi/ic_action.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-hdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-mdpi/ic_action.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-mdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-xhdpi/ic_action.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-xhdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-xxhdpi/ic_action.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/drawable-xxhdpi/ic_action_github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_account_circle_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_business_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_call_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_email_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_thumb_up_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_whatshot_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_user_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
18 |
19 |
25 |
26 |
37 |
38 |
39 |
50 |
51 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
70 |
71 |
76 |
77 |
90 |
91 |
96 |
97 |
98 |
101 |
102 |
107 |
108 |
116 |
117 |
118 |
119 |
120 |
124 |
125 |
130 |
131 |
139 |
140 |
141 |
142 |
143 |
147 |
148 |
153 |
154 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
185 |
186 |
190 |
191 |
194 |
195 |
200 |
201 |
209 |
210 |
211 |
212 |
213 |
216 |
217 |
223 |
224 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_users.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
24 |
29 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
46 |
47 |
54 |
55 |
66 |
67 |
68 |
69 |
70 |
79 |
80 |
85 |
86 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_user.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
26 |
27 |
28 |
34 |
40 |
41 |
42 |
55 |
56 |
69 |
70 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00BF9A
4 | #00AA8D
5 | #FF9800
6 | #ffffff
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 100dp
5 |
6 | 16dp
7 | 16dp
8 | 16dp
9 |
10 |
11 | 2dp
12 | 4dp
13 | 8dp
14 | 16dp
15 | 20dp
16 | 64dp
17 |
18 | 12sp
19 | 14sp
20 | 16sp
21 | 18sp
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Users
3 |
4 | There seems to have been some error.
5 | Press the button to load people!
6 | Github
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/test/java/com/universetelecom/mvvm_users/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.universetelecom.mvvm_users;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AhmadShubita/MVVM-with-RXJava-and-Retrofit-Users-Generated-Example-/11bb1434e4374bebba481c1f403ed013683a4e8c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 01 14:24:03 EEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------