Skip to content

Commit

Permalink
Improves messaging on library sync success or failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsos committed Dec 21, 2020
1 parent 9e456ce commit 322eda4
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ class LibraryActivity : BaseActivity(),
pager.currentItem = savedInstanceState.getInt(PAGER_POSITION, 0)
}

override fun refreshFailed() {
Snackbar.make(pager, R.string.refresh_failed, Snackbar.LENGTH_SHORT).show()
override fun syncFailure() {
Snackbar.make(pager, R.string.library__sync_failed, Snackbar.LENGTH_LONG).show()
}

override fun showRefreshing() {
override fun showSyncProgress() {
findViewById<ProgressIndicator>(R.id.sync_progress).isGone = false
findViewById<TextView>(R.id.sync_progress_text).isGone = false
}

override fun hideRefreshing() {
override fun hideSyncProgress() {
findViewById<ProgressIndicator>(R.id.sync_progress).isGone = true
findViewById<TextView>(R.id.sync_progress_text).isGone = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.kelsos.mbrc.mvp.BaseView
import com.kelsos.mbrc.mvp.Presenter

interface LibraryView : BaseView {
fun refreshFailed()
fun showRefreshing()
fun hideRefreshing()
fun syncFailure()
fun showSyncProgress()
fun hideSyncProgress()
fun updateArtistOnlyPreference(albumArtistOnly: Boolean?)
fun syncComplete(stats: LibraryStats)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ constructor(
LibrarySyncInteractor.OnStartListener {

override fun refresh() {
view?.showRefreshing()
view?.showSyncProgress()
scope.launch {
librarySyncInteractor.sync()
}
Expand All @@ -31,7 +31,7 @@ constructor(
librarySyncInteractor.setOnCompleteListener(this)
librarySyncInteractor.setOnStartListener(this)
if (!librarySyncInteractor.isRunning()) {
view.hideRefreshing()
view.hideSyncProgress()
}
}

Expand All @@ -43,13 +43,13 @@ constructor(

override fun onTermination() {
scope.launch {
view?.hideRefreshing()
view?.hideSyncProgress()
}
}

override fun onFailure(throwable: Throwable) {
scope.launch {
view?.refreshFailed()
view?.syncFailure()
}
}

Expand All @@ -75,7 +75,7 @@ constructor(

override fun onStart() {
scope.launch {
view?.showRefreshing()
view?.showSyncProgress()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.raizlabs.android.dbflow.list.FlowCursorList

interface BrowseAlbumView : BaseView {
fun update(cursor: FlowCursorList<Album>)
fun failure(throwable: Throwable)
fun search(term: String)
fun queue(success: Boolean, tracks: Int)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ class BrowseAlbumFragment : Fragment(),
adapter.update(cursor)
}

override fun failure(throwable: Throwable) {
Snackbar.make(recycler, R.string.refresh_failed, Snackbar.LENGTH_SHORT).show()
}

override fun queue(success: Boolean, tracks: Int) {
val message = if (success) {
getString(R.string.queue_result__success, tracks)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.raizlabs.android.dbflow.list.FlowCursorList

interface BrowseArtistView : BaseView {
fun update(data: FlowCursorList<Artist>)
fun failure(throwable: Throwable)
fun search(term: String)
fun queue(success: Boolean, tracks: Int)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,4 @@ class BrowseArtistFragment : Fragment(),
override fun update(data: FlowCursorList<Artist>) {
adapter.update(data)
}

override fun failure(throwable: Throwable) {
Snackbar.make(recycler, R.string.refresh_failed, Snackbar.LENGTH_SHORT).show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface BrowseGenrePresenter : Presenter<BrowseGenreView> {

interface BrowseGenreView : BaseView {
fun update(cursor: FlowCursorList<Genre>)
fun failure(it: Throwable)
fun search(term: String)
fun queue(success: Boolean, tracks: Int)
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ class BrowseGenreFragment : Fragment(),
actionHandler.genreSelected(genre, requireActivity())
}

override fun failure(it: Throwable) {
Snackbar.make(recycler, R.string.refresh_failed, Snackbar.LENGTH_SHORT).show()
}

override fun onDestroy() {
Toothpick.closeScope(this)
super.onDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ constructor(
view?.update(getData(term))
} catch (e: Exception) {
Timber.v(e, "Error while loading the data from the database")
view?.failure(e)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.raizlabs.android.dbflow.list.FlowCursorList

interface BrowseTrackView : BaseView {
fun update(it: FlowCursorList<Track>)
fun failure(it: Throwable)
fun search(term: String)
fun queue(success: Boolean, tracks: Int)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,4 @@ class BrowseTrackFragment : Fragment(),
override fun onItemClicked(track: Track) {
presenter.queue(track)
}

override fun failure(it: Throwable) {
Snackbar.make(recycler, R.string.refresh_failed, Snackbar.LENGTH_SHORT).show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ constructor(
view?.update(getData(term))
} catch (e: Exception) {
Timber.v(e, "Error while loading the data from the database")
view?.failure(e)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/raw/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<version
version="1.4.0"
release="Dec x,2020">
<feature>Improves visual feedback when performing a library metadata sync.</feature>
<feature>Adds a feedback message when queueing tracks/albums/genres/artists.</feature>
<feature>Adds the ability to queue the album or artist when browsing the track list.</feature>
<bug>Fixes a bug that would prevent users from queueing albums when browsing an artist's albums.</bug>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<string name="label_albums">Albums</string>
<string name="label_tracks">Tracks</string>
<string name="no_results_found">Sorry could not find any results for your search!</string>
<string name="refresh_failed">Refresh failed</string>
<string name="library__sync_failed">The library metadata sync was incomplete or failed completely. This might result in queueing not working properly..</string>
<string name="connect_button_description">Connect Button</string>
<string name="playback_progress">%1$02d:%2$02d</string>
<string name="notification_action_previous">Previous</string>
Expand Down Expand Up @@ -194,4 +194,5 @@
<string name="menu_play_artist">Play Now (Artist)</string>
<string name="menu_play_album">Play Now (Album)</string>
<string name="library__sync_complete">"Sync completed successfully. %1$d genres(s), %2$d artist(s) %3$d album(s), %4$d tracks and %5$d playlist(s) are available."</string>
<string name="refresh_failed">Refresh was unsuccessful.</string>
</resources>

0 comments on commit 322eda4

Please sign in to comment.