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

전남대 Android_최영빈_5주차 과제_step2 #81

Open
wants to merge 33 commits into
base: yb0x00
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e112db0
4주차 미션 코드 가져오기
yb0x00 Jul 23, 2024
8c900c2
docs: Add feature list to README.md
yb0x00 Jul 23, 2024
122599d
feat: Replace SQLite implementation with Room database
yb0x00 Jul 25, 2024
31f7ad8
refactor: Remove SQLite-related files after Room migration
yb0x00 Jul 25, 2024
1ab355e
docs: Update README
yb0x00 Jul 26, 2024
c951666
docs: Fix line break issues in README
yb0x00 Jul 26, 2024
b9171d4
refactor: Implement MapErrorViewModel with LiveData and data binding
yb0x00 Jul 26, 2024
86c41a5
rename: Reorganize project folder structure
yb0x00 Jul 26, 2024
9416857
refactor: Refactor DataSearchActivity to use DataBinding
yb0x00 Jul 26, 2024
51a96ef
Merge branch 'yb0x00' into step2
yb0x00 Jul 26, 2024
514a764
fix: Remove duplicate files and rename activity folder to view
yb0x00 Jul 26, 2024
3531fc6
fix: Remove duplicate files
yb0x00 Jul 26, 2024
e881ef1
remove: Remove unused files
yb0x00 Jul 26, 2024
40e8185
[주의]refactor: Attempt data binding implementation
yb0x00 Jul 27, 2024
f6201ac
fix: Display error messages on error screen
yb0x00 Jul 27, 2024
7ec08e2
fix: Add dependency injection
yb0x00 Jul 27, 2024
77bc26c
remove: Remove unused and duplicate files
yb0x00 Jul 27, 2024
dacda2c
remove: Remove unused files
yb0x00 Jul 27, 2024
4059074
[step1 수정 반영] refactor: Apply Hilt for dependency injection in DataSe…
yb0x00 Jul 29, 2024
e3e3542
[step1 수정 반영]refactor: Apply Hilt for dependency injection in HomeMap…
yb0x00 Jul 29, 2024
02c6e13
refactor: Refactor DataSearchActivity to use Hilt for injecting Searc…
yb0x00 Jul 29, 2024
606ac7f
refactor: Remove ViewModelFactory due to Hilt implementation
yb0x00 Jul 29, 2024
fff67d0
Refactor: Remove unnecessary function parameters
yb0x00 Jul 29, 2024
6b50b60
Refactor: Change variable visibility to private
yb0x00 Jul 29, 2024
856d42c
refactor: Remove unused import statements
yb0x00 Jul 29, 2024
f228c1d
refactor: Remove unnecessary logging statements
yb0x00 Jul 29, 2024
238a119
[step1 피드백 반영]refactor: Rename DBViewModel to SearchHistoryViewModel
yb0x00 Jul 29, 2024
787f37b
[step1 피드백 반영]refactor: Rename ViewModel variable for clarity
yb0x00 Jul 29, 2024
922cd84
[step2 피드백 반영]refactor: Fix DataBinding in BottomSheet to Display Loc…
yb0x00 Jul 29, 2024
ffcf8cc
style: Remove debug log statements from previous commit
yb0x00 Jul 29, 2024
9479cda
style: apply code formatting changes
yb0x00 Jul 29, 2024
ef760ac
[Step2 피드백 반영]refactor: Inject SearchHistoryDao directly into repository
yb0x00 Jul 29, 2024
49556a4
refactor: Rename setBind function to setBinding for consistency
yb0x00 Jul 30, 2024
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# android-map-refactoring

### 구현할 기능 목록
[step1]
- 데이터베이스를 Room으로 변경
- 의존성 주입 적용


[step2]
- MVVM 아키텍처 패턴 적용
- DataBinding, LiveData 사용
- 비동기 처리를 Coroutine으로 변경
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.rules.ActivityScenarioRule
import campus.tech.kakao.map.activity.DataSearchActivity
import campus.tech.kakao.map.view.DataSearchActivity
import org.junit.Rule
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.rules.ActivityScenarioRule
import campus.tech.kakao.map.activity.DataSearchActivity
import campus.tech.kakao.map.activity.HomeMapActivity
import campus.tech.kakao.map.view.DataSearchActivity
import campus.tech.kakao.map.view.HomeMapActivity
import org.junit.After
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -57,7 +57,7 @@ class HomeMapActivityTest {

@Test
fun 검색바를_클릭하면_검색화면으로_이동() {
onView(withId(R.id.search_home))
onView(withId(R.id.searchbar_home))
.perform(click())
intended(hasComponent(DataSearchActivity::class.java.name))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.rules.ActivityScenarioRule
import campus.tech.kakao.map.activity.HomeMapActivity
import campus.tech.kakao.map.activity.MapErrorActivity
import campus.tech.kakao.map.view.HomeMapActivity
import campus.tech.kakao.map.view.MapErrorActivity
import org.junit.Rule
import org.junit.Test

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
android:theme="@style/Theme.Map"
tools:targetApi="31">
<activity
android:name=".activity.MapErrorActivity"
android:name=".view.MapErrorActivity"
android:exported="true" />
<activity
android:name=".activity.HomeMapActivity"
android:name=".view.HomeMapActivity"
android:allowBackup="true"
android:exported="true">
<intent-filter>
Expand All @@ -29,7 +29,7 @@
</intent-filter>
</activity>
<activity
android:name=".activity.DataSearchActivity"
android:name=".view.DataSearchActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize" />
</application>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/campus/tech/kakao/map/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package campus.tech.kakao.map

import android.app.Application
import com.kakao.vectormap.KakaoMapSdk
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class Application : Application() {
override fun onCreate(){
super.onCreate()
Expand Down
16 changes: 0 additions & 16 deletions app/src/main/java/campus/tech/kakao/map/MapViewModelFactory.kt

This file was deleted.

137 changes: 0 additions & 137 deletions app/src/main/java/campus/tech/kakao/map/activity/DataSearchActivity.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.TextView
import androidx.lifecycle.viewModelScope
import androidx.recyclerview.widget.RecyclerView
import campus.tech.kakao.map.data.RecentSearchData
import campus.tech.kakao.map.R
import campus.tech.kakao.map.listener.RecentAdapterListener
import campus.tech.kakao.map.viewModel.RecentViewModel
import campus.tech.kakao.map.data.room.SearchHistoryData
import campus.tech.kakao.map.adapter.listener.RecentAdapterListener
import campus.tech.kakao.map.viewModel.SearchHistoryViewModel
import kotlinx.coroutines.launch

class RecentSearchAdapter(
private val recentDataList: List<RecentSearchData>,
private val viewModel: RecentViewModel,
private val searchHistoryDataList: List<SearchHistoryData>,
private val searchHistoryViewModel: SearchHistoryViewModel,
private val adapterListener: RecentAdapterListener
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

Expand All @@ -28,14 +30,17 @@ class RecentSearchAdapter(
return RecentViewHolder(view)
}

override fun getItemCount(): Int = recentDataList.count()
override fun getItemCount(): Int = searchHistoryDataList.count()

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val item = recentDataList[position]
val item = searchHistoryDataList[position]
val viewHolder = holder as RecentViewHolder
viewHolder.name.text = item.name

viewHolder.deleteBtn.setOnClickListener {
viewModel.deleteRecentData(item.name, item.address)
searchHistoryViewModel.viewModelScope.launch {
searchHistoryViewModel.deleteRecentData(item.name, item.address)
}
}

viewHolder.name.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.lifecycle.viewModelScope
import androidx.recyclerview.widget.RecyclerView
import campus.tech.kakao.map.R
import campus.tech.kakao.map.listener.SearchAdapterListener
import campus.tech.kakao.map.viewModel.RecentViewModel
import campus.tech.kakao.map.adapter.listener.SearchAdapterListener
import campus.tech.kakao.map.viewModel.SearchHistoryViewModel
import campus.tech.kakao.map.retrofit.Document
import kotlinx.coroutines.launch

class SearchDataAdapter(
private var items: List<Document>,
private val recentViewModel: RecentViewModel,
private val recentViewModel: SearchHistoryViewModel,
private var adapterListener: SearchAdapterListener
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

Expand Down Expand Up @@ -43,7 +45,9 @@ class SearchDataAdapter(
}
holder.itemView.setOnClickListener {
val searchTime = System.currentTimeMillis()
recentViewModel.addRecentData(item.name, item.address, searchTime)
recentViewModel.viewModelScope.launch {
recentViewModel.addRecentSearchItem(item.name, item.address, searchTime)
}
adapterListener.displaySearchLocation(
item.name,
item.address,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package campus.tech.kakao.map.listener
package campus.tech.kakao.map.adapter.listener

interface RecentAdapterListener {
fun autoSearch(searchData: String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package campus.tech.kakao.map.listener
package campus.tech.kakao.map.adapter.listener

interface SearchAdapterListener {
fun displaySearchLocation(name: String, address: String, latitude: String, longitude: String)
Expand Down
28 changes: 0 additions & 28 deletions app/src/main/java/campus/tech/kakao/map/dBHelper/RecentDBHelper.kt

This file was deleted.

Loading