Add Check for Update (Parse Config)
This commit is contained in:
parent
4c67adc46a
commit
39f422e432
@ -1,8 +1,10 @@
|
|||||||
package net.adphi.apps.parseapplication
|
package net.adphi.apps.parseapplication
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.parse.ParseConfig
|
||||||
import com.parse.ParseQuery
|
import com.parse.ParseQuery
|
||||||
import com.parse.ParseUser
|
import com.parse.ParseUser
|
||||||
import net.adphi.apps.parseapplication.Models.CustomObject
|
import net.adphi.apps.parseapplication.Models.CustomObject
|
||||||
@ -13,12 +15,28 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private val TAG: String = getTAG(this)
|
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()
|
private var user: ParseUser? = ParseUser.getCurrentUser()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
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) {
|
if(user == null) {
|
||||||
ParseUser.logInInBackground("Adphi", "azertest", { user, e ->
|
ParseUser.logInInBackground("Adphi", "azertest", { user, e ->
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
|
@ -4,6 +4,7 @@ import android.app.Application
|
|||||||
import com.danylovolokh.androidlogger.AndroidLogger
|
import com.danylovolokh.androidlogger.AndroidLogger
|
||||||
import com.parse.Parse
|
import com.parse.Parse
|
||||||
import com.parse.ParseLiveQueryClient
|
import com.parse.ParseLiveQueryClient
|
||||||
|
import net.adphi.apps.parseapplication.Utils.LOG
|
||||||
import net.adphi.apps.parseapplication.Utils.getTAG
|
import net.adphi.apps.parseapplication.Utils.getTAG
|
||||||
import net.adphi.apps.parseapplication.Utils.registerParseObject
|
import net.adphi.apps.parseapplication.Utils.registerParseObject
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@ -33,7 +34,7 @@ class ParseApplication : Application() {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
} catch (e: IOException) {
|
} 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()
|
.maxRetries(1).build()
|
||||||
Parse.initialize(config)
|
Parse.initialize(config)
|
||||||
val liveQueryClient = ParseLiveQueryClient.Factory.getClient(URI("wss://parsetest.back4app.io"))
|
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