Add Check for Update (Parse Config)
This commit is contained in:
parent
4c67adc46a
commit
39f422e432
@ -1,8 +1,10 @@
|
||||
package net.adphi.apps.parseapplication
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.util.Log
|
||||
import com.parse.ParseConfig
|
||||
import com.parse.ParseQuery
|
||||
import com.parse.ParseUser
|
||||
import net.adphi.apps.parseapplication.Models.CustomObject
|
||||
@ -13,12 +15,28 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
private val TAG: String = getTAG(this)
|
||||
|
||||
private val LAST_VERSION_CODE = "LAST_VERSION_CODE"
|
||||
|
||||
private lateinit var config: ParseConfig
|
||||
private var user: ParseUser? = ParseUser.getCurrentUser()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
ParseConfig.getInBackground { config, e ->
|
||||
if (e != null) {
|
||||
this.config = ParseConfig.getCurrentConfig()
|
||||
}
|
||||
else {
|
||||
this.config = config
|
||||
}
|
||||
val lastVersionCode = this.config.getInt(LAST_VERSION_CODE)
|
||||
if(BuildConfig.VERSION_CODE < lastVersionCode) {
|
||||
AlertDialog.Builder(this).setTitle("Update").setMessage("New Version Available").create().show()
|
||||
}
|
||||
}
|
||||
|
||||
if(user == null) {
|
||||
ParseUser.logInInBackground("Adphi", "azertest", { user, e ->
|
||||
if (e != null) {
|
||||
|
@ -4,6 +4,7 @@ import android.app.Application
|
||||
import com.danylovolokh.androidlogger.AndroidLogger
|
||||
import com.parse.Parse
|
||||
import com.parse.ParseLiveQueryClient
|
||||
import net.adphi.apps.parseapplication.Utils.LOG
|
||||
import net.adphi.apps.parseapplication.Utils.getTAG
|
||||
import net.adphi.apps.parseapplication.Utils.registerParseObject
|
||||
import java.io.IOException
|
||||
@ -33,7 +34,7 @@ class ParseApplication : Application() {
|
||||
false
|
||||
)
|
||||
} catch (e: IOException) {
|
||||
// Some error happened - most likely there is no free space on the system
|
||||
LOG.err(TAG, "Could not create Log File. Error: ${e.message}")
|
||||
}
|
||||
|
||||
|
||||
@ -42,5 +43,6 @@ class ParseApplication : Application() {
|
||||
.maxRetries(1).build()
|
||||
Parse.initialize(config)
|
||||
val liveQueryClient = ParseLiveQueryClient.Factory.getClient(URI("wss://parsetest.back4app.io"))
|
||||
LOG.inf(TAG, "Current Version Code: ${BuildConfig.VERSION_CODE}")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user