Fixes #23.
This commit is contained in:
parent
4565079f29
commit
3da1d431db
@ -25,8 +25,8 @@ android {
|
|||||||
applicationId "apps.amine.bou.readerforselfoss"
|
applicationId "apps.amine.bou.readerforselfoss"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 1510
|
versionCode 1511
|
||||||
versionName "1.5.1"
|
versionName "1.5.1.1"
|
||||||
|
|
||||||
// Enabling multidex support.
|
// Enabling multidex support.
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
@ -31,7 +31,14 @@ class AddSourceActivity : AppCompatActivity() {
|
|||||||
val mTags = findViewById(R.id.tags) as EditText
|
val mTags = findViewById(R.id.tags) as EditText
|
||||||
val mSpoutsSpinner = findViewById(R.id.spoutsSpinner) as Spinner
|
val mSpoutsSpinner = findViewById(R.id.spoutsSpinner) as Spinner
|
||||||
val mSaveBtn = findViewById(R.id.saveBtn) as Button
|
val mSaveBtn = findViewById(R.id.saveBtn) as Button
|
||||||
val api = SelfossApi(this)
|
var api: SelfossApi? = null
|
||||||
|
|
||||||
|
try {
|
||||||
|
api = SelfossApi(this)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
mustLoginToAddSource()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val intent = intent
|
val intent = intent
|
||||||
@ -40,7 +47,7 @@ class AddSourceActivity : AppCompatActivity() {
|
|||||||
mNameInput.setText(intent.getStringExtra(Intent.EXTRA_TITLE))
|
mNameInput.setText(intent.getStringExtra(Intent.EXTRA_TITLE))
|
||||||
}
|
}
|
||||||
|
|
||||||
mSaveBtn.setOnClickListener { handleSaveSource(mTags, mNameInput.text.toString(), mSourceUri.text.toString(), api) }
|
mSaveBtn.setOnClickListener { handleSaveSource(mTags, mNameInput.text.toString(), mSourceUri.text.toString(), api!!) }
|
||||||
|
|
||||||
|
|
||||||
val spoutsKV = HashMap<String, String>()
|
val spoutsKV = HashMap<String, String>()
|
||||||
@ -58,14 +65,11 @@ class AddSourceActivity : AppCompatActivity() {
|
|||||||
val config = Config(this)
|
val config = Config(this)
|
||||||
|
|
||||||
if (config.baseUrl.isEmpty() || !isUrlValid(config.baseUrl)) {
|
if (config.baseUrl.isEmpty() || !isUrlValid(config.baseUrl)) {
|
||||||
Toast.makeText(this, getString(R.string.addStringNoUrl), Toast.LENGTH_SHORT).show()
|
mustLoginToAddSource()
|
||||||
val i = Intent(this, LoginActivity::class.java)
|
|
||||||
startActivity(i)
|
|
||||||
finish()
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
var items: Map<String, Spout>
|
var items: Map<String, Spout>
|
||||||
api.spouts().enqueue(object : Callback<Map<String, Spout>> {
|
api!!.spouts().enqueue(object : Callback<Map<String, Spout>> {
|
||||||
override fun onResponse(call: Call<Map<String, Spout>>, response: Response<Map<String, Spout>>) {
|
override fun onResponse(call: Call<Map<String, Spout>>, response: Response<Map<String, Spout>>) {
|
||||||
if (response.body() != null) {
|
if (response.body() != null) {
|
||||||
items = response.body()!!
|
items = response.body()!!
|
||||||
@ -99,6 +103,13 @@ class AddSourceActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun mustLoginToAddSource() {
|
||||||
|
Toast.makeText(this, getString(R.string.addStringNoUrl), Toast.LENGTH_SHORT).show()
|
||||||
|
val i = Intent(this, LoginActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleSaveSource(mTags: EditText, title: String, url: String, api: SelfossApi) {
|
private fun handleSaveSource(mTags: EditText, title: String, url: String, api: SelfossApi) {
|
||||||
|
|
||||||
if (title.isEmpty() || url.isEmpty() || mSpoutsValue == null || mSpoutsValue!!.isEmpty()) {
|
if (title.isEmpty() || url.isEmpty() || mSpoutsValue == null || mSpoutsValue!!.isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user