use of com.dante.data.model.Forum91PronItem 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.Forum91PronItem in project 91Pop by DanteAndroid.
the class ForumFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Forum91PronItem> forum91PronItemList = new ArrayList<>();
forun91PornAdapter = new Forum91PornAdapter(context, addressHelper, R.layout.item_forum_91_porn, forum91PronItemList);
}
use of com.dante.data.model.Forum91PronItem 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;
}
use of com.dante.data.model.Forum91PronItem in project 91Pop by DanteAndroid.
the class ParseForum91Porn method parseForumList.
public static BaseResult<List<Forum91PronItem>> parseForumList(String html, int currentPage) {
BaseResult<List<Forum91PronItem>> baseResult = new BaseResult<>();
baseResult.setTotalPage(1);
Document doc = Jsoup.parse(html);
Element table = doc.getElementsByClass("datatable").first();
Elements tbodys = table.select("tbody");
List<Forum91PronItem> forum91PronItemList = new ArrayList<>();
boolean contentStart = false;
for (Element tbody : tbodys) {
Forum91PronItem forum91PronItem = new Forum91PronItem();
Element th = tbody.select("th").first();
if (!contentStart && currentPage == 1) {
if (th.text().contains("版块主题")) {
contentStart = true;
}
continue;
}
if (th != null) {
String title = th.select("a").first().text();
forum91PronItem.setTitle(title);
String contentUrl = th.select("a").first().attr("href");
int starIndex = contentUrl.indexOf("tid=");
int endIndex = contentUrl.indexOf("&");
String tidStr = StringUtils.subString(contentUrl, starIndex + 4, endIndex);
if (!TextUtils.isEmpty(tidStr) && TextUtils.isDigitsOnly(tidStr)) {
forum91PronItem.setTid(Long.parseLong(tidStr));
} else {
Logger.t(TAG).d("tidStr::" + tidStr);
}
Elements imageElements = th.select("img");
List<String> stringList = null;
for (Element element : imageElements) {
if (stringList == null) {
stringList = new ArrayList<>();
}
stringList.add(element.attr("src"));
}
forum91PronItem.setImageList(stringList);
Elements agreeElements = th.select("font");
if (agreeElements != null && agreeElements.size() >= 1) {
String agreeCount = th.select("font").last().text();
forum91PronItem.setAgreeCount(agreeCount);
} else {
Logger.t(TAG).d("can not parse agreeCount");
}
}
Elements tds = tbody.select("td");
for (Element td : tds) {
switch(td.className()) {
case "folder":
String folder = td.select("img").attr("src");
forum91PronItem.setFolder(folder);
break;
case "icon":
Element iconElement = td.select("img").first();
if (iconElement != null) {
String icon = iconElement.attr("src");
forum91PronItem.setIcon(icon);
}
break;
case "author":
String author = td.select("a").first().text();
String authorPublishTime = td.select("em").first().text();
forum91PronItem.setAuthor(author);
forum91PronItem.setAuthorPublishTime(authorPublishTime);
break;
case "nums":
String replyCount = td.select("strong").first().text();
String viewCount = td.select("em").first().text();
if (!TextUtils.isEmpty(replyCount) && TextUtils.isDigitsOnly(replyCount)) {
forum91PronItem.setReplyCount(Long.parseLong(replyCount));
}
if (!TextUtils.isEmpty(viewCount) && TextUtils.isDigitsOnly(viewCount)) {
forum91PronItem.setViewCount(Long.parseLong(viewCount));
}
break;
case "lastpost":
String lastPostAuthor = td.select("a").first().text();
String lastPostTime = td.select("em").first().text();
forum91PronItem.setLastPostAuthor(lastPostAuthor);
forum91PronItem.setLastPostTime(lastPostTime);
break;
default:
}
}
forum91PronItemList.add(forum91PronItem);
}
if (currentPage == 1) {
Element pageElement = doc.getElementsByClass("pages").first();
String page = pageElement.getElementsByClass("last").first().text().replace("...", "").trim();
Logger.t(TAG).d("totalPage:::" + page);
if (!TextUtils.isEmpty(page) && TextUtils.isDigitsOnly(page)) {
baseResult.setTotalPage(Integer.parseInt(page));
}
}
baseResult.setData(forum91PronItemList);
return baseResult;
}
use of com.dante.data.model.Forum91PronItem in project 91Pop by DanteAndroid.
the class ForumFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
unbinder = ButterKnife.bind(this, view);
swipeLayout.setOnRefreshListener(this);
AppUtils.setColorSchemeColors(context, swipeLayout);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
recyclerView.setAdapter(forun91PornAdapter);
forun91PornAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
loadData(false);
}
}, recyclerView);
if ("17".equals(category.getCategoryValue()) || "4".equals(category.getCategoryValue())) {
tipTextView.setVisibility(View.VISIBLE);
swipeLayout.setEnabled(false);
}
forun91PornAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
Forum91PronItem forum91PronItem = (Forum91PronItem) adapter.getItem(position);
Intent intent = new Intent(context, Browse91PornActivity.class);
intent.putExtra(Keys.KEY_INTENT_BROWSE_FORUM_91_PORN_ITEM, forum91PronItem);
startActivityWithAnimotion(intent);
}
});
}
Aggregations