├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── iammert
│ │ └── com
│ │ └── instagramtags
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── iammert
│ │ │ └── com
│ │ │ └── instagramtags
│ │ │ ├── InstagramTagsApp.java
│ │ │ ├── di
│ │ │ ├── Activity.java
│ │ │ ├── Fragment.java
│ │ │ ├── app
│ │ │ │ ├── AppComponent.java
│ │ │ │ ├── AppModule.java
│ │ │ │ └── NetworkModule.java
│ │ │ ├── main
│ │ │ │ ├── MainComponent.java
│ │ │ │ └── MainModule.java
│ │ │ ├── medialist
│ │ │ │ ├── MediaListComponent.java
│ │ │ │ └── MediaListModule.java
│ │ │ ├── searchtag
│ │ │ │ ├── SearchTagComponent.java
│ │ │ │ └── SearchTagModule.java
│ │ │ └── splash
│ │ │ │ ├── SplashComponent.java
│ │ │ │ └── SplashModule.java
│ │ │ ├── domain
│ │ │ ├── medialist
│ │ │ │ ├── MediaListUsecase.java
│ │ │ │ └── MediaListUsecaseImpl.java
│ │ │ ├── searchtag
│ │ │ │ ├── SearchTagUsecase.java
│ │ │ │ └── SearchTagUsecaseImpl.java
│ │ │ └── splash
│ │ │ │ ├── SplashUsecase.java
│ │ │ │ └── SplashUsecaseImpl.java
│ │ │ ├── model
│ │ │ ├── api
│ │ │ │ ├── ApiSource.java
│ │ │ │ ├── ApiSourceImpl.java
│ │ │ │ ├── RetrofitInterface.java
│ │ │ │ └── entity
│ │ │ │ │ ├── Comment.java
│ │ │ │ │ ├── Image.java
│ │ │ │ │ ├── ImageWrapper.java
│ │ │ │ │ ├── Like.java
│ │ │ │ │ ├── Media.java
│ │ │ │ │ ├── MediaListResponse.java
│ │ │ │ │ ├── Tag.java
│ │ │ │ │ ├── TagSearchResponse.java
│ │ │ │ │ └── User.java
│ │ │ └── preferences
│ │ │ │ ├── PreferencesHelper.java
│ │ │ │ └── PreferencesHelperImpl.java
│ │ │ ├── util
│ │ │ ├── Constants.java
│ │ │ ├── DialogBuilder.java
│ │ │ ├── ImageDataBinding.java
│ │ │ ├── RxBus.java
│ │ │ ├── RxTransformer.java
│ │ │ └── SimpleTextWatcher.java
│ │ │ ├── view
│ │ │ ├── login
│ │ │ │ └── LoginActivity.java
│ │ │ ├── main
│ │ │ │ └── MainActivity.java
│ │ │ ├── medialist
│ │ │ │ ├── MediaListActivity.java
│ │ │ │ ├── MediaListAdapter.java
│ │ │ │ └── MediaListFragment.java
│ │ │ ├── searchtag
│ │ │ │ ├── SearchTagAdapter.java
│ │ │ │ └── SearchTagFragment.java
│ │ │ └── splash
│ │ │ │ └── SplashActivity.java
│ │ │ └── viewmodel
│ │ │ ├── main
│ │ │ └── MainViewModel.java
│ │ │ ├── medialist
│ │ │ ├── MediaListItemViewModel.java
│ │ │ └── MediaListViewModel.java
│ │ │ ├── searchtag
│ │ │ ├── SearchTagItemViewModel.java
│ │ │ ├── SearchTagViewModel.java
│ │ │ └── TagClickEvent.java
│ │ │ └── splash
│ │ │ └── SplashViewModel.java
│ └── res
│ │ ├── drawable
│ │ ├── bg_image.xml
│ │ ├── bg_search_bar.xml
│ │ ├── ic_favorite_border_white_24dp.xml
│ │ └── shadow_image.xml
│ │ ├── layout-w900dp
│ │ └── activity_main.xml
│ │ ├── layout
│ │ ├── activity_login.xml
│ │ ├── activity_main.xml
│ │ ├── activity_media_list.xml
│ │ ├── activity_splash.xml
│ │ ├── fragment_media_list.xml
│ │ ├── fragment_search_tag.xml
│ │ ├── item_media_list.xml
│ │ └── item_search_tag.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-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── iammert
│ └── com
│ └── instagramtags
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screeshots
├── arch.png
├── mobile_mockup.png
└── tablet_mockup.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/libraries
41 | .idea/
42 | .idea
43 |
44 | # Keystore files
45 | *.jks
46 |
47 | # External native build folder generated in Android Studio 2.2 and later
48 | .externalNativeBuild
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # InstagramTags
2 | Sample MVVM project uses instagram API. Supported two-pane layouts for tablets.
3 |
4 | #Screenshots
5 |
6 |
7 |
8 | #Technology used
9 | * Clean MVVM architecture
10 | * [Android Databinding](https://developer.android.com/topic/libraries/data-binding/index.html)
11 | * [Dagger 2](https://google.github.io/dagger/)
12 | * [RxJava](https://github.com/ReactiveX/RxJava)
13 | * [OkHttp](http://square.github.io/okhttp/)
14 | * [Retfofit](https://square.github.io/retrofit/)
15 | * [Picasso](http://square.github.io/picasso/)
16 |
17 | #Architectural Design
18 |
19 |
20 | #Setup
21 | Add your client_id and redirect_uri to Constants class for authentication. For more detail you can follow [instagram developer documentation](https://www.instagram.com/developer/).
22 | ```java
23 | public static final String CLIENT_ID = "REPLACE_HERE";
24 | public static final String REDIRECT_URI = "REPLACE_HERE";
25 | public static final String RESPONSE_TYPE = "token"; //you can change auth type
26 | public static final String SCOPE = "public_content"; //you can change auth scope
27 | ```
28 |
29 |
30 |
31 |
32 | License
33 | --------
34 |
35 |
36 | Copyright 2017 Mert Şimşek.
37 |
38 | Licensed under the Apache License, Version 2.0 (the "License");
39 | you may not use this file except in compliance with the License.
40 | You may obtain a copy of the License at
41 |
42 | http://www.apache.org/licenses/LICENSE-2.0
43 |
44 | Unless required by applicable law or agreed to in writing, software
45 | distributed under the License is distributed on an "AS IS" BASIS,
46 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47 | See the License for the specific language governing permissions and
48 | limitations under the License.
49 |
50 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/libraries
41 | .idea/
42 | .idea
43 |
44 | # Keystore files
45 | *.jks
46 |
47 | # External native build folder generated in Android Studio 2.2 and later
48 | .externalNativeBuild
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'me.tatarka.retrolambda'
3 | apply plugin: 'com.neenbedankt.android-apt'
4 |
5 | android {
6 |
7 | compileSdkVersion rootProject.ext.compileSdkVersion
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | productFlavors {
11 | dev {
12 | minSdkVersion rootProject.ext.devMinSdkVersion
13 | }
14 | prod {
15 | minSdkVersion rootProject.ext.minSdkVersion
16 | }
17 | }
18 |
19 | dataBinding {
20 | enabled = true
21 | }
22 |
23 | defaultConfig {
24 | applicationId "iammert.com.instagramtags"
25 | minSdkVersion rootProject.ext.minSdkVersion
26 | targetSdkVersion rootProject.ext.targetSdkVersion
27 | versionCode rootProject.ext.versionCode
28 | versionName rootProject.ext.versionName
29 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
30 | }
31 | buildTypes {
32 | release {
33 | minifyEnabled false
34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
35 | }
36 | }
37 |
38 | compileOptions {
39 | sourceCompatibility JavaVersion.VERSION_1_8
40 | targetCompatibility JavaVersion.VERSION_1_8
41 | }
42 |
43 | lintOptions {
44 | disable 'InvalidPackage'
45 | }
46 |
47 | packagingOptions {
48 | exclude 'META-INF/services/javax.annotation.processing.Processor'
49 | exclude 'META-INF/LICENSE.txt'
50 | exclude 'META-INF/NOTICE.txt'
51 | exclude 'META-INF/LICENSE'
52 | }
53 | }
54 |
55 | dependencies {
56 | compile fileTree(dir: 'libs', include: ['*.jar'])
57 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
58 | exclude group: 'com.android.support', module: 'support-annotations'
59 | })
60 |
61 | testCompile 'junit:junit:4.12'
62 |
63 | //dagger
64 | apt rootProject.ext.daggerCompiler
65 | compile rootProject.ext.daggerGlassfish
66 | compile rootProject.ext.dagger
67 |
68 | //support lib
69 | compile rootProject.ext.supportLibAppCompat
70 | compile rootProject.ext.supportLibDesign
71 | compile rootProject.ext.supportLibCardView
72 |
73 | //rxjava
74 | compile rootProject.ext.rxjava
75 | compile rootProject.ext.retrofitRxAdapter
76 |
77 | //rxAndroid & rxBinding
78 | compile rootProject.ext.rxAndroid
79 | compile rootProject.ext.rxBinding
80 |
81 | //retrofit
82 | compile rootProject.ext.retrofit
83 | compile rootProject.ext.gsonConverter
84 | compile rootProject.ext.retrofitLogging
85 |
86 | //ui
87 | compile rootProject.ext.picasso
88 | compile rootProject.ext.materialDialog
89 | compile rootProject.ext.circleImage
90 |
91 | //Parceler
92 | compile rootProject.ext.parcelerApi
93 | apt rootProject.ext.parceler
94 | }
95 |
--------------------------------------------------------------------------------
/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 /Users/mertsimsek/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/src/androidTest/java/iammert/com/instagramtags/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags;
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("iammert.com.instagramtags", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/InstagramTagsApp.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags;
2 |
3 | import android.app.Application;
4 |
5 | import iammert.com.instagramtags.di.app.AppComponent;
6 | import iammert.com.instagramtags.di.app.AppModule;
7 | import iammert.com.instagramtags.di.app.DaggerAppComponent;
8 | import iammert.com.instagramtags.di.app.NetworkModule;
9 |
10 | /**
11 | * Created by mertsimsek on 13/01/17.
12 | */
13 |
14 | public class InstagramTagsApp extends Application {
15 |
16 | AppComponent appComponent;
17 |
18 | @Override
19 | public void onCreate() {
20 | super.onCreate();
21 | initializeInjector();
22 | }
23 |
24 | private void initializeInjector() {
25 | appComponent = DaggerAppComponent.builder()
26 | .appModule(new AppModule(this))
27 | .networkModule(new NetworkModule())
28 | .build();
29 | }
30 |
31 | public AppComponent getAppComponent() {
32 | return appComponent;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/Activity.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di;
2 |
3 | import java.lang.annotation.Retention;
4 |
5 | import javax.inject.Scope;
6 |
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Created by mertsimsek on 13/01/17.
11 | */
12 |
13 | @Scope
14 | @Retention(RUNTIME)
15 | public @interface Activity {
16 | }
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/Fragment.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di;
2 |
3 | import java.lang.annotation.Retention;
4 |
5 | import javax.inject.Scope;
6 |
7 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
8 |
9 | /**
10 | * Created by mertsimsek on 13/01/17.
11 | */
12 |
13 | @Scope
14 | @Retention(RUNTIME)
15 | public @interface Fragment {
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/app/AppComponent.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.app;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import javax.inject.Singleton;
8 |
9 | import dagger.Component;
10 | import iammert.com.instagramtags.model.api.ApiSource;
11 | import iammert.com.instagramtags.util.RxBus;
12 |
13 | /**
14 | * Created by mertsimsek on 13/01/17.
15 | */
16 |
17 | @Singleton
18 | @Component(modules = {AppModule.class, NetworkModule.class})
19 | public interface AppComponent {
20 | ApiSource apiSource();
21 | SharedPreferences sharedPreferences();
22 | Gson gson();
23 | RxBus bus();
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/app/AppModule.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.app;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.preference.PreferenceManager;
7 |
8 | import com.google.gson.Gson;
9 |
10 | import javax.inject.Singleton;
11 |
12 | import dagger.Module;
13 | import dagger.Provides;
14 | import iammert.com.instagramtags.util.RxBus;
15 |
16 | /**
17 | * Created by mertsimsek on 13/01/17.
18 | */
19 |
20 | @Module
21 | public class AppModule {
22 |
23 | Application app;
24 |
25 | public AppModule(Application app) {
26 | this.app = app;
27 | }
28 |
29 | @Provides
30 | @Singleton
31 | Application provideApplication() {
32 | return app;
33 | }
34 |
35 | @Provides
36 | @Singleton
37 | Context provideContext() {
38 | return app.getApplicationContext();
39 | }
40 |
41 | @Provides
42 | @Singleton
43 | Gson provideGson() {
44 | return new Gson();
45 | }
46 |
47 | @Provides
48 | @Singleton
49 | RxBus provideBus() {
50 | return RxBus.getInstance();
51 | }
52 |
53 | @Provides
54 | @Singleton
55 | SharedPreferences providesSharedPreferences(Application application) {
56 | return PreferenceManager.getDefaultSharedPreferences(application);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/app/NetworkModule.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.app;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.TimeUnit;
6 |
7 | import javax.inject.Singleton;
8 |
9 | import dagger.Module;
10 | import dagger.Provides;
11 | import iammert.com.instagramtags.model.api.ApiSource;
12 | import iammert.com.instagramtags.model.api.ApiSourceImpl;
13 | import iammert.com.instagramtags.util.Constants;
14 | import okhttp3.OkHttpClient;
15 | import okhttp3.Protocol;
16 | import okhttp3.logging.HttpLoggingInterceptor;
17 | import retrofit2.Retrofit;
18 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
19 | import retrofit2.converter.gson.GsonConverterFactory;
20 |
21 | /**
22 | * Created by mertsimsek on 13/01/17.
23 | */
24 |
25 | @Module
26 | public class NetworkModule {
27 |
28 | @Provides
29 | @Singleton
30 | HttpLoggingInterceptor provideHttpInterceptor() {
31 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
32 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
33 | return interceptor;
34 | }
35 |
36 | @Provides
37 | @Singleton
38 | OkHttpClient provideOkHttpClient(HttpLoggingInterceptor httpLoggingInterceptor) {
39 | List protocols = new ArrayList<>();
40 | protocols.add(Protocol.HTTP_1_1);
41 | OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder();
42 | okHttpClient.connectTimeout(1, TimeUnit.MINUTES);
43 | okHttpClient.readTimeout(1, TimeUnit.MINUTES);
44 | okHttpClient.protocols(protocols);
45 | okHttpClient.addInterceptor(httpLoggingInterceptor);
46 | return okHttpClient.build();
47 | }
48 |
49 | @Provides
50 | @Singleton
51 | Retrofit provideRetrofit(OkHttpClient okHttpClient) {
52 | Retrofit retrofit = new Retrofit.Builder()
53 | .baseUrl(Constants.BASE_URL)
54 | .addConverterFactory(GsonConverterFactory.create())
55 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
56 | .client(okHttpClient)
57 | .build();
58 | return retrofit;
59 | }
60 |
61 | @Provides
62 | @Singleton
63 | ApiSource provideApiSource(Retrofit retrofit) {
64 | return new ApiSourceImpl(retrofit);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/main/MainComponent.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.main;
2 |
3 | import dagger.Component;
4 | import iammert.com.instagramtags.di.Activity;
5 | import iammert.com.instagramtags.di.app.AppComponent;
6 | import iammert.com.instagramtags.view.main.MainActivity;
7 |
8 | /**
9 | * Created by mertsimsek on 13/01/17.
10 | */
11 | @Activity
12 | @Component(dependencies = AppComponent.class, modules = MainModule.class)
13 | public interface MainComponent {
14 | void inject(MainActivity mainActivity);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/main/MainModule.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.main;
2 |
3 | import dagger.Module;
4 | import dagger.Provides;
5 | import iammert.com.instagramtags.di.Activity;
6 | import iammert.com.instagramtags.util.RxBus;
7 | import iammert.com.instagramtags.viewmodel.main.MainViewModel;
8 |
9 | /**
10 | * Created by mertsimsek on 13/01/17.
11 | */
12 | @Module
13 | public class MainModule {
14 |
15 | MainViewModel.MainListener mainListener;
16 |
17 | public MainModule(MainViewModel.MainListener mainListener) {
18 | this.mainListener = mainListener;
19 | }
20 |
21 | @Provides
22 | @Activity
23 | MainViewModel provideMainViewModel(RxBus rxBus){
24 | return new MainViewModel(rxBus, mainListener);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/medialist/MediaListComponent.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.medialist;
2 |
3 | import dagger.Component;
4 | import iammert.com.instagramtags.di.Fragment;
5 | import iammert.com.instagramtags.di.app.AppComponent;
6 | import iammert.com.instagramtags.view.medialist.MediaListFragment;
7 |
8 | /**
9 | * Created by mertsimsek on 14/01/17.
10 | */
11 | @Fragment
12 | @Component(dependencies = AppComponent.class, modules = MediaListModule.class)
13 | public interface MediaListComponent {
14 | void inject(MediaListFragment fragment);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/medialist/MediaListModule.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.medialist;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import dagger.Module;
8 | import dagger.Provides;
9 | import iammert.com.instagramtags.di.Fragment;
10 | import iammert.com.instagramtags.domain.medialist.MediaListUsecase;
11 | import iammert.com.instagramtags.domain.medialist.MediaListUsecaseImpl;
12 | import iammert.com.instagramtags.model.api.ApiSource;
13 | import iammert.com.instagramtags.model.api.entity.Tag;
14 | import iammert.com.instagramtags.model.preferences.PreferencesHelper;
15 | import iammert.com.instagramtags.model.preferences.PreferencesHelperImpl;
16 | import iammert.com.instagramtags.view.medialist.MediaListAdapter;
17 | import iammert.com.instagramtags.viewmodel.medialist.MediaListViewModel;
18 |
19 | /**
20 | * Created by mertsimsek on 14/01/17.
21 | */
22 | @Module
23 | public class MediaListModule {
24 |
25 | MediaListViewModel.MediaListListener listener;
26 | Tag tag;
27 |
28 | public MediaListModule(MediaListViewModel.MediaListListener listener, Tag tag) {
29 | this.listener = listener;
30 | this.tag = tag;
31 | }
32 |
33 | @Provides
34 | @Fragment
35 | PreferencesHelper provideTokenPreferencesHelper(SharedPreferences preferences, Gson gson){
36 | return new PreferencesHelperImpl<>(preferences, gson);
37 | }
38 |
39 | @Provides
40 | @Fragment
41 | MediaListUsecase provideMediaListUsecase(ApiSource apiSource, PreferencesHelper tokenPreferencesHelper){
42 | return new MediaListUsecaseImpl(apiSource, tokenPreferencesHelper);
43 | }
44 |
45 | @Provides
46 | @Fragment
47 | MediaListViewModel provideMediaListViewModel(MediaListUsecase mediaListUsecase){
48 | return new MediaListViewModel(mediaListUsecase, listener, tag);
49 | }
50 |
51 | @Provides
52 | @Fragment
53 | MediaListAdapter provideMediaListAdapter(){
54 | return new MediaListAdapter();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/searchtag/SearchTagComponent.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.searchtag;
2 |
3 | import dagger.Component;
4 | import iammert.com.instagramtags.di.Fragment;
5 | import iammert.com.instagramtags.di.app.AppComponent;
6 | import iammert.com.instagramtags.view.searchtag.SearchTagFragment;
7 |
8 | /**
9 | * Created by mertsimsek on 13/01/17.
10 | */
11 | @Fragment
12 | @Component(dependencies = AppComponent.class, modules = SearchTagModule.class)
13 | public interface SearchTagComponent {
14 | void inject(SearchTagFragment searchTagFragment);
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/searchtag/SearchTagModule.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.searchtag;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import dagger.Module;
8 | import dagger.Provides;
9 | import iammert.com.instagramtags.di.Fragment;
10 | import iammert.com.instagramtags.domain.searchtag.SearchTagUsecase;
11 | import iammert.com.instagramtags.domain.searchtag.SearchTagUsecaseImpl;
12 | import iammert.com.instagramtags.model.api.ApiSource;
13 | import iammert.com.instagramtags.model.preferences.PreferencesHelper;
14 | import iammert.com.instagramtags.model.preferences.PreferencesHelperImpl;
15 | import iammert.com.instagramtags.util.RxBus;
16 | import iammert.com.instagramtags.view.searchtag.SearchTagAdapter;
17 | import iammert.com.instagramtags.viewmodel.searchtag.SearchTagViewModel;
18 |
19 | /**
20 | * Created by mertsimsek on 13/01/17.
21 | */
22 | @Module
23 | public class SearchTagModule {
24 |
25 | SearchTagViewModel.SearchTagListener listener;
26 |
27 | public SearchTagModule(SearchTagViewModel.SearchTagListener listener) {
28 | this.listener = listener;
29 | }
30 |
31 | @Provides
32 | @Fragment
33 | PreferencesHelper provideTokenPreferencesHelper(SharedPreferences sharedPreferences, Gson gson){
34 | return new PreferencesHelperImpl<>(sharedPreferences, gson);
35 | }
36 |
37 | @Provides
38 | @Fragment
39 | SearchTagUsecase provideSearchTagUsecase(PreferencesHelper tokenHelper, ApiSource apiSource){
40 | return new SearchTagUsecaseImpl(tokenHelper, apiSource);
41 | }
42 |
43 | @Provides
44 | @Fragment
45 | SearchTagViewModel provideSearchTagViewModel(SearchTagUsecase usecase){
46 | return new SearchTagViewModel(usecase, listener);
47 | }
48 |
49 | @Provides
50 | @Fragment
51 | SearchTagAdapter provideSearchTagAdapter(RxBus rxBus){
52 | return new SearchTagAdapter(rxBus);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/splash/SplashComponent.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.splash;
2 |
3 | import dagger.Component;
4 | import iammert.com.instagramtags.di.Activity;
5 | import iammert.com.instagramtags.di.app.AppComponent;
6 | import iammert.com.instagramtags.view.splash.SplashActivity;
7 |
8 | /**
9 | * Created by mertsimsek on 13/01/17.
10 | */
11 |
12 | @Activity
13 | @Component(dependencies = AppComponent.class, modules = SplashModule.class)
14 | public interface SplashComponent {
15 | void inject(SplashActivity activity);
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/di/splash/SplashModule.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.di.splash;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import dagger.Module;
8 | import dagger.Provides;
9 | import iammert.com.instagramtags.di.Activity;
10 | import iammert.com.instagramtags.domain.splash.SplashUsecase;
11 | import iammert.com.instagramtags.domain.splash.SplashUsecaseImpl;
12 | import iammert.com.instagramtags.model.preferences.PreferencesHelper;
13 | import iammert.com.instagramtags.model.preferences.PreferencesHelperImpl;
14 | import iammert.com.instagramtags.viewmodel.splash.SplashViewModel;
15 |
16 | /**
17 | * Created by mertsimsek on 13/01/17.
18 | */
19 |
20 | @Module
21 | public class SplashModule {
22 |
23 | SplashViewModel.SplashListener listener;
24 |
25 | public SplashModule(SplashViewModel.SplashListener listener) {
26 | this.listener = listener;
27 | }
28 |
29 | @Provides
30 | @Activity
31 | PreferencesHelper provideTokenPreferencesHelper(SharedPreferences sharedPreferences, Gson gson){
32 | return new PreferencesHelperImpl<>(sharedPreferences, gson);
33 | }
34 |
35 | @Provides
36 | @Activity
37 | SplashUsecase provideSplashUsecase(PreferencesHelper tokenPreferencesHelper){
38 | return new SplashUsecaseImpl(tokenPreferencesHelper);
39 | }
40 |
41 | @Provides
42 | @Activity
43 | SplashViewModel provideSplashViewModel(SplashUsecase splashUsecase){
44 | return new SplashViewModel(splashUsecase, listener);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/domain/medialist/MediaListUsecase.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.domain.medialist;
2 |
3 | import iammert.com.instagramtags.model.api.entity.MediaListResponse;
4 | import rx.Observable;
5 |
6 | /**
7 | * Created by mertsimsek on 13/01/17.
8 | */
9 |
10 | public interface MediaListUsecase {
11 |
12 | Observable searchMedia(String tag);
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/domain/medialist/MediaListUsecaseImpl.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.domain.medialist;
2 |
3 | import javax.inject.Inject;
4 |
5 | import iammert.com.instagramtags.model.api.ApiSource;
6 | import iammert.com.instagramtags.model.api.entity.MediaListResponse;
7 | import iammert.com.instagramtags.model.preferences.PreferencesHelper;
8 | import iammert.com.instagramtags.util.Constants;
9 | import iammert.com.instagramtags.util.RxTransformer;
10 | import rx.Observable;
11 |
12 | /**
13 | * Created by mertsimsek on 13/01/17.
14 | */
15 |
16 | public class MediaListUsecaseImpl implements MediaListUsecase{
17 |
18 | private ApiSource apiSource;
19 | private PreferencesHelper tokenPreferencesHelper;
20 |
21 | @Inject
22 | public MediaListUsecaseImpl(ApiSource apiSource, PreferencesHelper tokenPreferencesHelper) {
23 | this.apiSource = apiSource;
24 | this.tokenPreferencesHelper = tokenPreferencesHelper;
25 | }
26 |
27 | @Override
28 | public Observable searchMedia(String tag) {
29 | return tokenPreferencesHelper.get(Constants.SHARED_KEY_TOKEN, String.class)
30 | .flatMap(s -> apiSource.searchMedia(tag, s))
31 | .compose(RxTransformer.applyIOSchedulers());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/domain/searchtag/SearchTagUsecase.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.domain.searchtag;
2 |
3 | import iammert.com.instagramtags.model.api.entity.TagSearchResponse;
4 | import rx.Observable;
5 |
6 | /**
7 | * Created by mertsimsek on 13/01/17.
8 | */
9 |
10 | public interface SearchTagUsecase {
11 |
12 | Observable searchTag(String query);
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/domain/searchtag/SearchTagUsecaseImpl.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.domain.searchtag;
2 |
3 | import javax.inject.Inject;
4 |
5 | import iammert.com.instagramtags.model.api.ApiSource;
6 | import iammert.com.instagramtags.model.api.entity.TagSearchResponse;
7 | import iammert.com.instagramtags.model.preferences.PreferencesHelper;
8 | import iammert.com.instagramtags.util.Constants;
9 | import iammert.com.instagramtags.util.RxTransformer;
10 | import rx.Observable;
11 |
12 | /**
13 | * Created by mertsimsek on 13/01/17.
14 | */
15 |
16 | public class SearchTagUsecaseImpl implements SearchTagUsecase {
17 |
18 | private PreferencesHelper tokenHelper;
19 | private ApiSource apiSource;
20 |
21 | @Inject
22 | public SearchTagUsecaseImpl(PreferencesHelper tokenHelper, ApiSource apiSource) {
23 | this.tokenHelper = tokenHelper;
24 | this.apiSource = apiSource;
25 | }
26 |
27 | @Override
28 | public Observable searchTag(String query) {
29 | return tokenHelper.get(Constants.SHARED_KEY_TOKEN, String.class)
30 | .flatMap(s -> apiSource.searchTag(query, s))
31 | .compose(RxTransformer.applyIOSchedulers());
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/domain/splash/SplashUsecase.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.domain.splash;
2 |
3 |
4 | import rx.Observable;
5 |
6 | /**
7 | * Created by mertsimsek on 13/01/17.
8 | */
9 |
10 | public interface SplashUsecase {
11 |
12 | Observable saveToken(String token);
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/domain/splash/SplashUsecaseImpl.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.domain.splash;
2 |
3 | import javax.inject.Inject;
4 |
5 | import iammert.com.instagramtags.model.preferences.PreferencesHelper;
6 | import iammert.com.instagramtags.util.Constants;
7 | import iammert.com.instagramtags.util.RxTransformer;
8 | import rx.Observable;
9 |
10 | /**
11 | * Created by mertsimsek on 13/01/17.
12 | */
13 |
14 | public class SplashUsecaseImpl implements SplashUsecase{
15 |
16 | PreferencesHelper tokenHelper;
17 |
18 | @Inject
19 | public SplashUsecaseImpl(PreferencesHelper tokenHelper) {
20 | this.tokenHelper = tokenHelper;
21 | }
22 |
23 | @Override
24 | public Observable saveToken(String token) {
25 | return tokenHelper.save(Constants.SHARED_KEY_TOKEN, token)
26 | .compose(RxTransformer.applyComputationSchedulers());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/ApiSource.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api;
2 |
3 | import iammert.com.instagramtags.model.api.entity.MediaListResponse;
4 | import iammert.com.instagramtags.model.api.entity.TagSearchResponse;
5 | import rx.Observable;
6 |
7 | /**
8 | * Created by mertsimsek on 13/01/17.
9 | */
10 |
11 | public interface ApiSource {
12 |
13 | Observable searchTag(String query, String token);
14 |
15 | Observable searchMedia(String tag, String token);
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/ApiSourceImpl.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api;
2 |
3 | import iammert.com.instagramtags.model.api.entity.MediaListResponse;
4 | import iammert.com.instagramtags.model.api.entity.TagSearchResponse;
5 | import retrofit2.Retrofit;
6 | import rx.Observable;
7 |
8 | /**
9 | * Created by mertsimsek on 13/01/17.
10 | */
11 |
12 | public class ApiSourceImpl implements ApiSource{
13 |
14 | RetrofitInterface retrofitInterface;
15 |
16 | public ApiSourceImpl(Retrofit retrofit) {
17 | retrofitInterface = retrofit.create(RetrofitInterface.class);
18 | }
19 |
20 | @Override
21 | public Observable searchTag(String query, String token) {
22 | return retrofitInterface.searchTag(query, token);
23 | }
24 |
25 | @Override
26 | public Observable searchMedia(String tag, String token) {
27 | return retrofitInterface.searchMediaWithTag(tag, token);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/RetrofitInterface.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api;
2 |
3 | import iammert.com.instagramtags.model.api.entity.MediaListResponse;
4 | import iammert.com.instagramtags.model.api.entity.TagSearchResponse;
5 | import retrofit2.http.GET;
6 | import retrofit2.http.Path;
7 | import retrofit2.http.Query;
8 | import rx.Observable;
9 |
10 | /**
11 | * Created by mertsimsek on 13/01/17.
12 | */
13 |
14 | public interface RetrofitInterface {
15 |
16 | @GET("tags/search")
17 | Observable searchTag(@Query("q") String query,
18 | @Query("access_token") String token);
19 |
20 | @GET("tags/{tag_name}/media/recent")
21 | Observable searchMediaWithTag(@Path("tag_name") String tag,
22 | @Query("access_token") String token);
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/Comment.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import org.parceler.Parcel;
4 |
5 | /**
6 | * Created by mertsimsek on 14/01/17.
7 | */
8 | @Parcel
9 | public class Comment {
10 | public int count;
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/Image.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import org.parceler.Parcel;
4 |
5 | /**
6 | * Created by mertsimsek on 14/01/17.
7 | */
8 | @Parcel
9 | public class Image {
10 | public String url;
11 | public int width;
12 | public int height;
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/ImageWrapper.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import org.parceler.Parcel;
6 |
7 | /**
8 | * Created by mertsimsek on 14/01/17.
9 | */
10 | @Parcel
11 | public class ImageWrapper {
12 | @SerializedName("low_resolution")
13 | public Image lowResolution;
14 | public Image thumbnail;
15 | @SerializedName("standard_resolution")
16 | public Image standartResolution;
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/Like.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import org.parceler.Parcel;
4 |
5 | /**
6 | * Created by mertsimsek on 14/01/17.
7 | */
8 | @Parcel
9 | public class Like {
10 | public int count;
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/Media.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import org.parceler.Parcel;
4 |
5 | /**
6 | * Created by mertsimsek on 14/01/17.
7 | */
8 | @Parcel
9 | public class Media {
10 | public String id;
11 | public String type;
12 | public String filter;
13 | public Comment comments;
14 | public Like likes;
15 | public User user;
16 | public ImageWrapper images;
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/MediaListResponse.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import org.parceler.Parcel;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by mertsimsek on 14/01/17.
9 | */
10 | @Parcel
11 | public class MediaListResponse {
12 | public List data;
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/Tag.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import org.parceler.Parcel;
6 |
7 | /**
8 | * Created by mertsimsek on 13/01/17.
9 | */
10 | @Parcel
11 | public class Tag {
12 | public String name;
13 | @SerializedName("media_count")
14 | public int mediaCount;
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/TagSearchResponse.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import org.parceler.Parcel;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by mertsimsek on 13/01/17.
9 | */
10 | @Parcel
11 | public class TagSearchResponse {
12 | public List data;
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/api/entity/User.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.api.entity;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import org.parceler.Parcel;
6 |
7 | /**
8 | * Created by mertsimsek on 14/01/17.
9 | */
10 | @Parcel
11 | public class User {
12 | public String id;
13 | public String username;
14 | @SerializedName("profile_picture")
15 | public String profilePicture;
16 | @SerializedName("full_name")
17 | public String fullName;
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/preferences/PreferencesHelper.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.preferences;
2 |
3 | import rx.Observable;
4 |
5 | /**
6 | * Created by mertsimsek on 13/01/17.
7 | */
8 |
9 | public interface PreferencesHelper {
10 |
11 | Observable save(String key, T value);
12 |
13 | Observable get(String key, Class generic);
14 |
15 | Observable clear();
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/model/preferences/PreferencesHelperImpl.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.model.preferences;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import javax.inject.Inject;
8 |
9 | import rx.Observable;
10 |
11 | /**
12 | * Created by mertsimsek on 13/01/17.
13 | */
14 |
15 | public class PreferencesHelperImpl implements PreferencesHelper {
16 |
17 | SharedPreferences sharedPreferences;
18 | Gson gson;
19 |
20 | @Inject
21 | public PreferencesHelperImpl(SharedPreferences sharedPreferences, Gson gson) {
22 | this.sharedPreferences = sharedPreferences;
23 | this.gson = gson;
24 | }
25 |
26 | @Override
27 | public Observable save(String key, T value) {
28 | return Observable.create(subscriber -> {
29 | sharedPreferences.edit().putString(key, gson.toJson(value)).apply();
30 | subscriber.onNext(value);
31 | subscriber.onCompleted();
32 | });
33 | }
34 |
35 | @Override
36 | public Observable get(String key, Class generic) {
37 | return Observable.create(subscriber -> {
38 | String json = sharedPreferences.getString(key, "");
39 | T myClass = gson.fromJson(json, generic);
40 | subscriber.onNext(myClass);
41 | subscriber.onCompleted();
42 | });
43 | }
44 |
45 | @Override
46 | public Observable clear() {
47 | return Observable.create(subscriber -> {
48 | sharedPreferences.edit().clear().commit();
49 | subscriber.onNext(true);
50 | subscriber.onCompleted();
51 | });
52 | }
53 | }
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/util/Constants.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.util;
2 |
3 | /**
4 | * Created by mertsimsek on 13/01/17.
5 | */
6 |
7 | public class Constants {
8 |
9 | /**
10 | * Base url for api call
11 | */
12 | public static final String BASE_URL = "https://api.instagram.com/v1/";
13 |
14 | /**
15 | * Client info, scope info, response type
16 | */
17 | public static final String CLIENT_ID = "";
18 | public static final String REDIRECT_URI = "";
19 | public static final String RESPONSE_TYPE = "token";
20 | public static final String SCOPE = "public_content";
21 |
22 | /**
23 | * Static login url
24 | */
25 | public static final String LOGIN_URL = "https://www.instagram.com/oauth/authorize/?client_id=" +
26 | CLIENT_ID + "&redirect_uri=" + REDIRECT_URI +
27 | "&response_type=" + RESPONSE_TYPE + "&scope=" + SCOPE;
28 |
29 | /**
30 | * Intent Keys
31 | */
32 | public static final String KEY_INTENT_TOKEN = "token";
33 |
34 | /**
35 | * Shared Preferences Keys
36 | */
37 | public static final String SHARED_KEY_TOKEN = "shared_key_token";
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/util/DialogBuilder.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.util;
2 |
3 | import android.content.Context;
4 |
5 | import com.afollestad.materialdialogs.MaterialDialog;
6 |
7 | import iammert.com.instagramtags.R;
8 |
9 | /**
10 | * Created by mertsimsek on 15/01/17.
11 | */
12 |
13 | public class DialogBuilder {
14 |
15 | public static MaterialDialog.Builder progressDialog(Context context, int title, int content) {
16 | return new MaterialDialog.Builder(context)
17 | .title(title)
18 | .content(content)
19 | .canceledOnTouchOutside(false)
20 | .progress(true, 0);
21 | }
22 |
23 | public static MaterialDialog.Builder infoDialog(Context context, int title, int content) {
24 | return new MaterialDialog.Builder(context)
25 | .title(title)
26 | .content(content)
27 | .positiveText(R.string.dialog_action_ok)
28 | .positiveColorRes(R.color.colorPrimary);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/util/ImageDataBinding.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.util;
2 |
3 | import android.databinding.BindingAdapter;
4 | import android.graphics.drawable.Drawable;
5 | import android.widget.ImageView;
6 |
7 | import com.squareup.picasso.Picasso;
8 |
9 | import de.hdodenhof.circleimageview.CircleImageView;
10 |
11 | /**
12 | * Created by mertsimsek on 14/01/17.
13 | */
14 |
15 | public class ImageDataBinding {
16 |
17 | @BindingAdapter({"bind:imageUrl", "bind:placeHolder"})
18 | public static void loadImage(ImageView view, String url, Drawable placeHolder) {
19 | if (url != null && !url.equals(""))
20 | Picasso.with(view.getContext()).load(url).placeholder(placeHolder).resize(500, 500).centerCrop().into(view);
21 | }
22 |
23 | @BindingAdapter({"bind:circleLibImageUrl", "bind:circleLibPlaceHolder"})
24 | public static void loadCircleImage(CircleImageView view, String url, Drawable placeHolder) {
25 | if (url != null && !url.equals(""))
26 | Picasso.with(view.getContext()).load(url).placeholder(placeHolder).resize(500, 500).centerCrop().into(view);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/iammert/com/instagramtags/util/RxBus.java:
--------------------------------------------------------------------------------
1 | package iammert.com.instagramtags.util;
2 |
3 | import rx.Observable;
4 | import rx.subjects.PublishSubject;
5 | import rx.subjects.SerializedSubject;
6 | import rx.subjects.Subject;
7 |
8 | /**
9 | * Created by mertsimsek on 13/01/17.
10 | */
11 |
12 | public class RxBus {
13 |
14 | private static RxBus instance = null;
15 | private final Subject