Giter Site home page Giter Site logo

janishar / android-mvp-interactor-architecture Goto Github PK

View Code? Open in Web Editor NEW
405.0 31.0 97.0 1.16 MB

Extension of the android-mvp-architecture for very large projects.

License: Apache License 2.0

Java 100.00%
mvp android-mvp-architecture rxjava interactor dagger greendao mindorks blueprint placeholderview fast-android-networking

android-mvp-interactor-architecture's Introduction

Deprecated


This Project is [Deprecated] goto latest project: Modern Android Development - WhereIsMyMotivation


Deprecated

Android MVP Architecture: Enhanced with Interactors and Repositories: Sample App

This repository is an extension of the android-mvp-architecture. It breaks the DataManager into Interactors and DbHelper into Repositories. These changes makes it fit for very large projects, for smaller projects the above mentioned repository is better.

This repository contains a detailed sample app that implements MVP architecture enhanced with Interactors and DbRepositories for complete decoupling, using Dagger2, GreenDao, RxJava, FastAndroidNetworking, PlaceHolderView and AndroidDebugDatabase

Architecture Blueprint

Blueprint

Project Structure

Structure




About The Author

You can connect with me here:

Read the below listed articles. They describe the MVP concepts and the Project structure.

  1. Android MVP Architecture Extension with Interactors and Repositories
  2. MVP: Part 1
  3. MVP: Part 2
  4. MVP: Part 3

The app has following packages:

  1. data: It contains all the data accessing and manipulating components.
  2. di: Dependency providing classes using Dagger2.
  3. ui: View classes along with their corresponding Presenters and Interactors.
  4. service: Services for the application.
  5. utils: Utility classes.

Classes have been designed in such a way that it could be inherited and maximize the code reuse.

Read the below listed articles. They describe the MVP concepts and the Project structure.

  1. MVP: Part 1
  2. MVP: Part 2
  3. MVP: Part 3
  4. Extension with Interactors and Repositories

The app has following packages:

  1. data: It contains all the data accessing and manipulating components.
  2. di: Dependency providing classes using Dagger2.
  3. ui: View classes along with their corresponding Presenters.
  4. service: Services for the application.
  5. utils: Utility classes.

Classes have been designed in such a way that it could be inherited and maximize the code reuse.

Library reference resources:

  1. Dagger2: https://github.com/janishar/android-dagger2-example
  2. PlaceHolderView: https://github.com/janishar/PlaceHolderView
  3. Calligraphy: https://github.com/chrisjenx/Calligraphy
  4. GreenDao: http://greenrobot.org/greendao/
  5. ButterKnife: http://jakewharton.github.io/butterknife/

Concept reference resources:

  1. Introduction to Dagger 2: Part 1
  2. Introduction to Dagger 2: Part 2
  3. Android Dagger2: Critical things to know before you implement
  4. Android Tinder Swipe View Example
  5. RxJava Anatomy: What is RxJava, how RxJava is designed, and how RxJava works.
  6. Powerful Android ORM: greenDAO 3 Tutorial

How do I use this project?

This is a boilerplate project aimed to help bootstrap new Android MVP Applications. Feel free to fork this application or use AndroidStarters to create new app using this boilerplate.

License

   Copyright (C) 2023 JANISHAR ALI ANWAR

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Contributing to Android MVP Architecture

Just make pull request. You are in!

android-mvp-interactor-architecture's People

Contributors

amitshekhariitbhu avatar anandwana001 avatar isatya avatar janishar avatar jkozh avatar jonathan-caryl avatar ravidsrk avatar ravikumar-n avatar thanhsontube avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-mvp-interactor-architecture's Issues

ERROR: Could not find method debugImplementation() for arguments [com.amitshekhar.android:debug-db:1.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Gradle project sync failed with the error :
ERROR: Could not find method debugImplementation() for arguments [com.amitshekhar.android:debug-db:1.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Also these lines causes error too:
destination "something something"
should be
destination file("something something")
Unfortunately, i cannot run the project it gives many gradle related error. Please update the fix.

What is the role of com.mindorks.framework.mvp.ui.main.QuestionCard class

First of all I would like to say thank to you for the awesome post. I have been playing around with the project for couple weeks. Have some questions as below:
1)What role of the QuestionCard class in this pattern because it contains some Views (TextView, ImageView and Buttons) and a model (Question)?
2)This application does not store use local variable to store states of Screens/App. Instead of that, it reads data from assets, stores it into database (GreenDao). Whenever the app needs data, it retrieves from database and load displays to Views. Would you please add a screen that contains some local variables (user defined classes) to store state data?
3)This application does not show how to transfer data between an MVP to another MVP. When a new screen started, it needs to call Presenter-Interactor to retrieve data. Would you please create a demo for this purpose?

How to add custom view to this structure?

It was a great structure, and I have start using it in my projects, so first I want to say Thanks.
but I have a problem of how can I add my custom view (e.g. customTextView) to this structure that can access other app components like sharedPreferences and other components?

so please, could you help us to support it in this structure?

JobService using getApplication() for daggerServiceComponent causing a Class cast exception.

I have an exception "Class Cast Exception" that is happening on Android 7.0 when try to use the getApplication() inside the service

ServiceComponent component = DaggerServiceComponent.builder() .applicationComponent(((MediCountApplication) getApplication()).getComponent()) .build(); component.inject(this);

Exception is:
java.lang.RuntimeException: at android.app.ActivityThread.handleCreateService (ActivityThread.java:3544) at android.app.ActivityThread.-wrap6 (ActivityThread.java) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1732) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:154) at android.app.ActivityThread.main (ActivityThread.java:6776) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1496) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1386) Caused by: java.lang.ClassCastException: at global.medicount.healthpass.services.NetworkSchedulerService.onCreate (Unknown Source) at android.app.ActivityThread.handleCreateService (ActivityThread.java:3534)

Service Java Class

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class NetworkSchedulerService extends JobService {
   @Inject
   NetworkStateChangeReceiver mConnectivityReceiver;

   @Override
   public void onCreate() {
       super.onCreate();
       ServiceComponent component = DaggerServiceComponent.builder()
               .applicationComponent(((MediCountApplication) getApplication()).getComponent())
               .build();
       component.inject(this);
   }

   @Override
   public int onStartCommand(Intent intent, int flags, int startId) {
       return START_NOT_STICKY;
   }

   @Override
   public boolean onStartJob(JobParameters params) {
       registerReceiver(mConnectivityReceiver, new IntentFilter(AppConstants.CONNECTIVITY_ACTION));
       return true;
   }

   @Override
   public boolean onStopJob(JobParameters params) {
       try {
           unregisterReceiver(mConnectivityReceiver);
       } catch (IllegalArgumentException e) { }
       return true;
   }
}

After google it I have found the following reference here.
And unfortunately, there's no real fix to this rare crash. Google won't fix the lifecycle-related issue, but said it reduced in Android 7.1+.

Is there any way to fix this issue when we use this MVP structure ?

Is an Interactor allowed to depend on more than one repositories?

Hi, just stumbled with your articles on medium and had this quick question regarding the interactor pattern: is an Interactor supposed to have one and only one dependency on a repository or can actually depend on more than one?

For example: Lets suppose that we have a UserProfileInteractor wich has only one method called GetUser and a UserRepository which has N methods (doesn't matter which ones for the sake of the example). Now, that user needs to belong to a Company and that model "belongs" to its own repository called CompanyRepository which has other methods, but specifically one called getCompany that we'll need to invoke to assemble our user on the UserProfileInteractor. For completeness we also have a presenter called UserProfilePresenter which will have an instance of UserProfileInteractor and is in charge of "presenting" the user profile displaying the user information + that user's company data.

How would you handle such a thing? Would you make UserProfileInteractor have dependencies on both UserRepository and CompanyRepository? Would an interactor depending on two repositories violate the separation of concerns in any way?

Cheers and thanks for the articles, really enjoying them.

Why not using separate datasource(Local-DB, Cloud-API) in the reposiotry?

Here repository is the bridge to get data from Database. It has no other data source. So if you want to use data cache what will you do? In that case, it will be better if repository may have two data sources. One is local data store and another is cloud data store or you can use a data store factory to create a data source for the repository. I am telling that because it is a standard boilerplate. If you add that then it will help others in that scenario.

I want to know your opinion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.