بدر الزهراني
unknown
plain_text
3 years ago
2.7 kB
3
Indexable
package com.example.convertercapacities import android.annotation.SuppressLint import android.app.AlertDialog import android.content.DialogInterface import android.content.Intent import android.net.Uri import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button import android.widget.EditText import android.widget.TextView import android.widget.Toast import com.example.myapplicationss.R import com.google.android.material.dialog.MaterialAlertDialogBuilder class MainActivity : AppCompatActivity() { @SuppressLint("a", "MissingInflatedId") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val ca: EditText = findViewById(R.id.capacity_inp) val Mega: TextView = findViewById(R.id.totalMega) val Kilo: TextView = findViewById(R.id.totalKilo) val Byt: TextView = findViewById(R.id.totalByte) val Bit: TextView = findViewById(R.id.totalBit) val convert: Button = findViewById(R.id.convert) val exit: Button = findViewById(R.id.exit) var urll=findViewById<Button>(R.id.button2) urll.setOnClickListener { val openUrl= Intent(Intent.ACTION_VIEW) openUrl.data= Uri.parse("https://www.unitconverters.net/") startActivity(openUrl) } convert.setOnClickListener { val value: Double = ca.text.toString().toDouble() if (value < 60000) { ("الحجم الاجمالي بالميجا:" + value * 1024).also { Mega.text = it } ("الحجم الاجمالي بالكيلو بايت:" + value * 1024 * 1024).also { Kilo.text = it } ("الحجم الاجمالي بالبايت:" + value * 1024 * 1024 * 1024).also { Byt.text = it } ("الحجم الاجمالي بالبت:" + value * 1024 * 1024 * 1024 * 8).also { Bit.text = it } } else { Toast.makeText(applicationContext, "Enter a reasonable number!", Toast.LENGTH_LONG) .show() } } exit.setOnClickListener { AlertDialog.Builder(this).setTitle("تحذير") .setMessage("هل تريد اغلاق البرنامج؟") .setPositiveButton( "نعم" ) { p0, p1 -> this.finish() }.setNegativeButton("لا") { p0, p1 -> }.create().show() } } }
Editor is loading...