├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_favorite_white_24dp.png │ │ │ │ └── ic_settings_black_24dp.png │ │ │ ├── drawable-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_favorite_white_24dp.png │ │ │ │ └── ic_settings_black_24dp.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_favorite_white_24dp.png │ │ │ │ └── ic_settings_black_24dp.png │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_favorite_white_24dp.png │ │ │ │ └── ic_settings_black_24dp.png │ │ │ ├── drawable │ │ │ │ └── tool_bar_background.9.png │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── menu │ │ │ │ ├── menu_edit_product.xml │ │ │ │ ├── menu_main.xml │ │ │ │ ├── menu_list_product.xml │ │ │ │ └── menu_grid_movie.xml │ │ │ ├── layout │ │ │ │ ├── activity_movie_list.xml │ │ │ │ ├── fragment_tv_grid.xml │ │ │ │ ├── activity_product_list.xml │ │ │ │ ├── fragment_main_navigation_drawer.xml │ │ │ │ ├── fragment_movie_grid.xml │ │ │ │ ├── fragment_tv.xml │ │ │ │ ├── fragment_movie.xml │ │ │ │ ├── activity_product_edit.xml │ │ │ │ ├── list_header_movie_detail.xml │ │ │ │ ├── activity_movie_detail.xml │ │ │ │ ├── view_pager_item_movie_cover.xml │ │ │ │ ├── recycle_view_item_movie.xml │ │ │ │ ├── recycle_view_item_tv.xml │ │ │ │ ├── list_header_main_navigation.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── recycle_view_item_movie_cast.xml │ │ │ │ └── activity_signin.xml │ │ │ └── values-w820dp │ │ │ │ └── dimens.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── taskworld │ │ │ │ └── android │ │ │ │ └── restfulandroidkotlin │ │ │ │ ├── extension │ │ │ │ ├── Generics.kt │ │ │ │ ├── StringBuilders.kt │ │ │ │ ├── Fragments.kt │ │ │ │ ├── Views.kt │ │ │ │ ├── Activities.kt │ │ │ │ ├── Strings.kt │ │ │ │ └── Realms.kt │ │ │ │ ├── event │ │ │ │ ├── OnToolbarTitleChangedEvent.kt │ │ │ │ ├── OnMovieCategorySelectedEvent.kt │ │ │ │ ├── BaseEvent.kt │ │ │ │ └── OnDrawerToggledEvent.kt │ │ │ │ ├── presenter │ │ │ │ ├── Presenter.kt │ │ │ │ └── SignInPresenter.kt │ │ │ │ ├── action │ │ │ │ └── SignInUIAction.kt │ │ │ │ ├── network │ │ │ │ ├── request │ │ │ │ │ ├── GetMovieSpiceRequest.kt │ │ │ │ │ ├── GetTokenSpiceRequest.kt │ │ │ │ │ ├── GetMovieCreditsSpiceRequest.kt │ │ │ │ │ ├── GetListTVPopularSpiceRequest.kt │ │ │ │ │ ├── GetListTVAiringtodaySpiceRequest.kt │ │ │ │ │ ├── GetMovieImagesSpiceRequest.kt │ │ │ │ │ ├── GetListMovieTopratedSpiceRequest.kt │ │ │ │ │ ├── GetNewSessionSpiceRequest.kt │ │ │ │ │ ├── GetListMovieNowplayingSpiceRequest.kt │ │ │ │ │ └── ValidateTokenSpiceRequest.kt │ │ │ │ ├── response │ │ │ │ │ └── EventBusRequestListener.kt │ │ │ │ ├── service │ │ │ │ │ └── TheMovieAPISpiceService.kt │ │ │ │ └── api │ │ │ │ │ └── TheMovieDBAPI.kt │ │ │ │ ├── view │ │ │ │ ├── activity │ │ │ │ │ ├── BaseSpiceActivity.kt │ │ │ │ │ ├── MainActivity.kt │ │ │ │ │ ├── BaseActivity.kt │ │ │ │ │ ├── ProductEditActivity.kt │ │ │ │ │ ├── SignInActivity.kt │ │ │ │ │ ├── MovieListActivity.kt │ │ │ │ │ ├── ProductListActivity.kt │ │ │ │ │ └── MovieDetailActivity.kt │ │ │ │ └── fragment │ │ │ │ │ ├── BaseSpiceFragment.kt │ │ │ │ │ ├── TVFragment.kt │ │ │ │ │ ├── MovieFragment.kt │ │ │ │ │ ├── BaseFragment.kt │ │ │ │ │ ├── BaseDrawerFragment.kt │ │ │ │ │ ├── MainNavigationDrawerFragment.kt │ │ │ │ │ ├── TVGridFragment.kt │ │ │ │ │ └── MovieGridFragment.kt │ │ │ │ ├── util │ │ │ │ ├── CircularTransformation.kt │ │ │ │ └── Preference.kt │ │ │ │ ├── interactor │ │ │ │ └── SignInInteractor.kt │ │ │ │ └── resource │ │ │ │ ├── router │ │ │ │ └── ResourceRouter.kt │ │ │ │ └── client │ │ │ │ └── ResourceClient.kt │ │ ├── java │ │ │ └── com │ │ │ │ └── taskworld │ │ │ │ └── android │ │ │ │ └── restfulandroidkotlin │ │ │ │ ├── model │ │ │ │ ├── Image.java │ │ │ │ ├── Product.java │ │ │ │ ├── Cast.java │ │ │ │ ├── Movie.java │ │ │ │ └── TV.java │ │ │ │ └── adapter │ │ │ │ └── ParallaxRecyclerAdapter.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── taskworld │ │ └── realmwithkotlin │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── apiary.apib /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/tool_bar_background.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable/tool_bar_background.9.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | restful-android-kotlin 2 | ====================== 3 | 4 | POC for Restful Android App with Realm, Robospice, Retrofit. All of them will be wrote with Kotlin 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_favorite_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-hdpi/ic_favorite_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_settings_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-hdpi/ic_settings_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_favorite_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-mdpi/ic_favorite_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_settings_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-mdpi/ic_settings_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_favorite_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-xhdpi/ic_favorite_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_settings_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-xhdpi/ic_settings_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_favorite_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-xxhdpi/ic_favorite_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_settings_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerachadW/restful-android-kotlin/HEAD/app/src/main/res/drawable-xxhdpi/ic_settings_black_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_edit_product.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/extension/Generics.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.extension 2 | 3 | /** 4 | * Created by Kittinun Vantasin on 10/18/14. 5 | */ 6 | 7 | fun T.tag(): String { 8 | return javaClass.getSimpleName() 9 | } 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/event/OnToolbarTitleChangedEvent.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.event 2 | 3 | /** 4 | * Created by Kittinun Vantasin on 11/7/14. 5 | */ 6 | 7 | class OnToolbarTitleChangedEvent(val title: String) : BaseEvent() { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_movie_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_tv_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/event/OnMovieCategorySelectedEvent.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.event 2 | 3 | /** 4 | * Created by Kittinun Vantasin on 11/7/14. 5 | */ 6 | 7 | class OnMovieCategorySelectedEvent(val category: String) : BaseEvent() { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_product_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/event/BaseEvent.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.event 2 | 3 | import com.taskworld.android.restfulandroidkotlin.extension.tag 4 | 5 | /** 6 | * Created by Kittinun Vantasin on 10/18/14. 7 | */ 8 | 9 | open class BaseEvent { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/presenter/Presenter.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.presenter 2 | 3 | /** 4 | * Created by Kittinun Vantasin on 11/17/14. 5 | */ 6 | 7 | trait Presenter { 8 | 9 | fun onResume() { 10 | 11 | } 12 | 13 | fun onPause() { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/extension/StringBuilders.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.extension 2 | 3 | /** 4 | * Created by Kittinun Vantasin on 10/29/14. 5 | */ 6 | 7 | fun StringBuilder.plus(add: String?): StringBuilder { 8 | if (add != null) { 9 | append(add) 10 | } 11 | return this 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/event/OnDrawerToggledEvent.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.event 2 | 3 | import com.taskworld.android.restfulandroidkotlin.view.fragment.BaseDrawerFragment.Direction 4 | 5 | /** 6 | * Created by Kittinun Vantasin on 11/6/14. 7 | */ 8 | 9 | class OnDrawerToggledEvent(val direction: Direction) : BaseEvent() { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/action/SignInUIAction.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.action 2 | 3 | /** 4 | * Created by Kittinun Vantasin on 11/14/14. 5 | */ 6 | 7 | trait SignInUIAction { 8 | fun showProgress() 9 | fun hideProgress() 10 | fun setUnauthorizedError() 11 | fun setNetworkError() 12 | fun navigateToMain(sessionId: String) 13 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main_navigation_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_list_product.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/extension/Fragments.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.extension 2 | 3 | import android.support.v4.app.Fragment 4 | import android.widget.Toast 5 | 6 | /** 7 | * Created by Kittinun Vantasin on 11/5/14. 8 | */ 9 | 10 | fun Fragment.toast(text: String?): Unit { 11 | if (text == null) return 12 | Toast.makeText(getActivity(), text, Toast.LENGTH_LONG).show() 13 | } 14 | -------------------------------------------------------------------------------- /app/src/androidTest/java/taskworld/realmwithkotlin/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package taskworld.realmwithkotlin; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/extension/Views.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.extension 2 | 3 | import android.view.View 4 | 5 | /** 6 | * Created by Kittinun Vantasin on 10/18/14. 7 | */ 8 | 9 | fun View.bindView(id: Int): T { 10 | val view = findViewById(id) ?: 11 | throw IllegalArgumentException("Given ID $id could not be found in $this!") 12 | [suppress("unchecked_cast")] 13 | return view as T 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_movie_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_tv.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_movie.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | restful-android-kotlin 5 | Hello world! 6 | Settings 7 | 8 | Open navigation drawer 9 | Close navigation drawer 10 | 11 | Sign into The Movie DB 12 | Sign in 13 | 14 | 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Windows thumbnail db 19 | Thumbs.db 20 | 21 | # OSX files 22 | .DS_Store 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | 28 | # Android Studio 29 | .idea 30 | *.iml 31 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 32 | .gradle 33 | build/ 34 | 35 | # Realm specific 36 | *.timestamp 37 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_grid_movie.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 12 | 13 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/extension/Activities.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.extension 2 | 3 | import android.app.Activity 4 | import android.view.View 5 | import android.widget.Toast 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 10/17/14. 9 | */ 10 | 11 | fun Activity.bindView(id: Int) : T { 12 | val view = findViewById(id) ?: 13 | throw IllegalArgumentException("Given ID $id could not be found in $this!") 14 | [suppress("unchecked_cast")] 15 | return view as T 16 | } 17 | 18 | fun Activity.toast(text: String?) { 19 | if (text == null) return 20 | Toast.makeText(this, text, Toast.LENGTH_LONG).show() 21 | } -------------------------------------------------------------------------------- /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/VerachadW/.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/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetMovieSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 4 | import com.taskworld.android.restfulandroidkotlin.model.Movie 5 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 10/29/14. 9 | */ 10 | 11 | class GetMovieSpiceRequest(val path: String) : 12 | RetrofitSpiceRequest(javaClass(), javaClass()) { 13 | 14 | override fun loadDataFromNetwork(): Movie? { 15 | return getService().get(path) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetTokenSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.retrofit.RetrofitGsonSpiceService 4 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by VerachadW on 11/4/14. 9 | */ 10 | class GetTokenSpiceRequest : 11 | RetrofitSpiceRequest, TheMovieDBAPI.Authentication>(javaClass>(), javaClass()) { 12 | 13 | override fun loadDataFromNetwork(): Map? { 14 | return getService().getRequestToken() 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetMovieCreditsSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 4 | import com.taskworld.android.restfulandroidkotlin.model.Cast 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/11/14. 9 | */ 10 | 11 | class GetMovieCreditsSpiceRequest(val path: String) : 12 | RetrofitSpiceRequest(javaClass(), javaClass()) { 13 | 14 | override fun loadDataFromNetwork(): Cast.CastList? { 15 | return getService().getCastList(path) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetListTVPopularSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 4 | import com.taskworld.android.restfulandroidkotlin.model.TV 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/11/14. 9 | */ 10 | 11 | class GetListTVPopularSpiceRequest(val path: String) : 12 | RetrofitSpiceRequest(javaClass(), javaClass()) { 13 | 14 | override fun loadDataFromNetwork(): TV.ResultList? { 15 | return getService().getPopularList(path) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetListTVAiringtodaySpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 4 | import com.taskworld.android.restfulandroidkotlin.model.TV 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/11/14. 9 | */ 10 | 11 | class GetListTVAiringtodaySpiceRequest(val path: String) : 12 | RetrofitSpiceRequest(javaClass(), javaClass()) { 13 | 14 | override fun loadDataFromNetwork(): TV.ResultList? { 15 | return getService().getAiringTodayList(path) 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetMovieImagesSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 4 | import com.taskworld.android.restfulandroidkotlin.model.Image 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/13/14. 9 | */ 10 | 11 | class GetMovieImagesSpiceRequest(val path: String) : 12 | RetrofitSpiceRequest(javaClass(), javaClass()) { 13 | 14 | override fun loadDataFromNetwork(): Image.PosterList? { 15 | return getService().getPosterImageList(path) 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetListMovieTopratedSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 4 | import com.taskworld.android.restfulandroidkotlin.model.Movie 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/11/14. 9 | */ 10 | 11 | class GetListMovieTopratedSpiceRequest(val path: String) : 12 | RetrofitSpiceRequest(javaClass(), javaClass()) { 13 | 14 | override fun loadDataFromNetwork(): Movie.ResultList? { 15 | return getService().getTopRatedList(path) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetNewSessionSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.retrofit.RetrofitGsonSpiceService 4 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by VerachadW on 11/4/14. 9 | */ 10 | class GetNewSessionSpiceRequest(val token: String) : 11 | RetrofitSpiceRequest, TheMovieDBAPI.Authentication>(javaClass>(), javaClass()) { 12 | 13 | override fun loadDataFromNetwork(): Map? { 14 | return getService().getNewSession(token) 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/extension/Strings.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.extension 2 | 3 | /** 4 | * Created by Kittinun Vantasin on 10/29/14. 5 | */ 6 | 7 | fun String.toStartingLetterUppercase(): String { 8 | if (this.isEmpty()) return this 9 | 10 | var firstChar = this.charAt(0) 11 | val valueOfFirstChar = firstChar.toInt() 12 | 13 | if (valueOfFirstChar in 97..122) { 14 | firstChar = (valueOfFirstChar - 32).toChar() 15 | } 16 | 17 | val builder = StringBuilder() 18 | 19 | var i = 0 20 | for (ch in this) { 21 | if (i == 0) { 22 | builder.append(firstChar) 23 | } else { 24 | builder.append(ch) 25 | } 26 | i++ 27 | } 28 | 29 | return builder.toString() 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/GetListMovieNowplayingSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 4 | import com.taskworld.android.restfulandroidkotlin.model.Movie 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/11/14. 9 | */ 10 | 11 | class GetListMovieNowplayingSpiceRequest(val path: String) : 12 | RetrofitSpiceRequest(javaClass(), javaClass()) { 13 | 14 | override fun loadDataFromNetwork(): Movie.ResultList? { 15 | return getService().getNowPlayingList(path) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/taskworld/android/restfulandroidkotlin/model/Image.java: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.model; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/13/14. 9 | */ 10 | public class Image { 11 | 12 | @SerializedName("file_path") 13 | private String filePath; 14 | 15 | @SerializedName("vote_count") 16 | private int voteCount; 17 | 18 | public static class PosterList { 19 | 20 | @SerializedName("posters") 21 | private List results; 22 | 23 | public List getResults() { 24 | return results; 25 | } 26 | } 27 | 28 | public String getFilePath() { 29 | return filePath; 30 | } 31 | 32 | public int getVoteCount() { 33 | return voteCount; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/network/request/ValidateTokenSpiceRequest.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.network.request 2 | 3 | import com.octo.android.robospice.retrofit.RetrofitGsonSpiceService 4 | import com.octo.android.robospice.request.retrofit.RetrofitSpiceRequest 5 | import com.taskworld.android.restfulandroidkotlin.network.api.TheMovieDBAPI 6 | 7 | /** 8 | * Created by VerachadW on 11/4/14. 9 | */ 10 | class ValidateTokenSpiceRequest (val username: String, val password: String, val token: String) : 11 | RetrofitSpiceRequest, TheMovieDBAPI.Authentication>(javaClass>(), javaClass()) { 12 | 13 | 14 | override fun loadDataFromNetwork(): Map? { 15 | return getService().validateToken(username, password, token) 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /app/src/main/java/com/taskworld/android/restfulandroidkotlin/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.model; 2 | 3 | import io.realm.RealmObject; 4 | import io.realm.annotations.Ignore; 5 | 6 | /** 7 | * Created by Kittinun Vantasin on 10/19/14. 8 | */ 9 | public class Product extends RealmObject { 10 | 11 | @Ignore 12 | public static final String TABLE_NAME = "Product"; 13 | 14 | public enum Field { 15 | name, 16 | price 17 | } 18 | 19 | private String name; 20 | private int price; 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public int getPrice() { 31 | return price; 32 | } 33 | 34 | public void setPrice(int price) { 35 | this.price = price; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/view/activity/BaseSpiceActivity.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.view.activity 2 | 3 | import com.octo.android.robospice.SpiceManager 4 | import com.taskworld.android.restfulandroidkotlin.network.service.TheMovieAPISpiceService 5 | 6 | /** 7 | * Created by Kittinun Vantasin on 10/24/14. 8 | */ 9 | 10 | abstract class BaseSpiceActivity : BaseActivity() { 11 | 12 | val mSpiceManager: SpiceManager = SpiceManager(javaClass()) 13 | 14 | override fun onStart() { 15 | super.onStart() 16 | mSpiceManager.start(this) 17 | } 18 | 19 | override fun onStop() { 20 | super.onStop() 21 | mSpiceManager.shouldStop() 22 | } 23 | 24 | fun getServiceSpiceManager(): SpiceManager { 25 | return mSpiceManager 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/taskworld/android/restfulandroidkotlin/view/fragment/BaseSpiceFragment.kt: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.view.fragment 2 | 3 | import com.octo.android.robospice.SpiceManager 4 | import com.taskworld.android.restfulandroidkotlin.network.service.TheMovieAPISpiceService 5 | 6 | /** 7 | * Created by Kittinun Vantasin on 11/5/14. 8 | */ 9 | 10 | abstract class BaseSpiceFragment : BaseFragment() { 11 | 12 | val mSpiceManager: SpiceManager = SpiceManager(javaClass()) 13 | 14 | override fun onStart() { 15 | super.onStart() 16 | mSpiceManager.start(getActivity()) 17 | } 18 | 19 | override fun onStop() { 20 | super.onStop() 21 | mSpiceManager.shouldStop() 22 | } 23 | 24 | fun getServiceSpiceManager(): SpiceManager { 25 | return mSpiceManager 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/taskworld/android/restfulandroidkotlin/model/Cast.java: -------------------------------------------------------------------------------- 1 | package com.taskworld.android.restfulandroidkotlin.model; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Kittinun Vantasin on 11/11/14. 9 | */ 10 | public class Cast { 11 | 12 | private String character; 13 | 14 | private String name; 15 | 16 | @SerializedName("profile_path") 17 | private String profilePath; 18 | 19 | public static class CastList { 20 | private List cast; 21 | 22 | public List getCasts() { 23 | return cast; 24 | } 25 | } 26 | 27 | public String getCharacter() { 28 | return character; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public String getProfilePath() { 36 | return profilePath; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_product_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 13 | 14 | 19 | 20 |