Skip to content

Commit

Permalink
feat: onReceive at day, not weekend.
Browse files Browse the repository at this point in the history
on api 26+
  • Loading branch information
HI-JIN2 committed Nov 6, 2024
1 parent 4250af2 commit 067ec92
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import com.eatssu.android.R
import com.eatssu.android.ui.main.MainActivity
import java.time.DayOfWeek
import java.time.LocalDateTime

class NotificationReceiver : BroadcastReceiver() {

@RequiresApi(Build.VERSION_CODES.O)
override fun onReceive(context: Context, intent: Intent) {
showNotification(context)
// ํ˜„์žฌ ์š”์ผ์ด ํ‰์ผ์ธ ๊ฒฝ์šฐ์—๋งŒ ์•Œ๋ฆผ์„ ๋ฐœ์†ก
val currentDay = LocalDateTime.now().dayOfWeek
if (currentDay != DayOfWeek.SATURDAY && currentDay != DayOfWeek.SUNDAY) {
showNotification(context)
}
}

private fun showNotification(context: Context) {
Expand Down

0 comments on commit 067ec92

Please sign in to comment.