Snaptube v4.40.0.4401610版本的 MD5 值为:ca2b95dcff63007195db02a6c93091b9
以下内容为反编译后的 CommentListFragment.java 源代码,内容仅作参考
package com.snaptube.mixed_list.fragment;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import com.dayuwuxian.em.comment.common.proto.Comment;
import com.dayuwuxian.em.comment.common.proto.CommentBody;
import com.dayuwuxian.em.comment.common.proto.CommentPage;
import com.snaptube.mixed_list.R;
import com.snaptube.mixed_list.model.CommentInfo;
import com.snaptube.mixed_list.model.ResourceInfo;
import com.trello.rxlifecycle.android.FragmentEvent;
import com.trello.rxlifecycle.components.RxFragment;
import com.wandoujia.base.utils.RxBus;
import com.wandoujia.em.common.proto.Card;
import com.wandoujia.em.common.proto.CardAnnotation;
import com.wandoujia.em.common.proto.ListPageResponse;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import o.bdk;
import o.bdm;
import o.beg;
import o.bel;
import o.bfo;
import o.bhr;
import o.cds;
import o.cdz;
import o.crc;
import retrofit2.adapter.rxjava.HttpException;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
public abstract class CommentListFragment extends NetworkMixedListFragment {
public static final String f10234 = CommentListFragment.class.getSimpleName();
private String f10235;
@crc
public bdm f10237;
boolean f10238 = false;
boolean f10239 = false;
int f10240 = 0;
int f10236 = 0;
private boolean f10241 = true;
public interface InterfaceC0201 {
void mo9819(CommentListFragment commentListFragment);
}
public abstract ResourceInfo mo9800();
public abstract String mo9801();
public abstract boolean mo9809();
@Override
public void onAttach(Context context) {
super.onAttach(context);
((InterfaceC0201) cds.m20403(context)).mo9819(this);
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
m9837(0);
}
@Override
protected bhr mo9806() {
return new Cif(this);
}
public class Cif extends bhr {
public Cif(RxFragment rxFragment) {
super(rxFragment);
}
@Override
public boolean mo9818() {
if (CommentListFragment.this.mo9809()) {
return super.mo9818() || CommentListFragment.this.f10241;
}
return super.mo9818();
}
}
@Override
public void onResume() {
super.onResume();
m9783();
}
@Override
public boolean mo9805(ListPageResponse listPageResponse) {
return super.mo9805(listPageResponse);
}
@Override
public boolean mo9807() {
if (mo9809()) {
return m9810() && m9797();
}
return m9810();
}
public boolean m9810() {
return super.mo9807();
}
protected boolean m9797() {
return !this.f10241;
}
@Override
public boolean mo9798() {
return super.mo9798();
}
@Override
public boolean mo9799() {
return super.mo9799();
}
@Override
public void mo9808() {
mo9875(false, 1);
}
public boolean m9782() {
return TextUtils.isEmpty(this.f10235);
}
@Override
public Observable<ListPageResponse> mo9775(boolean z, int i) {
if (m9782()) {
m9837(mo9862());
this.f10329.mo18857("list/" + mo9800().id + "/comments", null);
}
return this.f10237.mo16918(mo9800().id, this.f10235, mo9862()).map(new Func1<CommentPage, ListPageResponse>() {
@Override
public ListPageResponse call(CommentPage commentPage) {
List<Card> m9812;
if (commentPage == null) {
return null;
}
if (CommentListFragment.this.m9782()) {
CommentListFragment.this.f10238 = true;
m9812 = m9811(commentPage);
} else {
m9812 = m9812(commentPage);
}
CommentListFragment.this.f10235 = commentPage.offset;
CommentListFragment.this.f10241 = TextUtils.isEmpty(CommentListFragment.this.f10235) ? false : true;
return new ListPageResponse.Builder().card(m9812).nextOffset(null).build();
}
private List<Card> m9811(CommentPage commentPage) {
CommentListFragment.this.f10240 = commentPage.topComments == null ? 0 : commentPage.topComments.size();
CommentListFragment.this.f10236 = commentPage.comments != null ? commentPage.comments.size() : 0;
ArrayList arrayList = new ArrayList((CommentListFragment.this.f10240 > 0 ? 2 : 1) + CommentListFragment.this.f10240 + CommentListFragment.this.f10236);
if (CommentListFragment.this.f10240 > 0) {
arrayList.add(beg.m16961(CommentListFragment.this.getContext()));
for (Comment comment : commentPage.topComments) {
arrayList.add(CommentListFragment.this.m9784(comment));
}
}
arrayList.add(beg.m16964(CommentListFragment.this.getContext()));
if (CommentListFragment.this.f10236 > 0) {
for (Comment comment2 : commentPage.comments) {
arrayList.add(CommentListFragment.this.m9784(comment2));
}
} else {
arrayList.add(beg.m16967());
}
return arrayList;
}
private List<Card> m9812(CommentPage commentPage) {
if (commentPage.comments == null || commentPage.comments.isEmpty()) {
return new ArrayList();
}
ArrayList arrayList = new ArrayList(commentPage.comments.size());
for (Comment comment : commentPage.comments) {
arrayList.add(CommentListFragment.this.m9784(comment));
}
return arrayList;
}
});
}
public Card m9784(Comment comment) {
Uri build = Uri.parse("http://snaptubeapp.com").buildUpon().path("list/comment/" + comment.id + "/detail").build();
String string = getString(R.string.comments);
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(build);
intent.putExtra("show_input_method", true);
intent.putExtra("resource_info", mo9800().toString());
intent.putExtra("videoId", mo9801());
intent.putExtra("resource_id", mo9800().id);
intent.putExtra("title", string);
Intent intent2 = new Intent("android.intent.action.VIEW");
intent2.setData(build);
intent2.putExtra("show_input_method", false);
intent2.putExtra("resource_info", mo9800().toString());
intent2.putExtra("videoId", mo9801());
intent2.putExtra("resource_id", mo9800().id);
intent2.putExtra("title", string);
String quantityString = comment.subCommentCount.intValue() > 0 ? getResources().getQuantityString(R.plurals.view_all_replies, comment.subCommentCount.intValue(), comment.subCommentCount) : null;
String m16996 = bel.m16996(intent);
CardAnnotation[] cardAnnotationArr = new CardAnnotation[11];
cardAnnotationArr[0] = bdk.m16907(9, comment.id);
cardAnnotationArr[1] = bdk.m16907(20033, comment.resourceId);
cardAnnotationArr[2] = bdk.m16907(20028, comment.user.id);
cardAnnotationArr[3] = bdk.m16905(20026, comment.user.avatar, (String) null);
cardAnnotationArr[4] = bdk.m16905(20024, comment.user.name, (String) null);
cardAnnotationArr[5] = bdk.m16902(11, comment.commentTime.longValue());
cardAnnotationArr[6] = bdk.m16900(10009, comment.starred.booleanValue() ? 1 : 0);
cardAnnotationArr[7] = bdk.m16900(10008, comment.starCount.intValue());
cardAnnotationArr[8] = bdk.m16907(20016, comment.content);
cardAnnotationArr[9] = bdk.m16900(12, comment.subCommentCount.intValue());
cardAnnotationArr[10] = bdk.m16905(20030, quantityString, bel.m16996(intent2));
return bdk.m16899(1166, m16996, cardAnnotationArr);
}
@Override
public void mo9804(List<Card> list, boolean z, boolean z2, int i) {
Log.d(f10234, "onDataLoaded: cards.size(): " + list.size() + ", hasNext: " + z + ", swap: " + (!m9810()));
super.mo9804(list, z, m9810() ? false : true, i);
}
@Override
public void mo9803(List<Card> list, int i) {
super.mo9803(list, i);
if (this.f10239) {
RxBus.getInstance().send(new RxBus.Event(1032, -1));
this.f10239 = false;
}
}
public boolean mo9802() {
return false;
}
private void m9783() {
RxBus.getInstance().filter(1027, 1029, 1032).compose(m12701()).compose(RxBus.OBSERVE_ON_MAIN_THREAD).subscribe(new Action1<RxBus.Event>() {
@Override
public void call(RxBus.Event event) {
switch (event.what) {
case 1027:
CommentBody m16995 = bel.m16995(event.obj1);
if (m16995 != null) {
CommentListFragment.this.m9787(m16995);
return;
}
return;
case 1028:
case 1030:
case 1031:
default:
return;
case 1029:
CommentInfo commentInfo = (CommentInfo) event.obj1;
CommentListFragment.this.m9790(commentInfo.commentId, commentInfo.resourceId);
return;
case 1032:
if (!CommentListFragment.this.f10238) {
CommentListFragment.this.f10239 = true;
return;
}
return;
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable th) {
cdz.m20416(new IllegalStateException(th));
}
});
}
public void m9790(String str, String str2) {
int i;
int i2;
Iterator<Card> it = m9848().m17395().iterator();
int i3 = -1;
while (it.hasNext()) {
int i4 = i3 + 1;
Card next = it.next();
if (next.cardId.intValue() != 1166) {
i3 = i4;
} else if (TextUtils.equals(bfo.m17206(next, 9), str)) {
it.remove();
m9848().notifyItemRemoved(i4);
i3 = i4;
} else {
i3 = i4;
}
}
List<Card> m17395 = m9848().m17395();
int size = m17395.size() - 1;
int i5 = -1;
int i6 = -1;
while (size >= 0) {
if (m17395.get(size).cardId.intValue() != 1170) {
i = i5;
i2 = i6;
} else if (i5 == -1) {
i = size;
i2 = i6;
} else if (i6 == -1) {
i = i5;
i2 = size;
} else {
i = i5;
i2 = i6;
}
size--;
i6 = i2;
i5 = i;
}
if (i5 != -1 && i6 != -1 && i6 == i5 - 1) {
m9848().m17395().remove(i6);
m9848().notifyItemRemoved(i6);
}
if (i5 == m9848().m17395().size() - 1) {
m9848().m17395().add(beg.m16967());
m9848().notifyItemInserted(i5 + 1);
}
}
public void m9787(CommentBody commentBody) {
this.f10237.mo16916(commentBody).compose(m12699(FragmentEvent.DESTROY)).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Comment>() {
@Override
public void call(Comment comment) {
CommentListFragment.this.m9793(comment);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable th) {
if ((th instanceof HttpException) && ((HttpException) th).code() == 403) {
bel.m16997(CommentListFragment.this.getContext());
} else {
cdz.m20416(new RuntimeException(th));
}
}
});
}
public void m9793(Comment comment) {
int i;
if (comment.parentId == null) {
CommentInfo commentInfo = new CommentInfo();
commentInfo.commentId = comment.id;
commentInfo.resourceId = comment.resourceId;
RxBus.getInstance().send(new RxBus.Event(1028, commentInfo));
if (!this.f10238) {
RxBus.getInstance().send(new RxBus.Event(1032, -1));
return;
}
List<Card> m17395 = m9848().m17395();
Card m9784 = m9784(comment);
if (this.f10236 == 0) {
int size = m17395.size() - 1;
if (m17395.get(size).cardId.intValue() != 1169) {
cdz.m20416(new IllegalArgumentException("Empty comments card not found"));
return;
}
m9848().m17395().remove(size);
m9848().notifyItemRemoved(size);
m9848().m17395().add(m9784);
m9848().notifyItemInserted(size);
this.f10236++;
RxBus.getInstance().send(new RxBus.Event(1032, size));
return;
}
int size2 = m17395.size() - 1;
while (true) {
if (size2 < 0) {
i = 0;
break;
} else if (m17395.get(size2).cardId.intValue() != 1170) {
size2--;
} else {
i = size2 + 1;
break;
}
}
if (i == 0) {
cdz.m20416(new IllegalArgumentException("cannot find recent comment header"));
}
m9848().m17395().add(i, m9784);
m9848().notifyItemInserted(i);
this.f10236++;
RxBus.getInstance().send(new RxBus.Event(1032, i - 1));
}
}
}