CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 09:39:12 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=528c205410950580a4fd617863967f7064d6119b4ad3e428d98f851f3fd8a16fa%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22WfcnETN-vOpzuv_XtfM1RcKHUd9JhnYa%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d5a0f37e2eb22e-BLR
utility kotlin android - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package asia.ifarmer.ifield.utils
- import android.app.ProgressDialog
- import android.content.Context
- import android.content.pm.PackageManager
- import android.net.ConnectivityManager
- import android.os.Build
- import android.os.StrictMode
- import android.os.StrictMode.ThreadPolicy
- import android.util.Log
- import android.view.View
- import android.view.inputmethod.InputMethodManager
- import android.widget.Toast
- import androidx.lifecycle.LifecycleOwner
- import androidx.lifecycle.lifecycleScope
- import asia.ifarmer.ifield.R
- import com.elvishew.xlog.LogLevel
- import com.elvishew.xlog.XLog
- import kotlinx.coroutines.launch
- import java.io.File
- import java.math.BigDecimal
- import java.math.RoundingMode
- import java.text.SimpleDateFormat
- import java.util.Locale
- import java.util.TimeZone
- class Utility(context: Context) {
- var context: Context? = context
- var mProgressDialog: ProgressDialog? = null
- var mLastClickTime: Long = 0
- private lateinit var dataManager: DataManager
- //var gson: Gson = Gson()
- init {
- val policy = ThreadPolicy.Builder().permitAll().build()
- StrictMode.setThreadPolicy(policy)
- freeMemory()
- XLog.init(LogLevel.ALL)
- dataManager = DataManager(context)
- }
- private fun freeMemory() {
- System.runFinalization()
- Runtime.getRuntime().gc()
- System.gc()
- }
- /*
- ================ Log function ===============
- */
- fun logger(message: String) {
- XLog.enableBorder().tag(context?.resources?.getString(R.string.app_name)).d(message)
- }
- /*
- ================ Show Toast Message ===============
- */
- fun showToast(msg: String) {
- Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
- }
- //================ Show Progress Dialog ===============
- fun showProgress(isCancelable: Boolean, message: String?) {
- hideProgress()
- mProgressDialog = ProgressDialog(context, R.style.ProgressDialogStyle)
- mProgressDialog!!.setIndeterminate(true)
- mProgressDialog!!.setCancelable(isCancelable)
- mProgressDialog!!.setMessage(message)
- mProgressDialog!!.show()
- }
- //================ Hide Progress Dialog ===============
- fun hideProgress() {
- try {
- if (mProgressDialog != null && mProgressDialog!!.isShowing) {
- mProgressDialog!!.dismiss()
- }
- } catch (e: java.lang.Exception) {
- Log.d("Error Line Number", Log.getStackTraceString(e))
- }
- }
- //================ Checking Internet Connection ===============
- fun checkConnection(context: Context): Boolean {
- val connectivityManager =
- context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
- val activeNetworkInfo = connectivityManager.activeNetworkInfo
- return activeNetworkInfo != null && activeNetworkInfo.isConnected
- }
- //================ Double CLick Check ===============
- fun dblClick(): Boolean {
- if (System.currentTimeMillis() - mLastClickTime < 1000) {
- return true
- }
- mLastClickTime = System.currentTimeMillis()
- return false
- }
- /*
- ================ Hide Keyboard from Screen ===============
- */
- fun hideKeyboard(view: View) {
- val imm = context!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
- imm.hideSoftInputFromWindow(view.windowToken, 0)
- }
- /*
- ================ Get Device Info ===============
- */
- fun getDeviceInfo(): HashMap<String?, String?> {
- val map = HashMap<String?, String?>()
- map.put("Serial", Build.SERIAL)
- map.put("Model", Build.MODEL)
- //map.put("Id", Build.ID);
- map.put("Id", Build.SERIAL)
- map.put("Manufacture", Build.MANUFACTURER)
- map.put("Type", Build.TYPE)
- map.put("User", Build.USER)
- map.put("Base", Build.VERSION_CODES.BASE.toString())
- map.put("Incremental", Build.VERSION.INCREMENTAL)
- map.put("Board", Build.BOARD)
- map.put("Brand", Build.BRAND)
- map.put("Host", Build.HOST)
- map.put("Version Code", Build.VERSION.RELEASE)
- return map
- }
- //================ Convert Number Into Bangla ===============
- fun convertNumber(data: String): String {
- var result = ""
- try {
- result = data.replace("0".toRegex(), "০").replace("1".toRegex(), "১")
- .replace("2".toRegex(), "২").replace("3".toRegex(), "৩").replace("4".toRegex(), "৪")
- .replace("5".toRegex(), "৫").replace("6".toRegex(), "৬").replace("7".toRegex(), "৭")
- .replace("8".toRegex(), "৮").replace("9".toRegex(), "৯")
- } catch (e: Exception) {
- Log.d("Error line", e.toString())
- }
- return result
- }
- /*public RequestOptions Glide_Cache_On_profile() {
- RequestOptions requestOptions = new RequestOptions();
- requestOptions.placeholder(R.drawable.ic_loading);
- requestOptions.error(R.drawable.ic_user2);
- return requestOptions;
- }*/
- fun getAppVersionCode(): Int {
- var versionCode = 1
- try {
- val pInfo = context!!.packageManager.getPackageInfo(context!!.packageName, 0)
- versionCode = pInfo.versionCode
- } catch (e: PackageManager.NameNotFoundException) {
- e.printStackTrace()
- }
- return versionCode
- }
- //database
- fun saveAuthToken(token: String, lifecycle: LifecycleOwner) {
- logger("String" + token)
- lifecycle.lifecycleScope.launch {
- dataManager.storeAuthToken(token)
- }
- }
- fun getAuthToken(lifecycle: LifecycleOwner): String {
- /* dataManager.userNameFlow.asLiveData().observe(this) {
- tvName.text = "Name: $it"
- };*/
- var token = ""
- lifecycle.lifecycleScope.launch {
- dataManager.getAuthToken().collect {
- logger("pasi na ds" + it)
- if (it.isNotEmpty()) {
- token = it
- }
- }
- }
- return token
- }
- fun createImageFile(imagePath: String): Result<File> {
- return try {
- val file = File(imagePath)
- // Validate it's an image file (basic check by extension)
- val imageExtensions = listOf("jpg", "jpeg", "png", "gif", "bmp", "webp")
- val extension = file.extension.lowercase()
- if (extension in imageExtensions) {
- Result.success(file)
- } else {
- Result.failure(IllegalArgumentException("Not an image file: $imagePath"))
- }
- } catch (e: Exception) {
- Result.failure(e)
- }
- }
- fun stringToDouble(input: String): Double {
- val value = input.toDoubleOrNull() ?: 0.0
- val rounded = BigDecimal(value).setScale(2, RoundingMode.HALF_UP).toDouble()
- return rounded
- }
- fun cartCalculation(price: String, count: String): String {
- val priceValue = price.toDoubleOrNull() ?: 0.0
- val priceRounded = BigDecimal(priceValue).setScale(2, RoundingMode.HALF_UP).toDouble()
- val countValue = count.toDoubleOrNull() ?: 0.0
- val countRounded = BigDecimal(countValue).setScale(2, RoundingMode.HALF_UP).toDouble()
- val result = BigDecimal(priceRounded * countRounded)
- .setScale(2, RoundingMode.HALF_UP)
- .toDouble()
- return result.toString()
- }
- fun addTwo(a: Double, b: Double, decimals: Int = 2): Double {
- val sum = a + b
- return BigDecimal(sum)
- .setScale(decimals, RoundingMode.HALF_UP)
- .toDouble()
- }
- fun formatDateForUi(input: String): String {
- try {
- val inputFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.getDefault())
- inputFormat.timeZone = TimeZone.getTimeZone("UTC") // server timezone
- val outputFormat = SimpleDateFormat("dd/mm/yyyy", Locale.getDefault())
- val date = inputFormat.parse(input)
- return outputFormat.format(date!!)
- } catch (e: Exception) {
- e.printStackTrace()
- return input
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ L
JavaScript | 1 min ago | 0.25 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ S
JavaScript | 1 min ago | 0.25 KB
-
⭐✅ Swapzone Glitch ✅ Working ⭐⭐ P
JavaScript | 1 min ago | 0.25 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ Z
JavaScript | 1 min ago | 0.25 KB
-
📌 Swapzone +37% glitch ⭐ P
JavaScript | 1 min ago | 0.25 KB
-
✅⭐ Make huge profits on trading ⭐⭐ R
JavaScript | 2 min ago | 0.25 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 2 min ago | 0.25 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ L
JavaScript | 2 min ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand