mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 11:02:35 +01:00
made channel activity use recycler view
This commit is contained in:
parent
557bcc40ef
commit
1ab82dfa32
@ -7,6 +7,8 @@ import android.os.Handler;
|
||||
import android.support.design.widget.CollapsingToolbarLayout;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@ -18,6 +20,8 @@ import android.widget.Toast;
|
||||
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
import org.schabi.newpipe.detail.VideoItemDetailActivity;
|
||||
import org.schabi.newpipe.detail.VideoItemDetailFragment;
|
||||
import org.schabi.newpipe.extractor.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.ChannelInfo;
|
||||
import org.schabi.newpipe.extractor.ExtractionException;
|
||||
@ -25,6 +29,7 @@ import org.schabi.newpipe.extractor.ParsingException;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.StreamPreviewInfo;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.info_list.InfoListAdapter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -43,6 +48,7 @@ public class ChannelActivity extends AppCompatActivity {
|
||||
private String channelUrl = "";
|
||||
|
||||
private ImageLoader imageLoader = ImageLoader.getInstance();
|
||||
private InfoListAdapter infoListAdapter = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -55,6 +61,21 @@ public class ChannelActivity extends AppCompatActivity {
|
||||
channelUrl = i.getStringExtra(CHANNEL_URL);
|
||||
serviceId = i.getIntExtra(SERVICE_ID, -1);
|
||||
|
||||
infoListAdapter = new InfoListAdapter(this, rootView);
|
||||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.channel_streams_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setAdapter(infoListAdapter);
|
||||
infoListAdapter.setOnItemSelectedListener(new InfoListAdapter.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void selected(String url) {
|
||||
Intent detailIntent = new Intent(ChannelActivity.this, VideoItemDetailActivity.class);
|
||||
detailIntent.putExtra(VideoItemDetailFragment.VIDEO_URL, url);
|
||||
detailIntent.putExtra(
|
||||
VideoItemDetailFragment.STREAMING_SERVICE, serviceId);
|
||||
startActivity(detailIntent);
|
||||
}
|
||||
});
|
||||
|
||||
// start processing
|
||||
Thread channelExtractorThread = new Thread(new Runnable() {
|
||||
Handler h = new Handler();
|
||||
@ -109,13 +130,11 @@ public class ChannelActivity extends AppCompatActivity {
|
||||
CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.channel_toolbar_layout);
|
||||
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
||||
ImageView channelBanner = (ImageView) findViewById(R.id.channel_banner_image);
|
||||
View channelContentView = findViewById(R.id.channel_content_view);
|
||||
FloatingActionButton feedButton = (FloatingActionButton) findViewById(R.id.channel_rss_fab);
|
||||
ImageView avatarView = (ImageView) findViewById(R.id.channel_avatar_view);
|
||||
ImageView haloView = (ImageView) findViewById(R.id.channel_avatar_halo);
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
channelContentView.setVisibility(View.VISIBLE);
|
||||
|
||||
if(info.channel_name != null && !info.channel_name.isEmpty()) {
|
||||
ctl.setTitle(info.channel_name);
|
||||
@ -150,14 +169,7 @@ public class ChannelActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void initVideos(final ChannelInfo info, StreamInfoItemViewCreator viCreator) {
|
||||
LinearLayout streamLayout = (LinearLayout) findViewById(R.id.channel_streams_view);
|
||||
ArrayList<StreamPreviewInfo> streamsList = new ArrayList<>(info.related_streams);
|
||||
|
||||
for(final StreamPreviewInfo streamInfo : streamsList) {
|
||||
View itemView = viCreator.getViewFromVideoInfoItem(null, streamLayout, streamInfo);
|
||||
itemView = viCreator.setupView(itemView, streamInfo);
|
||||
streamLayout.addView(itemView);
|
||||
}
|
||||
infoListAdapter.addStreamItemList(info.related_streams);
|
||||
}
|
||||
|
||||
private void postNewErrorToast(Handler h, final int stringResource) {
|
||||
|
@ -551,7 +551,7 @@ public class VideoItemDetailFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void initSimilarVideos(final StreamInfo info, StreamInfoItemViewCreator videoItemViewCreator) {
|
||||
similarStreamsAdapter.addVideoList(info.related_streams);
|
||||
similarStreamsAdapter.addStreamItemList(info.related_streams);
|
||||
}
|
||||
|
||||
private void onErrorBlockedByGema() {
|
||||
|
@ -46,12 +46,12 @@ public class InfoListAdapter extends RecyclerView.Adapter<InfoItemHolder> {
|
||||
this.onItemSelectedListener = onItemSelectedListener;
|
||||
}
|
||||
|
||||
public void addVideoList(List<StreamPreviewInfo> videos) {
|
||||
public void addStreamItemList(List<StreamPreviewInfo> videos) {
|
||||
streamList.addAll(videos);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void clearVideoList() {
|
||||
public void clearSteamItemList() {
|
||||
streamList = new Vector<>();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||
sw.setSearchWorkerResultListner(new SearchWorker.SearchWorkerResultListner() {
|
||||
@Override
|
||||
public void onResult(SearchResult result) {
|
||||
infoListAdapter.addVideoList(result.resultList);
|
||||
infoListAdapter.addStreamItemList(result.resultList);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ public class SearchInfoItemFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void search(String query) {
|
||||
infoListAdapter.clearVideoList();
|
||||
infoListAdapter.clearSteamItemList();
|
||||
pageNumber = 0;
|
||||
search(query, pageNumber);
|
||||
}
|
||||
|
@ -285,8 +285,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_below="@id/detailSimilarTitle">
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
android:layout_below="@id/detailSimilarTitle"/>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
@ -96,11 +96,12 @@
|
||||
android:id="@+id/channel_content_view"
|
||||
android:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/channel_streams_view"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="fill_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/channel_streams_view">
|
||||
</LinearLayout>
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
@ -272,8 +272,7 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/detailSimilarTitle">
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
android:layout_below="@id/detailSimilarTitle"/>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user