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
apply plugin: 'java' | |
/*...*/ | |
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
compile rootProject.ext.libraries.rxjava | |
testCompile rootProject.ext.testLibraries.junit | |
testCompile rootProject.ext.testLibraries.mockito |
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.cache; | |
import dagger.Module; | |
import dagger.Provides; | |
@Module | |
class CacheModule { | |
private CacheView view; |
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 | |
public HttpLoggingInterceptor provideHttpLoggingInterceptor() { | |
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); | |
logging.setLevel(HttpLoggingInterceptor.Level.BODY); | |
return logging; | |
} |
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; | |
import android.app.Application; | |
public abstract class MarvelApplication extends Application { | |
private static ApplicationComponent component; | |
public static ApplicationComponent getComponent() { | |
return component; |
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; | |
import timber.log.Timber; | |
public class MarvelApplicationImpl extends MarvelApplication { | |
@Override | |
public void initApplication() { | |
// initialize Timber in debug version to log |
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 |
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
<?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.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
@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(); | |
} |