mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-26 01:50:32 +00:00
smoother transition to comments fragment
This commit is contained in:
parent
66c753f3a3
commit
d694c5f511
@ -121,7 +121,7 @@ public class VideoDetailFragment
|
|||||||
// Amount of videos to show on start
|
// Amount of videos to show on start
|
||||||
private static final int INITIAL_RELATED_VIDEOS = 8;
|
private static final int INITIAL_RELATED_VIDEOS = 8;
|
||||||
// Amount of comments to show on start
|
// Amount of comments to show on start
|
||||||
private static final int INITIAL_COMMENTS = 8;
|
public static final int INITIAL_COMMENTS = 8;
|
||||||
|
|
||||||
private InfoItemBuilder infoItemBuilder = null;
|
private InfoItemBuilder infoItemBuilder = null;
|
||||||
|
|
||||||
@ -503,32 +503,8 @@ public class VideoDetailFragment
|
|||||||
if (DEBUG) Log.d(TAG, "toggleExpandComments() called with: info = [" + info + "]");
|
if (DEBUG) Log.d(TAG, "toggleExpandComments() called with: info = [" + info + "]");
|
||||||
if (!showComments || null == info) return;
|
if (!showComments || null == info) return;
|
||||||
|
|
||||||
int initialCount = INITIAL_COMMENTS;
|
|
||||||
int currentCount = commentsView.getChildCount();
|
|
||||||
|
|
||||||
//collapse
|
|
||||||
if (currentCount > initialCount && !info.hasNextPage()) {
|
|
||||||
commentsView.removeViews(initialCount,
|
|
||||||
currentCount - (initialCount));
|
|
||||||
commentsExpandButton.setImageDrawable(ContextCompat.getDrawable(
|
|
||||||
activity, ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.expand)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentCount < info.getRelatedItems().size()){
|
|
||||||
//expand
|
|
||||||
for (int i = currentCount; i < info.getRelatedItems().size(); i++) {
|
|
||||||
CommentsInfoItem item = info.getRelatedItems().get(i);
|
|
||||||
commentsView.addView(infoItemBuilder.buildView(commentsView, item));
|
|
||||||
}
|
|
||||||
if(!info.hasNextPage()){
|
|
||||||
commentsExpandButton.setImageDrawable(
|
|
||||||
ContextCompat.getDrawable(activity,
|
|
||||||
ThemeHelper.resolveResourceIdFromAttr(activity, R.attr.collapse)));
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
NavigationHelper.openCommentsFragment(getFragmentManager(), serviceId, url, name);
|
NavigationHelper.openCommentsFragment(getFragmentManager(), serviceId, url, name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -34,6 +34,7 @@ import org.schabi.newpipe.extractor.channel.ChannelInfo;
|
|||||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
|
import org.schabi.newpipe.fragments.detail.VideoDetailFragment;
|
||||||
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
|
||||||
import org.schabi.newpipe.info_list.InfoItemDialog;
|
import org.schabi.newpipe.info_list.InfoItemDialog;
|
||||||
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
||||||
@ -153,7 +154,7 @@ public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
|
|||||||
public void handleResult(@NonNull CommentsInfo result) {
|
public void handleResult(@NonNull CommentsInfo result) {
|
||||||
super.handleResult(result);
|
super.handleResult(result);
|
||||||
if(initialLoad){
|
if(initialLoad){
|
||||||
itemsList.smoothScrollToPosition(infoListAdapter.getItemCount());
|
itemsList.smoothScrollToPosition(VideoDetailFragment.INITIAL_COMMENTS);
|
||||||
initialLoad = false;
|
initialLoad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user