Small changes for user with no data

This commit is contained in:
wiecktobi 2020-06-02 23:09:15 +02:00
parent 20ab2931f2
commit 2ed09692f8
2 changed files with 16 additions and 11 deletions

View File

@ -106,6 +106,7 @@ class MainActivity : AppCompatActivity() {
showUsername()
actionButton = findViewById(R.id.button_start_stop)
actionButton.setBackgroundColor(resources.getColor(R.color.colorPrimaryDark))
actionButton.setOnClickListener {
callStartStop()
}
@ -166,6 +167,8 @@ class MainActivity : AppCompatActivity() {
getTimetrackAccounts(username!!)
lbl_username.text = "Hello " + firstname
if (location?.latitude == null) {
button_start_stop?.text = "No geofence set for you"
button_start_stop?.setBackgroundColor(resources.getColor(R.color.colorPrimaryDark))
Toast.makeText(this@MainActivity, "No geofence set for you", Toast.LENGTH_LONG)
.show()
} else {
@ -195,19 +198,24 @@ class MainActivity : AppCompatActivity() {
) {
if (response.isSuccessful) {
accounts = response.body()!!.accounts
accounts.entries.forEach {
accountNames.add(it.name + "")
if (!accounts.entries.isEmpty()) {
accounts.entries.forEach {
accountNames.add(it.name + "")
}
} else {
accountNames.add("None")
initializeDropdown(accountNames)
display_description.setText("You dont have any Timetrack Accounts")
Toast.makeText(this@MainActivity, "You dont have any Timetrack Accounts", Toast.LENGTH_LONG)
.show()
}
initializeDropdown(accountNames)
println("Dropdown initialized")
}
}
override fun onFailure(call: Call<EmbeddedAccounts>, t: Throwable) {
accountNames.add("None")
initializeDropdown(accountNames)
button_start_stop?.text = "No Timetrack Accounts"
Toast.makeText(this@MainActivity, "You dont have any Timetrack Accounts ", Toast.LENGTH_LONG)
.show()
println("Failed to get accounts")
}
})
}
@ -229,8 +237,6 @@ class MainActivity : AppCompatActivity() {
display_description.setText(accounts.entries.get(position).description)
display_revenue.setText(accounts.entries.get(position).revenue.toString())
} else {
display_description.visibility = View.GONE
display_description_layout.visibility = View.GONE
display_revenue.visibility = View.GONE
display_revenue_layout.visibility = View.GONE
}

View File

@ -96,8 +96,7 @@
android:foregroundGravity="right|center_horizontal"
android:textAlignment="textEnd"
app:layout_constraintBottom_toBottomOf="@+id/selected_acc"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/selected_acc" />
app:layout_constraintEnd_toEndOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/display_description_layout"