use of com.dante.data.model.PinnedHeaderEntity in project 91Pop by DanteAndroid.
the class Forum91IndexFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
unbinder = ButterKnife.bind(this, view);
AppUtils.setColorSchemeColors(context, swipeLayout);
swipeLayout.setOnRefreshListener(this);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
recyclerView.addItemDecoration(new PinnedHeaderItemDecoration.Builder(BaseHeaderAdapter.TYPE_HEADER).setDividerId(R.drawable.divider).enableDivider(true).create());
recyclerView.setAdapter(forum91PornIndexAdapter);
forum91PornIndexAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
PinnedHeaderEntity<Forum91PronItem> forum91PronItemPinnedHeaderEntity = (PinnedHeaderEntity<Forum91PronItem>) adapter.getItem(position);
if (forum91PronItemPinnedHeaderEntity == null || forum91PronItemPinnedHeaderEntity.getData() == null) {
return;
}
Intent intent = new Intent(context, Browse91PornActivity.class);
intent.putExtra(Keys.KEY_INTENT_BROWSE_FORUM_91_PORN_ITEM, forum91PronItemPinnedHeaderEntity.getData());
startActivityWithAnimotion(intent);
}
});
}
use of com.dante.data.model.PinnedHeaderEntity in project 91Pop by DanteAndroid.
the class ParseForum91Porn method parseIndex.
public static BaseResult<List<PinnedHeaderEntity<Forum91PronItem>>> parseIndex(String html) {
BaseResult<List<PinnedHeaderEntity<Forum91PronItem>>> baseResult = new BaseResult<>();
Document doc = Jsoup.parse(html);
Elements tds = doc.getElementsByAttributeValue("background", "images/listbg.gif");
List<PinnedHeaderEntity<Forum91PronItem>> forum91PornItemSectionList = new ArrayList<>();
for (Element td : tds) {
Elements elements = td.select("a");
if (td.select("a").first().attr("title").contains("最新精华")) {
PinnedHeaderEntity<Forum91PronItem> pronItemPinnedHeaderEntity = new PinnedHeaderEntity<>(null, BaseHeaderAdapter.TYPE_HEADER, "最新精华");
forum91PornItemSectionList.add(pronItemPinnedHeaderEntity);
} else if (td.select("a").first().attr("title").contains("最新回复")) {
PinnedHeaderEntity<Forum91PronItem> pronItemPinnedHeaderEntity = new PinnedHeaderEntity<>(null, BaseHeaderAdapter.TYPE_HEADER, "最新回复");
forum91PornItemSectionList.add(pronItemPinnedHeaderEntity);
} else {
PinnedHeaderEntity<Forum91PronItem> pronItemPinnedHeaderEntity = new PinnedHeaderEntity<>(null, BaseHeaderAdapter.TYPE_HEADER, "本周热门");
forum91PornItemSectionList.add(pronItemPinnedHeaderEntity);
}
for (Element element : elements) {
Forum91PronItem forum91PronItem = new Forum91PronItem();
String allInfo = element.attr("title").replaceAll("\n", "");
int titleIndex = allInfo.indexOf("主题标题:");
int authorIndex = allInfo.indexOf("主题作者:");
int authorPublishTimeIndex = allInfo.indexOf("发表时间:");
int viewCountIndex = allInfo.indexOf("浏览次数:");
int replyCountIndex = allInfo.indexOf("回复次数:");
int lastPostTimeIndex = allInfo.indexOf("最后回复:");
int lastPostAuthorIndex = allInfo.indexOf("最后发表:");
String title = StringUtils.subString(allInfo, titleIndex + 5, authorIndex);
String author = StringUtils.subString(allInfo, authorIndex + 5, authorPublishTimeIndex);
String authorPublishTime = StringUtils.subString(allInfo, authorPublishTimeIndex + 5, viewCountIndex);
String viewCount = StringUtils.subString(allInfo, viewCountIndex + 5, replyCountIndex).replace("次", "").trim();
String replyCount = StringUtils.subString(allInfo, replyCountIndex + 5, lastPostTimeIndex).replace("次", "").trim();
String lastPostTime = StringUtils.subString(allInfo, lastPostTimeIndex + 5, lastPostAuthorIndex);
String lastPostAuthor = StringUtils.subString(allInfo, lastPostAuthorIndex + 5, allInfo.length());
forum91PronItem.setLastPostTime(lastPostTime);
forum91PronItem.setLastPostAuthor(lastPostAuthor);
forum91PronItem.setTitle(title);
forum91PronItem.setAuthor(author);
forum91PronItem.setViewCount(Long.parseLong(viewCount));
forum91PronItem.setReplyCount(Long.parseLong(replyCount));
forum91PronItem.setAuthorPublishTime(authorPublishTime);
String contentUrl = element.attr("href");
int starIndex = contentUrl.indexOf("tid=");
String tidStr = StringUtils.subString(contentUrl, starIndex + 4, contentUrl.length());
if (!TextUtils.isEmpty(tidStr) && TextUtils.isDigitsOnly(tidStr)) {
forum91PronItem.setTid(Long.parseLong(tidStr));
}
PinnedHeaderEntity<Forum91PronItem> pronItemPinnedHeaderEntity = new PinnedHeaderEntity<>(forum91PronItem, BaseHeaderAdapter.TYPE_DATA, "");
forum91PornItemSectionList.add(pronItemPinnedHeaderEntity);
}
}
baseResult.setData(forum91PornItemSectionList);
return baseResult;
}
Aggregations