Skip to content

Commit

Permalink
add sample
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksTuev committed Jul 5, 2016
1 parent 167854c commit 18ba657
Show file tree
Hide file tree
Showing 47 changed files with 1,667 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@
* If subscribe to {@link Observable} via one of {@link #subscribe(Observable, Subscriber)} method,
* all rx events (onNext, onError, onComplete) would be frozen when view destroyed and unfrozen
* when view recreated (see {@link OperatorFreeze}).
* If option freezeEventOnPause enabled (see {@link #setFreezeOnPauseEnabled(boolean)}, all events
* would be also frozen when screen paused and unfrozen when screen resumed.
*
* When screen finally destroyed, all subscriptions would be automatically unsubscribed.
*
* When configuration changed, presenter isn't destroyed and reused for new view
*
* If option freezeEventOnPause enabled (see {@link #setFreezeOnPauseEnabled(boolean)}, all events
* would be also frozen when screen paused and unfrozen when screen resumed.
* If option freezeEventOnPause disabled, screen may handle event when it invisible
* (e.g. when Activity in back stack) and user can miss important information e.g. SnackBar
*/
public class MvpRxPresenter<V extends BaseView> extends MvpPresenter<V> {

Expand Down
1 change: 1 addition & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "com.agna.ferro.sample"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":ferro-mvp-rx")
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'

compile 'io.reactivex:rxjava:1.1.6'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'com.annimon:stream:1.0.9'

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

compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.jakewharton.timber:timber:4.1.2'

testCompile 'junit:junit:4.12'
}
17 changes: 17 additions & 0 deletions sample/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in J:\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.agna.ferro.sample;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
28 changes: 28 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.agna.ferro.sample">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".app.App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ui.screen.catalog.CatalogActivityView"
android:label="Ferro MVP Rx Sample">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<activity
android:name=".ui.screen.book.BookActivity"
android:label="Book" />
</application>

</manifest>
31 changes: 31 additions & 0 deletions sample/src/main/java/com/agna/ferro/sample/app/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.agna.ferro.sample.app;

import android.app.Application;

import timber.log.Timber;

public class App extends Application {

private AppComponent appComponent;

@Override
public void onCreate() {
super.onCreate();
initInjector();
initLog();
}

private void initLog() {
Timber.plant(new Timber.DebugTree());
}

private void initInjector() {
appComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
}

public AppComponent getAppComponent() {
return this.appComponent;
}
}
37 changes: 37 additions & 0 deletions sample/src/main/java/com/agna/ferro/sample/app/AppComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (C) 2015 Fernando Cejas Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.agna.ferro.sample.app;

import android.content.Context;

import com.agna.ferro.mvp.dagger.scope.PerApplication;
import com.agna.ferro.sample.module.book.BookRepository;

import dagger.Component;

/**
* Application-level component
*/
@PerApplication
@Component(modules = AppModule.class)
public interface AppComponent {

//Exposed to sub-graphs.
Context context();

BookRepository bookRepository();

}
42 changes: 42 additions & 0 deletions sample/src/main/java/com/agna/ferro/sample/app/AppModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (C) 2015 Fernando Cejas Open Source Project
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.agna.ferro.sample.app;

import android.content.Context;

import com.agna.ferro.mvp.dagger.scope.PerApplication;

import dagger.Module;
import dagger.Provides;

/**
* Application-level module, which provides appContext
*/
@Module
public class AppModule {
private final Context applicationContext;

public AppModule(Context applicationContext) {
this.applicationContext = applicationContext;
}

@Provides
@PerApplication
Context provideApplicationContext() {
return this.applicationContext;
}

}
46 changes: 46 additions & 0 deletions sample/src/main/java/com/agna/ferro/sample/domain/entity/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.agna.ferro.sample.domain.entity;

/**
* Book entity
*/
public class Book {
private String id;
private String name;
private int downloadProgress;
private String imageUrl;

public Book(String id, String name, String imageUrl) {
this.id = id;
this.name = name;
this.imageUrl = imageUrl;
this.downloadProgress = -1;
}

public String getId() {
return id;
}

public String getName() {
return name;
}

public String getImageUrl() {
return imageUrl;
}

public boolean isDownloaded() {
return downloadProgress == 100;
}

public boolean isDownloading() {
return downloadProgress >= 0;
}

public int getDownloadProgress() {
return downloadProgress;
}

public void setDownloadProgress(int downloadProgress) {
this.downloadProgress = downloadProgress;
}
}
Loading

0 comments on commit 18ba657

Please sign in to comment.