Skip to content

Commit

Permalink
Merge pull request #106 from MYONGSIK/fix/remove_love
Browse files Browse the repository at this point in the history
[fix/remove_love] : #105 맛있어요, 맛없어요 제거
  • Loading branch information
SsongSik authored May 7, 2023
2 parents c682057 + 2dfef86 commit fcaccfa
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 1,060 deletions.
15 changes: 0 additions & 15 deletions app/src/main/java/com/myongsik/myongsikandroid/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.NavigationUI
import com.myongsik.myongsikandroid.alarm.AlarmBroadCastReceiver
import com.myongsik.myongsikandroid.databinding.ActivityMainBinding
import com.myongsik.myongsikandroid.util.MyongsikApplication
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -78,18 +76,5 @@ class MainActivity : AppCompatActivity() {
binding.myongsikHomeFragmentView.setPadding(0,0,0,0)
}
}

// Background
val alarmManager = getSystemService(ALARM_SERVICE) as AlarmManager
val triggerTime = Calendar.getInstance()
triggerTime.set(Calendar.HOUR_OF_DAY, 23)
triggerTime.set(Calendar.MINUTE, 59)
triggerTime.set(Calendar.SECOND, 0)
triggerTime.set(Calendar.MILLISECOND, 0)

val intent = Intent(this@MainActivity, AlarmBroadCastReceiver::class.java)
val pIntent = PendingIntent.getBroadcast(this@MainActivity, 0, intent, PendingIntent.FLAG_IMMUTABLE)
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, triggerTime.timeInMillis, AlarmManager.INTERVAL_DAY, pIntent)

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,10 @@ interface FoodRepository {
suspend fun getOneRestaurant(storeId : Int) : Response<ResponseOneRestaurant>

//DataStore
suspend fun saveLunchEvaluation(type: String, evaluation: String)

suspend fun saveSortType(key: Preferences.Key<String>, value: String)

suspend fun saveWidgetType(type : String)

suspend fun defaultDataStore()

suspend fun getLunchEvaluation(): Flow<String>

suspend fun getLunchBEvaluation(): Flow<String>

suspend fun getDinnerEvaluation(): Flow<String>

suspend fun getLunchSEvaluation(): Flow<String>

suspend fun getDinnerSEvaluation(): Flow<String>

suspend fun getLunchHEvaluation(): Flow<String>

suspend fun getDinnerHEvaluation(): Flow<String>

suspend fun getCurrentSortType(): Flow<String>

suspend fun getCurrentWidgetType(): Flow<String?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.emptyPreferences
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
Expand All @@ -15,15 +14,6 @@ import com.myongsik.myongsikandroid.data.model.food.*
import com.myongsik.myongsikandroid.data.model.kakao.Restaurant
import com.myongsik.myongsikandroid.data.model.review.RequestReviewData
import com.myongsik.myongsikandroid.data.model.review.ResponseReviewData
import com.myongsik.myongsikandroid.data.model.user.RequestUserData
import com.myongsik.myongsikandroid.data.model.user.ResponseUserData
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl.PreferencesKeys.DINNER_EVALUATION
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl.PreferencesKeys.DINNER_EVALUATION_H
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl.PreferencesKeys.DINNER_EVALUATION_S
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl.PreferencesKeys.LUNCH_A_EVALUATION_H
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl.PreferencesKeys.LUNCH_A_EVALUATION_S
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl.PreferencesKeys.LUNCH_B_EVALUATION
import com.myongsik.myongsikandroid.data.repository.food.FoodRepositoryImpl.PreferencesKeys.LUNCH_EVALUATION
import com.myongsik.myongsikandroid.util.Constant
import com.myongsik.myongsikandroid.util.DataStoreKey
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -66,57 +56,6 @@ class FoodRepositoryImpl @Inject constructor(
}

//DataStore
private object PreferencesKeys {
val LUNCH_EVALUATION = stringPreferencesKey("lunch_evaluation")
val LUNCH_B_EVALUATION = stringPreferencesKey("lunch_b_evaluation")
val DINNER_EVALUATION = stringPreferencesKey("dinner_evaluation")
val DINNER_EVALUATION_S = stringPreferencesKey("dinner_s_evaluation")
val LUNCH_A_EVALUATION_S = stringPreferencesKey("lunch_s_evaluation")
val DINNER_EVALUATION_H = stringPreferencesKey("dinner_h_evaluation")
val LUNCH_A_EVALUATION_H = stringPreferencesKey("lunch_h_evaluation")
}

//중식 A, B 석식 평가 저장
override suspend fun saveLunchEvaluation(type: String, evaluation: String) {
when (type) {
"A" -> {
dataStore.edit { prefs ->
prefs[LUNCH_EVALUATION] = evaluation
}
}
"B" -> {
dataStore.edit { prefs ->
prefs[LUNCH_B_EVALUATION] = evaluation
}
}
"D" -> {
dataStore.edit { prefs ->
prefs[DINNER_EVALUATION] = evaluation
}
}
"DS" -> {
dataStore.edit { prefs ->
prefs[DINNER_EVALUATION_S] = evaluation
}
}
"AS" -> {
dataStore.edit { prefs ->
prefs[LUNCH_A_EVALUATION_S] = evaluation
}
}
"AH" -> {
dataStore.edit { prefs ->
prefs[LUNCH_A_EVALUATION_H] = evaluation
}
}
"DH" -> {
dataStore.edit { prefs ->
prefs[DINNER_EVALUATION_H] = evaluation
}
}
}
}

override suspend fun saveSortType(key: Preferences.Key<String>, value: String) {
dataStore.edit { prefs ->
prefs[key] = value
Expand All @@ -129,142 +68,6 @@ class FoodRepositoryImpl @Inject constructor(
}
}

//DataStore 초기화
override suspend fun defaultDataStore() {
dataStore.edit { prefs ->
prefs[LUNCH_EVALUATION] = ""
}
dataStore.edit { prefs ->
prefs[LUNCH_B_EVALUATION] = ""
}
dataStore.edit { prefs ->
prefs[DINNER_EVALUATION] = ""
}
dataStore.edit { prefs ->
prefs[LUNCH_A_EVALUATION_S] = ""
}
dataStore.edit { prefs ->
prefs[DINNER_EVALUATION_S] = ""
}
dataStore.edit { prefs ->
prefs[LUNCH_A_EVALUATION_H] = ""
}
dataStore.edit { prefs ->
prefs[DINNER_EVALUATION_H] = ""
}
}

override suspend fun getLunchEvaluation(): Flow<String> {
return dataStore.data
.catch { exception ->
if (exception is IOException) {
exception.printStackTrace()
emit(emptyPreferences())
} else {
throw exception
}
}
.map { prefs ->
prefs[LUNCH_EVALUATION] ?: ""
}
}

override suspend fun getLunchBEvaluation(): Flow<String> {
return dataStore.data //data 메서드
//실패 했을 대비에 예외처리
.catch { exception ->
if (exception is IOException) {
exception.printStackTrace()
emit(emptyPreferences())
} else {
throw exception
}
}
.map { prefs ->
prefs[LUNCH_B_EVALUATION] ?: ""
}
}

override suspend fun getDinnerEvaluation(): Flow<String> {
return dataStore.data //data 메서드
//실패 했을 대비에 예외처리
.catch { exception ->
if (exception is IOException) {
exception.printStackTrace()
emit(emptyPreferences())
} else {
throw exception
}
}
.map { prefs ->
prefs[DINNER_EVALUATION] ?: ""
}
}

override suspend fun getLunchSEvaluation(): Flow<String> {
return dataStore.data //data 메서드
//실패 했을 대비에 예외처리
.catch { exception ->
if (exception is IOException) {
exception.printStackTrace()
emit(emptyPreferences())
} else {
throw exception
}
}
.map { prefs ->
prefs[LUNCH_A_EVALUATION_S] ?: ""
}
}

override suspend fun getDinnerSEvaluation(): Flow<String> {
return dataStore.data //data 메서드
//실패 했을 대비에 예외처리
.catch { exception ->
if (exception is IOException) {
exception.printStackTrace()
emit(emptyPreferences())
} else {
throw exception
}
}
.map { prefs ->
prefs[DINNER_EVALUATION_S] ?: ""
}
}

override suspend fun getLunchHEvaluation(): Flow<String> {
return dataStore.data //data 메서드
//실패 했을 대비에 예외처리
.catch { exception ->
if (exception is IOException) {
exception.printStackTrace()
emit(emptyPreferences())
} else {
throw exception
}
}
.map { prefs ->
prefs[LUNCH_A_EVALUATION_H] ?: ""
}
}

override suspend fun getDinnerHEvaluation(): Flow<String> {
return dataStore.data //data 메서드
//실패 했을 대비에 예외처리
.catch { exception ->
if (exception is IOException) {
exception.printStackTrace()
emit(emptyPreferences())
} else {
throw exception
}
}
.map { prefs ->
prefs[DINNER_EVALUATION_H] ?: ""
}
}

override suspend fun getCurrentSortType(): Flow<String> {
return dataStore.data //data 메서드
.catch { exception ->
Expand Down
Loading

0 comments on commit fcaccfa

Please sign in to comment.