- package com.example.horoscope
- import android.app.DatePickerDialog
- import android.graphics.Color
- import androidx.appcompat.app.AppCompatActivity
- import android.os.Bundle
- import android.view.View
- import android.widget.DatePicker
- import android.widget.TextView
- import androidx.core.content.res.ResourcesCompat
- import androidx.core.graphics.alpha
- import androidx.core.graphics.drawable.DrawableCompat.inflate
- import com.example.horoscope.databinding.ActivityMainBinding
- import java.util.*
- import javax.xml.datatype.DatatypeConstants.MONTHS
- class MainActivity : AppCompatActivity() {
- private lateinit var binding: ActivityMainBinding
- val aries_desc = "Aries are spontaneous and courageous. They have a sense of adventure and love to explore. They're determined and bold, and are good at initiating new projects. They have high energy and can initiate quick actions."
- val aries_day = listOf<String>()
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- binding = ActivityMainBinding.inflate(layoutInflater)
- val view = binding.root
- setContentView(view)
- binding.openCalendar.setOnClickListener()
- {
- var datePickerFragment = DatePickerDialog(this)
- val onDateSetListener = object : DatePickerDialog.OnDateSetListener {
- override fun onDateSet(p0: DatePicker?, p1: Int, p2: Int, p3: Int) {
- var day = p0?.dayOfMonth.toString()
- if (day.length==1){
- day = "0$day"
- }
- var month = (p0?.month?.plus(1)).toString()
- if (month.length==1){
- month = "0$month"
- }
- var clickedType = "day"
- var dayPrediction = ""
- var weekPrediction = ""
- var monthPrediction = ""
- //binding.openCalendar.text="${actionBar?.title}"
- binding.openCalendar.text="${day}.${month}.${p0?.year}"
- val zodiacName = zodiac(dataPicker = datePickerFragment.datePicker)
- setTitle(zodiacName)
- val onDayClickListener = object : View.OnClickListener{
- override fun onClick(p0: View?) {
- if (clickedType != "day"){
- binding.day.setBackgroundColor(resources.getColor(R.color.purple_500))
- if (clickedType=="week"){
- binding.week.setBackgroundColor(resources.getColor(R.color.purple_200))
- } else if (clickedType == "month"){
- binding.month.setBackgroundColor(resources.getColor(R.color.purple_200))
- }
- binding.prediction.text = dayPrediction
- clickedType="day"
- }
- }
- }
- val onWeekClickListener = object : View.OnClickListener{
- override fun onClick(p0: View?) {
- if (clickedType != "week"){
- binding.week.setBackgroundColor(resources.getColor(R.color.purple_500))
- binding.prediction.text = weekPrediction
- if (clickedType=="day"){
- binding.day.setBackgroundColor(resources.getColor(R.color.purple_200))
- } else if (clickedType == "month"){
- binding.month.setBackgroundColor(resources.getColor(R.color.purple_200))
- }
- clickedType="week"
- }
- }
- }
- val onMonthClickListener = object : View.OnClickListener{
- override fun onClick(p0: View?) {
- if (clickedType != "month"){
- binding.month.setBackgroundColor(resources.getColor(R.color.purple_500))
- binding.prediction.text = monthPrediction
- if (clickedType=="week"){
- binding.week.setBackgroundColor(resources.getColor(R.color.purple_200))
- } else if (clickedType == "day"){
- binding.day.setBackgroundColor(resources.getColor(R.color.purple_200))
- }
- clickedType="month"
- }
- }
- }
- when(zodiacName){
- "aries"->{
- binding.description.text = resources.getText(R.string.aries_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.aries_day_1), resources.getString(R.string.aries_day_2), resources.getString(R.string.aries_day_3), resources.getString(R.string.aries_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.aries_week_1), resources.getString(R.string.aries_week_2), resources.getString(R.string.aries_week_3), resources.getString(R.string.aries_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.aries_month_1), resources.getString(R.string.aries_month_2), resources.getString(R.string.aries_month_3), resources.getString(R.string.aries_month_4)).random()
- }
- "taurus"->{
- binding.description.text = resources.getText(R.string.taurus_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.taurus_day_1), resources.getString(R.string.taurus_day_2), resources.getString(R.string.taurus_day_3), resources.getString(R.string.taurus_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.taurus_week_1), resources.getString(R.string.taurus_week_2), resources.getString(R.string.taurus_week_3), resources.getString(R.string.taurus_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.taurus_month_1), resources.getString(R.string.taurus_month_2), resources.getString(R.string.taurus_month_3), resources.getString(R.string.taurus_month_4)).random()
- }
- "gemini"->{
- binding.description.text = resources.getText(R.string.gemini_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.gemini_day_1), resources.getString(R.string.gemini_day_2), resources.getString(R.string.gemini_day_3), resources.getString(R.string.gemini_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.gemini_week_1), resources.getString(R.string.gemini_week_2), resources.getString(R.string.gemini_week_3), resources.getString(R.string.gemini_week_4)).random()
- dayPrediction = listOf<String>(resources.getString(R.string.gemini_month_1), resources.getString(R.string.gemini_month_2), resources.getString(R.string.gemini_month_3), resources.getString(R.string.gemini_month_4)).random()
- }
- "cancer"->{
- binding.description.text = resources.getText(R.string.cancer_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.cancer_day_1), resources.getString(R.string.cancer_day_2), resources.getString(R.string.cancer_day_3), resources.getString(R.string.cancer_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.cancer_week_1), resources.getString(R.string.cancer_week_2), resources.getString(R.string.cancer_week_3), resources.getString(R.string.cancer_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.cancer_month_1), resources.getString(R.string.cancer_month_2), resources.getString(R.string.cancer_month_3), resources.getString(R.string.cancer_month_4)).random()
- }
- "leo"->{
- binding.description.text = resources.getText(R.string.leo_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.leo_day_1), resources.getString(R.string.leo_day_2), resources.getString(R.string.leo_day_3), resources.getString(R.string.leo_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.leo_week_1), resources.getString(R.string.leo_week_2), resources.getString(R.string.leo_week_3), resources.getString(R.string.leo_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.leo_month_1), resources.getString(R.string.leo_month_2), resources.getString(R.string.leo_month_3), resources.getString(R.string.leo_month_4)).random()
- }
- "virgo"->{
- binding.description.text = resources.getText(R.string.virgo_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.virgo_day_1), resources.getString(R.string.virgo_day_2), resources.getString(R.string.virgo_day_3), resources.getString(R.string.virgo_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.virgo_week_1), resources.getString(R.string.virgo_week_2), resources.getString(R.string.virgo_week_3), resources.getString(R.string.virgo_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.virgo_month_1), resources.getString(R.string.virgo_month_2), resources.getString(R.string.virgo_month_3), resources.getString(R.string.virgo_month_4)).random()
- }
- "libra"->{
- binding.description.text = resources.getText(R.string.libra_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.libra_day_1), resources.getString(R.string.libra_day_2), resources.getString(R.string.libra_day_3), resources.getString(R.string.libra_day_4)).random()
- dayPrediction = listOf<String>(resources.getString(R.string.libra_week_1), resources.getString(R.string.libra_week_2), resources.getString(R.string.libra_week_3), resources.getString(R.string.libra_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.libra_month_1), resources.getString(R.string.libra_month_2), resources.getString(R.string.libra_month_3), resources.getString(R.string.libra_month_4)).random()
- }
- "scorpio"->{
- binding.description.text = resources.getText(R.string.scorpio_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.scorpio_day_1), resources.getString(R.string.scorpio_day_2), resources.getString(R.string.scorpio_day_3), resources.getString(R.string.scorpio_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.scorpio_week_1), resources.getString(R.string.scorpio_week_2), resources.getString(R.string.scorpio_week_3), resources.getString(R.string.scorpio_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.scorpio_month_1), resources.getString(R.string.scorpio_month_2), resources.getString(R.string.scorpio_month_3), resources.getString(R.string.scorpio_month_4)).random()
- }
- "saggitarius"->{
- binding.description.text = resources.getText(R.string.saggitarius_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.saggitarius_day_1), resources.getString(R.string.saggitarius_day_2), resources.getString(R.string.saggitarius_day_3), resources.getString(R.string.saggitarius_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.saggitarius_week_1), resources.getString(R.string.saggitarius_week_2), resources.getString(R.string.saggitarius_week_3), resources.getString(R.string.saggitarius_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.saggitarius_month_1), resources.getString(R.string.saggitarius_month_2), resources.getString(R.string.saggitarius_month_3), resources.getString(R.string.saggitarius_month_4)).random()
- }
- "capricorn"->{
- binding.description.text = resources.getText(R.string.capricorn_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.capricorn_day_1), resources.getString(R.string.capricorn_day_2), resources.getString(R.string.capricorn_day_3), resources.getString(R.string.capricorn_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.capricorn_week_1), resources.getString(R.string.capricorn_week_2), resources.getString(R.string.capricorn_week_3), resources.getString(R.string.capricorn_week_4)).random()
- dayPrediction = listOf<String>(resources.getString(R.string.capricorn_month_1), resources.getString(R.string.capricorn_month_2), resources.getString(R.string.capricorn_month_3), resources.getString(R.string.capricorn_month_4)).random()
- }
- "aquarius"->{
- binding.description.text = resources.getText(R.string.aquarius_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.aquarius_day_1), resources.getString(R.string.aquarius_day_2), resources.getString(R.string.aquarius_day_3), resources.getString(R.string.aquarius_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.aquarius_week_1), resources.getString(R.string.aquarius_week_2), resources.getString(R.string.aquarius_week_3), resources.getString(R.string.aquarius_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.aquarius_month_1), resources.getString(R.string.aquarius_month_2), resources.getString(R.string.aquarius_month_3), resources.getString(R.string.aquarius_month_4)).random()
- }
- "pisces"->{
- binding.description.text = resources.getText(R.string.pisces_desc)
- dayPrediction = listOf<String>(resources.getString(R.string.pisces_day_1), resources.getString(R.string.pisces_day_2), resources.getString(R.string.pisces_day_3), resources.getString(R.string.pisces_day_4)).random()
- weekPrediction = listOf<String>(resources.getString(R.string.pisces_week_1), resources.getString(R.string.pisces_week_2), resources.getString(R.string.pisces_week_3), resources.getString(R.string.pisces_week_4)).random()
- monthPrediction = listOf<String>(resources.getString(R.string.pisces_month_1), resources.getString(R.string.pisces_month_2), resources.getString(R.string.pisces_month_3), resources.getString(R.string.pisces_month_4)).random()
- }
- }
- if (binding.day.hasOnClickListeners()){
- binding.day.setOnClickListener(null)
- }
- binding.day.setOnClickListener(onDayClickListener)
- if (binding.week.hasOnClickListeners()){
- binding.week.setOnClickListener(null)
- }
- binding.week.setOnClickListener(onWeekClickListener)
- if (binding.month.hasOnClickListeners()){
- binding.month.setOnClickListener(null)
- }
- binding.month.setOnClickListener(onMonthClickListener)
- binding.prediction.text = dayPrediction
- binding.day.setBackgroundColor(resources.getColor(R.color.purple_500))
- binding.week.setBackgroundColor(resources.getColor(R.color.purple_200))
- binding.month.setBackgroundColor(resources.getColor(R.color.purple_200))
- }
- }
- datePickerFragment.setOnDateSetListener(onDateSetListener)
- datePickerFragment.show()
- }
- }
- fun zodiac(dataPicker: DatePicker):String {
- when (dataPicker.month) {
- 0 -> {
- if (dataPicker.dayOfMonth < 20)
- return "capricorn"
- else
- return "aquarius"
- }
- 1 -> {
- if (dataPicker.dayOfMonth < 19)
- return "aquarius"
- else
- return "pisces"
- }
- 2 -> {
- if (dataPicker.dayOfMonth < 21)
- return "pisces"
- else
- return "aries"
- }
- 3 -> {
- if (dataPicker.dayOfMonth < 20)
- return "aries"
- else
- return "taurus"
- }
- 4 -> {
- if (dataPicker.dayOfMonth < 21)
- return "taurus"
- else
- return "gemini"
- }
- 5 -> {
- if (dataPicker.dayOfMonth < 21)
- return "gemini"
- else
- return "cancer"
- }
- 6 -> {
- if (dataPicker.dayOfMonth < 23)
- return "cancer"
- else
- return "leo"
- }
- 7 -> {
- if (dataPicker.dayOfMonth < 23)
- return "leo"
- else
- return "virgo"
- }
- 8 -> {
- if (dataPicker.dayOfMonth < 23)
- return "virgo"
- else
- return "libra"
- }
- 9 -> {
- if (dataPicker.dayOfMonth < 23)
- return "libra"
- else
- return "scorpio"
- }
- 10 -> {
- if (dataPicker.dayOfMonth < 22)
- return "scorpio"
- else
- return "sagittarius"
- }
- 11 -> {
- if (dataPicker.dayOfMonth < 22)
- return "sagittarius"
- else
- return "capricon"
- }
- }
- return "error"
- }
- }
[text] чел
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new:
File Description
- чел
- Paste Code
- 24 Sep-2021
- 17.53 Kb
You can Share it:
Latest Code Pastes