-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from boostcampwm-2022/feat/user_location_history
사용 위치 기록
- Loading branch information
Showing
15 changed files
with
111 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
domain/src/main/java/com/lighthouse/domain/model/UsageHistory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package com.lighthouse.domain.model | ||
|
||
import com.lighthouse.domain.VertexLocation | ||
import java.util.Date | ||
|
||
data class UsageHistory( | ||
val date: Date, | ||
val address: String, | ||
val location: VertexLocation?, | ||
val amount: Int | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
presentation/src/main/java/com/lighthouse/presentation/util/Geography.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.lighthouse.presentation.util | ||
|
||
import android.content.Context | ||
import android.location.Address | ||
import android.location.Geocoder | ||
import android.os.Build | ||
import com.lighthouse.domain.VertexLocation | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class Geography @Inject constructor(@ApplicationContext private val context: Context) { | ||
|
||
// 위도 경도로 주소 구하는 Reverse-GeoCoding | ||
fun getAddress(position: VertexLocation?): String { | ||
position ?: return "" | ||
|
||
val geoCoder = Geocoder(context) | ||
var addr = "-" | ||
|
||
// GRPC 오류 대응 | ||
try { | ||
var location: Address? = null | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
geoCoder.getFromLocation(position.latitude, position.longitude, 1) { | ||
location = it.first() | ||
} | ||
} else { | ||
location = geoCoder.getFromLocation(position.latitude, position.longitude, 1)?.first() | ||
} | ||
addr = listOfNotNull( | ||
location?.adminArea, | ||
location?.subAdminArea, | ||
location?.locality, | ||
location?.subLocality, | ||
location?.thoroughfare | ||
).joinToString(" ") | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} | ||
return addr | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters