├── .gitignore
├── README.md
├── app_java
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── tech
│ │ └── thdev
│ │ └── android_mvp_sample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── tech
│ │ │ └── thdev
│ │ │ └── android_mvp_sample
│ │ │ ├── adapter
│ │ │ ├── ImageAdapter.java
│ │ │ ├── contract
│ │ │ │ └── ImageAdapterContract.java
│ │ │ └── holder
│ │ │ │ └── ImageViewHolder.java
│ │ │ ├── data
│ │ │ ├── ImageItem.java
│ │ │ └── source
│ │ │ │ └── image
│ │ │ │ ├── SampleImageLocalDataSource.java
│ │ │ │ ├── SampleImageRepository.java
│ │ │ │ └── SampleImageSource.java
│ │ │ ├── listener
│ │ │ └── OnItemClickListener.java
│ │ │ ├── util
│ │ │ └── ImageAsync.java
│ │ │ └── view
│ │ │ └── main
│ │ │ ├── MainActivity.java
│ │ │ └── presenter
│ │ │ ├── MainContract.java
│ │ │ └── MainPresenter.java
│ └── res
│ │ ├── drawable
│ │ ├── reload.png
│ │ ├── sample_00.png
│ │ ├── sample_01.png
│ │ ├── sample_02.png
│ │ ├── sample_03.png
│ │ ├── sample_04.png
│ │ ├── sample_05.png
│ │ ├── sample_06.png
│ │ ├── sample_07.png
│ │ ├── sample_08.png
│ │ ├── sample_09.png
│ │ ├── sample_10.png
│ │ ├── sample_11.png
│ │ ├── sample_12.png
│ │ ├── sample_13.png
│ │ └── sample_14.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── content_main.xml
│ │ └── item_image.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
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── tech
│ └── thdev
│ └── android_mvp_sample
│ └── ExampleUnitTest.java
├── app_kotlin
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── tech
│ │ └── thdev
│ │ └── app_kotlin
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── tech
│ │ │ └── thdev
│ │ │ └── app_kotlin
│ │ │ ├── adapter
│ │ │ ├── ImageAdapter.kt
│ │ │ ├── ImageViewHolder.kt
│ │ │ └── contract
│ │ │ │ └── ImageAdapterContract.kt
│ │ │ ├── data
│ │ │ ├── ImageItem.kt
│ │ │ └── source
│ │ │ │ └── image
│ │ │ │ ├── SampleImageLocalDataSource.kt
│ │ │ │ ├── SampleImageRepository.kt
│ │ │ │ └── SampleImageSource.kt
│ │ │ ├── util
│ │ │ └── ImageAsync.kt
│ │ │ └── view
│ │ │ └── main
│ │ │ ├── MainActivity.kt
│ │ │ └── presenter
│ │ │ ├── MainContract.kt
│ │ │ └── MainPresenter.kt
│ └── res
│ │ ├── drawable
│ │ ├── reload.png
│ │ ├── sample_00.png
│ │ ├── sample_01.png
│ │ ├── sample_02.png
│ │ ├── sample_03.png
│ │ ├── sample_04.png
│ │ ├── sample_05.png
│ │ ├── sample_06.png
│ │ ├── sample_07.png
│ │ ├── sample_08.png
│ │ ├── sample_09.png
│ │ ├── sample_10.png
│ │ ├── sample_11.png
│ │ ├── sample_12.png
│ │ ├── sample_13.png
│ │ └── sample_14.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── content_main.xml
│ │ └── item_image.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
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── tech
│ └── thdev
│ └── app_kotlin
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
└── device-2016-10-23-174436.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /captures
3 | .externalNativeBuild
4 | ### Android template
5 | # Built application files
6 | *.apk
7 | *.ap_
8 |
9 | # Files for the ART/Dalvik VM
10 | *.dex
11 |
12 | # Java class files
13 | *.class
14 |
15 | # Generated files
16 | bin/
17 | gen/
18 | out/
19 |
20 | # Gradle files
21 | .gradle/
22 | build/
23 | .idea/
24 |
25 | # Local configuration file (sdk path, etc)
26 | local.properties
27 |
28 | # Proguard folder generated by Eclipse
29 | proguard/
30 |
31 | # Log Files
32 | *.log
33 |
34 | # Android Studio Navigation editor temp files
35 | .navigation/
36 |
37 | # Android Studio captures folder
38 | captures/
39 |
40 | # Intellij
41 | *.iml
42 | .idea/workspace.xml
43 |
44 | # Keystore files
45 | *.jks
46 |
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android MVP Sample
2 |
3 | []()
4 |
5 | Android MVP Sample.
6 |
7 | ## Sample list
8 |
9 | - [Java](https://github.com/taehwandev/AndroidMVPSample/app_java)
10 | - [Kotlin](https://github.com/taehwandev/AndroidMVPSample/app_kotlin)
11 |
12 | ## Blog post
13 |
14 | 한국어 자료
15 | - [Android MVP 무작정 따라하기 - Intro](http://thdev.tech/androiddev/2016/10/12/Android-MVP-Intro.html)
16 | - [Android MVP 무작정 따라하기 - MVC 구조 이해하기](http://thdev.tech/androiddev/2016/10/23/Android-MVC-Architecture.html)
17 | - [Android MVP 무작정 따라하기 - Presenter/View 생성하기](http://thdev.tech/androiddev/2016/11/28/Android-MVP-One.html)
18 | - [Android MVP 무작정 따라하기 - Presenter/View 생성하기 Other](http://thdev.tech/androiddev/2016/11/30/Android-MVP-Two.html)
19 | - [Android MVP 무작정 따라하기 - Presenter 분리하기](http://thdev.tech/androiddev/2016/12/23/Android-MVP-Three.html)
20 | - [Android MVP 무작정 따라하기 - Adapter Contract 정의하기](http://thdev.tech/androiddev/2016/12/26/Android-MVP-Four.html)
21 | - [Android MVP 무작정 따라하기 - Adapter Contract 정의하기 2번째(동영상)](http://thdev.tech/androiddev/2016/12/27/Android-MVP-Four-Two.html)
22 | - [Android MVP 무작정 따라하기 - Adapter OnClick 정의하기(동영상)](http://thdev.tech/androiddev/2016/12/29/Android-MVP-Four-Three.html)
23 | - [Android MVP 무작정 따라하기 - Model 정의하기](http://thdev.tech/androiddev/2016/12/29/Android-MVP-Model-One.html)
24 | - [Android MVP 무작정 따라하기 - Google Architecture의 Model](http://thdev.tech/androiddev/2017/01/09/Android-MVP-Model-Two.html)
25 | - [Android MVP 무작정 따라하기 - Google Architecture Model(영상 포함)](http://thdev.tech/androiddev/2017/01/29/Android-MVP-Google-Architecture-Model.html)
26 |
27 | ## License
28 |
29 | ```
30 | Copyright 2017 Tae-hwan
31 |
32 | Licensed under the Apache License, Version 2.0 (the "License");
33 | you may not use this file except in compliance with the License.
34 | You may obtain a copy of the License at
35 |
36 | http://www.apache.org/licenses/LICENSE-2.0
37 |
38 | Unless required by applicable law or agreed to in writing, software
39 | distributed under the License is distributed on an "AS IS" BASIS,
40 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 | See the License for the specific language governing permissions and
42 | limitations under the License.
43 | ```
44 |
--------------------------------------------------------------------------------
/app_java/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app_java/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion compileSdkVersionInfo
5 | buildToolsVersion buildToolsVersionInfo
6 |
7 | defaultConfig {
8 | applicationId "tech.thdev.android_mvp_sample"
9 | minSdkVersion minSdkVerisonInfo
10 | targetSdkVersion targetSdkVersionInfo
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | compileOptions {
25 | sourceCompatibility JavaVersion.VERSION_1_8
26 | targetCompatibility JavaVersion.VERSION_1_8
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 |
33 | implementation "androidx.appcompat:appcompat:$appcompatVersion"
34 | implementation "com.google.android.material:material:$materialVersion"
35 |
36 | // ButterKnife
37 | implementation "com.jakewharton:butterknife:$butterKnifeVersion"
38 | annotationProcessor "com.jakewharton:butterknife-compiler:$butterKnifeVersion"
39 |
40 | // Image library
41 | implementation "com.github.bumptech.glide:glide:$glideVersion"
42 | annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
43 | }
--------------------------------------------------------------------------------
/app_java/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 /Users/tae-hwan/Library/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_java/src/androidTest/java/tech/thdev/android_mvp_sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("tech.thdev.android_mvp_sample", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app_java/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/adapter/ImageAdapter.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.adapter;
2 |
3 | import android.view.ViewGroup;
4 |
5 | import androidx.annotation.NonNull;
6 | import androidx.recyclerview.widget.RecyclerView;
7 |
8 | import java.util.ArrayList;
9 |
10 | import tech.thdev.android_mvp_sample.adapter.contract.ImageAdapterContract;
11 | import tech.thdev.android_mvp_sample.adapter.holder.ImageViewHolder;
12 | import tech.thdev.android_mvp_sample.data.ImageItem;
13 | import tech.thdev.android_mvp_sample.listener.OnItemClickListener;
14 |
15 | /**
16 | * Created by tae-hwan on 10/23/16.
17 | */
18 | public class ImageAdapter extends RecyclerView.Adapter implements ImageAdapterContract.Model, ImageAdapterContract.View {
19 |
20 | private OnItemClickListener onItemClickListener;
21 |
22 | private ArrayList imageItems;
23 |
24 | @Override
25 | public void addItems(ArrayList imageItems) {
26 | this.imageItems = imageItems;
27 | }
28 |
29 | @Override
30 | public void clearItem() {
31 | if (imageItems != null) {
32 | imageItems.clear();
33 | }
34 | }
35 |
36 | @Override
37 | public void notifyAdapter() {
38 | notifyDataSetChanged();
39 | }
40 |
41 | @Override
42 | public int getItemCount() {
43 | return imageItems != null ? imageItems.size() : 0;
44 | }
45 |
46 | @NonNull
47 | @Override
48 | public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
49 | return new ImageViewHolder(parent, onItemClickListener);
50 | }
51 |
52 | @Override
53 | public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
54 | holder.onBind(getItem(position), position);
55 | }
56 |
57 | @Override
58 | public void setOnClickListener(OnItemClickListener clickListener) {
59 | this.onItemClickListener = clickListener;
60 | }
61 |
62 | @Override
63 | public ImageItem getItem(int position) {
64 | return imageItems.get(position);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/adapter/contract/ImageAdapterContract.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.adapter.contract;
2 |
3 | import java.util.ArrayList;
4 |
5 | import tech.thdev.android_mvp_sample.data.ImageItem;
6 | import tech.thdev.android_mvp_sample.listener.OnItemClickListener;
7 |
8 | /**
9 | * Created by tae-hwan on 12/27/16.
10 | */
11 | public interface ImageAdapterContract {
12 |
13 | interface View {
14 |
15 | void setOnClickListener(OnItemClickListener clickListener);
16 |
17 | void notifyAdapter();
18 | }
19 |
20 | interface Model {
21 |
22 | void addItems(ArrayList imageItems);
23 |
24 | void clearItem();
25 |
26 | ImageItem getItem(int position);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/adapter/holder/ImageViewHolder.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.adapter.holder;
2 |
3 | import android.view.LayoutInflater;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.ImageView;
7 |
8 | import androidx.recyclerview.widget.RecyclerView;
9 |
10 | import butterknife.BindView;
11 | import butterknife.ButterKnife;
12 | import tech.thdev.android_mvp_sample.R;
13 | import tech.thdev.android_mvp_sample.data.ImageItem;
14 | import tech.thdev.android_mvp_sample.listener.OnItemClickListener;
15 | import tech.thdev.android_mvp_sample.util.ImageAsync;
16 |
17 | /**
18 | * Created by tae-hwan on 12/26/16.
19 | */
20 | public class ImageViewHolder extends RecyclerView.ViewHolder {
21 |
22 | private OnItemClickListener onItemClickListener;
23 |
24 | @BindView(R.id.img_view)
25 | ImageView imageView;
26 |
27 | public ImageViewHolder(ViewGroup parent, OnItemClickListener onItemClickListener) {
28 | super(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_image, parent, false));
29 |
30 | this.onItemClickListener = onItemClickListener;
31 |
32 | ButterKnife.bind(this, itemView);
33 | }
34 |
35 | public void onBind(ImageItem item, final int position) {
36 | itemView.setOnClickListener(new View.OnClickListener() {
37 |
38 | @Override
39 | public void onClick(View v) {
40 | if (onItemClickListener != null) {
41 | onItemClickListener.onItemClick(position);
42 | }
43 | }
44 | });
45 |
46 | new ImageAsync(imageView.getContext(), imageView).execute(item.getImageRes());
47 | }
48 | }
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/data/ImageItem.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.data;
2 |
3 | /**
4 | * Created by tae-hwan on 10/23/16.
5 | */
6 | public class ImageItem {
7 |
8 | private int imageRes;
9 | private String title;
10 |
11 | public ImageItem(int imageRes, String title) {
12 | this.imageRes = imageRes;
13 | this.title = title;
14 | }
15 |
16 | public int getImageRes() {
17 | return imageRes;
18 | }
19 |
20 | public String getTitle() {
21 | return title;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/data/source/image/SampleImageLocalDataSource.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.data.source.image;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 |
7 | import tech.thdev.android_mvp_sample.data.ImageItem;
8 |
9 | /**
10 | * Created by tae-hwan on 1/30/17.
11 | */
12 | public class SampleImageLocalDataSource implements SampleImageSource {
13 |
14 | @Override
15 | public void getImages(Context context, int size, LoadImageCallback loadImageCallback) {
16 | ArrayList items = new ArrayList<>();
17 |
18 | for (int i = 0; i < size; i++) {
19 | final int random = (int) (Math.random() * 15);
20 | final String name = String.format("sample_%02d", random);
21 | final int resource = context.getResources().getIdentifier(name, "drawable", context.getApplicationContext().getPackageName());
22 | items.add(new ImageItem(resource, name));
23 | }
24 |
25 | if (loadImageCallback != null) {
26 | loadImageCallback.onImageLoaded(items);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/data/source/image/SampleImageRepository.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.data.source.image;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 |
7 | import tech.thdev.android_mvp_sample.data.ImageItem;
8 |
9 | /**
10 | * Created by tae-hwan on 1/30/17.
11 | *
12 | * Memory cache / Local/Remote DataSource
13 | */
14 | public class SampleImageRepository implements SampleImageSource {
15 |
16 | private static SampleImageRepository sampleImageRepository;
17 |
18 | public static SampleImageRepository getInstance() {
19 | if (sampleImageRepository == null) {
20 | sampleImageRepository = new SampleImageRepository();
21 | }
22 | return sampleImageRepository;
23 | }
24 |
25 | private SampleImageLocalDataSource sampleImageLocalDataSource;
26 |
27 | private SampleImageRepository() {
28 | sampleImageLocalDataSource = new SampleImageLocalDataSource();
29 | }
30 |
31 | @Override
32 | public void getImages(Context context, int size, final LoadImageCallback loadImageCallback) {
33 | sampleImageLocalDataSource.getImages(context, size, new LoadImageCallback() {
34 | @Override
35 | public void onImageLoaded(ArrayList list) {
36 | if (loadImageCallback != null) {
37 | loadImageCallback.onImageLoaded(list);
38 | }
39 | }
40 | });
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/data/source/image/SampleImageSource.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.data.source.image;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 |
7 | import tech.thdev.android_mvp_sample.data.ImageItem;
8 |
9 | /**
10 | * Created by tae-hwan on 1/30/17.
11 | */
12 | public interface SampleImageSource {
13 |
14 | interface LoadImageCallback {
15 |
16 | void onImageLoaded(ArrayList list);
17 | }
18 |
19 | void getImages(Context context, int size, LoadImageCallback loadImageCallback);
20 | }
21 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/listener/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.listener;
2 |
3 | /**
4 | * Created by tae-hwan on 12/26/16.
5 | */
6 | public interface OnItemClickListener {
7 |
8 | void onItemClick(int position);
9 | }
10 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/util/ImageAsync.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.util;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.os.AsyncTask;
7 | import android.widget.ImageView;
8 |
9 | import java.lang.ref.WeakReference;
10 |
11 | /**
12 | * Created by tae-hwan on 12/26/16.
13 | */
14 | public class ImageAsync extends AsyncTask {
15 |
16 | private Context context;
17 | private final WeakReference imageViewReference;
18 |
19 | public ImageAsync(Context context, ImageView imageView) {
20 | this.context = context;
21 | imageViewReference = new WeakReference<>(imageView);
22 | }
23 |
24 | @Override
25 | protected Bitmap doInBackground(Integer... params) {
26 | BitmapFactory.Options options = new BitmapFactory.Options();
27 | options.inSampleSize = 2;
28 | return BitmapFactory.decodeResource(context.getResources(), params[0], options);
29 | }
30 |
31 | @Override
32 | protected void onPreExecute() {
33 | super.onPreExecute();
34 | imageViewReference.get().setImageResource(0);
35 | }
36 |
37 | @Override
38 | protected void onPostExecute(Bitmap bitmap) {
39 | super.onPostExecute(bitmap);
40 | imageViewReference.get().setImageBitmap(bitmap);
41 | }
42 | }
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/view/main/MainActivity.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.view.main;
2 |
3 | import android.os.Bundle;
4 | import android.view.Menu;
5 | import android.view.MenuItem;
6 | import android.view.View;
7 | import android.widget.Toast;
8 |
9 | import androidx.appcompat.app.AppCompatActivity;
10 | import androidx.appcompat.widget.Toolbar;
11 | import androidx.recyclerview.widget.LinearLayoutManager;
12 | import androidx.recyclerview.widget.RecyclerView;
13 |
14 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
15 | import com.google.android.material.snackbar.Snackbar;
16 |
17 | import butterknife.BindView;
18 | import butterknife.ButterKnife;
19 | import tech.thdev.android_mvp_sample.R;
20 | import tech.thdev.android_mvp_sample.adapter.ImageAdapter;
21 | import tech.thdev.android_mvp_sample.data.source.image.SampleImageRepository;
22 | import tech.thdev.android_mvp_sample.view.main.presenter.MainContract;
23 | import tech.thdev.android_mvp_sample.view.main.presenter.MainPresenter;
24 |
25 | public class MainActivity extends AppCompatActivity implements MainContract.View {
26 |
27 | @BindView(R.id.recycler_view)
28 | RecyclerView recyclerView;
29 |
30 | private ImageAdapter imageAdapter;
31 |
32 | private MainPresenter mainPresenter;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_main);
38 |
39 | ButterKnife.bind(this);
40 |
41 | imageAdapter = new ImageAdapter();
42 | recyclerView.setAdapter(imageAdapter);
43 |
44 | mainPresenter = new MainPresenter();
45 | mainPresenter.attachView(this);
46 | mainPresenter.setImageAdapterModel(imageAdapter);
47 | mainPresenter.setImageAdapterView(imageAdapter);
48 | mainPresenter.setSampleImageData(SampleImageRepository.getInstance());
49 |
50 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
51 | setSupportActionBar(toolbar);
52 |
53 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
54 |
55 | mainPresenter.loadItems(this, false);
56 |
57 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
58 | fab.setOnClickListener(new View.OnClickListener() {
59 | @Override
60 | public void onClick(View view) {
61 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
62 | .setAction("Action", null).show();
63 | }
64 | });
65 | }
66 |
67 | @Override
68 | public void showToast(String title) {
69 | Toast.makeText(this, title, Toast.LENGTH_SHORT).show();
70 | }
71 |
72 | @Override
73 | protected void onDestroy() {
74 | super.onDestroy();
75 |
76 | mainPresenter.detachView();
77 | }
78 |
79 | @Override
80 | public boolean onCreateOptionsMenu(Menu menu) {
81 | // Inflate the menu; this adds items to the action bar if it is present.
82 | getMenuInflater().inflate(R.menu.menu_main, menu);
83 | return true;
84 | }
85 |
86 | @Override
87 | public boolean onOptionsItemSelected(MenuItem item) {
88 | // Handle action bar item clicks here. The action bar will
89 | // automatically handle clicks on the Home/Up button, so long
90 | // as you specify a parent activity in AndroidManifest.xml.
91 | int id = item.getItemId();
92 |
93 | //noinspection SimplifiableIfStatement
94 | if (id == R.id.action_reload) {
95 | mainPresenter.loadItems(this, true);
96 | return true;
97 | }
98 |
99 | return super.onOptionsItemSelected(item);
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/view/main/presenter/MainContract.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.view.main.presenter;
2 |
3 | import android.content.Context;
4 |
5 | import tech.thdev.android_mvp_sample.adapter.contract.ImageAdapterContract;
6 | import tech.thdev.android_mvp_sample.data.source.image.SampleImageRepository;
7 |
8 | /**
9 | * Created by tae-hwan on 12/22/16.
10 | */
11 | public interface MainContract {
12 |
13 | interface View {
14 |
15 | void showToast(String title);
16 | }
17 |
18 | interface Presenter {
19 |
20 | void attachView(View view);
21 |
22 | void setImageAdapterModel(ImageAdapterContract.Model adapterModel);
23 |
24 | void setImageAdapterView(ImageAdapterContract.View adapterView);
25 |
26 | void detachView();
27 |
28 | void setSampleImageData(SampleImageRepository sampleImageData);
29 |
30 | void loadItems(Context context, boolean isClear);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app_java/src/main/java/tech/thdev/android_mvp_sample/view/main/presenter/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample.view.main.presenter;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 |
7 | import tech.thdev.android_mvp_sample.adapter.contract.ImageAdapterContract;
8 | import tech.thdev.android_mvp_sample.data.ImageItem;
9 | import tech.thdev.android_mvp_sample.data.source.image.SampleImageRepository;
10 | import tech.thdev.android_mvp_sample.data.source.image.SampleImageSource;
11 | import tech.thdev.android_mvp_sample.listener.OnItemClickListener;
12 |
13 | /**
14 | * Created by tae-hwan on 12/22/16.
15 | */
16 | public class MainPresenter implements MainContract.Presenter, OnItemClickListener {
17 |
18 | private MainContract.View view;
19 |
20 | private ImageAdapterContract.Model adapterModel;
21 | private ImageAdapterContract.View adapterView;
22 |
23 | private SampleImageRepository sampleImageData;
24 |
25 | @Override
26 | public void attachView(MainContract.View view) {
27 | this.view = view;
28 | }
29 |
30 | @Override
31 | public void detachView() {
32 | view = null;
33 | }
34 |
35 | @Override
36 | public void setSampleImageData(SampleImageRepository sampleImageData) {
37 | this.sampleImageData = sampleImageData;
38 | }
39 |
40 | @Override
41 | public void loadItems(Context context, final boolean isClear) {
42 | sampleImageData.getImages(context, 10, new SampleImageSource.LoadImageCallback() {
43 | @Override
44 | public void onImageLoaded(ArrayList list) {
45 | if (list != null) {
46 | if (isClear) {
47 | adapterModel.clearItem();
48 | }
49 | adapterModel.addItems(list);
50 | adapterView.notifyAdapter();
51 | }
52 | }
53 | });
54 |
55 |
56 | }
57 |
58 | @Override
59 | public void setImageAdapterModel(ImageAdapterContract.Model adapterModel) {
60 | this.adapterModel = adapterModel;
61 | }
62 |
63 | @Override
64 | public void setImageAdapterView(ImageAdapterContract.View adapterView) {
65 | this.adapterView = adapterView;
66 |
67 | this.adapterView.setOnClickListener(this);
68 | }
69 |
70 | @Override
71 | public void onItemClick(int position) {
72 | ImageItem imageItem = adapterModel.getItem(position);
73 | view.showToast(imageItem.getTitle());
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/reload.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_00.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_01.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_02.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_03.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_04.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_05.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_06.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_07.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_08.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_09.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_10.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_11.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_12.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_13.png
--------------------------------------------------------------------------------
/app_java/src/main/res/drawable/sample_14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/drawable/sample_14.png
--------------------------------------------------------------------------------
/app_java/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app_java/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/app_java/src/main/res/layout/item_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
--------------------------------------------------------------------------------
/app_java/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/app_java/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_java/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_java/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_java/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_java/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_java/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_java/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #BB86FC
4 | #6200EE
5 | #3700B3
6 | #03DAC5
7 |
--------------------------------------------------------------------------------
/app_java/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app_java/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidMVPSample-Java
3 | Settings
4 | Reload
5 |
6 |
--------------------------------------------------------------------------------
/app_java/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app_java/src/test/java/tech/thdev/android_mvp_sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.android_mvp_sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app_kotlin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app_kotlin/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion compileSdkVersionInfo
7 | buildToolsVersion buildToolsVersionInfo
8 |
9 | defaultConfig {
10 | applicationId "tech.thdev.app_kotlin"
11 | minSdkVersion minSdkVerisonInfo
12 | targetSdkVersion targetSdkVersionInfo
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | compileOptions {
27 | sourceCompatibility JavaVersion.VERSION_1_8
28 | targetCompatibility JavaVersion.VERSION_1_8
29 | }
30 |
31 | kotlinOptions {
32 | jvmTarget = '1.8'
33 | }
34 | }
35 |
36 | dependencies {
37 | implementation fileTree(dir: 'libs', include: ['*.jar'])
38 |
39 | implementation "androidx.appcompat:appcompat:$appcompatVersion"
40 | implementation "com.google.android.material:material:$materialVersion"
41 |
42 | // kotlin
43 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
44 |
45 | // Image loader
46 | implementation "com.github.bumptech.glide:glide:$glideVersion"
47 | kapt "com.github.bumptech.glide:compiler:$glideVersion"
48 | }
--------------------------------------------------------------------------------
/app_kotlin/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 /Users/tae-hwan/Library/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_kotlin/src/androidTest/java/tech/thdev/app_kotlin/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("tech.thdev.app_kotlin", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/adapter/ImageAdapter.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.adapter
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 | import tech.thdev.app_kotlin.adapter.contract.ImageAdapterContract
6 | import tech.thdev.app_kotlin.data.ImageItem
7 |
8 | /**
9 | * Created by tae-hwan on 10/23/16.
10 | */
11 | class ImageAdapter : ImageAdapterContract.View, RecyclerView.Adapter(), ImageAdapterContract.Model {
12 |
13 | private lateinit var imageList: ArrayList
14 |
15 | override var onClickFunc: ((Int) -> Unit)? = null
16 |
17 | override fun onBindViewHolder(holder: ImageViewHolder, position: Int) {
18 | imageList[position].let {
19 | holder.onBind(it, position)
20 | }
21 | }
22 |
23 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ImageViewHolder =
24 | ImageViewHolder(parent, onClickFunc)
25 |
26 | override fun getItemCount() = imageList.size
27 |
28 | override fun notifyAdapter() {
29 | notifyDataSetChanged()
30 | }
31 |
32 | override fun getItem(position: Int) = imageList[position]
33 |
34 | override fun addItems(imageItems: ArrayList) {
35 | this.imageList = imageItems
36 | }
37 |
38 | override fun clearItem() {
39 | imageList.clear()
40 | }
41 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/adapter/ImageViewHolder.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.adapter
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import android.widget.ImageView
6 | import android.widget.TextView
7 | import androidx.recyclerview.widget.RecyclerView
8 | import tech.thdev.app_kotlin.R
9 | import tech.thdev.app_kotlin.data.ImageItem
10 | import tech.thdev.app_kotlin.util.ImageAsync
11 |
12 | /**
13 | * Created by tae-hwan on 10/23/16.
14 | */
15 | class ImageViewHolder(
16 | parent: ViewGroup,
17 | private val listenerFunc: ((Int) -> Unit)?
18 | ) : RecyclerView.ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_image, parent, false)) {
19 |
20 | private val imageView by lazy {
21 | itemView.findViewById(R.id.img_view) as ImageView
22 | }
23 |
24 | private val textView by lazy {
25 | itemView.findViewById(R.id.text) as TextView
26 | }
27 |
28 | fun onBind(item: ImageItem, position: Int) {
29 | ImageAsync(imageView.context, imageView).execute(item.resource)
30 | textView.text = item.title
31 |
32 | itemView.setOnClickListener {
33 | listenerFunc?.invoke(position)
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/adapter/contract/ImageAdapterContract.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.adapter.contract
2 |
3 | import tech.thdev.app_kotlin.data.ImageItem
4 | import java.util.*
5 |
6 | /**
7 | * Created by tae-hwan on 12/27/16.
8 | */
9 | interface ImageAdapterContract {
10 |
11 | interface View {
12 |
13 | var onClickFunc : ((Int) -> Unit)?
14 |
15 | fun notifyAdapter()
16 | }
17 |
18 | interface Model {
19 |
20 | fun addItems(imageItems: ArrayList)
21 |
22 | fun clearItem()
23 |
24 | fun getItem(position: Int): ImageItem
25 | }
26 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/data/ImageItem.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.data
2 |
3 | /**
4 | * Created by tae-hwan on 10/23/16.
5 | */
6 | data class ImageItem(val resource:Int, val title: String)
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/data/source/image/SampleImageLocalDataSource.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.data.source.image
2 |
3 | import android.content.Context
4 | import tech.thdev.app_kotlin.data.ImageItem
5 | import java.util.*
6 |
7 | /**
8 | * Created by tae-hwan on 1/30/17.
9 | */
10 | object SampleImageLocalDataSource : SampleImageSource {
11 |
12 | override fun getImages(context: Context, size: Int, loadImageCallback: SampleImageSource.LoadImageCallback?) {
13 | val list = ArrayList()
14 | for (index in 0..size) {
15 | val name = String.format("sample_%02d", (Math.random() * 15).toInt())
16 | val resource = context.resources.getIdentifier(name, "drawable", context.packageName)
17 | list.add(ImageItem(resource, name))
18 | }
19 | loadImageCallback?.onLoadImages(list)
20 | }
21 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/data/source/image/SampleImageRepository.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.data.source.image
2 |
3 | import android.content.Context
4 | import tech.thdev.app_kotlin.data.ImageItem
5 | import java.util.*
6 |
7 | /**
8 | * Created by tae-hwan on 1/30/17.
9 | */
10 | object SampleImageRepository : SampleImageSource {
11 |
12 | private val sampleImageLocalDataSource = SampleImageLocalDataSource
13 |
14 | override fun getImages(context: Context, size: Int, loadImageCallback: SampleImageSource.LoadImageCallback?) {
15 | sampleImageLocalDataSource.getImages(context, size, object : SampleImageSource.LoadImageCallback {
16 | override fun onLoadImages(list: ArrayList) {
17 | loadImageCallback?.onLoadImages(list)
18 | }
19 | })
20 | }
21 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/data/source/image/SampleImageSource.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.data.source.image
2 |
3 | import android.content.Context
4 | import tech.thdev.app_kotlin.data.ImageItem
5 | import java.util.*
6 |
7 | /**
8 | * Created by tae-hwan on 1/30/17.
9 | */
10 |
11 | interface SampleImageSource {
12 |
13 | interface LoadImageCallback {
14 |
15 | fun onLoadImages(list: ArrayList)
16 | }
17 |
18 | fun getImages(context: Context, size: Int, loadImageCallback: LoadImageCallback?)
19 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/util/ImageAsync.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.util
2 |
3 | import android.content.Context
4 | import android.graphics.Bitmap
5 | import android.graphics.BitmapFactory
6 | import android.os.AsyncTask
7 | import android.widget.ImageView
8 | import java.lang.ref.WeakReference
9 |
10 | /**
11 | * Created by tae-hwan on 12/26/16.
12 | */
13 | class ImageAsync(
14 | private val context: Context,
15 | imageView: ImageView
16 | ) : AsyncTask() {
17 |
18 | private val imageViewReference: WeakReference = WeakReference(imageView)
19 |
20 | override fun doInBackground(vararg params: Int?): Bitmap? {
21 | val options = BitmapFactory.Options()
22 | options.inSampleSize = 2
23 | return BitmapFactory.decodeResource(context.resources, params[0] as Int, options)
24 | }
25 |
26 | override fun onPreExecute() {
27 | super.onPreExecute()
28 | imageViewReference.get()?.setImageResource(0)
29 | }
30 |
31 | override fun onPostExecute(result: Bitmap?) {
32 | super.onPostExecute(result)
33 | result?.let { imageViewReference.get()?.setImageBitmap(result) }
34 | }
35 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/view/main/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.view.main
2 |
3 | import android.os.Bundle
4 | import android.view.Menu
5 | import android.view.MenuItem
6 | import android.widget.Toast
7 | import androidx.appcompat.app.AppCompatActivity
8 | import androidx.appcompat.widget.Toolbar
9 | import androidx.recyclerview.widget.RecyclerView
10 | import com.google.android.material.floatingactionbutton.FloatingActionButton
11 | import com.google.android.material.snackbar.Snackbar
12 | import tech.thdev.app_kotlin.R
13 | import tech.thdev.app_kotlin.adapter.ImageAdapter
14 | import tech.thdev.app_kotlin.data.source.image.SampleImageRepository
15 | import tech.thdev.app_kotlin.view.main.presenter.MainContract
16 | import tech.thdev.app_kotlin.view.main.presenter.MainPresenter
17 |
18 | class MainActivity : AppCompatActivity(), MainContract.View {
19 |
20 | private val recyclerView by lazy {
21 | findViewById(R.id.recycler_view)
22 | }
23 |
24 | private val imageAdapter: ImageAdapter by lazy {
25 | ImageAdapter()
26 | }
27 |
28 | private val presenter: MainPresenter by lazy {
29 | MainPresenter(
30 | view = this@MainActivity,
31 | imageData = SampleImageRepository,
32 | adapterModel = imageAdapter,
33 | adapterView = imageAdapter
34 | )
35 | }
36 |
37 | override fun onCreate(savedInstanceState: Bundle?) {
38 | super.onCreate(savedInstanceState)
39 | setContentView(R.layout.activity_main)
40 | val toolbar = findViewById(R.id.toolbar)
41 | setSupportActionBar(toolbar)
42 |
43 | recyclerView.adapter = imageAdapter
44 |
45 | findViewById(R.id.fab).setOnClickListener { view ->
46 | Snackbar.make(
47 | view,
48 | "Replace with your own action",
49 | Snackbar.LENGTH_LONG
50 | ).setAction("Action", null).show()
51 | }
52 |
53 | presenter.loadItems(this, false)
54 | }
55 |
56 | override fun onCreateOptionsMenu(menu: Menu): Boolean {
57 | // Inflate the menu; this adds items to the action bar if it is present.
58 | menuInflater.inflate(R.menu.menu_main, menu)
59 | return true
60 | }
61 |
62 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
63 | // Handle action bar item clicks here. The action bar will
64 | // automatically handle clicks on the Home/Up button, so long
65 | // as you specify a parent activity in AndroidManifest.xml.
66 | val id = item.itemId
67 |
68 | //noinspection SimplifiableIfStatement
69 | if (id == R.id.action_reload) {
70 | presenter.loadItems(this, true)
71 | return true
72 | }
73 |
74 | return super.onOptionsItemSelected(item)
75 | }
76 |
77 | override fun showToast(title: String) {
78 | Toast.makeText(this, "OnClick Item $title", Toast.LENGTH_SHORT).show()
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/view/main/presenter/MainContract.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.view.main.presenter
2 |
3 | import android.content.Context
4 |
5 | /**
6 | * Created by tae-hwan on 12/23/16.
7 | */
8 | interface MainContract {
9 |
10 | interface View {
11 |
12 | fun showToast(title: String)
13 | }
14 |
15 | interface Presenter {
16 |
17 | fun loadItems(context: Context, isClear: Boolean)
18 | }
19 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/java/tech/thdev/app_kotlin/view/main/presenter/MainPresenter.kt:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin.view.main.presenter
2 |
3 | import android.content.Context
4 | import tech.thdev.app_kotlin.adapter.contract.ImageAdapterContract
5 | import tech.thdev.app_kotlin.data.ImageItem
6 | import tech.thdev.app_kotlin.data.source.image.SampleImageRepository
7 | import tech.thdev.app_kotlin.data.source.image.SampleImageSource
8 |
9 | /**
10 | * Created by tae-hwan on 12/23/16.
11 | */
12 | class MainPresenter(
13 | private val view: MainContract.View,
14 | private val imageData: SampleImageRepository,
15 | private val adapterModel: ImageAdapterContract.Model,
16 | private val adapterView: ImageAdapterContract.View
17 | ) : MainContract.Presenter {
18 |
19 | init {
20 | adapterView.onClickFunc = {
21 | onClickListener(it)
22 | }
23 | }
24 |
25 | override fun loadItems(context: Context, isClear: Boolean) {
26 | imageData.getImages(context, 10, object : SampleImageSource.LoadImageCallback {
27 | override fun onLoadImages(list: ArrayList) {
28 | if (isClear) {
29 | adapterModel.clearItem()
30 | }
31 |
32 | adapterModel.addItems(list)
33 | adapterView.notifyAdapter()
34 | }
35 | })
36 | }
37 |
38 | private fun onClickListener(position: Int) {
39 | adapterModel.getItem(position).let {
40 | view.showToast(it.title)
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/reload.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_00.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_01.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_02.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_03.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_04.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_05.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_06.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_07.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_08.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_09.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_10.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_11.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_12.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_13.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/drawable/sample_14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/drawable/sample_14.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/layout/item_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
20 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/app_kotlin/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #BB86FC
4 | #6200EE
5 | #3700B3
6 | #03DAC5
7 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidMVPSample-Kotlin
3 | Settings
4 | Reload
5 |
6 |
--------------------------------------------------------------------------------
/app_kotlin/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app_kotlin/src/test/java/tech/thdev/app_kotlin/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package tech.thdev.app_kotlin;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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 | mavenCentral()
6 | google()
7 | jcenter()
8 | }
9 |
10 | ext {
11 | compileSdkVersionInfo = 29
12 | buildToolsVersionInfo = "29.0.3"
13 | minSdkVerisonInfo = 24
14 | targetSdkVersionInfo = 29
15 |
16 | appcompatVersion = '1.1.0'
17 | materialVersion = '1.1.0'
18 |
19 | kotlin_version = '1.3.72'
20 |
21 | // Bind view
22 | butterKnifeVersion = '10.2.1'
23 |
24 | // Image Library
25 | // https://github.com/bumptech/glide
26 | glideVersion = '4.11.0'
27 | }
28 |
29 | dependencies {
30 | classpath 'com.android.tools.build:gradle:3.6.3'
31 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
32 |
33 | // NOTE: Do not place your application dependencies here; they belong
34 | // in the individual module build.gradle files
35 | }
36 | }
37 |
38 | allprojects {
39 | repositories {
40 | mavenCentral()
41 | google()
42 | jcenter()
43 | }
44 | }
45 |
46 | task clean(type: Delete) {
47 | delete rootProject.buildDir
48 | }
49 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu May 07 23:18:01 KST 2020
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-6.3-all.zip
--------------------------------------------------------------------------------
/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/images/device-2016-10-23-174436.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/taehwandev/AndroidMVPSample/e6ce0eba9989c200e04f3d7bb75180d2d2f32383/images/device-2016-10-23-174436.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app_java', ':app_kotlin'
2 |
--------------------------------------------------------------------------------