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