Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions GithubCommit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
18 changes: 18 additions & 0 deletions GithubCommit/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions GithubCommit/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions GithubCommit/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions GithubCommit/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions GithubCommit/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions GithubCommit/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions GithubCommit/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "io.esid.dev.githubcommit"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})

testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

implementation "com.android.support:appcompat-v7:$android_support"
implementation "com.android.support:design:$android_support"

//squareup
compile "com.squareup.retrofit2:retrofit:$retrofit"
compile "com.squareup.retrofit2:converter-gson:$retrofit"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofit"
compile "com.squareup.okhttp3:okhttp:$okhttp_3"

//rxJava2 and rxAndroid2
compile "io.reactivex.rxjava2:rxjava:$rx_java_2"
compile "io.reactivex.rxjava2:rxandroid:$rx_android_2"
}
25 changes: 25 additions & 0 deletions GithubCommit/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Aldi\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.esid.dev.githubcommit

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("io.esid.dev.githubcommit", appContext.packageName)
}
}
23 changes: 23 additions & 0 deletions GithubCommit/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.esid.dev.githubcommit">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".presentation.GithubCommitActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.esid.dev.githubcommit

/**
* Created by Aldi on 2/25/2018.
*/
interface BaseView{
fun showProgress()
fun hideProgress()
fun showError(message: String)
fun noInternet()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.esid.dev.githubcommit

/**
* Created by Aldi on 2/25/2018.
*/
object Constant{
const val GITHUB_API = "https://api.github.com/"

//okhttp timeout
const val HTTP_TIME_OUT = 20L

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.esid.dev.githubcommit.model

/**
* Created by Aldi on 2/25/2018.
*/
class GithubAuthor(val name: String, val email: String, val date: String)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.esid.dev.githubcommit.model

/**
* Created by Aldi on 2/25/2018.
*/
class GithubCommit(val author: GithubAuthor,
val message: String,
val url: String,
val html_url: String)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.esid.dev.githubcommit.model

/**
* Created by Aldi on 2/25/2018.
*/
class GithubCommitResponse(val sha: String, val commit: GithubCommit)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.esid.dev.githubcommit.network

import io.esid.dev.githubcommit.model.GithubCommitResponse
import io.reactivex.Flowable
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

/**
* Created by Aldi on 2/25/2018.
*/

interface API {

@GET("repos/{user}/{repos}/commits")
fun getCommit(@Path("user") user: String,
@Path("repos") repos: String,
@Query("per_page") limit: Int): Flowable<MutableList<GithubCommitResponse>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.esid.dev.githubcommit.network

import io.esid.dev.githubcommit.Constant
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

/**
* Created by Aldi on 2/25/2018.
*/
object Injector{

fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl(Constant.GITHUB_API)
.client(getHttpClient())
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
}

fun getHttpClient(): OkHttpClient {
val okHttpClient = OkHttpClient.Builder()
.readTimeout(Constant.HTTP_TIME_OUT, TimeUnit.SECONDS)
.connectTimeout(Constant.HTTP_TIME_OUT, TimeUnit.SECONDS)
return okHttpClient.build()
}

fun getApi(): API {
return provideRetrofit().create(API::class.java)
}

}
Loading