Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF-1 MyFriends 구현 #2

Open
wants to merge 13 commits into
base: feature/SF-1-MyFriends
Choose a base branch
from
6 changes: 6 additions & 0 deletions .idea/codeStyles/Project.xml

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

49 changes: 48 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 30
Expand All @@ -22,14 +23,60 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

androidExtensions {
experimental = true
}

dataBinding {
enabled = true
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.0'

//Android UI and appcompat
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

//retrofit
def retrofitVersion = '2.3.0'
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"

//Retrofit 에서 받은 응답을 옵서버블로 변환해주는 라이브러리
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"

//okHttp
def okHttpVersion = '3.8.1'
implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"

//glide
def glideVersion = '4.10.0'
implementation "com.github.bumptech.glide:glide:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"

//rx android
def rxandoirdVersion = '2.1.1'
def rxjavaVersion = '2.2.19'
implementation "io.reactivex.rxjava2:rxandroid:$rxandoirdVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxjavaVersion"

//koin
def koinVersion = '2.0.1'
implementation "org.koin:koin-android:$koinVersion"
implementation "org.koin:koin-androidx-viewmodel:$koinVersion"

//google map
implementation 'com.google.android.gms:play-services-maps:17.0.0'

//test
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.studyfork.sfoide">

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

<application
android:name=".SfoidApplication"
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=".MainActivity">
<activity android:name=".presentation.main.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".presentation.detail.DetailActivity" />

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyALmqJwCQi05QLPED056s12E9NyjatRM1I" />
</application>

</manifest>
11 changes: 0 additions & 11 deletions app/src/main/java/com/studyfork/sfoide/MainActivity.kt

This file was deleted.

43 changes: 43 additions & 0 deletions app/src/main/java/com/studyfork/sfoide/SfoidApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.studyfork.sfoide

import android.app.Application
import com.studyfork.sfoide.di.appModule
import com.studyfork.sfoide.di.networkModule
import com.studyfork.sfoide.di.repositoryModule
import com.studyfork.sfoide.di.viewModel
import org.koin.android.ext.koin.androidContext
import org.koin.android.logger.AndroidLogger
import org.koin.core.context.startKoin
import org.koin.core.logger.EmptyLogger

class SfoidApplication : Application() {

override fun onCreate() {
super.onCreate()

setupKoin()
}

private fun setupKoin() {
startKoin {
logger(
if (BuildConfig.DEBUG) {
AndroidLogger()
} else {
EmptyLogger()
}
)

androidContext(this@SfoidApplication)

modules(
listOf(
appModule,
networkModule,
repositoryModule,
viewModel
)
)
}
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/com/studyfork/sfoide/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.studyfork.sfoide.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

abstract class BaseActivity<B : ViewDataBinding>(private val layoutId: Int) : AppCompatActivity() {
protected lateinit var binding: B

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, layoutId)
binding.lifecycleOwner = this

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.studyfork.sfoide.base

import androidx.recyclerview.widget.DiffUtil

class BaseDiffUtilCallback<D>(
private val oldList: List<D>, private val newList: List<D>
) : DiffUtil.Callback() {

override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) =
oldList[oldItemPosition] == newList[newItemPosition]

override fun getOldListSize() = oldList.size

override fun getNewListSize() = newList.size

override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) =
oldList[oldItemPosition] == newList[newItemPosition]
}
28 changes: 28 additions & 0 deletions app/src/main/java/com/studyfork/sfoide/base/BaseFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.studyfork.sfoide.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment

abstract class BaseFragment<B : ViewDataBinding>(
@LayoutRes private val layoutId: Int
) : Fragment() {

protected lateinit var binding: B

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DataBindingUtil.inflate(inflater, layoutId, container, false)
binding.lifecycleOwner = viewLifecycleOwner

return binding.root
}
}
27 changes: 27 additions & 0 deletions app/src/main/java/com/studyfork/sfoide/base/BaseViewHolder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.studyfork.sfoide.base

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView

abstract class BaseViewHolder<out B : ViewDataBinding, in D>(
parent: ViewGroup,
@LayoutRes layoutRes: Int
) : RecyclerView.ViewHolder(
LayoutInflater.from(parent.context)
.inflate(layoutRes, parent, false)
) {

protected val context: Context = itemView.context
protected val binding: B = DataBindingUtil.bind(itemView)!!

abstract fun bind(data: D)

open fun recycled() {

}
}
14 changes: 14 additions & 0 deletions app/src/main/java/com/studyfork/sfoide/base/BaseViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.studyfork.sfoide.base

import androidx.lifecycle.ViewModel
import io.reactivex.disposables.CompositeDisposable

abstract class BaseViewModel : ViewModel() {

val compositeDisposable = CompositeDisposable()

override fun onCleared() {
compositeDisposable.clear()
super.onCleared()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.studyfork.sfoide.bindingadapter

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions

@BindingAdapter("setImageUrl")
fun ImageView.setImageUrl(url: String?) {
Glide.with(context)
.load(url)
.placeholder(ColorDrawable(Color.GRAY))
.error(ColorDrawable(Color.DKGRAY))
.into(this)
}

@BindingAdapter("setCircleImageUrl")
fun ImageView.setCircleImageUrl(url: String?) {

val options = RequestOptions().apply {
circleCrop()
}

Glide.with(context)
.load(url)
.apply(options)
.placeholder(ColorDrawable(Color.GRAY))
.error(ColorDrawable(Color.DKGRAY))
.into(this)
}

@BindingAdapter("setIsRefreshing")
fun SwipeRefreshLayout.setIsRefreshing(flag: Boolean) {
isRefreshing = flag
}
Loading