saulmm / avengers Goto Github PK
View Code? Open in Web Editor NEW[Deprecated] This project aims to work as a demo project and reference using the common frameworks and tools
License: Other
[Deprecated] This project aims to work as a demo project and reference using the common frameworks and tools
License: Other
thank you very much
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));
}
}
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.
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!!
It would be nice to implement a realm, firebase or just an sqlite instance to let users save their favourite characters
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)
Add drag to close the detail screen, as the Plaid app.
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
Change marvel_private_key to local property. gradle-properties isn't a good way to store it, cuase it is versioned.
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
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.
minSdk is pointing to cfg.compileVersion in app/build.gradle
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]
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.
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.
**
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)
Please add the Gradle Wrapper to the project so we can open it easily from Studio.
Presenter should not have any reference to the android framework, just the implementations of Views
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: 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.
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));
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.