Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

16 changes: 2 additions & 14 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
.idea/*
69 changes: 45 additions & 24 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'

def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

// signingConfigs {
// Yappl {
// keyAlias keystoreProperties['keyAlias']
// keyPassword keystoreProperties['keyPassword']
// storeFile file(keystoreProperties['storeFile'])
// storePassword keystoreProperties['storePassword']
// }
// }
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "ru.aleien.yapplication"
minSdkVersion 15
Expand All @@ -15,7 +27,7 @@ android {
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

Expand All @@ -24,12 +36,6 @@ android {
}
}

sourceSets {
androidTest {
setRoot('src/test')
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -38,34 +44,49 @@ android {

dependencies {
ext.supportVersion = '23.3.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:support-v4:$supportVersion"
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:design:$supportVersion"
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'

// Annotation heaven
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton:butterknife:8.2.1'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile 'javax.annotation:jsr250-api:1.0'

// UI
compile "com.android.support:cardview-v7:$supportVersion"
compile "com.android.support:recyclerview-v7:$supportVersion"
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'

// Testing
testCompile 'junit:junit:4.12'
androidTestCompile "com.android.support:support-annotations:$supportVersion"
androidTestCompile 'com.android.support.test:runner:0.4.1'
testCompile "org.robolectric:robolectric:3.0"
testCompile "org.mockito:mockito-core:1.10.19"
androidTestCompile "com.android.support:support-annotations:24.1.1"
androidTestCompile 'com.android.support.test:runner:0.5'
testCompile 'org.mockito:mockito-core:2.0.99-beta'
testCompile "org.robolectric:robolectric:3.1.2"
testCompile 'org.robolectric:shadows-support-v4:3.1.2'

// Network
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.retrofit2:retrofit:2.0.0'

compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'

// Image processor
compile 'com.github.bumptech.glide:glide:3.7.0'

// DI
compile 'com.google.dagger:dagger:2.6'
apt 'com.google.dagger:dagger-compiler:2.6'
provided 'javax.annotation:jsr250-api:1.0'

// Rx
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.8'

debugCompile 'com.facebook.stetho:stetho:1.2.0'
compile 'com.jakewharton.timber:timber:4.1.2'

}
23 changes: 23 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,26 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Butterknife
-keep public class * implements butterknife.internal.ViewBinder { public <init>(); }

# Prevent obfuscation of types which use ButterKnife annotations since the simple name
# is used to reflectively look up the generated ViewBinder.
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
-keepnames class * { @butterknife.Bind *;}

# Dagger
-keepclassmembers,allowobfuscation class * {
@javax.inject.* *;
@dagger.* *;
<init>();
}

-keep class javax.inject.** { *; }
-keep class **$$ModuleAdapter
-keep class **$$InjectAdapter
-keep class **$$StaticInjection
-keep class dagger.** { *; }
21 changes: 15 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.aleien.yapplication">
package="ru.aleien.yapplication">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"

android:theme="@style/AppTheme">
<activity android:name=".ListArtistsActivity">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем здесь активити?


<provider
android:name=".contentprovider.ArtistsContentProvider"
android:exported="true"
android:readPermission="u.aleien.yapplication.contentprovider"
android:authorities="ru.aleien.yapplication.provider"/>

</application>

</manifest>
30 changes: 30 additions & 0 deletions app/src/main/java/ru/aleien/yapplication/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ru.aleien.yapplication;

import android.app.Application;

import com.facebook.stetho.Stetho;

import ru.aleien.yapplication.di.AppComponent;
import ru.aleien.yapplication.di.AppModule;
import ru.aleien.yapplication.di.DaggerAppComponent;
import timber.log.Timber;

public class App extends Application {
private AppComponent component;


@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
Stetho.initializeWithDefaults(this.getApplicationContext());
component = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();

}

public AppComponent dagger() {
return component;
}
}
40 changes: 36 additions & 4 deletions app/src/main/java/ru/aleien/yapplication/ArtistsPresenter.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package ru.aleien.yapplication;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.util.Log;

import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.List;

import javax.inject.Inject;

import ru.aleien.yapplication.base.BasePresenter;
import ru.aleien.yapplication.database.DBBackend;
import ru.aleien.yapplication.dataprovider.ArtistsProvider;
import ru.aleien.yapplication.dataprovider.WebArtistsProvider;
import ru.aleien.yapplication.model.Artist;
Expand All @@ -17,6 +20,10 @@
import ru.aleien.yapplication.screens.list.ArtistsListView;
import ru.aleien.yapplication.screens.list.ArtistsRecyclerFragment;
import ru.aleien.yapplication.utils.adapters.ArtistsRecyclerAdapter;
import rx.Completable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import timber.log.Timber;

/**
* Created by aleien on 09.04.16.
Expand All @@ -25,17 +32,33 @@
*/
public class ArtistsPresenter extends BasePresenter<MainView> implements ArtistsRequester, ArtistClickHandler, Serializable {
ArtistsProvider artistsProvider;
private final DBBackend dbSource;
private WeakReference<ArtistsListView<RecyclerView.Adapter>> artistsListView;
private WeakReference<Fragment> currentFragment;

public ArtistsPresenter(Context context) {
artistsProvider = new WebArtistsProvider(this, context);
@Inject
public ArtistsPresenter(DBBackend dbSource,
// Как здесь получать интерфейс?
WebArtistsProvider artistsProvider) {
this.dbSource = dbSource;
this.artistsProvider = artistsProvider;
}

@Override
public void takeListView(ArtistsListView<RecyclerView.Adapter> list) {
artistsListView = new WeakReference<>(list);
artistsProvider.requestData();

subscribe(dbSource.getAllArtists()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::provideData,
throwable -> Timber.e("DBError", "Error while reading cached artists")));

artistsProvider.requestData()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::provideData,
e -> Timber.e(e, "takeListView -> requestData"));
}

@Override
Expand All @@ -47,6 +70,15 @@ public void takeDetailedView(ArtistInfoView info, Artist artist) {
@Override
public void provideData(List<Artist> response) {
artistsListView.get().setAdapter(new ArtistsRecyclerAdapter(response, this));
dbSource.clearArtists();
Completable.fromAction(() -> {
Timber.e("Working on: " + Thread.currentThread().getName());
for (Artist artist : response) {
dbSource.insertArtist(artist);
}
}).subscribeOn(Schedulers.io()).subscribe();


}

@Override
Expand Down
Loading