├── .gitignore ├── LICENSE.md ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jaime │ │ └── toca │ │ └── MVPActors │ │ └── presentation │ │ └── ActorsPopularActivityTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── Pacifico.ttf │ ├── java │ └── com │ │ └── jaime │ │ └── toca │ │ └── MVPActors │ │ ├── ActorsApp.java │ │ ├── di │ │ ├── components │ │ │ ├── ActorDetailComponent.java │ │ │ ├── AppComponent.java │ │ │ └── PopularActorsComponent.java │ │ ├── modules │ │ │ ├── ActorDetailModule.java │ │ │ ├── AppModule.java │ │ │ ├── DomainModule.java │ │ │ └── PopularActorsModule.java │ │ └── scopes │ │ │ └── PerActivity.java │ │ ├── domain │ │ ├── interactor │ │ │ ├── GetDetailActorImp.java │ │ │ ├── GetPopularActorsImp.java │ │ │ └── Interactor.java │ │ ├── model │ │ │ ├── Actor.java │ │ │ ├── ActorDetail.java │ │ │ ├── ActorsWrapper.java │ │ │ └── Known_for.java │ │ └── repository │ │ │ ├── DataSource.java │ │ │ └── rest │ │ │ ├── ActorDatabaseAPI.java │ │ │ ├── RestActorSource.java │ │ │ └── RestDataSource.java │ │ ├── mvp │ │ ├── presenters │ │ │ ├── ActorDetailPresenter.java │ │ │ ├── PopularActorsPresenter.java │ │ │ └── Presenter.java │ │ └── views │ │ │ ├── ActorDetailView.java │ │ │ ├── PopularActorsView.java │ │ │ └── View.java │ │ ├── ui │ │ ├── activities │ │ │ ├── ActorDetailActivity.java │ │ │ └── ActorsPopularActivity.java │ │ ├── adapters │ │ │ ├── ActorsAdapter.java │ │ │ └── DividerItemDecoration.java │ │ ├── fragments │ │ │ └── ActorListFragment.java │ │ └── listeners │ │ │ └── RecyclerViewClickListener.java │ │ └── utils │ │ └── Constants.java │ └── res │ ├── drawable-hdpi │ └── ic_person_black_18dp.png │ ├── drawable-mdpi │ └── ic_person_black_18dp.png │ ├── drawable-xhdpi │ └── ic_person_black_18dp.png │ ├── drawable-xxhdpi │ └── ic_person_black_18dp.png │ ├── drawable-xxxhdpi │ └── ic_person_black_18dp.png │ ├── drawable │ ├── divider.xml │ └── person_.photo.jpg │ ├── layout │ ├── activity_main.xml │ ├── fragment_list.xml │ ├── item_row.xml │ └── user_detail.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── captures ├── SystemInfo_2015.08.07_19.45.41.txt ├── SystemInfo_2015.08.07_19.45.55.txt └── SystemInfo_2015.08.07_19.46.00.txt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pictures ├── list-optimized.gif ├── mvp.png ├── profile-optimized.gif └── row-optimazed.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | 6 | # Files for the Dalvik VM 7 | *.dex 8 | 9 | 10 | # Java class files 11 | *.class 12 | 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | 28 | # Proguard folder generated by Eclipse 29 | proguard/ 30 | 31 | 32 | # IntelliJ files 33 | .idea 34 | *.iml 35 | 36 | 37 | # Maven output folder 38 | target 39 | 40 | 41 | # Misc 42 | .DS_Store 43 | Thumbs.db 44 | *.swp 45 | *.bak 46 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2015 Jaime Toca
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 | 6 | http://www.apache.org/licenses/LICENSE-2.0
7 | 8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android MVP (Deprecated) 2 | This repository is deprecated
3 | 4 | Sample project using MVP Clean architecture (check out the diagram at the bottom) . This small app show a list of the most famous hollywood actors (retrieve from themoviedb.org), when any of them is clicked a new screen will be opened with detailed information about the specific actor. Libraries and technologies used in this project: 5 | 6 | - Model-View-Presenter Pattern 7 | - RxJava/ReactiveX 8 | - Coordinator Layout, Toolbar (Hide/show) , RecyclerView and some material design features 9 | - Dagger 2.0 framework and dependency injection 10 | - Retrofit (REST Client for android/java) 11 | - Picasso 12 | - ButterKnife to avoid duplicated code
13 | And many more things :D
14 | 15 | # Screenshots 16 | 17 | 18 | ![enter image description here](https://github.com/JaimeToca/AndroidMVP/blob/master/pictures/list-optimized.gif) 19 | 20 | ![enter image description here](https://github.com/JaimeToca/AndroidMVP/blob/master/pictures/profile-optimized.gif) 21 | 22 | ![enter image description here](https://github.com/JaimeToca/AndroidMVP/blob/master/pictures/row-optimazed.gif) 23 | 24 | 25 | # Motivation and References 26 | After study and see [Saulmm's](https://github.com/saulmm) project "Material Movies" I made my own implementation of mvp android clean architecture. Also "Avengers" was very helpful. I really recommend you to check out his repository
27 | 28 | 29 | # MVP 30 | 31 | ![picture from blog.nodejitsu.com/](https://github.com/JaimeToca/AndroidMVP/blob/master/pictures/mvp.png)
32 | Image from blog.nodejitsu.com 33 | 34 | 35 | **Reference Links**
36 | https://www.youtube.com/watch?v=lOEOK3UvmJM
37 | https://github.com/pedrovgs/EffectiveAndroidUI
38 | http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/
39 | https://github.com/jlmd/UpcomingMoviesMVP
40 | https://github.com/saulmm/Material-Movies
41 | https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter
42 | http://www.vogella.com/tutorials/JavaLibrary-EventBusOtto/article.html 43 | 44 | 45 | 46 | # Licence 47 | 48 | Copyright 2015 Jaime Toca 49 | Licensed under the Apache License, Version 2.0 (the "License"); 50 | you may not use this file except in compliance with the License. 51 | You may obtain a copy of the License at 52 | 53 | http://www.apache.org/licenses/LICENSE-2.0 54 | 55 | Unless required by applicable law or agreed to in writing, software 56 | distributed under the License is distributed on an "AS IS" BASIS, 57 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 58 | See the License for the specific language governing permissions and 59 | limitations under the License. 60 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.neenbedankt.android-apt' 3 | apply plugin: 'me.tatarka.retrolambda' 4 | 5 | android { 6 | compileSdkVersion 21 7 | buildToolsVersion "21.1.2" 8 | 9 | defaultConfig { 10 | applicationId "toca.jaime.com.pruebas" 11 | minSdkVersion 16 12 | targetSdkVersion 21 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | 30 | packagingOptions { 31 | exclude 'LICENSE.txt' 32 | exclude 'META-INF/DEPENDENCIES' 33 | exclude 'META-INF/ASL2.0' 34 | exclude 'META-INF/NOTICE' 35 | exclude 'META-INF/LICENSE' 36 | } 37 | } 38 | 39 | dependencies { 40 | compile fileTree(dir: 'libs', include: ['*.jar']) 41 | compile 'com.android.support:appcompat-v7:22.0.0' 42 | compile 'com.android.support:cardview-v7:21.0.+' 43 | compile 'com.android.support:palette-v7:21.0.0' 44 | compile 'com.android.support:recyclerview-v7:22.2.0' 45 | compile 'com.android.support:support-v4:22.0.0' 46 | compile 'com.android.support:support-v13:21.0.3' 47 | compile 'com.android.support:design:22.2.0' 48 | 49 | compile 'com.jakewharton:butterknife:7.0.1' 50 | 51 | compile 'com.squareup.retrofit:retrofit:1.9.0' 52 | compile 'com.squareup.picasso:picasso:2.4.0' 53 | compile 'com.squareup:otto:1.3.8' 54 | 55 | apt 'com.google.dagger:dagger-compiler:2.0' 56 | compile 'com.google.dagger:dagger:2.0' 57 | compile 'org.glassfish:javax.annotation:10.0-b28' 58 | 59 | compile 'io.reactivex:rxjava:1.0.0' 60 | compile 'io.reactivex:rxandroid:0.24.0' 61 | 62 | androidTestCompile 'com.android.support.test:runner:0.3' 63 | androidTestCompile 'com.android.support.test:rules:0.3' 64 | androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' 65 | testCompile "org.robolectric:robolectric:3.0" 66 | testCompile 'junit:junit:4.12' 67 | } 68 | 69 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Toca\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/jaime/toca/MVPActors/presentation/ActorsPopularActivityTest.java: -------------------------------------------------------------------------------- 1 | package com.jaime.toca.MVPActors.presentation; 2 | 3 | import android.app.Fragment; 4 | import android.content.Intent; 5 | import android.test.ActivityInstrumentationTestCase2; 6 | 7 | import com.jaime.toca.MVPActors.R; 8 | import com.jaime.toca.MVPActors.ui.activities.ActorsPopularActivity; 9 | import static org.hamcrest.CoreMatchers.is; 10 | import static org.hamcrest.CoreMatchers.notNullValue; 11 | import static org.hamcrest.MatcherAssert.assertThat; 12 | /** 13 | * Created by Jaime on 16/09/2015. 14 | */ 15 | 16 | public class ActorsPopularActivityTest extends ActivityInstrumentationTestCase2 { 17 | 18 | private ActorsPopularActivity actorsPopularActivity; 19 | 20 | public ActorsPopularActivityTest() { 21 | super(ActorsPopularActivity.class); 22 | } 23 | 24 | @Override protected void setUp() throws Exception { 25 | super.setUp(); 26 | actorsPopularActivity = getActivity(); 27 | } 28 | 29 | @Override protected void tearDown() throws Exception { 30 | super.tearDown(); 31 | } 32 | 33 | public void testContainsUserListFragment() { 34 | Fragment userListFragment = 35 | actorsPopularActivity.getFragmentManager().findFragmentById(R.id.fragmentUserList); 36 | assertThat(userListFragment, is(notNullValue())); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/assets/Pacifico.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/assets/Pacifico.ttf -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/ActorsApp.java: -------------------------------------------------------------------------------- 1 | package com.jaime.toca.MVPActors; 2 | import android.app.Application; 3 | import com.jaime.toca.MVPActors.di.components.AppComponent; 4 | import com.jaime.toca.MVPActors.di.components.DaggerAppComponent; 5 | import com.jaime.toca.MVPActors.di.modules.AppModule; 6 | import com.jaime.toca.MVPActors.di.modules.DomainModule; 7 | 8 | public class ActorsApp extends Application { 9 | 10 | private AppComponent appComponent; 11 | 12 | @Override public void onCreate() { 13 | super.onCreate(); 14 | this.initializeDependencyInjector(); 15 | } 16 | 17 | private void initializeDependencyInjector() { 18 | appComponent = DaggerAppComponent.builder() 19 | .appModule(new AppModule(this)) 20 | .domainModule(new DomainModule()) 21 | .build(); 22 | } 23 | 24 | public AppComponent getAppComponent() { 25 | return appComponent; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/components/ActorDetailComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.di.components; 17 | 18 | import com.jaime.toca.MVPActors.di.modules.ActorDetailModule; 19 | import com.jaime.toca.MVPActors.di.scopes.PerActivity; 20 | import com.jaime.toca.MVPActors.ui.activities.ActorDetailActivity; 21 | 22 | import dagger.Component; 23 | 24 | @PerActivity 25 | @Component(dependencies = AppComponent.class, modules = ActorDetailModule.class) 26 | public interface ActorDetailComponent { 27 | 28 | void inject (ActorDetailActivity actorDetailActivity); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/components/AppComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.di.components; 17 | import com.jaime.toca.MVPActors.di.modules.AppModule; 18 | import com.jaime.toca.MVPActors.di.modules.DomainModule; 19 | import com.jaime.toca.MVPActors.domain.repository.rest.RestActorSource; 20 | 21 | import javax.inject.Singleton; 22 | import dagger.Component; 23 | 24 | @Singleton 25 | @Component(modules = { 26 | AppModule.class, 27 | DomainModule.class, 28 | }) 29 | 30 | public interface AppComponent { 31 | 32 | RestActorSource restActorSource(); 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/components/PopularActorsComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.di.components; 17 | import com.jaime.toca.MVPActors.di.modules.PopularActorsModule; 18 | import com.jaime.toca.MVPActors.di.scopes.PerActivity; 19 | import com.jaime.toca.MVPActors.ui.activities.ActorsPopularActivity; 20 | import com.jaime.toca.MVPActors.ui.fragments.ActorListFragment; 21 | 22 | import dagger.Component; 23 | 24 | @PerActivity 25 | @Component(dependencies = AppComponent.class, modules = PopularActorsModule.class) 26 | public interface PopularActorsComponent { 27 | void inject (ActorsPopularActivity actorsPopularActivity); 28 | void inject (ActorListFragment actorListFragment); 29 | } -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/modules/ActorDetailModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.di.modules; 17 | import com.jaime.toca.MVPActors.domain.interactor.GetDetailActorImp; 18 | import com.jaime.toca.MVPActors.domain.repository.rest.RestActorSource; 19 | 20 | import dagger.Module; 21 | import dagger.Provides; 22 | 23 | 24 | @Module 25 | public class ActorDetailModule { 26 | 27 | private final String actorId; 28 | 29 | public ActorDetailModule(String actorId) { 30 | this.actorId = actorId; 31 | } 32 | 33 | @Provides 34 | GetDetailActorImp provideGetActorDetailInteractor (RestActorSource actorSource) { 35 | return new GetDetailActorImp(actorId, actorSource); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/modules/AppModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.di.modules; 17 | 18 | import android.content.Context; 19 | import com.jaime.toca.MVPActors.ActorsApp; 20 | import javax.inject.Singleton; 21 | import dagger.Module; 22 | import dagger.Provides; 23 | 24 | @Module 25 | public class AppModule { 26 | 27 | private final ActorsApp app; 28 | 29 | public AppModule(ActorsApp app) { 30 | this.app = app; 31 | } 32 | 33 | @Provides @Singleton 34 | Context provideAppContext () { return app; } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/modules/DomainModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.di.modules; 17 | import com.jaime.toca.MVPActors.domain.repository.rest.RestActorSource; 18 | 19 | import javax.inject.Singleton; 20 | import dagger.Module; 21 | import dagger.Provides; 22 | 23 | @Module 24 | public class DomainModule { 25 | 26 | @Provides @Singleton 27 | RestActorSource provideDataSource () { return new RestActorSource(); } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/modules/PopularActorsModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.di.modules; 17 | import com.jaime.toca.MVPActors.domain.interactor.GetPopularActorsImp; 18 | import com.jaime.toca.MVPActors.domain.repository.rest.RestActorSource; 19 | import dagger.Module; 20 | import dagger.Provides; 21 | 22 | @Module 23 | public class PopularActorsModule { 24 | 25 | @Provides 26 | GetPopularActorsImp providePopularActorsInteractor (RestActorSource actorSource) { 27 | return new GetPopularActorsImp(actorSource); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/di/scopes/PerActivity.java: -------------------------------------------------------------------------------- 1 | package com.jaime.toca.MVPActors.di.scopes; 2 | import java.lang.annotation.Retention; 3 | 4 | import javax.inject.Scope; 5 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 | 7 | 8 | @Scope 9 | @Retention(RUNTIME) 10 | public @interface PerActivity { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/interactor/GetDetailActorImp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.interactor; 17 | import com.jaime.toca.MVPActors.domain.model.ActorDetail; 18 | import com.jaime.toca.MVPActors.domain.repository.rest.RestDataSource; 19 | import rx.Observable; 20 | import rx.android.schedulers.AndroidSchedulers; 21 | import rx.schedulers.Schedulers; 22 | 23 | public class GetDetailActorImp implements Interactor { 24 | 25 | private final RestDataSource mRestDataSource; 26 | private final String mActorId; 27 | private ActorDetail mActorDetail; 28 | 29 | public GetDetailActorImp(String id,RestDataSource dataSource){ 30 | mRestDataSource = dataSource; 31 | mActorId = id; 32 | } 33 | 34 | @Override 35 | public Observable execute() { 36 | return mRestDataSource.getDetailActor(mActorId) 37 | .map(actorDetail -> mActorDetail = actorDetail) 38 | .subscribeOn(Schedulers.newThread()) 39 | .observeOn(AndroidSchedulers.mainThread()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/interactor/GetPopularActorsImp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.interactor; 17 | import com.jaime.toca.MVPActors.domain.model.ActorsWrapper; 18 | import com.jaime.toca.MVPActors.domain.repository.rest.RestDataSource; 19 | import javax.inject.Inject; 20 | import rx.Observable; 21 | import rx.android.schedulers.AndroidSchedulers; 22 | import rx.schedulers.Schedulers; 23 | 24 | public class GetPopularActorsImp implements Interactor{ 25 | 26 | private final RestDataSource mRestDataSource; 27 | private ActorsWrapper mActorsWrapper; 28 | 29 | @Inject 30 | public GetPopularActorsImp(RestDataSource dataSource) { 31 | mRestDataSource = dataSource; 32 | } 33 | 34 | @Override 35 | public Observable execute() { 36 | return mRestDataSource.getPopularActors() 37 | .map(actorsWrapper -> mActorsWrapper = actorsWrapper) 38 | .subscribeOn(Schedulers.newThread()) 39 | .observeOn(AndroidSchedulers.mainThread()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/interactor/Interactor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.interactor; 17 | 18 | import rx.Observable; 19 | 20 | public interface Interactor { 21 | Observable execute(); 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/model/Actor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.model; 17 | 18 | import java.util.List; 19 | 20 | @SuppressWarnings("UnusedDeclaration") 21 | public class Actor { 22 | 23 | private String adult; 24 | private Number id; 25 | private List known_for; 26 | private String name; 27 | private Number popularity; 28 | private String profile_path; 29 | private boolean isLoaded; 30 | 31 | public Actor(Number id, String name) { 32 | this.id = id; 33 | this.name = name; 34 | } 35 | 36 | public String getAdult(){ 37 | return adult; 38 | } 39 | 40 | public Number getId(){ 41 | return id; 42 | } 43 | 44 | public List getKnownFor(){ 45 | return known_for; 46 | } 47 | 48 | public String getName(){ 49 | return name; 50 | } 51 | 52 | public Number getPopularity(){ 53 | return popularity; 54 | } 55 | 56 | public String getProfilePath(){ 57 | return profile_path; 58 | } 59 | 60 | public void setIsLoaded(boolean isLoadedActor){ 61 | this.isLoaded=isLoadedActor; 62 | } 63 | 64 | public Boolean getIsLoaded(){ 65 | return isLoaded; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/model/ActorDetail.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.model; 17 | import java.util.List; 18 | 19 | 20 | @SuppressWarnings("UnusedDeclaration") 21 | public class ActorDetail { 22 | 23 | private boolean isLoaded; 24 | private String adult; 25 | private List also_known_as; 26 | private String biography; 27 | private String birthday; 28 | private String deathday; 29 | private String homepage; 30 | private Number id; 31 | private String name; 32 | private String place_of_birth; 33 | private String profile_path; 34 | 35 | public String getAdult(){ 36 | return adult; 37 | } 38 | 39 | public List getAlsoKnownAs(){ 40 | return also_known_as; 41 | } 42 | 43 | public String getBiography(){ 44 | return biography; 45 | } 46 | 47 | public String getBirthday(){ 48 | return birthday; 49 | } 50 | 51 | public String getDeathday(){ 52 | return deathday; 53 | } 54 | 55 | public String getHomepage(){ 56 | return homepage; 57 | } 58 | 59 | public Number getId(){ 60 | return id; 61 | } 62 | 63 | public String getName(){ 64 | return name; 65 | } 66 | 67 | public String getPlaceOfBirth(){ 68 | return place_of_birth; 69 | } 70 | 71 | public String getProfilePath(){ 72 | return profile_path; 73 | } 74 | 75 | public void setIsLoaded(boolean isLoadedActor){ 76 | this.isLoaded=isLoadedActor; 77 | } 78 | 79 | public Boolean getIsLoaded(){ 80 | return isLoaded; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/model/ActorsWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.model; 17 | 18 | import java.io.Serializable; 19 | import java.util.List; 20 | 21 | @SuppressWarnings("UnusedDeclaration") 22 | public class ActorsWrapper implements Serializable { 23 | 24 | private Number page; 25 | private List results; 26 | private Number total_pages; 27 | private Number total_results; 28 | 29 | public ActorsWrapper(List results) { 30 | this.results = results; 31 | } 32 | 33 | public List getResults() { 34 | return results; 35 | } 36 | 37 | public Number getPage() { 38 | return this.page; 39 | } 40 | 41 | public void setPage(Number page) { 42 | this.page = page; 43 | } 44 | 45 | public Number getTotal_results() { 46 | return this.total_results; 47 | } 48 | 49 | public void setTotal_results(Number total_results) { 50 | this.total_results = total_results; 51 | } 52 | 53 | public Number getTotal_pages() { 54 | return this.total_pages; 55 | } 56 | 57 | public void setTotal_pages(Number total_pages) { 58 | this.total_pages = total_pages; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/model/Known_for.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.model; 17 | 18 | @SuppressWarnings("UnusedDeclaration") 19 | public class Known_for { 20 | 21 | private String adult; 22 | private String backdrop_path; 23 | private Number id; 24 | private String original_title; 25 | private String release_date; 26 | private String poster_path; 27 | private Number popularity; 28 | private String title; 29 | private Number vote_average; 30 | private Number vote_count; 31 | private String media_type; 32 | 33 | public String getAdult(){ 34 | return adult; 35 | } 36 | 37 | public String getBackdropPath(){ 38 | return backdrop_path; 39 | } 40 | 41 | public Number getId(){ 42 | return id; 43 | } 44 | 45 | public String getOriginalTitle(){ 46 | return original_title; 47 | } 48 | 49 | public String getReleaseDate(){ 50 | return release_date; 51 | } 52 | 53 | public String getPosterPath(){ 54 | return poster_path; 55 | } 56 | 57 | public Number getPopularity(){ 58 | return popularity; 59 | } 60 | 61 | public Number getVoteAverage(){ 62 | return vote_average; 63 | } 64 | 65 | public Number getVoteCount(){ 66 | return vote_count; 67 | } 68 | 69 | private String getMediaType(){ 70 | return media_type; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/repository/DataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.repository; 17 | 18 | import com.jaime.toca.MVPActors.domain.model.ActorDetail; 19 | import com.jaime.toca.MVPActors.domain.model.ActorsWrapper; 20 | 21 | import rx.Observable; 22 | 23 | public interface DataSource { 24 | Observable getPopularActors(); 25 | Observable getDetailActor(String id); 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/repository/rest/ActorDatabaseAPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.repository.rest; 17 | 18 | import retrofit.Callback; 19 | import retrofit.http.GET; 20 | import retrofit.http.Path; 21 | import retrofit.http.Query; 22 | import rx.Observable; 23 | 24 | import com.jaime.toca.MVPActors.domain.model.ActorDetail; 25 | import com.jaime.toca.MVPActors.domain.model.ActorsWrapper; 26 | 27 | public interface ActorDatabaseAPI { 28 | 29 | @GET("/person/popular") 30 | Observable getPopularActors( 31 | @Query("api_key") String apiKey); 32 | 33 | @GET("/person/{id}") 34 | Observable getDetailActor( 35 | @Query("api_key") String apiKey, 36 | @Path("id") String id); 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/repository/rest/RestActorSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.repository.rest; 17 | import android.util.Log; 18 | 19 | import com.jaime.toca.MVPActors.utils.Constants; 20 | import com.squareup.otto.Bus; 21 | import retrofit.Callback; 22 | import retrofit.RestAdapter; 23 | import retrofit.RetrofitError; 24 | import retrofit.client.Response; 25 | import rx.Observable; 26 | 27 | import com.jaime.toca.MVPActors.domain.model.ActorDetail; 28 | import com.jaime.toca.MVPActors.domain.model.ActorsWrapper; 29 | 30 | import java.util.List; 31 | 32 | public class RestActorSource implements RestDataSource { 33 | 34 | private final ActorDatabaseAPI mActorsDBApi; 35 | 36 | public RestActorSource() { 37 | RestAdapter movieAPIRest = new RestAdapter.Builder() 38 | .setEndpoint(Constants.HOST) 39 | .setLogLevel(RestAdapter.LogLevel.HEADERS_AND_ARGS) 40 | .build(); 41 | 42 | mActorsDBApi = movieAPIRest.create(ActorDatabaseAPI.class); 43 | } 44 | 45 | @Override 46 | public Observable getPopularActors(){ 47 | return mActorsDBApi.getPopularActors(Constants.API_KEY); 48 | } 49 | 50 | @Override 51 | public Observable getDetailActor(String id){ 52 | return mActorsDBApi.getDetailActor(Constants.API_KEY, id); 53 | } 54 | 55 | @Override 56 | public void getPopularActorsByPage (int page){ 57 | //Future implementation 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/domain/repository/rest/RestDataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.domain.repository.rest; 17 | 18 | import com.jaime.toca.MVPActors.domain.repository.DataSource; 19 | 20 | public interface RestDataSource extends DataSource { 21 | void getPopularActorsByPage (int page); 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/mvp/presenters/ActorDetailPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.mvp.presenters; 17 | import com.jaime.toca.MVPActors.R; 18 | import com.jaime.toca.MVPActors.domain.interactor.GetDetailActorImp; 19 | import com.jaime.toca.MVPActors.domain.model.ActorDetail; 20 | import com.jaime.toca.MVPActors.mvp.views.ActorDetailView; 21 | import com.jaime.toca.MVPActors.utils.Constants; 22 | import javax.inject.Inject; 23 | import rx.Subscription; 24 | 25 | public class ActorDetailPresenter implements Presenter { 26 | 27 | ActorDetailView mActorDetailView; 28 | private GetDetailActorImp mInteractDetailActor; 29 | private Subscription mDetailActorSubscription; 30 | 31 | @Inject 32 | public ActorDetailPresenter(GetDetailActorImp getDetailActor){ 33 | mInteractDetailActor = getDetailActor; 34 | } 35 | 36 | public void attachView (ActorDetailView actorDetailView) { 37 | mActorDetailView = actorDetailView; 38 | } 39 | 40 | @Override 41 | public void start() { 42 | mActorDetailView.showProgressBar(); 43 | mDetailActorSubscription = mInteractDetailActor.execute().subscribe( 44 | ActorDetail -> actorDetailReceived(ActorDetail)); 45 | } 46 | 47 | @Override 48 | public void stop() {} 49 | 50 | @Override 51 | public void destroy() {} 52 | 53 | public void actorDetailReceived(ActorDetail actorDetail){ 54 | showActorImage(actorDetail.getProfilePath()); 55 | showName(actorDetail.getName()); 56 | showBirthday(actorDetail.getBirthday()); 57 | showPlaceOfBirth(actorDetail.getPlaceOfBirth()); 58 | showHomepage(actorDetail.getHomepage()); 59 | showBiography(actorDetail.getBiography()); 60 | } 61 | 62 | public void showName(String name){ 63 | mActorDetailView.setName(name); 64 | } 65 | 66 | public void showBirthday(String birthday){ 67 | mActorDetailView.setBirthday(birthday); 68 | } 69 | 70 | public void showPlaceOfBirth(String placeOfBirth){ 71 | if (placeOfBirth == null) 72 | mActorDetailView.setPlaceOfBirth(mActorDetailView.getContext().getString(R.string.noPlaceOfBirth)); 73 | else 74 | mActorDetailView.setPlaceOfBirth(placeOfBirth); 75 | } 76 | 77 | public void showHomepage(String homepage){ 78 | if (homepage.length() < Constants.MIN_URL_SIZE) 79 | mActorDetailView.setHomePage(mActorDetailView.getContext().getString(R.string.noHomepage)); 80 | else 81 | mActorDetailView.setHomePage(homepage); 82 | } 83 | 84 | public void showBiography(String biography){ 85 | mActorDetailView.setBiography(biography); 86 | } 87 | 88 | public void showActorImage(String urlImage){ 89 | mActorDetailView.setActorImage(urlImage); 90 | } 91 | 92 | public void onPictureLoaded(){ 93 | mActorDetailView.hideProgressBar(); 94 | } 95 | 96 | public void onPictureError(){ 97 | return; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/mvp/presenters/PopularActorsPresenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.mvp.presenters; 17 | import com.jaime.toca.MVPActors.domain.interactor.GetPopularActorsImp; 18 | import com.jaime.toca.MVPActors.domain.model.ActorsWrapper; 19 | import com.jaime.toca.MVPActors.mvp.views.PopularActorsView; 20 | import javax.inject.Inject; 21 | import rx.Subscription; 22 | 23 | public class PopularActorsPresenter implements Presenter { 24 | 25 | private GetPopularActorsImp mInteracPopularActors; 26 | private PopularActorsView mPopularActorsView; 27 | private Subscription mPopularActorsSubscription; 28 | 29 | @Inject 30 | public PopularActorsPresenter(GetPopularActorsImp getPopularActors){ 31 | mInteracPopularActors = getPopularActors; 32 | } 33 | 34 | public void attachView (PopularActorsView ActorsView) { 35 | mPopularActorsView = ActorsView; 36 | } 37 | 38 | @Override 39 | public void start() { 40 | if (mPopularActorsView.EmptyList()){ 41 | mPopularActorsView.showProgressBar(); 42 | mPopularActorsSubscription = mInteracPopularActors.execute().subscribe( 43 | ActorsWrapper -> popularActorsReceived(ActorsWrapper)); 44 | } 45 | } 46 | 47 | public void popularActorsReceived(ActorsWrapper actorsWrapper){ 48 | mPopularActorsView.showMovies(actorsWrapper.getResults()); 49 | mPopularActorsView.hideProgressBar(); 50 | } 51 | 52 | public void onActorClicked(Number actorId){ 53 | mPopularActorsView.viewActorProfile(actorId); 54 | } 55 | 56 | @Override 57 | public void stop() {} 58 | 59 | @Override 60 | public void destroy() {} 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/mvp/presenters/Presenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.mvp.presenters; 17 | 18 | public interface Presenter { 19 | void start (); 20 | void stop (); 21 | void destroy(); 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/mvp/views/ActorDetailView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.mvp.views; 17 | 18 | public interface ActorDetailView extends View { 19 | 20 | void showProgressBar(); 21 | 22 | void hideProgressBar(); 23 | 24 | void setName (String name); 25 | 26 | void setBirthday (String birthday); 27 | 28 | void setPlaceOfBirth(String placeOfBirth); 29 | 30 | void setHomePage (String homepage); 31 | 32 | void setBiography (String biography); 33 | 34 | void setActorImage (String urlActorPhoto); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/mvp/views/PopularActorsView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.mvp.views; 17 | 18 | import com.jaime.toca.MVPActors.domain.model.Actor; 19 | import java.util.List; 20 | 21 | public interface PopularActorsView extends View{ 22 | 23 | void showProgressBar(); 24 | 25 | void hideProgressBar(); 26 | 27 | void showMovies(List actorList); 28 | 29 | boolean EmptyList (); 30 | 31 | void viewActorProfile(Number position); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/mvp/views/View.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.mvp.views; 17 | 18 | /** 19 | * Created by Jaime Toca on 07/07/2015. 20 | */ 21 | public interface View { 22 | 23 | public android.content.Context getContext(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/ui/activities/ActorDetailActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.ui.activities; 17 | 18 | import android.app.Activity; 19 | import android.content.Context; 20 | import android.graphics.Typeface; 21 | import android.os.Bundle; 22 | import android.view.View; 23 | import android.widget.ImageView; 24 | import android.widget.ProgressBar; 25 | import android.widget.TextView; 26 | 27 | import com.jaime.toca.MVPActors.ActorsApp; 28 | import com.jaime.toca.MVPActors.R; 29 | import com.jaime.toca.MVPActors.di.components.DaggerActorDetailComponent; 30 | import com.jaime.toca.MVPActors.di.modules.ActorDetailModule; 31 | import com.jaime.toca.MVPActors.mvp.presenters.ActorDetailPresenter; 32 | import com.jaime.toca.MVPActors.mvp.views.ActorDetailView; 33 | import com.jaime.toca.MVPActors.utils.Constants; 34 | import com.squareup.picasso.Picasso; 35 | import com.squareup.picasso.Callback; 36 | 37 | import java.util.List; 38 | 39 | import javax.inject.Inject; 40 | 41 | import butterknife.Bind; 42 | import butterknife.ButterKnife; 43 | 44 | 45 | public class ActorDetailActivity extends Activity implements ActorDetailView { 46 | 47 | @Bind(R.id.detailProgressBar) ProgressBar mProgressBar; 48 | @Bind(R.id.actorPhoto) ImageView mActorPhoto; 49 | @Bind({ R.id.actorName, R.id.actorBirthday, R.id.actorPlaceOfBirth, 50 | R.id.actorHomepage, R.id.actorBiography }) 51 | List profileInformation; 52 | 53 | public static final int NAME = 0; 54 | public static final int BIRTHDAY = 1; 55 | public static final int PLACE_OF_BIRTH = 2; 56 | public static final int HOMEPAGE = 3; 57 | public static final int BIOGRAPHY = 4; 58 | 59 | private Bundle bundle; 60 | private String mActorId; 61 | private Typeface mType; 62 | @Inject 63 | ActorDetailPresenter mDetailActorPresenter; 64 | 65 | @Override 66 | protected void onCreate(Bundle savedInstanceState) { 67 | super.onCreate(savedInstanceState); 68 | setContentView(R.layout.user_detail); 69 | ButterKnife.bind(this); 70 | initializeDependencyInjector(); 71 | mDetailActorPresenter.attachView(this); 72 | mType = Typeface.createFromAsset(getAssets(), "Pacifico.ttf"); 73 | actorInformation(NAME).setTypeface(mType); 74 | } 75 | 76 | @Override 77 | protected void onStart() { 78 | super.onStart(); 79 | mDetailActorPresenter.start(); 80 | } 81 | 82 | private void initializeDependencyInjector() { 83 | bundle = getIntent().getExtras(); 84 | if (bundle != null) 85 | mActorId = bundle.getString("actorId"); 86 | 87 | ActorsApp app = (ActorsApp) getApplication(); 88 | DaggerActorDetailComponent.builder() 89 | .appComponent(app.getAppComponent()) 90 | .actorDetailModule(new ActorDetailModule(mActorId)) 91 | .build().inject(this); 92 | } 93 | 94 | public TextView actorInformation(int n){ 95 | return profileInformation.get(n); 96 | } 97 | 98 | @Override 99 | public Context getContext() { 100 | return this; 101 | } 102 | 103 | @Override 104 | public void showProgressBar(){ 105 | mProgressBar.setVisibility(View.VISIBLE); 106 | } 107 | 108 | @Override 109 | public void hideProgressBar(){ 110 | mProgressBar.setVisibility(View.GONE); 111 | } 112 | 113 | @Override 114 | public void setName (String name){ 115 | actorInformation(NAME).setText(name); 116 | } 117 | 118 | @Override 119 | public void setBirthday (String birthday){ 120 | actorInformation(BIRTHDAY).setText(birthday); 121 | } 122 | 123 | @Override 124 | public void setPlaceOfBirth(String placeOfBirth){ 125 | actorInformation(PLACE_OF_BIRTH).setText(placeOfBirth); 126 | } 127 | 128 | @Override 129 | public void setHomePage (String homepage){ 130 | actorInformation(HOMEPAGE).setText(homepage); 131 | } 132 | 133 | @Override 134 | public void setBiography (String biography){ 135 | actorInformation(BIOGRAPHY).setText(biography); 136 | } 137 | 138 | @Override 139 | public void setActorImage (String urlActorPhoto){ 140 | Picasso.with(this) 141 | .load(Constants.URL_BASE_PHOTOS + urlActorPhoto) 142 | .into(mActorPhoto,new Callback() { 143 | @Override 144 | public void onSuccess() { 145 | mDetailActorPresenter.onPictureLoaded(); 146 | } 147 | @Override 148 | public void onError() { 149 | mDetailActorPresenter.onPictureError(); 150 | } 151 | }); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/ui/activities/ActorsPopularActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.ui.activities; 17 | import android.app.Activity; 18 | import android.content.Intent; 19 | import android.graphics.Typeface; 20 | import android.os.Bundle; 21 | import android.support.v7.widget.Toolbar; 22 | import android.widget.TextView; 23 | import com.jaime.toca.MVPActors.ActorsApp; 24 | import com.jaime.toca.MVPActors.di.components.DaggerPopularActorsComponent; 25 | import com.jaime.toca.MVPActors.di.modules.PopularActorsModule; 26 | import com.jaime.toca.MVPActors.R; 27 | import com.jaime.toca.MVPActors.ui.fragments.ActorListFragment; 28 | import butterknife.Bind; 29 | import butterknife.ButterKnife; 30 | 31 | public class ActorsPopularActivity extends Activity 32 | implements ActorListFragment.ActorListListener{ 33 | 34 | @Bind(R.id.toolbarTitle) TextView mToolbarTittle; 35 | @Bind(R.id.toolbar) Toolbar mToolbar; 36 | private Typeface mType; 37 | 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.activity_main); 42 | ButterKnife.bind(this); 43 | initializeDependencyInjector(); 44 | initializeToolbar(); 45 | } 46 | 47 | private void initializeToolbar(){ 48 | mType = Typeface.createFromAsset(getAssets(), "Pacifico.ttf"); 49 | mToolbarTittle.setTypeface(mType); 50 | } 51 | 52 | private void initializeDependencyInjector() { 53 | ActorsApp app = (ActorsApp) getApplication(); 54 | DaggerPopularActorsComponent.builder() 55 | .appComponent(app.getAppComponent()) 56 | .popularActorsModule(new PopularActorsModule()) 57 | .build().inject(this); 58 | } 59 | 60 | public void onActorListClicked(Number actorId){ 61 | Intent activityDetail = new Intent(this, ActorDetailActivity.class); 62 | activityDetail.putExtra("actorId", actorId + ""); 63 | startActivity(activityDetail); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/ui/adapters/ActorsAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.ui.adapters; 17 | 18 | import android.support.v7.widget.RecyclerView; 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.ImageView; 23 | import android.widget.TextView; 24 | import com.jaime.toca.MVPActors.R; 25 | import com.jaime.toca.MVPActors.domain.model.Actor; 26 | import com.jaime.toca.MVPActors.ui.listeners.RecyclerViewClickListener; 27 | import java.util.List; 28 | 29 | import butterknife.Bind; 30 | import butterknife.ButterKnife; 31 | 32 | 33 | public class ActorsAdapter extends RecyclerView.Adapter { 34 | 35 | private List actorsList; 36 | private RecyclerViewClickListener RecyclerViewListener; 37 | 38 | public ActorsAdapter(List actorsList) { 39 | this.actorsList = actorsList; 40 | } 41 | 42 | public void setRecyclerViewListener(RecyclerViewClickListener RecyclerViewListener) { 43 | this.RecyclerViewListener = RecyclerViewListener; 44 | } 45 | 46 | public List getActorsList(){ 47 | return actorsList; 48 | } 49 | 50 | @Override 51 | public ActorViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 52 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_row, parent, false); 53 | return new ActorViewHolder(view); 54 | } 55 | 56 | 57 | @Override 58 | public void onBindViewHolder(final ActorViewHolder holder, int position) { 59 | final Actor actor = actorsList.get(position); 60 | holder.name.setText(actor.getName()); 61 | holder.itemView.setOnClickListener(new View.OnClickListener() { 62 | @Override 63 | public void onClick(View v) { 64 | RecyclerViewListener.onClickRecyclerItem(v, actor.getId()); 65 | } 66 | }); 67 | } 68 | 69 | @Override 70 | public int getItemCount(){ 71 | if (actorsList != null) 72 | return actorsList.size(); 73 | else return 0; 74 | } 75 | 76 | @Override 77 | public long getItemId(int position) { 78 | return position; 79 | } 80 | 81 | static class ActorViewHolder extends RecyclerView.ViewHolder { 82 | @Bind(R.id.name) TextView name; 83 | 84 | public ActorViewHolder(View itemView) { 85 | super(itemView); 86 | ButterKnife.bind(this, itemView); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/ui/adapters/DividerItemDecoration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.ui.adapters; 17 | import android.content.Context; 18 | import android.graphics.Canvas; 19 | import android.graphics.drawable.Drawable; 20 | import android.support.v7.widget.RecyclerView; 21 | import android.view.View; 22 | import com.jaime.toca.MVPActors.R; 23 | 24 | /* 25 | * GITHUB Discussion thread for ItemDivider Implementation 26 | * 27 | * https://gist.github.com/polbins/e37206fbc444207c0e92 28 | */ 29 | public class DividerItemDecoration extends RecyclerView.ItemDecoration { 30 | 31 | private Drawable mDivider; 32 | 33 | public DividerItemDecoration(Context context) { 34 | mDivider = context.getResources().getDrawable(R.drawable.divider); 35 | } 36 | 37 | @Override 38 | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { 39 | int left = parent.getPaddingLeft(); 40 | int right = parent.getWidth() - parent.getPaddingRight() ; 41 | 42 | int childCount = parent.getChildCount(); 43 | for (int i = 0; i < childCount; i++) { 44 | 45 | View child = parent.getChildAt(i); 46 | 47 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); 48 | 49 | int top = child.getBottom() + params.bottomMargin; 50 | int bottom = top + mDivider.getIntrinsicHeight(); 51 | 52 | mDivider.setBounds(left, top, right, bottom); 53 | mDivider.draw(c); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/ui/fragments/ActorListFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.jaime.toca.MVPActors.ui.fragments; 18 | import android.app.Activity; 19 | import android.app.Fragment; 20 | import android.content.Context; 21 | import android.os.Bundle; 22 | import android.support.v7.widget.LinearLayoutManager; 23 | import android.support.v7.widget.RecyclerView; 24 | import android.view.LayoutInflater; 25 | import android.view.View; 26 | import android.view.ViewGroup; 27 | import android.widget.ProgressBar; 28 | 29 | import com.jaime.toca.MVPActors.ActorsApp; 30 | import com.jaime.toca.MVPActors.R; 31 | import com.jaime.toca.MVPActors.di.components.DaggerPopularActorsComponent; 32 | import com.jaime.toca.MVPActors.di.modules.PopularActorsModule; 33 | import com.jaime.toca.MVPActors.domain.model.Actor; 34 | import com.jaime.toca.MVPActors.mvp.presenters.PopularActorsPresenter; 35 | import com.jaime.toca.MVPActors.mvp.views.PopularActorsView; 36 | import com.jaime.toca.MVPActors.ui.adapters.ActorsAdapter; 37 | import com.jaime.toca.MVPActors.ui.adapters.DividerItemDecoration; 38 | import com.jaime.toca.MVPActors.ui.listeners.RecyclerViewClickListener; 39 | import java.util.List; 40 | import javax.inject.Inject; 41 | import butterknife.Bind; 42 | import butterknife.ButterKnife; 43 | 44 | public class ActorListFragment extends Fragment implements PopularActorsView { 45 | 46 | public interface ActorListListener { 47 | void onActorListClicked(Number actorId); 48 | } 49 | 50 | /* View Bindings */ 51 | @Bind(R.id.listProgressBar) ProgressBar progressBar; 52 | @Bind(R.id.actorsList) RecyclerView recyclerView; 53 | 54 | @Inject 55 | PopularActorsPresenter popularActorsPresenter; 56 | 57 | private ActorsAdapter adapter; 58 | private ActorListListener actorListListener; 59 | 60 | @Override 61 | public void onAttach(Activity activity) { 62 | super.onAttach(activity); 63 | actorListListener = (ActorListListener) activity; 64 | } 65 | 66 | @Override 67 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 68 | 69 | View fragmentView = inflater.inflate(R.layout.fragment_list, container, true); 70 | ButterKnife.bind(this, fragmentView); 71 | 72 | /* RecyclerView settings */ 73 | recyclerView.setHasFixedSize(true); 74 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); 75 | recyclerView.addItemDecoration(new DividerItemDecoration( 76 | getActivity() 77 | )); 78 | 79 | return fragmentView; 80 | } 81 | 82 | @Override public void onActivityCreated(Bundle savedInstanceState) { 83 | super.onActivityCreated(savedInstanceState); 84 | initializeDependencyInjector(); 85 | } 86 | 87 | private void initializeDependencyInjector() { 88 | ActorsApp app = (ActorsApp) getActivity().getApplication(); 89 | 90 | DaggerPopularActorsComponent.builder() 91 | .appComponent(app.getAppComponent()) 92 | .popularActorsModule(new PopularActorsModule()) 93 | .build().inject(this); 94 | } 95 | 96 | @Override 97 | public void onResume() { 98 | super.onResume(); 99 | popularActorsPresenter.attachView(this); 100 | popularActorsPresenter.start(); 101 | } 102 | 103 | @Override 104 | public void onStop() { 105 | super.onStop(); 106 | } 107 | 108 | @Override 109 | public void onDestroy() { 110 | super.onDestroy(); 111 | } 112 | 113 | @Override 114 | public void onDestroyView() { 115 | super.onDestroyView(); 116 | ButterKnife.unbind(this); 117 | } 118 | 119 | @Override 120 | public Context getContext() { 121 | return this.getActivity().getApplicationContext(); 122 | } 123 | 124 | @Override 125 | public void viewActorProfile(Number actorId){ 126 | actorListListener.onActorListClicked(actorId); 127 | } 128 | 129 | @Override 130 | public void showProgressBar(){ 131 | progressBar.setVisibility(View.VISIBLE); 132 | } 133 | 134 | @Override 135 | public void hideProgressBar(){ 136 | progressBar.setVisibility(View.GONE); 137 | } 138 | 139 | @Override 140 | public boolean EmptyList (){ 141 | return (adapter == null); 142 | } 143 | 144 | @Override 145 | public void showMovies(List actorsList){ 146 | startAdapter(actorsList); 147 | } 148 | 149 | public void startAdapter(final List actorsList){ 150 | adapter = new ActorsAdapter(actorsList); 151 | recyclerView.setAdapter(adapter); 152 | 153 | adapter.setRecyclerViewListener(new RecyclerViewClickListener() { 154 | @Override 155 | public void onClickRecyclerItem(View v, Number actorId) { 156 | popularActorsPresenter.onActorClicked(actorId); 157 | } 158 | }); 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/ui/listeners/RecyclerViewClickListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.ui.listeners; 17 | 18 | import android.view.View; 19 | 20 | 21 | public interface RecyclerViewClickListener { 22 | 23 | /* callback method for recyclerview click */ 24 | public void onClickRecyclerItem(View v, Number position); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/jaime/toca/MVPActors/utils/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Jaime Toca. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.jaime.toca.MVPActors.utils; 17 | 18 | public class Constants { 19 | public static final String HOST = "http://api.themoviedb.org/3/"; 20 | public static final String API_KEY = "ef7207d60c949efbe23d1d2c0d580eb2"; 21 | public static final int MIN_URL_SIZE = 2; 22 | public static final String URL_BASE_PHOTOS = "https://image.tmdb.org/t/p/original/"; 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_person_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/drawable-hdpi/ic_person_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_person_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/drawable-mdpi/ic_person_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_person_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/drawable-xhdpi/ic_person_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_person_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/drawable-xxhdpi/ic_person_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_person_black_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/drawable-xxxhdpi/ic_person_black_18dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/person_.photo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/drawable/person_.photo.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 15 | 16 | 21 | 22 | 27 | 28 | 29 | 30 | 31 | 32 | 40 | 41 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_row.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 22 | 23 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/user_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 15 | 16 | 20 | 21 | 27 | 28 | 39 | 40 | 41 | 42 | 47 | 48 | 49 | 56 | 57 | 61 | 66 | 67 | 72 | 77 | 78 | 82 | 83 | 88 | 89 | 93 | 94 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #0D47A1 4 | #64B5F6 5 | #BBDEFB 6 | #E3F2FD 7 | #FFFFFF 8 | #000000 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 2dp 7 | 8 | 22sp 9 | 10 | 5dp 11 | 20sp 12 | 13 | 50dp 14 | 5dp 15 | 16 | 180dp 17 | 32sp 18 | 5dp 19 | 15dp 20 | 15dp 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Actors Database 3 | Hello world! 4 | Settings 5 | Done 6 | ActorAPP 7 | 8 | Cannot access view 9 | 10 | NAME 11 | PLACE OF BIRTH 12 | BIRTHDAY 13 | HOMEPAGE 14 | BIOGRAPHY 15 | none 16 | unknown 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 16 | 17 | 18 | 24 | 25 | 26 | 27 | 39 | 40 | 41 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.2.3' 9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' 10 | classpath 'me.tatarka:gradle-retrolambda:3.1.0' 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | jcenter() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /captures/SystemInfo_2015.08.07_19.45.41.txt: -------------------------------------------------------------------------------- 1 | TASK toca.jaime.com.pruebas id=76 2 | ACTIVITY toca.jaime.com.pruebas/com.jaime.toca.MVPActors.ui.activities.ActorsPopularActivity 219be4ca pid=2199 3 | Local Activity 3db843a4 State: 4 | mResumed=true mStopped=false mFinished=false 5 | mLoadersStarted=true 6 | mChangingConfigurations=false 7 | mCurrentConfig={1.0 310mcc260mnc en_US ?layoutDir sw360dp w360dp h567dp 480dpi nrml port finger -keyb/v/h -nav/h s.5} 8 | Active Fragments in 15f11e48: 9 | #0: ActorListFragment{29404e1 #0 id=0x7f0c006c} 10 | mFragmentId=#7f0c006c mContainerId=#7f0c006b mTag=null 11 | mState=5 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0 12 | mAdded=true mRemoving=false mResumed=true mFromLayout=true mInLayout=true 13 | mHidden=false mDetached=false mMenuVisible=true mHasMenu=false 14 | mRetainInstance=false mRetaining=false mUserVisibleHint=true 15 | mFragmentManager=FragmentManager{15f11e48 in ActorsPopularActivity{3db843a4}} 16 | mActivity=com.jaime.toca.MVPActors.ui.activities.ActorsPopularActivity@3db843a4 17 | mView=android.widget.RelativeLayout{1988d206 V.E..... ........ 6,6-1074,1695 #7f0c006c app:id/fragmentUserList} 18 | Child FragmentManager{5e370c7 in ActorListFragment{29404e1}}: 19 | FragmentManager misc state: 20 | mActivity=com.jaime.toca.MVPActors.ui.activities.ActorsPopularActivity@3db843a4 21 | mContainer=android.app.Fragment$1@f1dd6f4 22 | mParent=ActorListFragment{29404e1 #0 id=0x7f0c006c} 23 | mCurState=5 mStateSaved=false mDestroyed=false 24 | Added Fragments: 25 | #0: ActorListFragment{29404e1 #0 id=0x7f0c006c} 26 | FragmentManager misc state: 27 | mActivity=com.jaime.toca.MVPActors.ui.activities.ActorsPopularActivity@3db843a4 28 | mContainer=android.app.Activity$1@3beb0e1d 29 | mCurState=5 mStateSaved=false mDestroyed=false 30 | ViewRoot: 31 | mAdded=true mRemoved=false 32 | mConsumeBatchedInputScheduled=false 33 | mConsumeBatchedInputImmediatelyScheduled=false 34 | mPendingInputEventCount=0 35 | mProcessInputEventsScheduled=false 36 | mTraversalScheduled=false 37 | android.view.ViewRootImpl$NativePreImeInputStage: mQueueLength=0 38 | android.view.ViewRootImpl$ImeInputStage: mQueueLength=0 39 | android.view.ViewRootImpl$NativePostImeInputStage: mQueueLength=0 40 | Choreographer: 41 | mFrameScheduled=false 42 | mLastFrameTime=70649 (523304 ms ago) 43 | View Hierarchy: 44 | com.android.internal.policy.impl.PhoneWindow$DecorView{28d00892 V.E..... R....... 0,0-1080,1920} 45 | android.widget.LinearLayout{361c5263 V.E..... ........ 0,0-1080,1776} 46 | android.view.ViewStub{6bb6e60 G.E..... ......I. 0,0-0,0 #1020373} 47 | android.widget.FrameLayout{37af6f19 V.E..... ........ 0,75-1080,1776 #1020002 android:id/content} 48 | android.support.design.widget.CoordinatorLayout{2fe21bde V.E..... ........ 0,0-1080,1701 #7f0c0067 app:id/coordinatorLayout} 49 | android.support.design.widget.AppBarLayout{3377b1bf V.E..... ........ 0,0-1080,168 #7f0c0068 app:id/appBarLayout} 50 | android.support.v7.widget.Toolbar{1ad9108c V.E..... ........ 0,0-1080,168 #7f0c0069 app:id/toolbar} 51 | android.widget.TextView{29bee3d5 V.ED.... ........ 48,27-495,141 #7f0c006a app:id/toolbarTitle} 52 | android.widget.RelativeLayout{3b7017ea V.E..... ........ 0,0-1080,1701 #7f0c006b app:id/fragmentContainer} 53 | android.widget.RelativeLayout{1988d206 V.E..... ........ 6,6-1074,1695 #7f0c006c app:id/fragmentUserList} 54 | android.support.v7.widget.RecyclerView{1effaadb VFED.V.. .F...... 0,0-1068,1689 #7f0c006d app:id/actorsList} 55 | android.widget.LinearLayout{194ca978 V.E...C. ........ 0,0-1068,180} 56 | android.widget.ImageView{2c16e851 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 57 | android.widget.TextView{2fc8b6 V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 58 | android.widget.LinearLayout{164419b7 V.E...C. ........ 0,180-1068,360} 59 | android.widget.ImageView{155ee524 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 60 | android.widget.TextView{2110b88d V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 61 | android.widget.LinearLayout{3667ba42 V.E...C. ........ 0,360-1068,540} 62 | android.widget.ImageView{15f69a53 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 63 | android.widget.TextView{2c372f90 V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 64 | android.widget.LinearLayout{3d5d5089 V.E...C. ........ 0,540-1068,720} 65 | android.widget.ImageView{223b388e V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 66 | android.widget.TextView{2a4688af V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 67 | android.widget.LinearLayout{2407b4bc V.E...C. ........ 0,720-1068,900} 68 | android.widget.ImageView{35c16c45 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 69 | android.widget.TextView{14b64f9a V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 70 | android.widget.LinearLayout{8fd00cb V.E...C. ........ 0,900-1068,1080} 71 | android.widget.ImageView{11f960a8 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 72 | android.widget.TextView{c9187c1 V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 73 | android.widget.LinearLayout{3199cb66 V.E...C. ........ 0,1080-1068,1260} 74 | android.widget.ImageView{3158dea7 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 75 | android.widget.TextView{32d7df54 V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 76 | android.widget.LinearLayout{3aeddefd V.E...C. ........ 0,1260-1068,1440} 77 | android.widget.ImageView{5e737f2 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 78 | android.widget.TextView{2daabe43 V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 79 | android.widget.LinearLayout{227d9cc0 V.E...C. ........ 0,1440-1068,1620} 80 | android.widget.ImageView{31be6df9 V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 81 | android.widget.TextView{3b2ce13e V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 82 | android.widget.LinearLayout{12b0fb9f V.E...C. ........ 0,1620-1068,1800} 83 | android.widget.ImageView{1dffc4ec V.ED.... ........ 15,15-165,165 #7f0c006f app:id/avatar} 84 | android.widget.TextView{2e6ef0b5 V.ED.... ........ 165,15-1053,165 #7f0c0070 app:id/name} 85 | android.widget.ProgressBar{3391d34a G.ED.... ......ID 451,762-616,927 #7f0c006e app:id/listProgressBar} 86 | android.view.View{18b3b2bb V.ED.... ........ 0,0-1080,75 #102002f android:id/statusBarBackground} 87 | android.view.View{3c9a43d8 V.ED.... ........ 0,1776-1080,1920 #1020030 android:id/navigationBarBackground} 88 | Looper (main, tid 1) {1f6ae331} 89 | (Total messages: 0, idling=false, quitting=false) 90 | -------------------------------------------------------------------------------- /captures/SystemInfo_2015.08.07_19.45.55.txt: -------------------------------------------------------------------------------- 1 | Activity Resolver Table: 2 | Non-Data Actions: 3 | android.intent.action.MAIN: 4 | 340f944b toca.jaime.com.pruebas/com.jaime.toca.MVPActors.ui.activities.ActorsPopularActivity 5 | 6 | Key Set Manager: 7 | [toca.jaime.com.pruebas] 8 | Signing KeySets: 99 9 | 10 | Packages: 11 | Package [toca.jaime.com.pruebas] (1f77fdd2): 12 | userId=10057 gids=[3003] 13 | pkg=Package{26d32e28 toca.jaime.com.pruebas} 14 | codePath=/data/app/toca.jaime.com.pruebas-2 15 | resourcePath=/data/app/toca.jaime.com.pruebas-2 16 | legacyNativeLibraryDir=/data/app/toca.jaime.com.pruebas-2/lib 17 | primaryCpuAbi=null 18 | secondaryCpuAbi=null 19 | versionCode=1 targetSdk=21 20 | versionName=1.0 21 | splits=[base] 22 | applicationInfo=ApplicationInfo{3aeb0741 toca.jaime.com.pruebas} 23 | flags=[ DEBUGGABLE HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] 24 | dataDir=/data/data/toca.jaime.com.pruebas 25 | supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] 26 | timeStamp=2015-08-07 18:36:47 27 | firstInstallTime=2015-07-30 18:10:15 28 | lastUpdateTime=2015-08-07 18:36:48 29 | signatures=PackageSignatures{34cad559 [f8e14e6]} 30 | permissionsFixed=true haveGids=true installStatus=1 31 | pkgFlags=[ DEBUGGABLE HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP ] 32 | User 0: installed=true hidden=false stopped=false notLaunched=false enabled=0 33 | grantedPermissions: 34 | android.permission.INTERNET 35 | -------------------------------------------------------------------------------- /captures/SystemInfo_2015.08.07_19.46.00.txt: -------------------------------------------------------------------------------- 1 | Applications Memory Usage (kB): 2 | Uptime: 612219 Realtime: 612220 3 | 4 | ** MEMINFO in pid 2199 [toca.jaime.com.pruebas] ** 5 | Pss Private Private Swapped Heap Heap Heap 6 | Total Dirty Clean Dirty Size Alloc Free 7 | ------ ------ ------ ------ ------ ------ ------ 8 | Native Heap 3291 3228 0 0 16384 13529 2854 9 | Dalvik Heap 2263 2212 0 0 2094 1690 404 10 | Dalvik Other 336 336 0 0 11 | Stack 108 108 0 0 12 | Other dev 4 0 4 0 13 | .so mmap 889 104 16 0 14 | .apk mmap 222 0 80 0 15 | .ttf mmap 14 0 8 0 16 | .dex mmap 3284 0 3280 0 17 | .oat mmap 1378 0 176 0 18 | .art mmap 940 572 8 0 19 | Other mmap 6 4 0 0 20 | Unknown 77 76 0 0 21 | TOTAL 12812 6640 3572 0 18478 15219 3258 22 | 23 | Objects 24 | Views: 44 ViewRootImpl: 1 25 | AppContexts: 3 Activities: 1 26 | Assets: 3 AssetManagers: 3 27 | Local Binders: 7 Proxy Binders: 12 28 | Parcel memory: 2 Parcel count: 10 29 | Death Recipients: 0 OpenSSL Sockets: 0 30 | 31 | SQL 32 | MEMORY_USED: 0 33 | PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0 34 | 35 | 36 | Asset Allocations 37 | zip:/data/app/toca.jaime.com.pruebas-2/base.apk:/assets/Pacifico.ttf: 74K 38 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /pictures/list-optimized.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/pictures/list-optimized.gif -------------------------------------------------------------------------------- /pictures/mvp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/pictures/mvp.png -------------------------------------------------------------------------------- /pictures/profile-optimized.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/pictures/profile-optimized.gif -------------------------------------------------------------------------------- /pictures/row-optimazed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaimeToca/AndroidMVP/c0c137df3204d08d8dfcb7400847e65ca646caf0/pictures/row-optimazed.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------