improve layout names

main
Conny Duck 5 years ago
parent 7f2aab7723
commit 04b81c5240
  1. 35
      app/src/main/java/com/keylesspalace/tusky/components/scheduled/ScheduledTootActivity.kt
  2. 8
      app/src/main/res/layout/activity_scheduled_toot.xml

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

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

Loading…
Cancel
Save