Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Ema 276 library pull to refresh #285

Merged
merged 2 commits into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ class NetModule {
authInterceptor: AuthInterceptorImpl
): OkHttpClient =
OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.connectTimeout(30, TimeUnit.SECONDS)
.callTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.addNetworkInterceptor(authInterceptor)
.addInterceptor(loggingInterceptor)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package com.razeware.emitron.ui.library

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo.*
import androidx.appcompat.widget.PopupMenu
import androidx.core.view.isVisible
import androidx.core.view.setPadding
import androidx.fragment.app.activityViewModels
Expand Down Expand Up @@ -151,6 +149,10 @@ class LibraryFragment : DaggerFragment() {
binding.textInputLayoutSearch.setEndIconOnClickListener {
handleQueryCleared()
}

binding.libraryPullToRefresh.setOnRefreshListener {
loadCollections()
}
}

private fun showRecentSearchControls() {
Expand Down Expand Up @@ -224,6 +226,10 @@ class LibraryFragment : DaggerFragment() {
toggleControls(true, uiState == UiStateManager.UiState.INIT_EMPTY)
hideRecentSearchControls()
progressDelegate.hideProgressView()
binding.libraryPullToRefresh.isRefreshing = false
}
UiStateManager.UiState.INIT_FAILED -> {
loadCollections() // retry
}
else -> {
// Handled by the adapter
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/res/layout/fragment_library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,31 @@
app:icon="@drawable/ic_material_icon_sort"
app:iconPadding="@dimen/button_padding_internal_dense"
app:iconTint="@color/colorIcon2"
app:layout_constraintBottom_toTopOf="@+id/recycler_view_library"
app:layout_constraintBottom_toTopOf="@+id/library_pull_to_refresh"
app:layout_constraintEnd_toEndOf="@id/guideline_right"
app:layout_constraintStart_toEndOf="@+id/text_library_count"
app:layout_constraintTop_toBottomOf="@+id/scroll_view_library_filter" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_library"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/library_pull_to_refresh"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/guideline_right"
app:layout_constraintStart_toStartOf="@id/guideline_left"
app:layout_constraintTop_toBottomOf="@+id/text_library_count"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_content" />
app:layout_constraintTop_toBottomOf="@+id/text_library_count">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_library"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/activity_vertical_margin"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_content" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

<FrameLayout
android:id="@+id/layout_progress_container"
Expand Down