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
4 changes: 2 additions & 2 deletions Picon/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.yapp.picon"
minSdkVersion 22
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionCode 3
versionName "1.2.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
6 changes: 2 additions & 4 deletions Picon/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.yapp.picon"
android:versionCode="001"
android:versionName="1.000">
package="com.yapp.picon">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Expand All @@ -13,7 +11,7 @@

<application
android:name=".MainApplication"
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.koin.dsl.module
import retrofit2.Converter
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

val networkModule = module {
factory { (baseUrl: String) ->
Expand All @@ -22,6 +23,9 @@ val networkModule = module {

single {
OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.addNetworkInterceptor(
HttpLoggingInterceptor().also {
it.level = HttpLoggingInterceptor.Level.BODY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.yapp.picon.presentation.collect

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import com.yapp.picon.BR
Expand All @@ -11,6 +12,7 @@ import com.yapp.picon.databinding.CollectItemBinding
import com.yapp.picon.presentation.base.BaseActivity
import com.yapp.picon.presentation.model.Pin
import com.yapp.picon.presentation.model.Post
import com.yapp.picon.presentation.nav.repository.EmotionDatabaseRepository
import com.yapp.picon.presentation.postdetail.PostDetailActivity
import org.koin.androidx.viewmodel.ext.android.viewModel

Expand All @@ -28,6 +30,8 @@ class CollectActivity : BaseActivity<CollectActivityBinding, CollectViewModel>(
{ item: Pin -> itemClicked(item) }
) {}

private val collectBottomSheetDialog = CollectBottomSheetDialog()

private fun itemClicked(item: Pin) {
clickItem(item)
}
Expand Down Expand Up @@ -56,6 +60,7 @@ class CollectActivity : BaseActivity<CollectActivityBinding, CollectViewModel>(
setAdapter()
setListeners()
setPosts()
setEmotions()
}

private fun setAdapter() {
Expand All @@ -65,23 +70,41 @@ class CollectActivity : BaseActivity<CollectActivityBinding, CollectViewModel>(

private fun setListeners() {
binding.collectIbBack.setOnClickListener { finish() }
binding.collectIbFilter.setOnClickListener {
//todo 필터 구현하기
showToast("필터는 현재 구현 중에 있습니다.")
}
binding.collectIbFilter.setOnClickListener { vm.toggleShowFilterYN() }
}

private fun setPosts() {
vm.setPosts()
}

private fun setEmotions() {
EmotionDatabaseRepository(application).getAll().observe(this, { vm.setEmotions(it) })
}

override fun initViewModel() {
binding.setVariable(BR.collectVM, vm)

val toastMsgObserver = Observer<String> {
showToast(it)
}
vm.toastMsg.observe(this, toastMsgObserver)

val showFilterYNObserver = Observer<Boolean> {
Log.e(TAG, "showFilterYNObserver : $it")

if (it) {
collectBottomSheetDialog.show(supportFragmentManager, "CollectBottomSheetDialog")
} else {
if (collectBottomSheetDialog.isVisible) {
collectBottomSheetDialog.dismiss()
}
}
}
vm.showFilterYN.observe(this, showFilterYNObserver)
}

companion object {
private const val TAG = "CollectActivity"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.yapp.picon.presentation.collect

import android.graphics.Typeface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.res.ResourcesCompat
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.yapp.picon.BR
import com.yapp.picon.R
import com.yapp.picon.databinding.CollectBottomSheetBinding
import org.koin.androidx.viewmodel.ext.android.sharedViewModel

class CollectBottomSheetDialog : BottomSheetDialogFragment() {

private lateinit var binding: CollectBottomSheetBinding
private val vm: CollectViewModel by sharedViewModel()

private fun initViewModel() {
binding.setVariable(BR.collectVM, vm)

val emotion1ClickedYNObserver = Observer<Boolean> {
if (it) {
selectedEmotion(binding.collectMbsTvEmotion1, binding.collectMbsIvEmotion1)
} else {
unselectedEmotion(binding.collectMbsTvEmotion1, binding.collectMbsIvEmotion1)
}
}
vm.emotion1ClickedYN.observe(this, emotion1ClickedYNObserver)

val emotion2ClickedYNObserver = Observer<Boolean> {
if (it) {
selectedEmotion(binding.collectMbsTvEmotion2, binding.collectMbsIvEmotion2)
} else {
unselectedEmotion(binding.collectMbsTvEmotion2, binding.collectMbsIvEmotion2)
}
}
vm.emotion2ClickedYN.observe(this, emotion2ClickedYNObserver)

val emotion3ClickedYNObserver = Observer<Boolean> {
if (it) {
selectedEmotion(binding.collectMbsTvEmotion3, binding.collectMbsIvEmotion3)
} else {
unselectedEmotion(binding.collectMbsTvEmotion3, binding.collectMbsIvEmotion3)
}
}
vm.emotion3ClickedYN.observe(this, emotion3ClickedYNObserver)

val emotion4ClickedYNObserver = Observer<Boolean> {
if (it) {
selectedEmotion(binding.collectMbsTvEmotion4, binding.collectMbsIvEmotion4)
} else {
unselectedEmotion(binding.collectMbsTvEmotion4, binding.collectMbsIvEmotion4)
}
}
vm.emotion4ClickedYN.observe(this, emotion4ClickedYNObserver)

val emotion5ClickedYNObserver = Observer<Boolean> {
if (it) {
selectedEmotion(binding.collectMbsTvEmotion5, binding.collectMbsIvEmotion5)
} else {
unselectedEmotion(binding.collectMbsTvEmotion5, binding.collectMbsIvEmotion5)
}
}
vm.emotion5ClickedYN.observe(this, emotion5ClickedYNObserver)
}

private fun selectedEmotion(textView: TextView, imageView: ImageView) {
textView.apply {
setTypeface(null, Typeface.BOLD)
setTextColor(ResourcesCompat.getColor(resources, R.color.pale_grey, null))
}
imageView.visibility = View.VISIBLE
}

private fun unselectedEmotion(textView: TextView, imageView: ImageView) {
textView.apply {
setTypeface(null, Typeface.NORMAL)
setTextColor(ResourcesCompat.getColor(resources, R.color.brown_grey, null))
}
imageView.visibility = View.GONE
}

private fun setListeners() {
binding.collectMbsLiEmotion1.setOnClickListener { vm.toggleEmotion1ClickedYN() }
binding.collectMbsLiEmotion2.setOnClickListener { vm.toggleEmotion2ClickedYN() }
binding.collectMbsLiEmotion3.setOnClickListener { vm.toggleEmotion3ClickedYN() }
binding.collectMbsLiEmotion4.setOnClickListener { vm.toggleEmotion4ClickedYN() }
binding.collectMbsLiEmotion5.setOnClickListener { vm.toggleEmotion5ClickedYN() }

binding.collectMbsTvApply.setOnClickListener {
vm.applyFilter()
vm.toggleShowFilterYN()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.TransparentStyle)
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding =
DataBindingUtil.inflate(inflater, R.layout.collect_bottom_sheet, container, false)

initViewModel()
setListeners()

return binding.root
}

}
Loading