JZVideoPlayerStandard 网络加载视频

package com.example.administrator.month_week_six_weekexam3;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;

import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

public class ViodeActivity extends AppCompatActivity {
    private String path="http://m2.qiushibaike.com/article/list/video?page=2&count=30&readarticles=[115762484,115762135,115764350,115761463,115760316,115764445,115763537,115758684]&rqcnt=17&r=804df97a1459411164081";
    private List list =new ArrayList<>();
    private ListView show_lv;
    private ViodeAdapter viodeAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_viode);
       show_lv = (ListView) findViewById(R.id.show_lview);

        viodeAdapter = new ViodeAdapter(list,this);
        show_lv.setAdapter(viodeAdapter);

        loagWebData();

    }

    private void loagWebData() {

        new AsyncTask, Void, String>() {
            @Override
            protected String doInBackground(Void... voids) {

                return HttpUtils.getJson(path);
            }

            @Override
            protected void onPostExecute(String s) {
                super.onPostExecute(s);
                if (!s.isEmpty())
                {
                    Gson gson =new Gson();
                    ViodeBean viodeBean = gson.fromJson(s, ViodeBean.class);
                    list.addAll(viodeBean.getItems());
                    viodeAdapter.notifyDataSetChanged();
                }

            }
        }.execute();


    }
}
 
  
package com.example.administrator.month_week_six_weekexam3;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.jzvd.JZVideoPlayer;
import cn.jzvd.JZVideoPlayerStandard;

/**
 * Created by Administrator on 2018/1/6.
 */

public class ViodeAdapter extends BaseAdapter {
    private List list;
    private Context context;
    private LayoutInflater inflater;
    public ViodeAdapter(List list, Context context) {
        this.list = list;
        this.context = context;
        inflater =LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHorlder horlder =null;
        if (view==null)
        {
            horlder=new ViewHorlder();
            view=inflater.inflate(R.layout.item_viode,viewGroup,false);
            horlder.Jz = (JZVideoPlayerStandard) view.findViewById(R.id.show_Jz);

            view.setTag(horlder);
        }
        else {
            horlder= (ViewHorlder) view.getTag();
        }
        ViodeBean.ItemsBean bean = list.get(i);
        String low_url = bean.getLow_url();
        String content = bean.getContent();
        horlder.Jz.setUp(low_url, JZVideoPlayer.SCREEN_WINDOW_FULLSCREEN,content);
        String pic_url = bean.getPic_url();
        ImageView thumbImageView = horlder.Jz.thumbImageView;
        Picasso.with(context).load(pic_url).into(horlder.Jz.thumbImageView);



        return view;
    }
    class ViewHorlder{
        JZVideoPlayerStandard Jz;


    }

}

你可能感兴趣的:(JZVideoPlayerStandard 网络加载视频)