├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── shihochan │ │ └── kotlin_news_reader │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── kotlin │ │ └── com │ │ │ └── shihochan │ │ │ └── kotlin_news_reader │ │ │ ├── ApiModule.kt │ │ │ ├── AppComponent.kt │ │ │ ├── AppGlideModule.kt │ │ │ ├── AppModule.kt │ │ │ ├── MainApp.kt │ │ │ ├── model │ │ │ ├── ApiConverter.kt │ │ │ ├── Endpoint.kt │ │ │ ├── QiitaRestAdapter.kt │ │ │ ├── api │ │ │ │ └── Qiita.kt │ │ │ ├── dao │ │ │ │ └── QiitaDao.kt │ │ │ └── dto │ │ │ │ └── qiita │ │ │ │ ├── ArticleDto.kt │ │ │ │ ├── TagDto.kt │ │ │ │ └── UserDto.kt │ │ │ ├── ui │ │ │ ├── activity │ │ │ │ └── MainActivity.kt │ │ │ ├── adapter │ │ │ │ ├── QiitaFeedAdapter.kt │ │ │ │ └── binder │ │ │ │ │ └── FeedOneColumnBinder.kt │ │ │ ├── fragment │ │ │ │ └── MainFragment.kt │ │ │ └── view │ │ │ │ └── FeedOneColumnView.kt │ │ │ └── util │ │ │ ├── FeedOneColumnItemDecoration.kt │ │ │ ├── RxBus.kt │ │ │ ├── RxBusProvider.kt │ │ │ ├── event │ │ │ └── OpenChromeTabsEvent.kt │ │ │ └── ext │ │ │ ├── FragmentActivityExt.kt │ │ │ └── FragmentExt.kt │ └── res │ │ ├── anim │ │ ├── scale_to_back.xml │ │ ├── scale_to_front.xml │ │ ├── slide_to_left.xml │ │ └── slide_to_right.xml │ │ ├── color │ │ └── nav_txt_color.xml │ │ ├── drawable-hdpi │ │ ├── ic_folder.png │ │ ├── ic_folder_clipped.png │ │ ├── ic_home.png │ │ └── ic_settings.png │ │ ├── drawable-mdpi │ │ ├── ic_folder.png │ │ ├── ic_folder_clipped.png │ │ ├── ic_home.png │ │ └── ic_settings.png │ │ ├── drawable-xhdpi │ │ ├── ic_folder.png │ │ ├── ic_folder_clipped.png │ │ ├── ic_home.png │ │ └── ic_settings.png │ │ ├── drawable-xxhdpi │ │ ├── ic_folder.png │ │ ├── ic_folder_clipped.png │ │ ├── ic_home.png │ │ └── ic_settings.png │ │ ├── drawable-xxxhdpi │ │ ├── ic_folder.png │ │ ├── ic_folder_clipped.png │ │ ├── ic_home.png │ │ └── ic_settings.png │ │ ├── drawable │ │ ├── circle_nav_header.xml │ │ ├── ripple_btn_default.xml │ │ ├── selector_btn_clipped.xml │ │ └── shadow_toolbar.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── fragment_main.xml │ │ ├── nav_header.xml │ │ └── view_feed_one_column.xml │ │ ├── menu │ │ └── drawer.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── shihochan │ └── kotlin_news_reader │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | 4 | .gradle 5 | /local.properties 6 | 7 | .idea 8 | !.idea/codeStyleSettings.xml 9 | *.iml 10 | 11 | /build 12 | /captures -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kotlin-news-reader 2 | 3 | This is a simple android news reader app developed by [Kotlin](https://kotlinlang.org/). 4 | 5 | In the first, I implemented [Qiita](http://qiita.com/) - [API](https://qiita.com/api/v2/docs) as known as japanease programming knowledge site. 6 | 7 | 8 | ## Features 9 | 10 | ![20160225225800](https://cloud.githubusercontent.com/assets/4586632/13321631/8c690056-dc13-11e5-93b4-cbd61c0b4d2c.jpg) 11 | 12 | * Show new articles 13 | 14 | ## Notes 15 | 16 | Develop with Android Studio and Kotlin v1.0. 17 | 18 | 19 | ## Future work 20 | 21 | * [feedly](https://feedly.com) - [API](https://developer.feedly.com/) 22 | * [Stack Over Flow](http://stackoverflow.com/) - [API](https://api.stackexchange.com/docs) 23 | * [はてなブログ](http://hatenablog.com/) - [API](http://developer.hatena.ne.jp/) 24 | * And any more blogs or sites... 25 | 26 | 27 | ## Libraries 28 | 29 | * [Dagger2](http://google.github.io/dagger/) - Google 30 | * [Retrofit2](http://square.github.io/retrofit/) - Square 31 | * [OkHttp2](https://github.com/square/okhttp/tree/master/okhttp/src/main/java/okhttp2) - Square 32 | * [RxJava](https://github.com/ReactiveX/RxJava) - Netflix 33 | * [RxAndroid](https://github.com/ReactiveX/RxAndroid) - ReactiveX 34 | * [ThreeTenABP](https://github.com/JakeWharton/ThreeTenABP) - JakeWharton 35 | * [Timber](https://github.com/JakeWharton/timber) - JakeWharton 36 | * [Glide](https://github.com/bumptech/glide) - bumptech 37 | * [glide-transformations](https://github.com/wasabeef/glide-transformations) - wasabeef 38 | * [MaterialProgressBar](https://github.com/DreaminginCodeZH/MaterialProgressBar) - Zhang Hai 39 | * [RecyclerView-MultipleViewTypesAdapter](https://github.com/yqritc/RecyclerView-MultipleViewTypesAdapter) - yqritc 40 | 41 | 42 | ## References 43 | 44 | * [kotlin-dagger-example](https://github.com/damianpetla/kotlin-dagger-example) - damianpetla 45 | * [kotlin-android-example](https://github.com/satorufujiwara/kotlin-android-example) - satorufujiwara 46 | 47 | 48 | ## License 49 | 50 | ``` 51 | Copyright 2016 Yuki Shiho 52 | 53 | Licensed under the Apache License, Version 2.0 (the "License"); 54 | you may not use this file except in compliance with the License. 55 | You may obtain a copy of the License at 56 | 57 | http://www.apache.org/licenses/LICENSE-2.0 58 | 59 | Unless required by applicable law or agreed to in writing, software 60 | distributed under the License is distributed on an "AS IS" BASIS, 61 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 62 | See the License for the specific language governing permissions and 63 | limitations under the License. 64 | ``` 65 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | 4 | android { 5 | compileSdkVersion COMPILE_SDK_VERSION as int 6 | buildToolsVersion BUILD_TOOLS_VERSION 7 | 8 | defaultConfig { 9 | applicationId PACKAGE_NAME 10 | minSdkVersion MIN_SDK_VERSION as int 11 | targetSdkVersion TARGET_SDK_VERSION as int 12 | versionCode VERSION_CODE as int 13 | versionName VERSION_NAME 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | sourceSets { 22 | main.java.srcDirs += 'src/main/kotlin' 23 | } 24 | } 25 | 26 | repositories { 27 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 28 | } 29 | 30 | dependencies { 31 | compile fileTree(dir: 'libs', include: ['*.jar']) 32 | 33 | // Kotlin 34 | compile "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION" 35 | 36 | // Google 37 | compile "com.android.support:support-v4:${SUPPORT_PACKAGE_VERSION}" 38 | compile "com.android.support:appcompat-v7:$SUPPORT_PACKAGE_VERSION" 39 | compile "com.android.support:design:${SUPPORT_PACKAGE_VERSION}" 40 | compile "com.android.support:recyclerview-v7:${SUPPORT_PACKAGE_VERSION}" 41 | compile "com.android.support:cardview-v7:${SUPPORT_PACKAGE_VERSION}" 42 | compile "com.android.support:customtabs:${SUPPORT_PACKAGE_VERSION}" 43 | 44 | compile 'com.google.code.gson:gson:2.5' 45 | compile 'com.google.dagger:dagger:2.0.2' 46 | kapt 'com.google.dagger:dagger-compiler:2.0.2' 47 | provided 'org.glassfish:javax.annotation:10.0-b28' 48 | 49 | // Square 50 | compile 'com.jakewharton:kotterknife:0.1.0-SNAPSHOT' 51 | compile 'com.squareup.okhttp:okhttp:2.7.1' 52 | compile 'com.squareup.retrofit:retrofit:1.9.0' 53 | compile 'com.jakewharton.timber:timber:3.1.0' 54 | compile 'com.jakewharton.threetenabp:threetenabp:1.0.2' 55 | 56 | // FRP 57 | compile 'io.reactivex:rxjava:1.1.0' 58 | compile 'io.reactivex:rxandroid:1.1.0' 59 | compile 'com.trello:rxlifecycle:0.3.0' 60 | compile 'com.trello:rxlifecycle-components:0.3.0' 61 | 62 | // UI 63 | compile 'com.yqritc:recyclerview-multiple-viewtypes-adapter:1.0.5' 64 | compile 'me.zhanghai.android.materialprogressbar:library:1.1.4' 65 | 66 | // Image Loader 67 | compile 'com.github.bumptech.glide:glide:3.6.1' 68 | compile 'com.github.bumptech.glide:okhttp-integration:1.3.1' 69 | compile 'jp.wasabeef:glide-transformations:1.3.1' 70 | 71 | testCompile 'junit:junit:4.12' 72 | } 73 | 74 | kapt { 75 | generateStubs = true 76 | } 77 | -------------------------------------------------------------------------------- /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/a13145/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/com/shihochan/kotlin_news_reader/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | 11 | public ApplicationTest() { 12 | super(Application.class); 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/ApiModule.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader 2 | 3 | import com.google.gson.Gson 4 | import com.shihochan.kotlin_news_reader.model.ApiConverter 5 | import com.shihochan.kotlin_news_reader.model.QiitaRestAdapter 6 | import com.shihochan.kotlin_news_reader.model.Endpoint 7 | import com.squareup.okhttp.OkHttpClient 8 | import dagger.Module 9 | import dagger.Provides 10 | import retrofit.RestAdapter 11 | import retrofit.client.Client 12 | import retrofit.client.OkClient 13 | import retrofit.converter.Converter 14 | import retrofit.converter.GsonConverter 15 | import java.net.CookieHandler 16 | import javax.inject.Singleton 17 | 18 | /** 19 | * Created by Yuki Shiho on 2016/02/21. 20 | */ 21 | @Module class ApiModule { 22 | 23 | @Provides @Singleton @QiitaRestAdapter 24 | fun provideQiitaRestAdapter(client: Client): RestAdapter { 25 | return RestAdapter.Builder() 26 | .setEndpoint(Endpoint.qiita) 27 | .setClient(client) 28 | .setLogLevel(RestAdapter.LogLevel.BASIC) 29 | .build() 30 | } 31 | 32 | @Provides @Singleton @ApiConverter 33 | fun provideConverter(): Converter { 34 | return GsonConverter(Gson()) 35 | } 36 | 37 | @Provides @Singleton 38 | fun provideClient(okHttpClient: OkHttpClient): Client { 39 | return OkClient(okHttpClient) 40 | } 41 | 42 | @Provides @Singleton 43 | fun provideOkHttpClient(): OkHttpClient { 44 | val okHttpClient = OkHttpClient() 45 | okHttpClient.cookieHandler = CookieHandler.getDefault() 46 | return okHttpClient 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/AppComponent.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader 2 | 3 | import com.shihochan.kotlin_news_reader.ui.fragment.MainFragment 4 | import dagger.Component 5 | import javax.inject.Singleton 6 | 7 | /** 8 | * Created by Yuki Shiho on 2016/02/22. 9 | */ 10 | @Singleton 11 | @Component(modules = arrayOf(AppModule::class, ApiModule::class)) 12 | interface AppComponent { 13 | 14 | fun inject(app: MainApp) 15 | 16 | fun inject(mainFragment: MainFragment) 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/AppGlideModule.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader 2 | 3 | import android.content.Context 4 | import com.bumptech.glide.Glide 5 | import com.bumptech.glide.GlideBuilder 6 | import com.bumptech.glide.load.DecodeFormat 7 | import com.bumptech.glide.load.engine.cache.LruResourceCache 8 | import com.bumptech.glide.module.GlideModule 9 | 10 | /** 11 | * In Glide 3.5, Glide.isSetup() and Glide.setup() are deprecated. 12 | * The best way to do this is to use GlideModules to do this kind of configuration lazily. 13 | * {@see https://github.com/bumptech/glide/wiki/Configuration} 14 | * 15 | * Created by Yuki Shiho on 2016/02/24. 16 | */ 17 | class AppGlideModule : GlideModule { 18 | 19 | override fun applyOptions(context: Context, builder: GlideBuilder) { 20 | builder.setMemoryCache(LruResourceCache(30 * 1024 * 1024)) 21 | .setDecodeFormat(DecodeFormat.PREFER_ARGB_8888) 22 | } 23 | 24 | override fun registerComponents(context: Context, glide: Glide) { 25 | // Register components it's done in Application class 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader 2 | 3 | import dagger.Module 4 | import dagger.Provides 5 | 6 | /** 7 | * Created by Yuki Shiho on 2016/02/21. 8 | */ 9 | @Module 10 | class AppModule(private val mainApp: MainApp) { 11 | 12 | @Provides 13 | fun provideApp(): MainApp { 14 | return mainApp 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/MainApp.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader 2 | 3 | import android.app.Application 4 | import com.bumptech.glide.Glide 5 | import com.bumptech.glide.integration.okhttp.OkHttpUrlLoader 6 | import com.bumptech.glide.load.model.GlideUrl 7 | import com.jakewharton.threetenabp.AndroidThreeTen 8 | import com.squareup.okhttp.OkHttpClient 9 | import java.io.InputStream 10 | import javax.inject.Inject 11 | 12 | /** 13 | * Created by Yuki Shiho on 2016/02/21. 14 | */ 15 | class MainApp : Application() { 16 | 17 | companion object { 18 | @JvmStatic lateinit var appComponent: AppComponent 19 | } 20 | 21 | @Inject lateinit var okHttpClient: OkHttpClient 22 | 23 | override fun onCreate() { 24 | super.onCreate() 25 | appComponent = DaggerAppComponent.builder() 26 | .appModule(AppModule(this)) 27 | .build() 28 | appComponent.inject(this) 29 | 30 | AndroidThreeTen.init(this) 31 | 32 | Glide.get(this).register(GlideUrl::class.java, InputStream::class.java, 33 | OkHttpUrlLoader.Factory(okHttpClient)) 34 | } 35 | 36 | override fun onTrimMemory(level: Int) { 37 | super.onTrimMemory(level) 38 | Glide.get(this).trimMemory(level) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/ApiConverter.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model 2 | 3 | import javax.inject.Qualifier 4 | 5 | /** 6 | * Created by Yuki Shiho on 2016/02/21. 7 | */ 8 | @Qualifier 9 | @kotlin.annotation.Retention(AnnotationRetention.RUNTIME) 10 | annotation class ApiConverter 11 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/Endpoint.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model 2 | 3 | /** 4 | * Created by Yuki Shiho on 2016/02/21. 5 | */ 6 | object Endpoint { 7 | 8 | val qiita: String 9 | get() = "http://qiita.com/api/v2/" 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/QiitaRestAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model 2 | 3 | import javax.inject.Qualifier 4 | 5 | /** 6 | * Created by Yuki Shiho on 2016/02/21. 7 | */ 8 | @Qualifier 9 | @kotlin.annotation.Retention(AnnotationRetention.RUNTIME) 10 | annotation class QiitaRestAdapter 11 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/api/Qiita.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model.api 2 | 3 | import com.shihochan.kotlin_news_reader.model.dto.qiita.ArticleDto 4 | import retrofit.http.GET 5 | import retrofit.http.Query 6 | import rx.Observable 7 | 8 | /** 9 | * Created by Yuki Shiho on 2016/02/21. 10 | */ 11 | interface Qiita { 12 | 13 | @GET("/items") 14 | fun getItems(@Query("per_page") perPage: Int): Observable> 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/dao/QiitaDao.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model.dao 2 | 3 | import com.shihochan.kotlin_news_reader.model.QiitaRestAdapter 4 | import com.shihochan.kotlin_news_reader.model.api.Qiita 5 | import com.shihochan.kotlin_news_reader.model.dto.qiita.ArticleDto 6 | import retrofit.RestAdapter 7 | import rx.Observable 8 | import javax.inject.Inject 9 | import javax.inject.Singleton 10 | 11 | /** 12 | * Created by Yuki Shiho on 2016/02/21. 13 | */ 14 | @Singleton 15 | class QiitaDao 16 | @Inject 17 | constructor(@QiitaRestAdapter private var qiitaRestAdapter: RestAdapter) { 18 | 19 | fun getHotEntry(count: Int): Observable> { 20 | return qiitaRestAdapter 21 | .create(Qiita::class.java) 22 | .getItems(count) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/dto/qiita/ArticleDto.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model.dto.qiita 2 | 3 | /** 4 | * Created by Yuki Shiho on 2016/02/21. 5 | */ 6 | data class ArticleDto( 7 | val id: String, 8 | val body: String, 9 | val title: String, 10 | val url: String, 11 | val created_at: String, 12 | val updated_at: String, 13 | val tags: List, 14 | val user: UserDto 15 | ) 16 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/dto/qiita/TagDto.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model.dto.qiita 2 | 3 | /** 4 | * Created by Yuki Shiho on 2016/02/25. 5 | */ 6 | data class TagDto( 7 | val name: String 8 | ) 9 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/model/dto/qiita/UserDto.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.model.dto.qiita 2 | 3 | /** 4 | * Created by Yuki Shiho on 2016/02/25. 5 | */ 6 | data class UserDto( 7 | val id: String, 8 | val name: String, 9 | val description: String, 10 | val profile_image_url: String, 11 | val website_url: String, 12 | val followers_count: Long, 13 | val followees_count: Long 14 | ) 15 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/ui/activity/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.ui.activity 2 | 3 | import android.content.res.Configuration 4 | import android.net.Uri 5 | import android.os.Bundle 6 | import android.support.customtabs.CustomTabsIntent 7 | import android.support.v4.widget.DrawerLayout 8 | import android.support.v7.app.ActionBarDrawerToggle 9 | import android.support.v7.widget.Toolbar 10 | import android.view.MenuItem 11 | import butterknife.bindView 12 | import com.shihochan.kotlin_news_reader.R 13 | import com.shihochan.kotlin_news_reader.ui.fragment.MainFragment 14 | import com.shihochan.kotlin_news_reader.util.RxBusProvider 15 | import com.shihochan.kotlin_news_reader.util.event.OpenChromeTabsEvent 16 | import com.shihochan.kotlin_news_reader.util.ext.setContentFragment 17 | import com.trello.rxlifecycle.components.support.RxAppCompatActivity 18 | import rx.android.schedulers.AndroidSchedulers 19 | 20 | /** 21 | * Created by Yuki Shiho on 2016/02/21. 22 | */ 23 | class MainActivity : RxAppCompatActivity() { 24 | 25 | private val toolBar: Toolbar by bindView(R.id.toolbar) 26 | private val drawerLayout: DrawerLayout by bindView(R.id.drawer_layout) 27 | private val drawerToggle: ActionBarDrawerToggle by lazy { 28 | ActionBarDrawerToggle(this, drawerLayout, toolBar, 29 | R.string.drawer_open, R.string.drawer_close) 30 | } 31 | 32 | override fun onCreate(savedInstanceState: Bundle?) { 33 | super.onCreate(savedInstanceState) 34 | setContentView(R.layout.activity_main) 35 | 36 | setSupportActionBar(toolBar) 37 | supportActionBar?.title = getString(R.string.drawer_home) 38 | supportActionBar?.setDisplayHomeAsUpEnabled(true) 39 | drawerToggle.isDrawerIndicatorEnabled = true 40 | 41 | setContentFragment(R.id.container, MainFragment.newInstance()) 42 | } 43 | 44 | override fun onResume() { 45 | super.onResume() 46 | 47 | RxBusProvider.bus.toObservable() 48 | .compose(bindToLifecycle()) 49 | .observeOn(AndroidSchedulers.mainThread()) 50 | .subscribe({ 51 | if (it is OpenChromeTabsEvent) { 52 | CustomTabsIntent.Builder() 53 | .setShowTitle(true) 54 | .setStartAnimations(this, R.anim.slide_to_left, R.anim.scale_to_back) 55 | .setExitAnimations(this, R.anim.scale_to_front, R.anim.slide_to_right) 56 | .build().launchUrl(this, Uri.parse(it.url)) 57 | } 58 | }) 59 | 60 | } 61 | 62 | override fun onPostCreate(savedInstanceState: Bundle?) { 63 | super.onPostCreate(savedInstanceState) 64 | drawerLayout.setDrawerListener(drawerToggle) 65 | drawerToggle.syncState() 66 | } 67 | 68 | override fun onConfigurationChanged(newConfig: Configuration?) { 69 | super.onConfigurationChanged(newConfig) 70 | drawerToggle.onConfigurationChanged(newConfig) 71 | } 72 | 73 | override fun onOptionsItemSelected(item: MenuItem?): Boolean { 74 | if (drawerToggle.onOptionsItemSelected(item)) 75 | return true 76 | else 77 | return super.onOptionsItemSelected(item) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/ui/adapter/QiitaFeedAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.ui.adapter 2 | 3 | import com.shihochan.kotlin_news_reader.model.dto.qiita.ArticleDto 4 | import com.shihochan.kotlin_news_reader.ui.adapter.binder.FeedOneColumnBinder 5 | import com.yqritc.recyclerviewmultipleviewtypesadapter.ListBindAdapter 6 | 7 | /** 8 | * Created by Yuki Shiho on 2016/02/24. 9 | */ 10 | class QiitaFeedAdapter : ListBindAdapter() { 11 | 12 | private val binder: FeedOneColumnBinder 13 | get() = getDataBinder(0) 14 | 15 | init { 16 | addAllBinder(FeedOneColumnBinder(this)) 17 | } 18 | 19 | fun addAll(contents: List) { 20 | binder.addAll(contents) 21 | } 22 | 23 | fun clearAll() { 24 | binder.clear() 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/ui/adapter/binder/FeedOneColumnBinder.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.ui.adapter.binder 2 | 3 | import android.support.v7.widget.RecyclerView 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import com.shihochan.kotlin_news_reader.R 8 | import com.shihochan.kotlin_news_reader.model.dto.qiita.ArticleDto 9 | import com.shihochan.kotlin_news_reader.ui.view.FeedOneColumnView 10 | import com.yqritc.recyclerviewmultipleviewtypesadapter.DataBindAdapter 11 | import com.yqritc.recyclerviewmultipleviewtypesadapter.DataBinder 12 | import java.util.* 13 | 14 | /** 15 | * Created by Yuki Shiho on 2016/02/24. 16 | */ 17 | class FeedOneColumnBinder(dataBindAdapter: DataBindAdapter) : DataBinder(dataBindAdapter) { 18 | 19 | private var qiitaContents = ArrayList() 20 | 21 | override fun newViewHolder(parent: ViewGroup): ViewHolder? { 22 | val view = LayoutInflater.from(parent.context) 23 | .inflate(R.layout.view_feed_one_column, parent, false) 24 | return ViewHolder(view) 25 | } 26 | 27 | override fun bindViewHolder(holder: ViewHolder, position: Int) { 28 | val view = holder.itemView as FeedOneColumnView 29 | view.bindTo(qiitaContents[position]) 30 | } 31 | 32 | override fun getItemCount(): Int { 33 | return qiitaContents.size 34 | } 35 | 36 | fun addAll(contents: List) { 37 | qiitaContents.addAll(contents) 38 | notifyBinderItemInserted(qiitaContents.size - 1) 39 | } 40 | 41 | fun clear() { 42 | qiitaContents.clear() 43 | notifyBinderDataSetChanged() 44 | } 45 | 46 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/ui/fragment/MainFragment.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.ui.fragment 2 | 3 | import android.os.Bundle 4 | import android.support.v7.widget.LinearLayoutManager 5 | import android.support.v7.widget.RecyclerView 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import butterknife.bindView 10 | import com.shihochan.kotlin_news_reader.AppComponent 11 | import com.shihochan.kotlin_news_reader.MainApp 12 | import com.shihochan.kotlin_news_reader.R 13 | import com.shihochan.kotlin_news_reader.model.dao.QiitaDao 14 | import com.shihochan.kotlin_news_reader.model.dto.qiita.ArticleDto 15 | import com.shihochan.kotlin_news_reader.ui.adapter.QiitaFeedAdapter 16 | import com.shihochan.kotlin_news_reader.util.FeedOneColumnItemDecoration 17 | import com.shihochan.kotlin_news_reader.util.ext.inflate 18 | import com.trello.rxlifecycle.components.support.RxFragment 19 | import me.zhanghai.android.materialprogressbar.MaterialProgressBar 20 | import rx.android.schedulers.AndroidSchedulers 21 | import timber.log.Timber 22 | import javax.inject.Inject 23 | 24 | /** 25 | * Created by Yuki Shiho on 2016/02/23. 26 | */ 27 | class MainFragment : RxFragment() { 28 | 29 | val component: AppComponent by lazy { 30 | MainApp.appComponent 31 | } 32 | private val adapterQiita: QiitaFeedAdapter = QiitaFeedAdapter() 33 | 34 | @Inject lateinit var qiitaDao: QiitaDao 35 | 36 | private val progressBar: MaterialProgressBar by bindView(R.id.progressbar) 37 | private val recyclerView: RecyclerView by bindView(R.id.recycler_view) 38 | 39 | companion object { 40 | @JvmStatic fun newInstance(): MainFragment { 41 | return MainFragment() 42 | } 43 | } 44 | 45 | override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { 46 | component.inject(this) 47 | return inflate(R.layout.fragment_main, inflater, container) 48 | } 49 | 50 | override fun onActivityCreated(savedInstanceState: Bundle?) { 51 | super.onActivityCreated(savedInstanceState) 52 | 53 | recyclerView.adapter = adapterQiita 54 | recyclerView.layoutManager = LinearLayoutManager(activity) 55 | recyclerView.addItemDecoration(FeedOneColumnItemDecoration(activity)) 56 | 57 | qiitaDao.getHotEntry(20) 58 | .compose(bindToLifecycle>()) 59 | .observeOn(AndroidSchedulers.mainThread()) 60 | .subscribe({ 61 | progressBar.visibility = View.GONE 62 | adapterQiita.addAll(it) 63 | }, { 64 | Timber.e(it, it.message) 65 | }) 66 | } 67 | 68 | override fun onDestroyView() { 69 | adapterQiita.clearAll() 70 | super.onDestroyView() 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/ui/view/FeedOneColumnView.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.ui.view 2 | 3 | import android.content.Context 4 | import android.support.v7.widget.CardView 5 | import android.text.Html 6 | import android.util.AttributeSet 7 | import android.widget.ImageView 8 | import android.widget.TextView 9 | import butterknife.bindView 10 | import com.bumptech.glide.Glide 11 | import com.shihochan.kotlin_news_reader.R 12 | import com.shihochan.kotlin_news_reader.model.dto.qiita.ArticleDto 13 | import com.shihochan.kotlin_news_reader.util.RxBusProvider 14 | import com.shihochan.kotlin_news_reader.util.event.OpenChromeTabsEvent 15 | import jp.wasabeef.glide.transformations.CropCircleTransformation 16 | import org.threeten.bp.ZonedDateTime 17 | import org.threeten.bp.format.DateTimeFormatter 18 | import kotlin.properties.Delegates 19 | 20 | /** 21 | * Created by Yuki Shiho on 2016/02/24. 22 | */ 23 | class FeedOneColumnView 24 | @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) 25 | : CardView(context, attrs, defStyleAttr) { 26 | 27 | private var url: String by Delegates.notNull() 28 | 29 | private val usrImg: ImageView by bindView(R.id.feed_one_column_usr_img) 30 | private val usrId: TextView by bindView(R.id.feed_one_column_usr_id) 31 | private val title: TextView by bindView(R.id.feed_one_column_title) 32 | private val content: TextView by bindView(R.id.feed_one_column_content) 33 | private val createdAt: TextView by bindView(R.id.feed_one_column_created_at) 34 | 35 | fun bindTo(item: ArticleDto) { 36 | 37 | url = item.url 38 | 39 | Glide.with(context) 40 | .load(item.user.profile_image_url) 41 | .bitmapTransform(CropCircleTransformation(context)) 42 | .into(usrImg) 43 | 44 | usrId.text = item.user.id 45 | title.text = item.title 46 | content.text = Html.fromHtml(item.body) 47 | 48 | var zonedDateTime = ZonedDateTime.parse(item.created_at) 49 | createdAt.text = zonedDateTime.format(DateTimeFormatter.ofPattern("YYYY/MM/dd hh:mm")) 50 | 51 | setOnClickListener({ 52 | RxBusProvider.bus.send(OpenChromeTabsEvent(url)) 53 | }) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/util/FeedOneColumnItemDecoration.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.util 2 | 3 | import android.content.Context 4 | import android.graphics.Rect 5 | import android.support.v7.widget.RecyclerView 6 | import android.view.View 7 | import com.shihochan.kotlin_news_reader.R 8 | 9 | /** 10 | * Created by Yuki Shiho on 2016/02/25. 11 | */ 12 | class FeedOneColumnItemDecoration(context: Context) : RecyclerView.ItemDecoration() { 13 | 14 | private val marginPx: Int 15 | 16 | init { 17 | marginPx = context.resources.getDimensionPixelSize(R.dimen.margin_s) 18 | } 19 | 20 | override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, 21 | state: RecyclerView.State?) { 22 | val itemPos = (view.layoutParams as RecyclerView.LayoutParams).viewAdapterPosition 23 | 24 | if (itemPos == 0) 25 | outRect.set(marginPx, marginPx, marginPx, marginPx) 26 | else 27 | outRect.set(marginPx, 0, marginPx, marginPx) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/util/RxBus.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.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 Yuki Shiho on 2016/02/27. 10 | */ 11 | class RxBus { 12 | 13 | private val bus : Subject = SerializedSubject(PublishSubject.create()) 14 | 15 | fun toObservable () : Observable = bus 16 | 17 | fun hasObservable() : Boolean = bus.hasObservers() 18 | 19 | fun send(any: Any) { 20 | bus.onNext(any) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/util/RxBusProvider.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.util 2 | 3 | /** 4 | * Created by Yuki Shiho on 2016/02/27. 5 | */ 6 | class RxBusProvider { 7 | 8 | companion object { 9 | final val bus: RxBus = RxBus() 10 | 11 | fun get() = bus 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/util/event/OpenChromeTabsEvent.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.util.event 2 | 3 | /** 4 | * Created by Yuki Shiho on 2016/02/27. 5 | */ 6 | data class OpenChromeTabsEvent(val url: String) 7 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/util/ext/FragmentActivityExt.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.util.ext 2 | 3 | import android.support.v4.app.Fragment 4 | import android.support.v4.app.FragmentActivity 5 | 6 | /** 7 | * Created by Yuki Shiho on 2016/02/23. 8 | */ 9 | 10 | fun FragmentActivity.setContentFragment(containerViewId: Int, fragment: Fragment?): Fragment? { 11 | val f: Fragment? = supportFragmentManager?.findFragmentById(containerViewId) 12 | f?.let { return@setContentFragment f } 13 | supportFragmentManager?.beginTransaction()?.add(containerViewId, fragment)?.commit() 14 | return fragment 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/shihochan/kotlin_news_reader/util/ext/FragmentExt.kt: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader.util.ext 2 | 3 | import android.app.Fragment 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.support.v4.app.Fragment as SupportFragment 8 | 9 | /** 10 | * Created by Yuki Shiho on 2016/02/23. 11 | */ 12 | 13 | fun SupportFragment.inflate(layoutResId: Int, inflater: LayoutInflater?, container: ViewGroup?): View? { 14 | return inflater?.inflate(layoutResId, container, false) 15 | } 16 | 17 | fun Fragment.inflate(layoutResId: Int, inflater: LayoutInflater?, container: ViewGroup?): View? { 18 | return inflater?.inflate(layoutResId, container, false) 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/scale_to_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/anim/scale_to_front.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_to_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/anim/slide_to_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/color/nav_txt_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-hdpi/ic_folder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_folder_clipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-hdpi/ic_folder_clipped.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-hdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-hdpi/ic_settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-mdpi/ic_folder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_folder_clipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-mdpi/ic_folder_clipped.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-mdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-mdpi/ic_settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xhdpi/ic_folder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_folder_clipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xhdpi/ic_folder_clipped.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xhdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xhdpi/ic_settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxhdpi/ic_folder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_folder_clipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxhdpi/ic_folder_clipped.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxhdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxhdpi/ic_settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxxhdpi/ic_folder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_folder_clipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxxhdpi/ic_folder_clipped.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxxhdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/drawable-xxxhdpi/ic_settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_nav_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ripple_btn_default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_btn_clipped.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shadow_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 16 | 17 | 20 | 21 | 27 | 28 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 19 | 20 | 34 | 35 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_feed_one_column.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 16 | 17 | 23 | 24 | 30 | 31 | 38 | 39 | 45 | 46 | 56 | 57 | 68 | 69 | 70 | 71 | 72 | 73 | 80 | 81 | 91 | 92 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /app/src/main/res/menu/drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #8BC34A 5 | #689F38 6 | #FF4081 7 | 8 | #000000 9 | #FFFFFF 10 | #B3FFFFFF 11 | #F2FFFFFF 12 | #1F000000 13 | #4D000000 14 | #DD000000 15 | #FAFAFA 16 | #EEEEEE 17 | #E0E0E0 18 | #9E9E9E 19 | #757575 20 | 21 | #E91E63 22 | #D81B60 23 | #8AE91E63 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 4dp 6 | 8dp 7 | 16dp 8 | 24dp 9 | 10 | 11 | 12sp 12 | 14sp 13 | 16sp 14 | 15 | 172dp 16 | 64dp 17 | 18 | 4dp 19 | 20 | 48dp 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | kotlin-news-reader 3 | 4 | ホーム 5 | 設定 6 | 7 | 開く 8 | 閉じる 9 | 10 | Shiho Chan 11 | heyfromshihochan@gmail.com 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/test/java/com/shihochan/kotlin_news_reader/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.shihochan.kotlin_news_reader; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | 12 | @Test 13 | public void addition_isCorrect() throws Exception { 14 | assertEquals(4, 2 + 2); 15 | } 16 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:2.0.0-beta5' 7 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION" 8 | } 9 | } 10 | 11 | allprojects { 12 | repositories { 13 | jcenter() 14 | } 15 | } 16 | 17 | task clean(type: Delete) { 18 | delete rootProject.buildDir 19 | } 20 | -------------------------------------------------------------------------------- /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 19 | 20 | PACKAGE_NAME=com.shihochan.kotlin_news_reader 21 | 22 | KOTLIN_VERSION=1.0.0 23 | 24 | VERSION_CODE=1 25 | VERSION_NAME=1.0.0 26 | 27 | COMPILE_SDK_VERSION=23 28 | BUILD_TOOLS_VERSION=23.0.2 29 | MIN_SDK_VERSION=16 30 | TARGET_SDK_VERSION=23 31 | SUPPORT_PACKAGE_VERSION=23.1.1 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shihochan/kotlin-news-reader/9e81a5107828cb54f04539ee0676797e28352fa2/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /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.10-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------