Skip to content
Closed
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
53 changes: 14 additions & 39 deletions app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@ import icepick.State
import java.util.Calendar
import kotlinx.android.synthetic.main.error_retry.error_button_retry
import kotlinx.android.synthetic.main.error_retry.error_message_view
import kotlinx.android.synthetic.main.fragment_feed.empty_state_view
import kotlinx.android.synthetic.main.fragment_feed.error_panel
import kotlinx.android.synthetic.main.fragment_feed.items_list
import kotlinx.android.synthetic.main.fragment_feed.loading_progress_bar
import kotlinx.android.synthetic.main.fragment_feed.loading_progress_text
import kotlinx.android.synthetic.main.fragment_feed.refresh_root_view
import kotlinx.android.synthetic.main.fragment_feed.refresh_subtitle_text
import kotlinx.android.synthetic.main.fragment_feed.refresh_text
import kotlinx.android.synthetic.main.fragment_feed.*
import org.schabi.newpipe.R
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
import org.schabi.newpipe.fragments.list.BaseListFragment
Expand Down Expand Up @@ -117,10 +110,6 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
}
}

// /////////////////////////////////////////////////////////////////////////
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bring back these comments.. sorry if I was unclear, I meant that old code shouldn't be commented-out but directly removed. But useful comments like this should be kept.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bring back these comments ;-)

// Menu
// /////////////////////////////////////////////////////////////////////////

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
activity.supportActionBar?.setTitle(R.string.fragment_feed_title)
Expand Down Expand Up @@ -169,45 +158,30 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
activity?.supportActionBar?.subtitle = null
}

// /////////////////////////////////////////////////////////////////////////
// Handling
// /////////////////////////////////////////////////////////////////////////

override fun showLoading() {
animateView(refresh_root_view, false, 0)
animateView(items_list, false, 0)

animateView(loading_progress_bar, true, 200)
animateView(loading_progress_text, true, 200)

empty_state_view?.let { animateView(it, false, 0) }
animateView(refresh_root_view, true, 0)
swipeRefreshLayout.isRefreshing=true
animateView(error_panel, false, 0)
}

override fun hideLoading() {
animateView(refresh_root_view, true, 200)
animateView(items_list, true, 300)

animateView(loading_progress_bar, false, 0)
animateView(loading_progress_text, false, 0)

empty_state_view?.let { animateView(it, false, 0) }
animateView(error_panel, false, 0)
swipeRefreshLayout.isRefreshing = false
video_fetch_progress_text.visibility = View.GONE
}

override fun showEmptyState() {
animateView(refresh_root_view, true, 200)
animateView(items_list, false, 0)

animateView(loading_progress_bar, false, 0)
animateView(loading_progress_text, false, 0)

empty_state_view?.let { animateView(it, true, 800) }
animateView(error_panel, false, 0)
swipeRefreshLayout.isRefreshing = false
video_fetch_progress_text.visibility = View.GONE
}

override fun showError(message: String, showRetryButton: Boolean) {
swipeRefreshLayout.isRefreshing = false
video_fetch_progress_text.visibility = View.GONE
infoListAdapter.clearStreamItemList()
animateView(refresh_root_view, false, 120)
animateView(items_list, false, 120)
Expand Down Expand Up @@ -238,10 +212,15 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {

if (!isIndeterminate) {
loading_progress_text.text = "${progressState.currentProgress}/${progressState.maxProgress}"
video_fetch_progress_text.visibility = View.VISIBLE
video_fetch_progress_text.text = getString(R.string.fetching_videos)+ " ${progressState.currentProgress}/${progressState.maxProgress}"
} else if (progressState.progressMessage > 0) {
loading_progress_text?.setText(progressState.progressMessage)
video_fetch_progress_text.visibility = View.VISIBLE
video_fetch_progress_text.text = getString(R.string.fetching_videos)+" ${progressState.currentProgress}/${progressState.maxProgress}"
} else {
loading_progress_text?.text = "∞/∞"
video_fetch_progress_text.visibility = View.GONE
}

loading_progress_bar.isIndeterminate = isIndeterminate ||
Expand Down Expand Up @@ -301,10 +280,6 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
refresh_text?.text = getString(R.string.feed_oldest_subscription_update, oldestSubscriptionUpdateText)
}

// /////////////////////////////////////////////////////////////////////////
// Load Service Handling
// /////////////////////////////////////////////////////////////////////////

override fun doInitialLoadLogic() {}
override fun reloadContent() = triggerUpdate()
override fun loadMoreItems() {}
Expand Down Expand Up @@ -340,4 +315,4 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
return feedFragment
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add back the newline at the end of the file (checkstyle should have complained)

}
12 changes: 12 additions & 0 deletions app/src/main/res/layout/fragment_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:textSize="12sp"
tools:text="@tools:sample/lorem/random" />
<TextView
android:id="@+id/video_fetch_progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="start|center_vertical"
android:maxLines="1"
android:visibility="gone"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="14sp" />


</LinearLayout>

<ImageView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -685,4 +685,5 @@
<string name="playlist_page_summary">Playlist page</string>
<string name="show_thumbnail_title">Show thumbnail</string>
<string name="show_thumbnail_summary">Show thumbnail on lock screen as background and inside notifications</string>
<string name="fetching_videos">\"Fetching videos \"</string>
</resources>