use of com.dante.data.model.Mm99 in project 91Pop by DanteAndroid.
the class AppApiHelper method list99Mm.
@Override
public Observable<BaseResult<List<Mm99>>> list99Mm(String category, final int page, boolean cleanCache) {
String url = buildUrl(category, page);
DynamicKeyGroup dynamicKeyGroup = new DynamicKeyGroup(category, page);
EvictDynamicKeyGroup evictDynamicKeyGroup = new EvictDynamicKeyGroup(cleanCache);
return cacheProviders.cacheWithLimitTime(mm99ServiceApi.imageList(url), dynamicKeyGroup, evictDynamicKeyGroup).map(new Function<Reply<String>, String>() {
@Override
public String apply(Reply<String> stringReply) {
return stringReply.getData();
}
}).map(new Function<String, BaseResult<List<Mm99>>>() {
@Override
public BaseResult<List<Mm99>> apply(String s) {
return Parse99Mm.parse99MmList(s, page);
}
});
}
use of com.dante.data.model.Mm99 in project 91Pop by DanteAndroid.
the class PictureViewerActivity method init.
private void init() {
// fixSwipeBack();
imageList = getIntent().getStringArrayListExtra(Keys.KEY_INTENT_PICTURE_VIEWER_IMAGE_ARRAY_LIST);
int currentPosition = getIntent().getIntExtra(Keys.KEY_INTENT_PICTURE_VIEWER_CURRENT_IMAGE_POSITION, 0);
updateNumberText(currentPosition);
if (imageList == null) {
imageList = new ArrayList<>();
}
pictureAdapter = new PictureAdapter(imageList);
viewPager.setAdapter(pictureAdapter);
viewPager.setCurrentItem(currentPosition);
int id = getIntent().getIntExtra(Keys.KEY_INTENT_MEI_ZI_TU_CONTENT_ID, 0);
if (id > 0) {
presenter.listMeZiPicture(id, false);
}
Mm99 mm99 = (Mm99) getIntent().getSerializableExtra(Keys.KEY_INTENT_99_MM_ITEM);
if (mm99 != null) {
presenter.list99MmPicture(mm99.getId(), mm99.getImgUrl(), false);
}
}
use of com.dante.data.model.Mm99 in project 91Pop by DanteAndroid.
the class Parse99Mm method parse99MmList.
public static BaseResult<List<Mm99>> parse99MmList(String html, int page) {
BaseResult<List<Mm99>> baseResult = new BaseResult<>();
baseResult.setTotalPage(1);
Logger.t(TAG).d(html);
Document doc = Jsoup.parse(html);
Element ul = doc.getElementById("piclist");
Elements lis = ul.select("li");
List<Mm99> mm99List = new ArrayList<>();
for (Element li : lis) {
Mm99 mm99 = new Mm99();
Element a = li.selectFirst("dt").selectFirst("a");
String contentUrl = "http://www.99mm.me" + a.attr("href");
mm99.setContentUrl(contentUrl);
int startIndex = contentUrl.lastIndexOf("/");
int endIndex = contentUrl.lastIndexOf(".");
String idStr = StringUtils.subString(contentUrl, startIndex + 1, endIndex);
if (!TextUtils.isEmpty(idStr) && TextUtils.isDigitsOnly(idStr)) {
mm99.setId(Integer.parseInt(idStr));
} else {
Logger.t(TAG).d(idStr);
}
Element img = a.selectFirst("img");
String title = img.attr("alt");
mm99.setTitle(title);
String imgUrl = img.attr("src");
mm99.setImgUrl(imgUrl);
int imgWidth = Integer.parseInt(img.attr("width"));
mm99.setImgWidth(imgWidth);
mm99List.add(mm99);
}
if (page == 1) {
Element pageElement = doc.getElementsByClass("all").first();
if (pageElement != null) {
String pageStr = pageElement.text().replace("...", "").trim();
if (!TextUtils.isEmpty(pageStr) && TextUtils.isDigitsOnly(pageStr)) {
baseResult.setTotalPage(Integer.parseInt(pageStr));
} else {
Logger.t(TAG).d(pageStr);
}
}
}
baseResult.setData(mm99List);
return baseResult;
}
use of com.dante.data.model.Mm99 in project 91Pop by DanteAndroid.
the class Mm99Fragment 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 StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
recyclerView.setAdapter(mm99Adapter);
mm99Adapter.setWidth(QMUIDisplayHelper.getScreenWidth(context) / 2);
mm99Adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
loadData(false, false);
}
});
mm99Adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
Mm99 mm99 = (Mm99) adapter.getItem(position);
if (mm99 == null) {
return;
}
Intent intent = new Intent(context, PictureViewerActivity.class);
intent.putExtra(Keys.KEY_INTENT_99_MM_ITEM, mm99);
startActivityWithAnimotion(intent);
}
});
}
Aggregations