Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hammad Tariq committed Apr 20, 2018
0 parents commit 351ab35
Show file tree
Hide file tree
Showing 49 changed files with 1,051 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

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

18 changes: 18 additions & 0 deletions .idea/gradle.xml

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

34 changes: 34 additions & 0 deletions .idea/misc.xml

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

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

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

1 change: 1 addition & 0 deletions app/.gitignore
@@ -0,0 +1 @@
/build
54 changes: 54 additions & 0 deletions app/build.gradle
@@ -0,0 +1,54 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

android {

kapt {
generateStubs = true
}
compileSdkVersion 27
defaultConfig {
applicationId "com.es.mewphone"
minSdkVersion 15
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'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

//RETROFIT ... NETWORK LIBRARY
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
// RETROFIT .. CONVERTER
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"

implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

// implementation 'com.google.dagger:dagger:2.15'
// kapt 'com.google.dagger:dagger-compiler:2.15'

implementation 'com.google.dagger:dagger-android:2.15'
implementation 'com.google.dagger:dagger-android-support:2.15'
// if you use the support libraries
kapt 'com.google.dagger:dagger-android-processor:2.15'
kapt 'com.google.dagger:dagger-compiler:2.15'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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
@@ -0,0 +1,24 @@
package com.es.developine

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("com.es.mewphone", appContext.packageName)
}
}
24 changes: 24 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.es.developine">

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

<application
android:name=".ApplicationClass"
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=".ui.login.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
23 changes: 23 additions & 0 deletions app/src/main/java/com/es/developine/ApplicationClass.kt
@@ -0,0 +1,23 @@
package com.es.developine

import android.app.Application
import com.es.developine.di.component.ApplicationComponent
import com.es.developine.di.component.DaggerApplicationComponent
import com.es.developine.di.module.AppModule
import com.es.developine.di.module.NetModule

open class ApplicationClass : Application() {


public lateinit var applicationComponent: ApplicationComponent

override fun onCreate() {
super.onCreate()

applicationComponent = DaggerApplicationComponent.builder()
.netModule(NetModule())
.build()

applicationComponent.inject(this)
}
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/es/developine/data/Post.kt
@@ -0,0 +1,3 @@
package com.es.developine.data

data class Post(var userId: Int, var postId: Int, var title: String, var body: String)
@@ -0,0 +1,17 @@
package com.es.developine.di.component

import com.es.developine.ApplicationClass
import com.es.developine.di.module.AppModule
import com.es.developine.di.module.NetModule
import com.es.developine.ui.login.LoginActivity
import com.es.developine.ui.login.LoginPresenterImpl
import dagger.Component

@Component(modules = [AppModule::class, NetModule::class])
interface ApplicationComponent {

fun inject(mewApplication: ApplicationClass)
fun inject(mLoginPresenterImpl: LoginPresenterImpl)
fun inject(mLoginActivity: LoginActivity)

}
23 changes: 23 additions & 0 deletions app/src/main/java/com/es/developine/di/module/AppModule.kt
@@ -0,0 +1,23 @@
package com.es.developine.di.module

import android.app.Application
import dagger.Module
import dagger.Provides
import javax.inject.Singleton

@Module
class AppModule(var application: Application) {

lateinit var applicationInst: Application

init {
applicationInst = application
}


@Provides
@Singleton
fun provideApplication(): Application {
return applicationInst
}
}
31 changes: 31 additions & 0 deletions app/src/main/java/com/es/developine/di/module/NetModule.kt
@@ -0,0 +1,31 @@
package com.es.developine.di.module

import com.es.developine.network.INetworkApi
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import dagger.Module
import dagger.Provides
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory

@Module
class NetModule {

@Provides
fun provideRetrofit(gson: Gson): Retrofit {
return Retrofit.Builder().addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.baseUrl("https://jsonplaceholder.typicode.com/").build()
}

@Provides
fun providesGson(): Gson {
return GsonBuilder().create()
}

@Provides
fun provideNetworkService(retrofit: Retrofit): INetworkApi {
return retrofit.create(INetworkApi::class.java)
}
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/es/developine/network/Endpoints.kt
@@ -0,0 +1,5 @@
package com.es.developine.network

object Endpoints {
const val posts = "posts/"
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/es/developine/network/INetworkApi.kt
@@ -0,0 +1,13 @@
package com.es.developine.network

import com.es.developine.data.Post
import com.google.gson.JsonElement
import io.reactivex.Observable
import retrofit2.Call
import retrofit2.http.GET

interface INetworkApi {

@GET(Endpoints.posts)
fun getAllPosts(): Observable<JsonElement>
}

0 comments on commit 351ab35

Please sign in to comment.