diff options
author | Martin Fietz <martin.fietz@gmail.com> | 2017-10-21 18:01:49 +0200 |
---|---|---|
committer | Martin Fietz <martin.fietz@gmail.com> | 2017-10-21 19:20:18 +0200 |
commit | ee50bca545da30d825c995649e9a6d7580921b77 (patch) | |
tree | 3aa79d9a71b03563ca50d6eced1c1f00819336a4 /app | |
parent | eb920d73630132780395596aa347100a80d9d17a (diff) | |
download | AntennaPod-ee50bca545da30d825c995649e9a6d7580921b77.zip |
Refactor
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java index d7bebb672..75514abb1 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.adapter; import android.content.Context; +import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.text.Layout; import android.text.Selection; @@ -42,8 +43,9 @@ public class ChaptersListAdapter extends ArrayAdapter<Chapter> { this.media = media; } + @NonNull @Override - public View getView(final int position, View convertView, ViewGroup parent) { + public View getView(final int position, View convertView, @NonNull ViewGroup parent) { Holder holder; Chapter sc = getItem(position); @@ -120,7 +122,7 @@ public class ChaptersListAdapter extends ArrayAdapter<Chapter> { if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); - } else if (action == MotionEvent.ACTION_DOWN){ + } else if (action == MotionEvent.ACTION_DOWN) { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); @@ -139,23 +141,17 @@ public class ChaptersListAdapter extends ArrayAdapter<Chapter> { callback.onPlayChapterButtonClicked(position); } }); + Chapter current = ChapterUtils.getCurrentChapter(media); - if (current != null) { - if (current == sc) { - int playingBackGroundColor; - if(UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) { - playingBackGroundColor = ContextCompat.getColor(getContext(), R.color.highlight_dark); - } else { - playingBackGroundColor = ContextCompat.getColor(getContext(), R.color.highlight_light); - } - holder.view.setBackgroundColor(playingBackGroundColor); - } else { - holder.view.setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); - holder.title.setTextColor(defaultTextColor); - holder.start.setTextColor(defaultTextColor); - } + if (current == sc) { + boolean darkTheme = UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark; + int highlight = darkTheme ? R.color.highlight_dark : R.color.highlight_light; + int playingBackGroundColor = ContextCompat.getColor(getContext(), highlight); + holder.view.setBackgroundColor(playingBackGroundColor); } else { - Log.w(TAG, "Could not find out what the current chapter is."); + holder.view.setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); + holder.title.setTextColor(defaultTextColor); + holder.start.setTextColor(defaultTextColor); } return convertView; @@ -172,7 +168,7 @@ public class ChaptersListAdapter extends ArrayAdapter<Chapter> { @Override public int getCount() { - if(media == null || media.getChapters() == null) { + if (media == null || media.getChapters() == null) { return 0; } // ignore invalid chapters |