This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mirhoseini.marvel.util; | |
import javax.inject.Inject; | |
import rx.Scheduler; | |
import rx.android.schedulers.AndroidSchedulers; | |
import rx.schedulers.Schedulers; | |
public class AppSchedulerProvider implements SchedulerProvider { | |
@Inject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void doSearch(boolean isConnected, String query, long timestamp) { | |
if (null != view) { | |
view.showProgress(); | |
} | |
subscription = interactor.loadCharacter(query, Constants.PRIVATE_KEY, Constants.PUBLIC_KEY, timestamp) | |
// check if result code is OK | |
.map(charactersResponse -> { | |
if (Constants.CODE_OK == charactersResponse.getCode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mirhoseini.marvel.domain; | |
/*...*/ | |
@Module | |
public class ApiModule { | |
@Provides | |
@Singleton | |
public MarvelApi provideMarvelApi(Retrofit retrofit) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mirhoseini.stylight.domain; | |
/*...*/ | |
@Module | |
public class ClientModule { | |
/*...*/ | |
@Singleton | |
@Provides |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
@Provides | |
@Named("retryInterceptor") | |
public Interceptor provideRetryInterceptor(@Named("retryCount") int retryCount) { | |
return chain -> { | |
Request request = chain.request(); | |
Response response = null; | |
IOException exception = null; | |
int tryCount = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Provides | |
@Singleton | |
public Cache provideCache(@Named("cacheDir") File cacheDir, @Named("cacheSize") long cacheSize) { | |
Cache cache = null; | |
try { | |
cache = new Cache(new File(cacheDir.getPath(), HTTP_CACHE_PATH), cacheSize); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mirhoseini.marvel.domain.client; | |
import com.mirhoseini.marvel.domain.model.CharactersResponse; | |
import retrofit2.http.GET; | |
import retrofit2.http.Query; | |
import rx.Observable; | |
public interface MarvelApi { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
package="com.mirhoseini.marvel"> | |
<!-- *** --> | |
<application | |
android:name=".MarvelApplicationImpl" | |
android:allowBackup="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mirhoseini.marvel.character.search; | |
import dagger.Subcomponent; | |
@Search | |
@Subcomponent(modules = { | |
AppSearchModule.class | |
}) | |
public interface SearchSubComponent { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mirhoseini.marvel; | |
/*...*/ | |
@Singleton | |
@Component(modules = { | |
AndroidModule.class, | |
ApplicationModule.class, | |
ApiModule.class, | |
DatabaseModule.class, | |
ClientModule.class |