improve layout names

This commit is contained in:
Conny Duck 2019-12-22 11:55:26 +01:00
parent 97350c59fa
commit 63d6fe7270
2 changed files with 20 additions and 23 deletions

View file

@ -5,7 +5,6 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -23,6 +22,7 @@ import com.uber.autodispose.AutoDispose.autoDisposable
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider.from import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider.from
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.activity_scheduled_toot.* import kotlinx.android.synthetic.main.activity_scheduled_toot.*
import kotlinx.android.synthetic.main.toolbar_basic.*
import okhttp3.ResponseBody import okhttp3.ResponseBody
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
@ -50,25 +50,22 @@ class ScheduledTootActivity : BaseActivity(), ScheduledTootAction, Injectable {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_scheduled_toot) setContentView(R.layout.activity_scheduled_toot)
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
val bar = supportActionBar supportActionBar?.run {
if (bar != null) { title = getString(R.string.title_scheduled_toot)
bar.title = getString(R.string.title_scheduled_toot) setDisplayHomeAsUpEnabled(true)
bar.setDisplayHomeAsUpEnabled(true) setDisplayShowHomeEnabled(true)
bar.setDisplayShowHomeEnabled(true)
} }
swipe_refresh_layout.setOnRefreshListener(this::refreshStatuses) swipeRefreshLayout.setOnRefreshListener(this::refreshStatuses)
scheduled_toot_list.setHasFixedSize(true) scheduledTootList.setHasFixedSize(true)
val layoutManager = LinearLayoutManager(this) val layoutManager = LinearLayoutManager(this)
scheduled_toot_list.layoutManager = layoutManager scheduledTootList.layoutManager = layoutManager
val divider = DividerItemDecoration(this, layoutManager.orientation) val divider = DividerItemDecoration(this, layoutManager.orientation)
scheduled_toot_list.addItemDecoration(divider) scheduledTootList.addItemDecoration(divider)
adapter = ScheduledTootAdapter(this) adapter = ScheduledTootAdapter(this)
scheduled_toot_list.adapter = adapter scheduledTootList.adapter = adapter
loadStatuses() loadStatuses()
@ -93,11 +90,11 @@ class ScheduledTootActivity : BaseActivity(), ScheduledTootAction, Injectable {
} }
fun loadStatuses() { fun loadStatuses() {
progress_bar.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE
mastodonApi.scheduledStatuses() mastodonApi.scheduledStatuses()
.enqueue(object : Callback<List<ScheduledStatus>> { .enqueue(object : Callback<List<ScheduledStatus>> {
override fun onResponse(call: Call<List<ScheduledStatus>>, response: Response<List<ScheduledStatus>>) { override fun onResponse(call: Call<List<ScheduledStatus>>, response: Response<List<ScheduledStatus>>) {
progress_bar.visibility = View.GONE progressBar.visibility = View.GONE
if (response.body().isNullOrEmpty()) { if (response.body().isNullOrEmpty()) {
errorMessageView.show() errorMessageView.show()
errorMessageView.setup(R.drawable.elephant_friend_empty, R.string.message_empty, errorMessageView.setup(R.drawable.elephant_friend_empty, R.string.message_empty,
@ -108,7 +105,7 @@ class ScheduledTootActivity : BaseActivity(), ScheduledTootAction, Injectable {
} }
override fun onFailure(call: Call<List<ScheduledStatus>>, t: Throwable) { override fun onFailure(call: Call<List<ScheduledStatus>>, t: Throwable) {
progress_bar.visibility = View.GONE progressBar.visibility = View.GONE
errorMessageView.show() errorMessageView.show()
errorMessageView.setup(R.drawable.elephant_error, R.string.error_generic) { errorMessageView.setup(R.drawable.elephant_error, R.string.error_generic) {
errorMessageView.hide() errorMessageView.hide()
@ -119,11 +116,11 @@ class ScheduledTootActivity : BaseActivity(), ScheduledTootAction, Injectable {
} }
private fun refreshStatuses() { private fun refreshStatuses() {
swipe_refresh_layout.isRefreshing = true swipeRefreshLayout.isRefreshing = true
mastodonApi.scheduledStatuses() mastodonApi.scheduledStatuses()
.enqueue(object : Callback<List<ScheduledStatus>> { .enqueue(object : Callback<List<ScheduledStatus>> {
override fun onResponse(call: Call<List<ScheduledStatus>>, response: Response<List<ScheduledStatus>>) { override fun onResponse(call: Call<List<ScheduledStatus>>, response: Response<List<ScheduledStatus>>) {
swipe_refresh_layout.isRefreshing = false swipeRefreshLayout.isRefreshing = false
if (response.body().isNullOrEmpty()) { if (response.body().isNullOrEmpty()) {
errorMessageView.show() errorMessageView.show()
errorMessageView.setup(R.drawable.elephant_friend_empty, R.string.message_empty, errorMessageView.setup(R.drawable.elephant_friend_empty, R.string.message_empty,
@ -134,7 +131,7 @@ class ScheduledTootActivity : BaseActivity(), ScheduledTootAction, Injectable {
} }
override fun onFailure(call: Call<List<ScheduledStatus>>, t: Throwable) { override fun onFailure(call: Call<List<ScheduledStatus>>, t: Throwable) {
swipe_refresh_layout.isRefreshing = false swipeRefreshLayout.isRefreshing = false
} }
}) })
} }

View file

@ -2,7 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_view_thread" android:id="@+id/activityScheduledToot"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="com.keylesspalace.tusky.AccountListActivity"> tools:context="com.keylesspalace.tusky.AccountListActivity">
@ -15,7 +15,7 @@
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progressBar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -37,12 +37,12 @@
tools:visibility="visible" /> tools:visibility="visible" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout" android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/scheduled_toot_list" android:id="@+id/scheduledTootList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />