├── app ├── .gitignore ├── src │ └── main │ │ ├── assets │ │ ├── screen1.png │ │ ├── screen2.png │ │ ├── screen3.png │ │ └── screen4.jpg │ │ ├── res │ │ ├── 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 │ │ │ ├── strings.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ ├── view_news_item.xml │ │ │ └── activity_main.xml │ │ ├── java │ │ └── com │ │ │ └── ktoi │ │ │ └── toi │ │ │ ├── view │ │ │ ├── interfaces │ │ │ │ └── NewsView.kt │ │ │ ├── adapters │ │ │ │ └── NewsAdapter.kt │ │ │ └── activities │ │ │ │ └── MainActivity.kt │ │ │ ├── shared │ │ │ ├── NewsApiInterface.kt │ │ │ ├── Constants.kt │ │ │ ├── AppDelegate.kt │ │ │ ├── NewsModule.kt │ │ │ └── DateUtil.kt │ │ │ ├── model │ │ │ ├── Image.kt │ │ │ ├── Pagination.kt │ │ │ ├── NewsResponse.java │ │ │ └── NewsItem.kt │ │ │ └── presenter │ │ │ └── NewsPresenter.kt │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── made_in_steelkiwi.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /made_in_steelkiwi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/made_in_steelkiwi.png -------------------------------------------------------------------------------- /app/src/main/assets/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/assets/screen1.png -------------------------------------------------------------------------------- /app/src/main/assets/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/assets/screen2.png -------------------------------------------------------------------------------- /app/src/main/assets/screen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/assets/screen3.png -------------------------------------------------------------------------------- /app/src/main/assets/screen4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/assets/screen4.jpg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steelkiwi/Getting-started-with-Kotlin/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | .idea/ 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 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.14.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TOI 3 | Agency: %s 4 | List is empty 5 | Connection error 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/ktoi/toi/view/interfaces/NewsView.kt: -------------------------------------------------------------------------------- 1 | package com.ktoi.toi.view.interfaces 2 | 3 | import com.ktoi.toi.model.NewsItem 4 | 5 | interface NewsView { 6 | 7 | fun onNewsItemLoaded(newsItems: List) 8 | 9 | fun onError(throwable: Throwable?) 10 | 11 | fun hideLoading() 12 | 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ktoi/toi/shared/NewsApiInterface.kt: -------------------------------------------------------------------------------- 1 | package com.ktoi.toi.shared 2 | 3 | import com.ktoi.toi.model.NewsResponse 4 | 5 | import retrofit2.http.GET 6 | import rx.Observable 7 | 8 | interface NewsApiInterface { 9 | 10 | @GET("/feeds/newsdefaultfeeds.cms?feedtype=sjson") 11 | fun getNews(): Observable 12 | 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ktoi/toi/shared/Constants.kt: -------------------------------------------------------------------------------- 1 | package com.ktoi.toi.shared 2 | 3 | class Constants { 4 | 5 | companion object { 6 | 7 | val NEWS_ENDPOINT = "http://timesofindia.indiatimes.com/" 8 | val DATE_PATTERN = "MMM dd, yyyy, hh.mma" 9 | val IST_TIME_ZONE = "IST" 10 | 11 | 12 | val LEADING_ZERO_TEMPLATE = "%02d" 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/ktoi/toi/model/Image.kt: -------------------------------------------------------------------------------- 1 | package com.ktoi.toi.model 2 | 3 | import com.google.gson.annotations.Expose 4 | import com.google.gson.annotations.SerializedName 5 | 6 | import io.realm.RealmObject 7 | 8 | open class Image : RealmObject() { 9 | 10 | 11 | @SerializedName("Photo") 12 | @Expose 13 | var photo: String? = null 14 | 15 | @SerializedName("Thumb") 16 | @Expose 17 | var thumb: String? = null 18 | 19 | 20 | @SerializedName("PhotoCaption") 21 | @Expose 22 | var photoCaption: String? = null 23 | 24 | } -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 16dp 7 | 40dp 8 | 16sp 9 | 56dp 10 | 13sp 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/ktoi/toi/model/Pagination.kt: -------------------------------------------------------------------------------- 1 | package com.ktoi.toi.model 2 | 3 | import com.google.gson.annotations.Expose 4 | import com.google.gson.annotations.SerializedName 5 | 6 | import javax.annotation.Generated 7 | 8 | @Generated("org.jsonschema2pojo") 9 | class Pagination { 10 | 11 | @SerializedName("TotalPages") 12 | @Expose 13 | var totalPages: String? = null 14 | 15 | @SerializedName("PageNo") 16 | @Expose 17 | var pageNo: String? = null 18 | 19 | @SerializedName("PerPage") 20 | @Expose 21 | var perPage: String? = null 22 | 23 | @SerializedName("WebURL") 24 | @Expose 25 | var webURL: String? = null 26 | 27 | } -------------------------------------------------------------------------------- /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 /home/polyakov/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 | -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/ktoi/toi/shared/AppDelegate.kt: -------------------------------------------------------------------------------- 1 | package com.ktoi.toi.shared 2 | 3 | import android.app.Application 4 | import com.ktoi.toi.view.activities.MainActivity 5 | import dagger.Component 6 | import io.realm.Realm 7 | import io.realm.RealmConfiguration 8 | import javax.inject.Singleton 9 | 10 | class AppDelegate : Application() { 11 | 12 | var injector: AppInjector? = null 13 | 14 | @Singleton 15 | @Component(modules = arrayOf(NewsModule::class)) 16 | interface AppInjector { 17 | 18 | fun inject(activity: MainActivity) 19 | 20 | } 21 | 22 | override fun onCreate() { 23 | super.onCreate() 24 | injector = DaggerAppDelegate_AppInjector.builder().build() 25 | 26 | Realm.init(this) 27 | val config = RealmConfiguration.Builder().build() 28 | Realm.setDefaultConfiguration(config) 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/ktoi/toi/model/NewsResponse.java: -------------------------------------------------------------------------------- 1 | package com.ktoi.toi.model; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * example of work of Kotlin project with Java class. 11 | */ 12 | public class NewsResponse { 13 | 14 | @SerializedName("Pagination") 15 | @Expose 16 | private Pagination pagination; 17 | @SerializedName("NewsItem") 18 | @Expose 19 | private List newsItem = new ArrayList(); 20 | 21 | public Pagination getPagination() { 22 | return pagination; 23 | } 24 | 25 | public void setPagination(Pagination pagination) { 26 | this.pagination = pagination; 27 | } 28 | 29 | public List getNewsItem() { 30 | return newsItem; 31 | } 32 | 33 | public void setNewsItem(List newsItem) { 34 | this.newsItem = newsItem; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 18 | 19 |