Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.clicker
- import android.content.Context
- import android.graphics.Color
- import android.os.Bundle
- import android.view.View
- import android.widget.TextView
- import android.widget.Toast
- import androidx.activity.enableEdgeToEdge
- import androidx.appcompat.app.AppCompatActivity
- import androidx.core.view.ViewCompat
- import androidx.core.view.WindowInsetsCompat
- import com.google.android.material.snackbar.Snackbar
- import java.lang.String
- import kotlin.Int
- import android.content.SharedPreferences
- import android.preference.PreferenceManager
- import android.preference.PreferenceManager.getDefaultSharedPreferences
- class MainActivity : AppCompatActivity() {
- var points: Int = 0
- var boost: Int = 0
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- enableEdgeToEdge()
- setContentView(R.layout.activity_main)
- points = getDefaultSharedPreferences(this).getInt("value", points)
- boost = getDefaultSharedPreferences(this).getInt("valu", boost)
- open()
- ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
- val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
- v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
- insets
- }
- }
- private fun open() {
- if (points >= 500) {
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#ff000f"))
- findViewById<TextView>(R.id.button).text = "\uD83D\uDC80"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 100) {
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#c500ff"))
- findViewById<TextView>(R.id.button).text = "\uD83D\uDE2D"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 50) {
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#00bdff"))
- findViewById<TextView>(R.id.button).text = "\uD83E\uDD79"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 10) {
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#00ff0c"))
- findViewById<TextView>(R.id.button).text = "\uD83E\uDD72"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points < 10) {
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.button).text = "\uD83D\uDE42"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- }
- }
- fun clear(view: View) {
- points = 0
- boost = 0
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#4D4D4D"))
- findViewById<TextView>(R.id.button).text = "\uD83D\uDE42"
- findViewById<TextView>(R.id.textView).text = points.toString()
- }
- fun clicko(view: View) {
- if (boost <= 0) {
- if (points >= 500) {
- points++
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#ff000f"))
- findViewById<TextView>(R.id.button).text = "\uD83D\uDC80"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 100) {
- points++
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#c500ff"))
- findViewById<TextView>(R.id.button).text = "\uD83D\uDE2D"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 50) {
- points++
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#00bdff"))
- findViewById<TextView>(R.id.button).text = "\uD83E\uDD79"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 10) {
- points++
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#00ff0c"))
- findViewById<TextView>(R.id.button).text = "\uD83E\uDD72"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points < 10) {
- points++
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.button).text = "\uD83D\uDE42"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- }
- } else if (boost >= 1) {
- if (points >= 500) {
- points = points + 2
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#ff000f"))
- findViewById<TextView>(R.id.button).text = "\uD83D\uDC80"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 100) {
- points = points + 2
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#c500ff"))
- findViewById<TextView>(R.id.button).text = "\uD83D\uDE2D"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 50) {
- points = points + 2
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#00bdff"))
- findViewById<TextView>(R.id.button).text = "\uD83E\uDD79"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points >= 10) {
- points = points + 2
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.textView).setTextColor(Color.parseColor("#00ff0c"))
- findViewById<TextView>(R.id.button).text = "\uD83E\uDD72"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- } else if (points < 10) {
- points = points + 2
- findViewById<TextView>(R.id.textView).text = points.toString()
- findViewById<TextView>(R.id.button).text = "\uD83D\uDE42"
- getDefaultSharedPreferences(this).edit().putInt("value", points).commit();
- }
- }
- }
- fun buy(view: View) {
- if (points <= 10000) {
- val text = "Недостаточно денег!"
- val duration = Toast.LENGTH_SHORT
- val toast = Toast.makeText(this, text, duration) // in Activity
- toast.show()
- } else if (points >= 10000) {
- boost = 1
- findViewById<TextView>(R.id.button2).text = ""
- findViewById<TextView>(R.id.button2).setBackgroundColor(Color.parseColor("#97C3E7"))
- val text = "2х куплен!"
- val duration = Toast.LENGTH_SHORT
- val toast = Toast.makeText(this, text, duration) // in Activity
- toast.show()
- getDefaultSharedPreferences(this).edit().putInt("valu", boost).commit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement