├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values-w360dp │ │ │ │ └── dimens.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── list_item_main_list.xml │ │ │ │ ├── fragment_main_list.xml │ │ │ │ ├── activity_main_list.xml │ │ │ │ ├── fragment_login.xml │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── inthecheesefactory │ │ │ │ └── lab │ │ │ │ └── mvpstructure │ │ │ │ ├── activity │ │ │ │ ├── main │ │ │ │ │ ├── view │ │ │ │ │ │ ├── IMainView.java │ │ │ │ │ │ └── MainActivity.java │ │ │ │ │ ├── interactor │ │ │ │ │ │ ├── IMainInteractor.java │ │ │ │ │ │ ├── OnMainInteractorListener.java │ │ │ │ │ │ └── MainInteractorImpl.java │ │ │ │ │ └── presenter │ │ │ │ │ │ ├── IMainPresenter.java │ │ │ │ │ │ └── MainPresenterImpl.java │ │ │ │ └── mainlist │ │ │ │ │ ├── view │ │ │ │ │ ├── IMainListView.java │ │ │ │ │ └── MainListActivity.java │ │ │ │ │ └── presenter │ │ │ │ │ ├── IMainListPresenter.java │ │ │ │ │ └── MainListPresenterImpl.java │ │ │ │ ├── fragment │ │ │ │ ├── login │ │ │ │ │ ├── view │ │ │ │ │ │ ├── ILoginFragmentView.java │ │ │ │ │ │ └── LoginFragment.java │ │ │ │ │ ├── interactor │ │ │ │ │ │ ├── OnLoginFragmentInteractorListener.java │ │ │ │ │ │ ├── ILoginFragmentInteractor.java │ │ │ │ │ │ └── LoginFragmentInteractorImpl.java │ │ │ │ │ ├── presenter │ │ │ │ │ │ ├── ILoginFragmentPresenter.java │ │ │ │ │ │ └── LoginFragmentPresenterImpl.java │ │ │ │ │ └── model │ │ │ │ │ │ └── UserModel.java │ │ │ │ └── mainlist │ │ │ │ │ ├── presenter │ │ │ │ │ ├── IMainListFragmentPresenter.java │ │ │ │ │ └── MainListFragmentPresenterImpl.java │ │ │ │ │ ├── adapter │ │ │ │ │ ├── view │ │ │ │ │ │ ├── IMainListAdapterView.java │ │ │ │ │ │ └── MainListAdapter.java │ │ │ │ │ └── presenter │ │ │ │ │ │ ├── IMainListAdapterPresenter.java │ │ │ │ │ │ └── MainListAdapterPresenterImpl.java │ │ │ │ │ ├── view │ │ │ │ │ ├── IMainListFragmentView.java │ │ │ │ │ └── MainListFragment.java │ │ │ │ │ └── interactor │ │ │ │ │ ├── IMainListFragmentInteractor.java │ │ │ │ │ └── MainListFragmentInteractorImpl.java │ │ │ │ ├── base │ │ │ │ └── BasePresenter.java │ │ │ │ ├── MainApplication.java │ │ │ │ ├── manager │ │ │ │ ├── http │ │ │ │ │ ├── APIService.java │ │ │ │ │ └── HTTPManager.java │ │ │ │ └── Contextor.java │ │ │ │ ├── dao │ │ │ │ ├── DessertItemCollectionDao.java │ │ │ │ └── DessertItemDao.java │ │ │ │ └── view │ │ │ │ └── CustomViewTemplate.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── inthecheesefactory │ │ │ └── lab │ │ │ └── mvpstructure │ │ │ ├── ExampleUnitTest.java │ │ │ └── activity │ │ │ └── presenter │ │ │ └── MainPresenterImplTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── inthecheesefactory │ │ └── lab │ │ └── mvpstructure │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── demo.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | MVPStructure -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuuneoi/MVPStructure/HEAD/demo.gif -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuuneoi/MVPStructure/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/values-w360dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 320dp 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuuneoi/MVPStructure/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuuneoi/MVPStructure/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuuneoi/MVPStructure/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuuneoi/MVPStructure/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nuuneoi/MVPStructure/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/main/view/IMainView.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.main.view; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public interface IMainView { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/mainlist/view/IMainListView.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.mainlist.view; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public interface IMainListView { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/main/interactor/IMainInteractor.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.main.interactor; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public interface IMainInteractor { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 21 11:34:03 PDT 2015 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-2.8-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/main/interactor/OnMainInteractorListener.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.main.interactor; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public interface OnMainInteractorListener { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/main/interactor/MainInteractorImpl.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.main.interactor; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public class MainInteractorImpl implements IMainInteractor { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 240dp 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MVPStructure 2 | 3 | An Android sample code structure in MVP (Model-View-Presenter) with Instance State Saving/Restoring. 4 | 5 | RxAndroid, RxJava, RxBinding, Retrolambda, Butterknife, Parceler and Retrofit are used in this project. 6 | 7 | ![Demo](https://raw.githubusercontent.com/nuuneoi/MVPStructure/master/demo.gif) 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/login/view/ILoginFragmentView.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.login.view; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public interface ILoginFragmentView { 7 | 8 | void onClearText(); 9 | void onLoginResult(boolean success); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/login/interactor/OnLoginFragmentInteractorListener.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.login.interactor; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public interface OnLoginFragmentInteractorListener { 7 | 8 | void onLoginResult(boolean success); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/main/presenter/IMainPresenter.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.main.presenter; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.base.BasePresenter; 4 | 5 | /** 6 | * Created by nuuneoi on 12/15/2015. 7 | */ 8 | public interface IMainPresenter extends BasePresenter { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/login/interactor/ILoginFragmentInteractor.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.login.interactor; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public interface ILoginFragmentInteractor { 7 | 8 | void login(String username, String password, OnLoginFragmentInteractorListener listener); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MVPStructure 3 | Username 4 | Password 5 | Login 6 | Clear 7 | Open Menu 8 | Close Menu 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/mainlist/presenter/IMainListFragmentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.presenter; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.base.BasePresenter; 4 | 5 | /** 6 | * Created by nuuneoi on 12/15/2015. 7 | */ 8 | public interface IMainListFragmentPresenter extends BasePresenter { 9 | 10 | void loadDessertList(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/mainlist/adapter/view/IMainListAdapterView.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.adapter.view; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.dao.DessertItemCollectionDao; 4 | 5 | /** 6 | * Created by nuuneoi on 12/15/2015. 7 | */ 8 | public interface IMainListAdapterView { 9 | 10 | void showDessertList(DessertItemCollectionDao dao); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/mainlist/view/IMainListFragmentView.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.view; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.dao.DessertItemCollectionDao; 4 | 5 | /** 6 | * Created by nuuneoi on 12/15/2015. 7 | */ 8 | public interface IMainListFragmentView { 9 | 10 | void showDessertList(boolean success, DessertItemCollectionDao dao); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/test/java/com/inthecheesefactory/lab/mvpstructure/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | 6 | /** 7 | * Created by nuuneoi on 12/15/2015. 8 | */ 9 | public interface BasePresenter { 10 | 11 | void onSaveInstanceState(@NonNull Bundle outState); 12 | void onRestoreInstanceState(@NonNull Bundle savedInstanceState); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item_main_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/mainlist/presenter/IMainListPresenter.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.mainlist.presenter; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.activity.mainlist.view.IMainListView; 4 | import com.inthecheesefactory.lab.mvpstructure.base.BasePresenter; 5 | 6 | /** 7 | * Created by nuuneoi on 12/15/2015. 8 | */ 9 | public interface IMainListPresenter extends BasePresenter { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/inthecheesefactory/lab/mvpstructure/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/login/presenter/ILoginFragmentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.login.presenter; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.base.BasePresenter; 4 | 5 | /** 6 | * Created by nuuneoi on 12/15/2015. 7 | */ 8 | public interface ILoginFragmentPresenter extends BasePresenter { 9 | 10 | void clear(); 11 | void login(String username, String password); 12 | 13 | String getLastUsername(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/mainlist/interactor/IMainListFragmentInteractor.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.interactor; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.dao.DessertItemCollectionDao; 4 | 5 | import rx.Observable; 6 | 7 | 8 | /** 9 | * Created by nuuneoi on 12/15/2015. 10 | */ 11 | public interface IMainListFragmentInteractor { 12 | 13 | Observable getLoadDessertListStream(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure; 2 | 3 | import android.app.Application; 4 | 5 | import com.inthecheesefactory.lab.mvpstructure.manager.Contextor; 6 | 7 | /** 8 | * Created by nuuneoi on 12/15/2015. 9 | */ 10 | public class MainApplication extends Application { 11 | 12 | @Override 13 | public void onCreate() { 14 | super.onCreate(); 15 | 16 | Contextor.getInstance().init(getApplicationContext()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/login/model/UserModel.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.login.model; 2 | 3 | import org.parceler.Parcel; 4 | 5 | /** 6 | * Created by nuuneoi on 12/15/2015. 7 | */ 8 | @Parcel 9 | public class UserModel { 10 | 11 | String username = ""; 12 | 13 | public String getUsername() { 14 | return username; 15 | } 16 | 17 | public void setUsername(String username) { 18 | this.username = username; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/mainlist/adapter/presenter/IMainListAdapterPresenter.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.adapter.presenter; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.base.BasePresenter; 4 | import com.inthecheesefactory.lab.mvpstructure.dao.DessertItemCollectionDao; 5 | 6 | /** 7 | * Created by nuuneoi on 12/15/2015. 8 | */ 9 | public interface IMainListAdapterPresenter extends BasePresenter { 10 | 11 | void setData(DessertItemCollectionDao dao); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/manager/http/APIService.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.manager.http; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.dao.DessertItemCollectionDao; 4 | 5 | import retrofit.Call; 6 | import retrofit.http.POST; 7 | import rx.Observable; 8 | 9 | /** 10 | * Created by nuuneoi on 10/8/2015 AD. 11 | */ 12 | public interface APIService { 13 | 14 | @POST("list") 15 | Call loadDesserts(); 16 | 17 | @POST("list") 18 | Observable loadDessertsRx(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/login/interactor/LoginFragmentInteractorImpl.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.login.interactor; 2 | 3 | /** 4 | * Created by nuuneoi on 12/15/2015. 5 | */ 6 | public class LoginFragmentInteractorImpl implements ILoginFragmentInteractor { 7 | 8 | @Override 9 | public void login(String username, String password, OnLoginFragmentInteractorListener listener) { 10 | if (username.equals("test") && password.equals("12345")) 11 | listener.onLoginResult(true); 12 | else 13 | listener.onLoginResult(false); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/manager/Contextor.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.manager; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by nuuneoi on 12/15/2015. 7 | */ 8 | public class Contextor { 9 | 10 | private static Contextor instance; 11 | 12 | public static Contextor getInstance() { 13 | if (instance == null) 14 | instance = new Contextor(); 15 | return instance; 16 | } 17 | 18 | private Context mContext; 19 | 20 | public void init(Context context) { 21 | this.mContext = context; 22 | } 23 | 24 | public Context getContext() { 25 | return mContext; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/mainlist/interactor/MainListFragmentInteractorImpl.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.interactor; 2 | 3 | import com.inthecheesefactory.lab.mvpstructure.dao.DessertItemCollectionDao; 4 | import com.inthecheesefactory.lab.mvpstructure.manager.http.HTTPManager; 5 | 6 | import rx.Observable; 7 | 8 | /** 9 | * Created by nuuneoi on 12/15/2015. 10 | */ 11 | public class MainListFragmentInteractorImpl implements IMainListFragmentInteractor { 12 | 13 | @Override 14 | public Observable getLoadDessertListStream() { 15 | return HTTPManager.getInstance().getService().loadDessertsRx(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /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 D:\Neois\Installer\AndroidSDK\android-sdk-windows/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 | -------------------------------------------------------------------------------- /.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/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/dao/DessertItemCollectionDao.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.dao; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import org.parceler.Parcel; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by nuuneoi on 10/8/2015 AD. 11 | */ 12 | @Parcel 13 | public class DessertItemCollectionDao { 14 | 15 | @SerializedName("success") boolean success; 16 | @SerializedName("data") List data; 17 | 18 | public boolean isSuccess() { 19 | return success; 20 | } 21 | 22 | public void setSuccess(boolean success) { 23 | this.success = success; 24 | } 25 | 26 | public List getData() { 27 | return data; 28 | } 29 | 30 | public void setData(List data) { 31 | this.data = data; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/mainlist/presenter/MainListPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.mainlist.presenter; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.inthecheesefactory.lab.mvpstructure.activity.mainlist.view.IMainListView; 7 | 8 | /** 9 | * Created by nuuneoi on 12/15/2015. 10 | */ 11 | public class MainListPresenterImpl implements IMainListPresenter { 12 | 13 | IMainListView mainListView; 14 | 15 | public MainListPresenterImpl(IMainListView mainListView) { 16 | this.mainListView = mainListView; 17 | } 18 | 19 | @Override 20 | public void onSaveInstanceState(@NonNull Bundle outState) { 21 | 22 | } 23 | 24 | @Override 25 | public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/activity/main/presenter/MainPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.activity.main.presenter; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.inthecheesefactory.lab.mvpstructure.activity.main.interactor.IMainInteractor; 7 | import com.inthecheesefactory.lab.mvpstructure.activity.main.interactor.OnMainInteractorListener; 8 | import com.inthecheesefactory.lab.mvpstructure.activity.main.view.IMainView; 9 | 10 | import org.parceler.Parcels; 11 | 12 | /** 13 | * Created by nuuneoi on 12/15/2015. 14 | */ 15 | public class MainPresenterImpl implements IMainPresenter, OnMainInteractorListener { 16 | 17 | private IMainView mainView; 18 | private IMainInteractor mainInteractor; 19 | 20 | public MainPresenterImpl(IMainView mainView, IMainInteractor mainInteractor) { 21 | this.mainView = mainView; 22 | this.mainInteractor = mainInteractor; 23 | } 24 | 25 | @Override 26 | public void onSaveInstanceState(@NonNull Bundle outState) { 27 | 28 | } 29 | 30 | @Override 31 | public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/manager/http/HTTPManager.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.manager.http; 2 | 3 | import android.content.Context; 4 | 5 | import com.google.gson.Gson; 6 | import com.google.gson.GsonBuilder; 7 | 8 | import retrofit.GsonConverterFactory; 9 | import retrofit.Retrofit; 10 | import retrofit.RxJavaCallAdapterFactory; 11 | 12 | /** 13 | * Created by nuuneoi on 11/16/2014. 14 | */ 15 | public class HTTPManager { 16 | 17 | private static HTTPManager instance; 18 | 19 | public static HTTPManager getInstance() { 20 | if (instance == null) 21 | instance = new HTTPManager(); 22 | return instance; 23 | } 24 | 25 | private APIService mService; 26 | 27 | private HTTPManager() { 28 | Gson gson = new GsonBuilder() 29 | .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") 30 | .create(); 31 | 32 | Retrofit retrofit = new Retrofit.Builder() 33 | .baseUrl("http://nuuneoi.com/courses/dessert_maker/") 34 | .addConverterFactory(GsonConverterFactory.create(gson)) 35 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 36 | .build(); 37 | 38 | mService = retrofit.create(APIService.class); 39 | } 40 | 41 | public APIService getService() { 42 | return mService; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/inthecheesefactory/lab/mvpstructure/fragment/mainlist/adapter/presenter/MainListAdapterPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.adapter.presenter; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.inthecheesefactory.lab.mvpstructure.dao.DessertItemCollectionDao; 7 | import com.inthecheesefactory.lab.mvpstructure.fragment.mainlist.adapter.view.IMainListAdapterView; 8 | 9 | import org.parceler.Parcels; 10 | 11 | /** 12 | * Created by nuuneoi on 12/15/2015. 13 | */ 14 | public class MainListAdapterPresenterImpl implements IMainListAdapterPresenter { 15 | 16 | IMainListAdapterView mainListAdapterView; 17 | DessertItemCollectionDao dao; 18 | 19 | public MainListAdapterPresenterImpl(IMainListAdapterView mainListAdapterView) { 20 | this.mainListAdapterView = mainListAdapterView; 21 | } 22 | 23 | @Override 24 | public void onSaveInstanceState(@NonNull Bundle outState) { 25 | outState.putParcelable("mainListAdapterPresenterDao", Parcels.wrap(dao)); 26 | } 27 | 28 | @Override 29 | public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { 30 | dao = Parcels.unwrap(savedInstanceState.getParcelable("mainListAdapterPresenterDao")); 31 | setData(dao); 32 | } 33 | 34 | @Override 35 | public void setData(DessertItemCollectionDao dao) { 36 | this.dao = dao; 37 | mainListAdapterView.showDessertList(dao); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 25 | 26 |