Giter VIP home page Giter VIP logo

material-movies's Introduction

This projects support a series of articles about how to setup an android environment to develop an scalable, maintainable and testable projects.

A useful stack on android

Screenshots

License

Copyright 2015 Saúl Molinero

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.

material-movies's People

Contributors

kix2902 avatar rashiq avatar saulmm avatar tonilopezmr 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  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

material-movies's Issues

MoviesPresenter class missing?

Hi, I don't see MoviesPresenter class, and unfortunately project won't compile

I've managed to recreate it using commits history - there was a change where you moved multiple interfaces + impl to single abstract Presenter base class, but unfortunately movies won't load at all.

Please check this -> maybe fresh clone and check what's what :)

Failed to resolve: com.jakewharton:butterknife:6.0.0

I can't compile the project and I am completely lost. Is this a bug?

After replacing classpath 'com.android.tools.build:gradle:1.1.0-rc1' by classpath 'com.android.tools.build:gradle:1.1.0 I try to sync gradle and I get the following error:

`Error:(53, 13) Failed to resolve: com.jakewharton:butterknife:6.0.0``

If I run ./gradlew clean I get this:

Download https://jcenter.bintray.com/com/jakewharton/butterknife/6.0.0/butterknife-6.0.0.pom
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.3.1/gson-2.3.1.pom

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve com.jakewharton:butterknife:6.0.0.
     Required by:
         HackVG:app:unspecified
      > Failed to move file '/private/var/folders/6y/pcdw03x506n5tl26mxhq7rb80000gn/T/gradle_download3409899847438911358bin' into filestore at '/Users/xavi/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife/6.0.0/de7746bd24355fadf8013d7095c083f7810f8e54/butterknife-6.0.0.pom'
   > Could not resolve com.google.code.gson:gson:2.3.1.
     Required by:
         HackVG:app:unspecified > HackVG:domain:unspecified > HackVG:model:unspecified > com.squareup.retrofit:retrofit:1.9.0
      > Failed to move file '/private/var/folders/6y/pcdw03x506n5tl26mxhq7rb80000gn/T/gradle_download7225264487116654668bin' into filestore at '/Users/xavi/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.3.1/284ce3bf374b92f3bfd554b559e6e7865c27009/gson-2.3.1.pom'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 23.723 secs

Can anybody point me in the right direction? Thanks!

Adding a DB to cache movies

It'd be really nice if the project used a database in the model layer, to store data on previously requested movies. What would be the best approach to get something like this working in a pure Java module?

Bus usage

Reading your code and the part of the article where you talk about the Otto usage to communicate your different modules I see two points I'd like to discuss with you:

The first one is related to BusProvider. This class is a really cool idea to hide the buses when you are going to choose to post a message or register to listen messages and to keep the buses inside a static attribute. This class is something like a "Factory" but I see something weird. You have been working really hard to decouple your implementations details but you are returning com.squareup.otto.Bus instances in this class. Don't you thing you are coupling all your layers to the same Bus implementation when the objective of all your code is just the opposite one?

The second question is related with the Bus philosophy. With the current implementation based on different layers and the usage of a bus I can post an event directly to any other module just doing something like:

Bus modelBus = BusProvider.getRestBusInstance();
modelBus.post(new AnyEvent());

Don't you think this is a little bit dangerous backdoor in your code? If someone is listening I can jump from one place of my code to other and create a collateral effect without any restrictions. Don't you prefer to do your dependencies explicit and invoke methods instead of post an event into the bus? I also use this library for some of my projects and I think Otto is a really powerful tool to notify global events and create plugins around this concept, for example to notify when your have received a new push notification.

Thanks again for your time and publish this code!!!

Presenter interfaces

Hi!!!

I see you have some presenters declared as a class and as an interface when you only have one implementation. I don't see any factory or other creational pattern to decouple the interface and the implementation, just a new XPrensenterImpl inside your activity. Don't you think you don't need the interfaces for MovieDetailPresenterImpl and PopularShowsPresenterImpl?

Callback replacement Rxjava

Hey saulmm,

I was wondering if you have given any thought to replacing the Callbacks with Rxjava observables.

Observables could further simplify and future proof the project.

having trouble with android fragments

@saulmm Hello I am following your article to building my app , whenever I create a new presenter in my fragment , the Activity with ViewPager + fragment , its come up with this log : I/Choreographer(2955): Skipped xx frames! The application may be doing too much work on its main thread. and got a little bit laggy , do you have any idea ? should I use dagger for presenter injection?

No nav drawer

Hello,
your screenshot on the repo shows that there should be a nav drawer on the top-left. However, when I run the sample app, no nav drawer is present.

What happened?
Igor

Domain and Model modules vs business logic module

Hi Saul! Thanks for your time to prepare this article and this repository!!

I'd like to comment some things to know your opinion:

In this article you use "domain" and "model" as a separated concept when most of the authors use "domain model" to talk about all the classes related to your business logic and abstractions needed to model the problem. Your "model" module is used to retrieve data from an external API and you comment that in the future will be used to persist data. The responsibility of this "model" module is more related to a repository or two different modules like one api client and one storage. In addition, I see your class TvMovie created in your "model" module is used from your "app" module, doing this you are coupling your "app" and "domain" module to the code related to the API Client and the persistence. Don't you prefer to move that entities to your business logic layer. What do you think?

Crashes when clicking one movie

04-23 18:00:29.350 22937-22937/com.hackvg.android E/RecyclerView﹕ No adapter attached; skipping layout
04-23 18:00:29.360 22937-22937/com.hackvg.android E/RecyclerView﹕ No adapter attached; skipping layout
04-23 18:00:47.190 22937-22937/com.hackvg.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.hackvg.android, PID: 22937
java.lang.NullPointerException
at com.hackvg.android.views.activities.MovieDetailActivity.setVibrantElements(MovieDetailActivity.java:505)
at com.hackvg.android.views.activities.MovieDetailActivity.onGenerated(MovieDetailActivity.java:499)
at android.support.v7.graphics.Palette$1.onPostExecute(Palette.java:184)
at android.support.v7.graphics.Palette$1.onPostExecute(Palette.java:176)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5290)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:859)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:675)
at dalvik.system.NativeStart.main(Native Method)

Test Issue

In GetMovieDetailsUsecaseTest.java use the never() function to replace the timer(1) at:

    verify(mockUiBus, never()).post(
            any(MovieDetail.class));

In GetMoviesUsecaseTest.java, use the never() function to replace the timer(1) all, change the object like below:

      @Mock
      private RestDataSource mockDataSource;

and add the config

lintOptions {
    abortOnError false
}

in build.gradle under app module

Toolbar

Can you please demo in your sample how to add the Material Toolbar with sliding tabs? This would be super-helpful in understanding MVP.

Thank you,
Igor

How will we handle retrofit errors.

I am posting the retrofit error on the Bus

public Callback retrofitCallback = new Callback() {
    @Override
    public void success(Object o, Response response) {
        if (o instanceof PlacesWrapper) {

            PlacesWrapper placesApiResponse = (PlacesWrapper) o;
            BusProvider.getRestBusInstance().post(
                    placesApiResponse);
        } else if (o instanceof LocationSearchWrapper) {

            LocationSearchWrapper locationSearchApiResponse = (LocationSearchWrapper) o;
            BusProvider.getRestBusInstance().post(
                    locationSearchApiResponse);
        }
    }

    @Override
    public void failure(RetrofitError error) {

        BusProvider.getRestBusInstance().post(error);
    }
};

and subscribing to it in my presenter which has another method subscribed to the success response:

@Subscribe
public void onPlacesReceived(PlacesWrapper placesWrapper) {

    mPlacesView.hideLoading();
    mPlacesView.showPlaces(placesWrapper.getResponse());

    isLoading = false;
}

@Subscribe
public void onErrorReceived(RetrofitError error) {

    Log.e("DEBUG", error.toString());
    mPlacesView.hideLoading();
    mPlacesView.showError(error.getMessage());
    isLoading = false;
}

Crashes when clicking Furious 7

Process: com.hackvg.android, PID: 31109
    java.lang.NullPointerException: Attempt to invoke virtual method 'int android.support.v7.graphics.Palette$Swatch.getRgb()' on a null object reference
            at com.hackvg.android.views.activities.MovieDetailActivity.setVibrantElements(MovieDetailActivity.java:505)
            at com.hackvg.android.views.activities.MovieDetailActivity.onGenerated(MovieDetailActivity.java:499)
            at android.support.v7.graphics.Palette$1.onPostExecute(Palette.java:184)
            at android.support.v7.graphics.Palette$1.onPostExecute(Palette.java:176)
            at android.os.AsyncTask.finish(AsyncTask.java:632)
            at android.os.AsyncTask.access$600(AsyncTask.java:177)
            at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

Unable to stop activity MoviesActivity. Missing event handler for an annotated method.

02-05 13:54:35.372      890-890/com.hackvg.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.hackvg.android, PID: 890
    java.lang.RuntimeException: Unable to stop activity {com.hackvg.android/com.hackvg.android.views.activities.MoviesActivity}: java.lang.IllegalArgumentException: Missing event handler for an annotated method. Is class com.hackvg.android.mvp.presenters.PopularShowsPresenterImpl registered?
            at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3344)
            at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3390)
            at android.app.ActivityThread.access$1100(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.IllegalArgumentException: Missing event handler for an annotated method. Is class com.hackvg.android.mvp.presenters.PopularShowsPresenterImpl registered?
            at com.squareup.otto.Bus.unregister(Bus.java:289)
            at com.hackvg.android.mvp.presenters.PopularShowsPresenterImpl.onStop(PopularShowsPresenterImpl.java:35)
            at com.hackvg.android.views.activities.MoviesActivity.onStop(MoviesActivity.java:84)
            at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1261)
            at android.app.Activity.performStop(Activity.java:6085)
            at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3341)
            at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3390)
            at android.app.ActivityThread.access$1100(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

about images

could you give us the template you used to create these pictures ??

and if you don't mind ,,, could you upload the psd for them?!!

License

Can you please add a license to this project?

Crashes when rotating

07-23 15:45:18.031 11884-11884/com.hackvg.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.hackvg.android, PID: 11884
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hackvg.android/com.hackvg.android.views.activities.MoviesActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.hackvg.android.mvp.views.MoviesView.isTheListEmpty()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2329)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3941)
at android.app.ActivityThread.access$1000(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)

Issue with build tools 21.1.2 and Gradle plugin version 1.1.0-rc1

Cloning this repo and trying to build it with the most recent version of Android build tools leads to the following issue:

A problem was found with the configuration of task ':app:installDebug'.
> File '/.../android-sdk/build-tools/21.1.2/split-select' specified for property 'splitSelectExe' does not exist.

This is a known issue:
https://code.google.com/p/android/issues/detail?id=135513

Updating the Gradle version used for this project from 1.1.0-rc1 to 1.1.0 solved the issue for me.

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.