jhoel99

upd

May 21st, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. private fun onlineUpdates(){
  2. update(this@MainActivity, object : update.Listener {
  3. override fun onCompleted(config: String) {
  4. val str = crypt.decryptBase64StringToString(config,AESEncyption.paths).toString()
  5.  
  6.  
  7. // toast(str.toString())
  8. val jsonObject = JSONObject(str)
  9. try {
  10. val default_version = defaultDPreference.getPrefInt("def_version", AppConfig.def_version)
  11. var new_version=jsonObject.getInt("Version")
  12. //defaultDPreference.setPrefInt("def_version", new_version)
  13. if(new_version<default_version || new_version==default_version ){
  14. toast("Latest version already use.")
  15. }else{
  16. val dialog = Dialog(this@MainActivity)
  17. dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
  18. dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
  19. dialog.setCancelable(false)
  20. dialog.setContentView(R.layout.update)
  21. val exitupdate = dialog.findViewById<LinearLayout>(R.id.exitupdate)
  22. val saveupdate = dialog.findViewById<LinearLayout>(R.id.saveupdate)
  23. val obj = JSONObject(str)
  24. val chlogs = dialog.findViewById<TextView>(R.id.chlogs)
  25. val upver = dialog.findViewById<TextView>(R.id.update_version)
  26. chlogs.text = obj.getString("Changelogs").toString()
  27. upver.text = obj.getInt("Version").toString()
  28. saveupdate.setOnClickListener {
  29. Utils.stopVService(this@MainActivity)
  30. Image_Switcher(this@MainActivity, "stop")
  31. defaultDPreference.setPrefString(AppConfig.mainJson,str.toString())
  32. doUpdate()
  33. dialog.dismiss()
  34. }
  35. exitupdate.setOnClickListener {
  36. dialog.dismiss()
  37. }
  38. dialog.show()
  39.  
  40. }
  41.  
  42. } catch (e: java.lang.Exception) {
  43. toast(e.message.toString())
  44. }
  45. }
  46.  
  47. override fun onCancelled() {
  48. // TODO: Implement this method
  49. }
  50.  
  51. override fun onException(ex: String?) {
  52. // TODO: Implement this method
  53. toast("Something went wrong, Please try again.")
  54. }
  55. }).execute()
  56.  
  57. }
Add Comment
Please, Sign In to add comment