-
Notifications
You must be signed in to change notification settings - Fork 0
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 #123 from plashdof/feature/aos-global
[Global/aos] 전역 Refactoring
- Loading branch information
Showing
16 changed files
with
192 additions
and
151 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
27 changes: 27 additions & 0 deletions
27
Aos/app/src/main/java/com/avengers/nibobnebob/presentation/customview/CalendarDatePicker.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,27 @@ | ||
package com.avengers.nibobnebob.presentation.customview | ||
|
||
|
||
import androidx.fragment.app.FragmentManager | ||
import com.avengers.nibobnebob.presentation.ui.toDateString | ||
import com.google.android.material.datepicker.MaterialDatePicker | ||
|
||
class CalendarDatePicker( | ||
private val onSelectDateListener: (String) -> Unit | ||
) { | ||
private val datePicker = MaterialDatePicker.Builder.datePicker() | ||
.setTitleText("생일을 고르세요") | ||
.setSelection(MaterialDatePicker.todayInUtcMilliseconds()) | ||
.build() | ||
|
||
init{ | ||
datePicker.addOnPositiveButtonClickListener { | ||
onSelectDateListener(it.toDateString()) | ||
} | ||
} | ||
|
||
fun show(fragmentManager: FragmentManager){ | ||
datePicker.show(fragmentManager,"") | ||
} | ||
} | ||
|
||
|
55 changes: 55 additions & 0 deletions
55
...pp/src/main/java/com/avengers/nibobnebob/presentation/customview/RestaurantBottomSheet.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,55 @@ | ||
package com.avengers.nibobnebob.presentation.customview | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import com.avengers.nibobnebob.R | ||
import com.avengers.nibobnebob.databinding.BottomSheetRestaurantBinding | ||
import com.avengers.nibobnebob.presentation.ui.main.home.model.UiMarkerData | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
|
||
|
||
class RestaurantBottomSheet( | ||
context: Context, | ||
private val data: UiMarkerData, | ||
private val onClickAddWishRestaurant: (Int, Boolean) -> Boolean, | ||
private val onClickAddMyRestaurant: (Int) -> Unit, | ||
private val onClickGoReview: (Int) -> Unit | ||
): BottomSheetDialog(context) { | ||
|
||
private var binding: BottomSheetRestaurantBinding | ||
private var isWishState = data.isInWishList | ||
|
||
init{ | ||
binding = BottomSheetRestaurantBinding.inflate(LayoutInflater.from(context)) | ||
setContentView(binding.root) | ||
binding.item = data | ||
setBottomSheetListener() | ||
} | ||
|
||
private fun setBottomSheetListener(){ | ||
binding.btnAddMyRestaurant.setOnClickListener { | ||
onClickAddMyRestaurant(data.id) | ||
dismiss() | ||
} | ||
|
||
binding.btnAddWishRestaurant.setOnClickListener { | ||
val result = onClickAddWishRestaurant(data.id, data.isInWishList) | ||
|
||
if (result) { | ||
isWishState = !isWishState | ||
|
||
if (isWishState) { | ||
binding.btnAddWishRestaurant.setBackgroundResource(R.drawable.ic_star_full) | ||
} else { | ||
binding.btnAddWishRestaurant.setBackgroundResource(R.drawable.ic_star_border) | ||
} | ||
} | ||
} | ||
|
||
binding.btnGoReview.setOnClickListener { | ||
onClickGoReview(data.id) | ||
dismiss() | ||
} | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
Aos/app/src/main/java/com/avengers/nibobnebob/presentation/ui/DataExtensions.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,13 @@ | ||
package com.avengers.nibobnebob.presentation.ui | ||
|
||
import java.text.SimpleDateFormat | ||
import java.util.Date | ||
import java.util.Locale | ||
import java.util.TimeZone | ||
|
||
internal fun Long.toDateString(): String { | ||
val dateFormat = SimpleDateFormat("yyyy/MM/dd", Locale.getDefault()) | ||
dateFormat.timeZone = TimeZone.getTimeZone("UTC") | ||
val date = Date(this) | ||
return dateFormat.format(date) | ||
} |
54 changes: 54 additions & 0 deletions
54
Aos/app/src/main/java/com/avengers/nibobnebob/presentation/ui/UiExtensions.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,54 @@ | ||
package com.avengers.nibobnebob.presentation.ui | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.location.LocationManager | ||
import android.provider.Settings | ||
import android.view.View | ||
import android.view.inputmethod.InputMethodManager | ||
import android.widget.Toast | ||
import androidx.core.content.ContextCompat | ||
|
||
internal fun Context.hideKeyboard(view: View) { | ||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | ||
imm.hideSoftInputFromWindow(view.windowToken, 0) | ||
} | ||
|
||
internal fun Context.requestLocationPermission( | ||
permissionList: Array<String>, | ||
onLauncherStart: () -> Unit, | ||
onTrackingChangeListener: (Boolean) -> Unit | ||
) { | ||
var permissionFlag = false | ||
permissionList.forEach { permission -> | ||
permissionFlag = ContextCompat.checkSelfPermission( | ||
this, | ||
permission | ||
) == PackageManager.PERMISSION_GRANTED | ||
} | ||
|
||
if (permissionFlag) { | ||
checkLocationIsOn(){ | ||
onTrackingChangeListener(it) | ||
} | ||
} else { | ||
onLauncherStart() | ||
Toast.makeText(this, "위치권한을 허용해주세요", Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
|
||
|
||
internal fun Context.checkLocationIsOn( | ||
onTrackingChangeListener: (Boolean) -> Unit | ||
) { | ||
val locationManager = | ||
getSystemService(Context.LOCATION_SERVICE) as LocationManager | ||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { | ||
onTrackingChangeListener(true) | ||
} else { | ||
startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)) | ||
Toast.makeText(this, "휴대폰 GPS를 켜주세요", Toast.LENGTH_SHORT).show() | ||
onTrackingChangeListener(false) | ||
} | ||
} |
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
Oops, something went wrong.