Search in sources :

Example 1 with PigAv

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;
}
Also used : BaseResult(com.dante.data.model.BaseResult) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PigAv(com.dante.data.model.PigAv) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 2 with PigAv

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);
        }
    });
}
Also used : PigAvAdapter(com.dante.adapter.PigAvAdapter) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) PigAv(com.dante.data.model.PigAv) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ExoVideoView(com.flymegoc.exolibrary.widget.ExoVideoView)

Example 3 with 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;
}
Also used : BaseResult(com.dante.data.model.BaseResult) PigAvVideo(com.dante.data.model.PigAvVideo) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) PigAv(com.dante.data.model.PigAv) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 4 with PigAv

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;
}
Also used : BaseResult(com.dante.data.model.BaseResult) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PigAv(com.dante.data.model.PigAv) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 5 with PigAv

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);
    }
}
Also used : ExoVideoControlsMobile(com.flymegoc.exolibrary.widget.ExoVideoControlsMobile) PigAv(com.dante.data.model.PigAv) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ExoVideoView(com.flymegoc.exolibrary.widget.ExoVideoView)

Aggregations

PigAv (com.dante.data.model.PigAv)6 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 BindView (butterknife.BindView)3 BaseResult (com.dante.data.model.BaseResult)3 ArrayList (java.util.ArrayList)3 Document (org.jsoup.nodes.Document)3 Element (org.jsoup.nodes.Element)3 Elements (org.jsoup.select.Elements)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)2 ExoVideoView (com.flymegoc.exolibrary.widget.ExoVideoView)2 List (java.util.List)2 Intent (android.content.Intent)1 PigAvAdapter (com.dante.adapter.PigAvAdapter)1 PigAvVideo (com.dante.data.model.PigAvVideo)1 PlayPigAvActivity (com.dante.ui.pigav.playpigav.PlayPigAvActivity)1 ExoVideoControlsMobile (com.flymegoc.exolibrary.widget.ExoVideoControlsMobile)1 Gson (com.google.gson.Gson)1