use of com.dante.data.model.PigAv in project 91Pop by DanteAndroid.
the class ParsePigAv method moreVideoList.
public static BaseResult<List<PigAv>> moreVideoList(String html) {
BaseResult<List<PigAv>> baseResult = new BaseResult<>();
baseResult.setTotalPage(1);
Document doc = Jsoup.parse(html);
Elements items = doc.getElementsByClass("td-block-span4");
List<PigAv> pigAvList = new ArrayList<>();
for (Element element : items) {
PigAv pigAv = new PigAv();
Element a = element.selectFirst("a");
String title = a.attr("title");
pigAv.setTitle(title);
String contentUrl = a.attr("href");
pigAv.setContentUrl(contentUrl);
Element img = element.selectFirst("img");
String imgUrl = img.attr("src");
int beginIndex = imgUrl.lastIndexOf("/");
int endIndex = imgUrl.lastIndexOf("-");
String bigImg = StringUtils.subString(imgUrl, 0, endIndex);
if (TextUtils.isEmpty(bigImg)) {
pigAv.setImgUrl(imgUrl);
} else {
pigAv.setImgUrl(bigImg + ".jpg");
}
String pId = StringUtils.subString(imgUrl, beginIndex + 1, endIndex);
Logger.t(TAG).d(pId);
pigAv.setpId(pId);
int imgWidth = Integer.parseInt(img.attr("width"));
pigAv.setImgWidth(imgWidth);
int imgHeight = Integer.parseInt(img.attr("height"));
pigAv.setImgHeight(imgHeight);
pigAvList.add(pigAv);
}
baseResult.setData(pigAvList);
return baseResult;
}
use of com.dante.data.model.PigAv in project 91Pop by DanteAndroid.
the class PlayPigAvActivity method listVideo.
@Override
public void listVideo(List<PigAv> pigAvList) {
PigAvAdapter pigAvAdapter = new PigAvAdapter(R.layout.item_pig_av);
pigAvAdapter.setWidth(QMUIDisplayHelper.getScreenWidth(context));
pigAvAdapter.setNewData(pigAvList);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(pigAvAdapter);
pigAvAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
PigAv pigAv = (PigAv) adapter.getItem(position);
if (pigAv == null) {
return;
}
videoPlayer.pause();
videoPlayer.reset();
parseVideoUrl(pigAv);
}
});
}
use of com.dante.data.model.PigAv in project 91Pop by DanteAndroid.
the class ParsePigAv method parserVideoUrl.
/**
* @param html 原网页
* @return json===
*/
public static BaseResult<PigAvVideo> parserVideoUrl(String html) {
BaseResult<PigAvVideo> baseResult = new BaseResult<>();
Document document = Jsoup.parse(html);
Element videoWrapper = document.getElementsByClass("td-post-content td-pb-padding-side").first();
String videoHtml = videoWrapper.html();
Logger.t(TAG).d(videoHtml);
int index = videoHtml.indexOf("setup") + 6;
int endIndexV = videoHtml.indexOf(");");
String videoUrl = videoHtml.substring(index, endIndexV);
Logger.t(TAG).d(videoUrl);
PigAvVideo pigAvVideo = new Gson().fromJson(videoUrl, PigAvVideo.class);
Elements items = document.getElementsByClass("td-block-span12");
List<PigAv> pigAvList = new ArrayList<>();
for (Element element : items) {
PigAv pigAv = new PigAv();
Element a = element.selectFirst("a");
String title = a.attr("title");
pigAv.setTitle(title);
String contentUrl = a.attr("href");
pigAv.setContentUrl(contentUrl);
Element img = element.selectFirst("img");
String imgUrl = img.attr("src");
int beginIndex = imgUrl.lastIndexOf("/");
int endIndex = imgUrl.indexOf("-");
String bigImg = StringUtils.subString(imgUrl, 0, endIndex);
if (TextUtils.isEmpty(bigImg)) {
pigAv.setImgUrl(imgUrl);
} else {
pigAv.setImgUrl(bigImg + ".jpg");
}
String pId = StringUtils.subString(imgUrl, beginIndex + 1, endIndex);
Logger.t(TAG).d(pId);
pigAv.setpId(pId);
int imgWidth = Integer.parseInt(img.attr("width"));
pigAv.setImgWidth(imgWidth);
int imgHeight = Integer.parseInt(img.attr("height"));
pigAv.setImgHeight(imgHeight);
pigAvList.add(pigAv);
}
pigAvVideo.setPigAvList(pigAvList);
baseResult.setData(pigAvVideo);
return baseResult;
}
use of com.dante.data.model.PigAv in project 91Pop by DanteAndroid.
the class ParsePigAv method videoList.
public static BaseResult<List<PigAv>> videoList(String html) {
BaseResult<List<PigAv>> baseResult = new BaseResult<>();
baseResult.setTotalPage(1);
Document doc = Jsoup.parse(html);
Elements items = doc.getElementsByClass("td-block-span4");
List<PigAv> pigAvList = new ArrayList<>();
for (Element element : items) {
PigAv pigAv = new PigAv();
Element a = element.selectFirst("a");
String title = a.attr("title");
pigAv.setTitle(title);
String contentUrl = a.attr("href");
pigAv.setContentUrl(contentUrl);
Element img = element.selectFirst("img");
String imgUrl = img.attr("src");
int beginIndex = imgUrl.lastIndexOf("/");
int endIndex = imgUrl.lastIndexOf("-");
String bigImg = StringUtils.subString(imgUrl, 0, endIndex);
if (TextUtils.isEmpty(bigImg)) {
pigAv.setImgUrl(imgUrl);
} else {
pigAv.setImgUrl(bigImg + ".jpg");
}
String pId = StringUtils.subString(imgUrl, beginIndex + 1, endIndex);
Logger.t(TAG).d(pId);
pigAv.setpId(pId);
int imgWidth = Integer.parseInt(img.attr("width"));
pigAv.setImgWidth(imgWidth);
int imgHeight = Integer.parseInt(img.attr("height"));
pigAv.setImgHeight(imgHeight);
pigAvList.add(pigAv);
}
baseResult.setData(pigAvList);
return baseResult;
}
use of com.dante.data.model.PigAv in project 91Pop by DanteAndroid.
the class PlayPigAvActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_pig_av);
ButterKnife.bind(this);
setVideoViewHeight(playContainer);
initDialog();
videoControlsMobile = (ExoVideoControlsMobile) videoPlayer.getVideoControls();
videoPlayer.setOnPreparedListener(this);
videoControlsMobile.setOnBackButtonClickListener(new ExoVideoControlsMobile.OnBackButtonClickListener() {
@Override
public void onBackClick(View view) {
onBackPressed();
}
});
PigAv pigAv = (PigAv) getIntent().getSerializableExtra(Keys.KEY_INTENT_PIG_AV_ITEM);
if (pigAv != null) {
parseVideoUrl(pigAv);
} else {
showMessage("参数错误,无法播放", TastyToast.WARNING);
}
}
Aggregations