Coder Social home page Coder Social logo

avengers's People

Contributors

saulmm 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

avengers's Issues

i copy some code of 有 contains a dependency cycle

Error:(23, 20) 错误: org.sunger.net.injector.components.AppComponent.getRestDataSource() contains a dependency cycle:
org.sunger.net.injector.modules.AppModule.provideDataRepository(org.net.sunger.mode.model.RestDataSource restDataSource)
[parameter: org.net.sunger.mode.model.RestDataSource `restDataSource]
@Module                                                                                         
public final class AppModule {                                                                  

    private final MsApplication mAvengersApplication;                                           

    public AppModule(MsApplication avengersApplication) {                                       
        this.mAvengersApplication = avengersApplication;                                        
    }                                                                                           

    @Provides                                                                                   
    @Singleton                                                                                  
    MsApplication provideAvengersAppContext() {                                                 
        return mAvengersApplication;                                                            
    }                                                                                           

    @Provides                                                                                   
    @Named("executor_thread")                                                                   
    Scheduler provideExecutorThread() {                                                         
        return Schedulers.newThread();                                                          
    }                                                                                           

    @Provides                                                                                   
    @Named("ui_thread")                                                                         
    Scheduler provideUiThread() {                                                               
        return AndroidSchedulers.mainThread();                                                  
    }                                                                                           

    @Provides                                                                                   
    File provideCacheFile(){                                                                    
        return FileUtils.createDirs(ConfigConstants.RX_CACHE_DIR);                              
    }                                                                                           

    @Provides                                                                                   
    MsAuthorizer provideMsAuthorizer() {                                                        
        MsAuthorizer msAuthorizer = new MsAuthorizer();                                         
        OauthUserEntity userEntity = mAvengersApplication.getOauthUserEntity();                 
        if (userEntity != null) {                                                               
            msAuthorizer.setAccessToken(userEntity.getAccess_token());                          
        }                                                                                       
        return msAuthorizer;                                                                    
    }                                                                                           

    @Provides @Singleton                                                                        
    RestDataSource provideDataRepository(RestDataSource restDataSource) {                       
        return restDataSource;                                                                  
    }                                                                                           
}                                                                                               
                                                                                                `
@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
    MsApplication application();
    RestDataSource getRestDataSource();

    MsAuthorizer msAuthorizer();

    File getCacheDir();

    @Named("ui_thread")
    Scheduler uiThread();
    @Named("executor_thread") Scheduler executorThread();

}
public class RestDataSource {
    private static final int CONNECT_TIMEOUT_MILLIS = 30;
    private static final int READ_TIMEOUT_MILLIS = 30;
    private final CacheProviders cacheProviders;
    private RestApiService restApi;


    @Inject
    public RestDataSource(File cacheDir, MsAuthorizer msAuthorizer) {
        cacheProviders = new RxCache.Builder()
                .persistence(cacheDir)
                .using(CacheProviders.class);
        HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient okHttpClient = new OkHttpClient().newBuilder().
                connectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.SECONDS).
                readTimeout(READ_TIMEOUT_MILLIS, TimeUnit.SECONDS).addInterceptor(new MsInterceptor(msAuthorizer.getAccessToken())).
                addInterceptor(httpLoggingInterceptor).build();
        Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL).
                client(okHttpClient).
                addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
                addConverterFactory(GsonConverterFactory.create()).build();
        restApi =retrofit.create(RestApiService.class);
    }

    public Observable<Reply<List<CategoryEntity>>> getCategory(final boolean update) {
        return cacheProviders.getCategory(restApi.getCategory(), new EvictProvider(update));
    }

}

onStart collision between Presenter and Subscriber

AvengerDetailPresenter extends Subscriber and implements Presenter but both of them have an onStart() method.

In your implementation the method is empty but if you put some code in it could have some unexpected behaviours.

Multiple Subscriber/UseCases on one Presenter

Hi!

First of all, I want to thank you for sharing this project and the blog post about it. It's great to see working examples, detailed and explained thoroughly.

I've been also reading a lot on Clean Architecture and I'm interested on implement my projects with that architecture in mind. Also the Reactive approach could save us from a lot of callback hell and it has much more sense on some parts of an application.

I think I stumbled with the same thing as you, regarding the issue of having two UseCase (reactive) on the same presenter. On the AvengerDetailPresenter (https://github.com/saulmm/Avengers/blob/master/app/src/main/java/saulmm/avengers/mvp/presenters/AvengerDetailPresenter.java#L67) you are about to call two methods that will return an observable each.

What are you planning to do? I've been thinking about it and having two inner method subscribers doesn't seem right, but I'm stuck on that.

Thanks!!

Crash on rotation

I was trying to see how you solved RxAndroid + Configuration changes but the app crashed when I tilted my phone. (in both branches, master and fix_load_more_characters_issue)
Here's the stacktrace

10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{saulmm.avengers/saulmm.avengers.views.activities.AvengersListActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ProgressBar$SavedState
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4077)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.app.ActivityThread.-wrap15(ActivityThread.java)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ProgressBar$SavedState
10-14 11:41:16.785 15543-15543/saulmm.avengers E/AndroidRuntime: at android.widget.ProgressBar.onRestoreInstanceState(ProgressBar.java:1824)

Gradle build failed : bad class file magic (cafebabe) or version (0034.0000)

Hi,

I have some issued when checking out the projet and opening with Android Studio 1.5.1 or Android Studio 2.1 preview 5.
With Android Studio 1.5.1 i tried to run the project with JDK 1.8.0_05 and i got the following error "Error:com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)".
With Android Studio 2.1 preview 5 same error.
If i try to change compileOptions i have other errors.

Do you have any ideas why this is happening ?
Thanks.

Regards

where can i find class DaggerAppComponent

AvengersApplication.java import saulmm.avengers.injector.components.DaggerAppComponent;

but no class file in saulmm.avengers.injector.components

EDIT: It will auto generated when build, sorry for create issue

Modules pattern

Why you are not using the module-oriented pattern for this project? I mean, on your previous project, you divided each part of the MVP pattern on different Java modules. That pattern was very useful I think. Any reason for changing this approach? Thanks.

dependency injection can't be used anywhere?

Hi
From ur code ,i see some class instance still be created by the new key, not injected. I have no idea which class should be injected ,which shouldn't.

    mCharacterListAdapter = new AvengersListAdapter(avengers,
        this, mAvengersListPresenter);

nice to get ur reply: [email protected]

AS must be 2.1??

Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

Crash when selecting year in dialog

Hi
When I was trying to filter by comic year then it crashed with a NullPointerException, and continuing crashed again with a ClassCastException.

Here are the specific logs:
java.lang.NullPointerException: Attempt to invoke virtual method 'rx.Subscription rx.Observable.subscribe(rx.functions.Action1)' on a null object reference
at saulmm.avengers.mvp.presenters.AvengerDetailPresenter.onItemSelected(AvengerDetailPresenter.java:148)

Unable to start activity ComponentInfo{saulmm.avengers/saulmm.avengers.views.activities.AvengersListActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ProgressBar$SavedState.

运行时出错 ( Runtime error)

**
jdk1.8.0_45

android studio 2.1 Preview 5

classpath 'com.android.tools.build:gradle:2.1.0-alpha5_
**

``
:app:transformClassesWithDexForDebug

Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1

求帮忙 (Please Help, Thanks)

Gradle Wrapper

Please add the Gradle Wrapper to the project so we can open it easily from Studio.

Error:Execution failed for task ':app:compileDebugJava'.

when i run this app,with the following poroblems,my jdk version is 1.7,what should i do ? thanks
ps:retrolambda need jdk version 1.8?

Error:Execution failed for task ':app:compileDebugJava'.

When running gradle with java 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable JAVA8_HOME

E/AndroidRuntime: FATAL EXCEPTION: main java.lang.VerifyError:

E/AndroidRuntime: FATAL EXCEPTION: main
                                                 java.lang.VerifyError: frogermcs/io/githubclient/ui/activity/SplashActivity$AjcClosure1
                                                     at frogermcs.io.githubclient.ui.activity.SplashActivity.onCreate(SplashActivity.java:48)
                                                     at android.app.Activity.performCreate(Activity.java:5104)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
                                                     at android.app.ActivityThread.access$600(ActivityThread.java:141)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
                                                     at android.os.Handler.dispatchMessage(Handler.java:99)
                                                     at android.os.Looper.loop(Looper.java:137)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5041)
                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                     at java.lang.reflect.Method.invoke(Method.java:511)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                                                     at dalvik.system.NativeStart.main(Native Method)

I want to run this app on API17level device,Could you tell me what can I do? Thank you very much.

i copy some code of your project ,but has catch: contains a dependency cycle

Error:(23, 20) 错误: org.sunger.net.injector.components.AppComponent.getRestDataSource() contains a dependency cycle:
org.sunger.net.injector.modules.AppModule.provideDataRepository(org.net.sunger.mode.model.RestDataSource restDataSource)
[parameter: org.net.sunger.mode.model.RestDataSource `restDataSource]
@Module                                                                                         
public final class AppModule {                                                                  

    private final MsApplication mAvengersApplication;                                           

    public AppModule(MsApplication avengersApplication) {                                       
        this.mAvengersApplication = avengersApplication;                                        
    }                                                                                           

    @Provides                                                                                   
    @Singleton                                                                                  
    MsApplication provideAvengersAppContext() {                                                 
        return mAvengersApplication;                                                            
    }                                                                                           

    @Provides                                                                                   
    @Named("executor_thread")                                                                   
    Scheduler provideExecutorThread() {                                                         
        return Schedulers.newThread();                                                          
    }                                                                                           

    @Provides                                                                                   
    @Named("ui_thread")                                                                         
    Scheduler provideUiThread() {                                                               
        return AndroidSchedulers.mainThread();                                                  
    }                                                                                           

    @Provides                                                                                   
    File provideCacheFile(){                                                                    
        return FileUtils.createDirs(ConfigConstants.RX_CACHE_DIR);                              
    }                                                                                           

    @Provides                                                                                   
    MsAuthorizer provideMsAuthorizer() {                                                        
        MsAuthorizer msAuthorizer = new MsAuthorizer();                                         
        OauthUserEntity userEntity = mAvengersApplication.getOauthUserEntity();                 
        if (userEntity != null) {                                                               
            msAuthorizer.setAccessToken(userEntity.getAccess_token());                          
        }                                                                                       
        return msAuthorizer;                                                                    
    }                                                                                           

    @Provides @Singleton                                                                        
    RestDataSource provideDataRepository(RestDataSource restDataSource) {                       
        return restDataSource;                                                                  
    }                                                                                           
}                                                                                               
                                                                                                `
@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
    MsApplication application();
    RestDataSource getRestDataSource();

    MsAuthorizer msAuthorizer();

    File getCacheDir();

    @Named("ui_thread")
    Scheduler uiThread();
    @Named("executor_thread") Scheduler executorThread();

}
public class RestDataSource {
    private static final int CONNECT_TIMEOUT_MILLIS = 30;
    private static final int READ_TIMEOUT_MILLIS = 30;
    private final CacheProviders cacheProviders;
    private RestApiService restApi;


    @Inject
    public RestDataSource(File cacheDir, MsAuthorizer msAuthorizer) {
        cacheProviders = new RxCache.Builder()
                .persistence(cacheDir)
                .using(CacheProviders.class);
        HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient okHttpClient = new OkHttpClient().newBuilder().
                connectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.SECONDS).
                readTimeout(READ_TIMEOUT_MILLIS, TimeUnit.SECONDS).addInterceptor(new MsInterceptor(msAuthorizer.getAccessToken())).
                addInterceptor(httpLoggingInterceptor).build();
        Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL).
                client(okHttpClient).
                addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
                addConverterFactory(GsonConverterFactory.create()).build();
        restApi =retrofit.create(RestApiService.class);
    }

    public Observable<Reply<List<CategoryEntity>>> getCategory(final boolean update) {
        return cacheProviders.getCategory(restApi.getCategory(), new EvictProvider(update));
    }

}

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.