// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.3.1' classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir}
以上是Appbuiler
apply plugin: 'com.android.application' apply plugin: 'org.greenrobot.greendao' android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.baway.admin.yuekaolianxi" minSdkVersion 15 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } greendao { schemaVersion 1 daoPackage 'com.baway.admin.yuekaolianxi.gen' targetGenDir 'src/main/java' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' compile 'com.squareup.retrofit2:retrofit:2.0.2' compile 'com.squareup.okhttp3:okhttp:3.1.2' compile 'com.squareup.retrofit2:converter-gson:2.0.2' compile 'com.squareup.picasso:picasso:2.5.2' compile 'io.reactivex:rxjava:1.0.14' compile 'io.reactivex:rxandroid:1.0.1' compile 'fm.jiecao:jiecaovideoplayer:4.8.3' compile 'com.github.bumptech.glide:glide:3.7.0' testCompile 'junit:junit:4.12' compile 'org.greenrobot:greendao:3.2.0' compile 'com.android.support.test:runner:0.5' compile 'com.jakewharton:butterknife:5.1.1' }以上是自己项目的builer<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.baway.admin.yuekaolianxi"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <application android:name=".utils.App" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".HomeActivity"></activity> </application> </manifest>以上是自己的mainface文件package com.baway.admin.yuekaolianxi.utils; import android.app.Application; import com.baway.admin.yuekaolianxi.gen.DaoMaster; import com.baway.admin.yuekaolianxi.gen.DaoSession; import com.baway.admin.yuekaolianxi.gen.UserDao; public class App extends Application { public static UserDao userDao; @Override public void onCreate() { super.onCreate(); DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(this, "lenvess.db", null); DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb()); DaoSession daoSession = daoMaster.newSession(); userDao = daoSession.getUserDao(); } }以上是自己的App文件
package com.baway.admin.yuekaolianxi.utils; import android.util.Log; import com.baway.admin.yuekaolianxi.bean.User; import com.baway.admin.yuekaolianxi.gen.UserDao; import java.util.ArrayList; import java.util.List; import static com.baway.admin.yuekaolianxi.utils.App.userDao; public class DownlaodSqlTool { /** * 创建下载的具体信息 */ public void insertInfos(List<DownloadInfo> infos) { for (DownloadInfo info : infos) { User user = new User(null, info.getThreadId(), info.getStartPos(), info.getEndPos(), info.getCompeleteSize(), info.getUrl()); userDao.insert(user); } } /** * 得到下载具体信息 */ public List<DownloadInfo> getInfos(String urlstr) { List<DownloadInfo> list = new ArrayList<DownloadInfo>(); List<User> list1 = userDao.queryBuilder().where(UserDao.Properties.Url.eq(urlstr)).build().list(); for (User user : list1) { DownloadInfo infoss = new DownloadInfo( user.getThread_id(), user.getStart_pos(), user.getEnd_pos(), user.getCompelete_size(), user.getUrl()); Log.d("main-----", infoss.toString()); list.add(infoss); } return list; } /** * 更新数据库中的下载信息 */ public void updataInfos(int threadId, int compeleteSize, String urlstr) { User user = userDao.queryBuilder() .where(UserDao.Properties.Thread_id.eq(threadId), UserDao.Properties.Url.eq(urlstr)).build().unique(); user.setCompelete_size(compeleteSize); userDao.update(user); } /** * 下载完成后删除数据库中的数据 */ public void delete(String url) { userDao.deleteAll(); } }DownlaodSqlTool以上
package com.baway.admin.yuekaolianxi.utils; import android.content.Context; import android.os.Handler; import android.os.Message; import android.util.Log; import java.io.File; import java.io.InputStream; import java.io.RandomAccessFile; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; public class DownloadHttpTool { /** * 利用Http协议进行多线程下载具体实践类 */ private static final String TAG = DownloadHttpTool.class.getSimpleName(); private int threadCount;//线程数量 private String urlstr;//URL地址 private Context mContext; private Handler mHandler; private List<DownloadInfo> downloadInfos;//保存下载信息的类 private String localPath;//目录 private String fileName;//文件名 private int fileSize; private DownlaodSqlTool sqlTool;//文件信息保存的数据库操作类 private enum Download_State { Downloading, Pause, Ready;//利用枚举表示下载的三种状态 } private Download_State state = Download_State.Ready;//当前下载状态 private int globalCompelete = 0;//所有线程下载的总数 public DownloadHttpTool(int threadCount, String urlString, String localPath, String fileName, Context context, Handler handler) { super(); this.threadCount = threadCount; this.urlstr = urlString; this.localPath = localPath; this.mContext = context; this.mHandler = handler; this.fileName = fileName; sqlTool = new DownlaodSqlTool(); } //在开始下载之前需要调用ready方法进行配置 public void ready() { Log.w(TAG, "ready"); globalCompelete = 0; downloadInfos = sqlTool.getInfos(urlstr); if (downloadInfos.size() == 0) { initFirst(); } else { File file = new File(localPath + "/" + fileName); if (!file.exists()) { sqlTool.delete(urlstr); initFirst(); } else { fileSize = downloadInfos.get(downloadInfos.size() - 1) .getEndPos(); for (DownloadInfo info : downloadInfos) { globalCompelete += info.getCompeleteSize(); } Log.w(TAG, "globalCompelete:::" + globalCompelete); } } } public void start() { Log.w(TAG, "start"); if (downloadInfos != null) { if (state == Download_State.Downloading) { return; } state = Download_State.Downloading; for (DownloadInfo info : downloadInfos) { Log.v(TAG, "startThread"); new DownloadThread(info.getThreadId(), info.getStartPos(), info.getEndPos(), info.getCompeleteSize(), info.getUrl()).start(); } } } public void pause() { state = Download_State.Pause; } public void delete() { compelete(); File file = new File(localPath + "/" + fileName); file.delete(); } public void compelete() { sqlTool.delete(urlstr); } public int getFileSize() { return fileSize; } public int getCompeleteSize() { return globalCompelete; } //第一次下载初始化 private void initFirst() { Log.w(TAG, "initFirst"); try { URL url = new URL(urlstr); HttpURLConnection connection = (HttpURLConnection) url .openConnection(); connection.setConnectTimeout(5000); connection.setRequestMethod("GET"); fileSize = connection.getContentLength(); Log.w(TAG, "fileSize::" + fileSize); File fileParent = new File(localPath); if (!fileParent.exists()) { fileParent.mkdir(); } File file = new File(fileParent, fileName); if (!file.exists()) { file.createNewFile(); } // 本地访问文件 RandomAccessFile accessFile = new RandomAccessFile(file, "rwd"); accessFile.setLength(fileSize); accessFile.close(); connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } int range = fileSize / threadCount; downloadInfos = new ArrayList<DownloadInfo>(); for (int i = 0; i < threadCount - 1; i++) { DownloadInfo info = new DownloadInfo(i, i * range, (i + 1) * range - 1, 0, urlstr); downloadInfos.add(info); } DownloadInfo info = new DownloadInfo(threadCount - 1, (threadCount - 1) * range, fileSize - 1, 0, urlstr); downloadInfos.add(info); sqlTool.insertInfos(downloadInfos); } //自定义下载线程 private class DownloadThread extends Thread { private int threadId; private int startPos; private int endPos; private int compeleteSize; private String urlstr; private int totalThreadSize; public DownloadThread(int threadId, int startPos, int endPos, int compeleteSize, String urlstr) { this.threadId = threadId; this.startPos = startPos; this.endPos = endPos; totalThreadSize = endPos - startPos + 1; this.urlstr = urlstr; this.compeleteSize = compeleteSize; } @Override public void run() { HttpURLConnection connection = null; RandomAccessFile randomAccessFile = null; InputStream is = null; try { randomAccessFile = new RandomAccessFile(localPath + "/" + fileName, "rwd"); randomAccessFile.seek(startPos + compeleteSize); URL url = new URL(urlstr); connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(5000); connection.setRequestMethod("GET"); connection.setRequestProperty("Range", "bytes=" + (startPos + compeleteSize) + "-" + endPos); is = connection.getInputStream(); byte[] buffer = new byte[1024]; int length = -1; while ((length = is.read(buffer)) != -1) { randomAccessFile.write(buffer, 0, length); compeleteSize += length; Message message = Message.obtain(); message.what = threadId; message.obj = urlstr; message.arg1 = length; mHandler.sendMessage(message); sqlTool.updataInfos(threadId, compeleteSize, urlstr); Log.w(TAG, "Threadid::" + threadId + " compelete::" + compeleteSize + " total::" + totalThreadSize); if (compeleteSize >= totalThreadSize) { break; } if (state != Download_State.Downloading) { break; } } } catch (Exception e) { e.printStackTrace(); } finally { try { if (is != null) { is.close(); } randomAccessFile.close(); connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } } } } }以上45
package com.baway.admin.yuekaolianxi.utils; public class DownloadInfo { /** * 保存每个下载线程下载信息类 * */ private int threadId;// 下载器id private int startPos;// 开始点 private int endPos;// 结束点 private int compeleteSize;// 完成度 private String url;// 下载文件的URL地址 public DownloadInfo(int threadId, int startPos, int endPos, int compeleteSize, String url) { this.threadId = threadId; this.startPos = startPos; this.endPos = endPos; this.compeleteSize = compeleteSize; this.url = url; } public DownloadInfo() { } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public int getThreadId() { return threadId; } public void setThreadId(int threadId) { this.threadId = threadId; } public int getStartPos() { return startPos; } public void setStartPos(int startPos) { this.startPos = startPos; } public int getEndPos() { return endPos; } public void setEndPos(int endPos) { this.endPos = endPos; } public int getCompeleteSize() { return compeleteSize; } public void setCompeleteSize(int compeleteSize) { this.compeleteSize = compeleteSize; } @Override public String toString() { return "DownloadInfo [threadId=" + threadId + ", startPos=" + startPos + ", endPos=" + endPos + ", compeleteSize=" + compeleteSize + "]"; } }以上
package com.baway.admin.yuekaolianxi.utils; import android.annotation.SuppressLint; import android.content.Context; import android.os.AsyncTask; import android.os.Handler; import android.os.Message; import android.util.Log; /** public class DownloadUtil { private DownloadHttpTool mDownloadHttpTool; private OnDownloadListener onDownloadListener; private int fileSize; private int downloadedSize = 0; @SuppressLint("HandlerLeak") private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); int length = msg.arg1; synchronized (this) {//加锁保证已下载的正确性 downloadedSize += length; } if (onDownloadListener != null) { onDownloadListener.downloadProgress(downloadedSize); } if (downloadedSize >= fileSize) { mDownloadHttpTool.compelete(); if (onDownloadListener != null) { onDownloadListener.downloadEnd(); } } } }; public DownloadUtil(int threadCount, String filePath, String filename, String urlString, Context context) { mDownloadHttpTool = new DownloadHttpTool(threadCount, urlString,filePath, filename, context, mHandler); } //下载之前首先异步线程调用ready方法获得文件大小信息,之后调用开始方法 public void start() { new AsyncTask<Void,Void,Void>() { @Override protected Void doInBackground(Void... arg0) { // TODO Auto-generated method stub mDownloadHttpTool.ready(); return null; } @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); fileSize = mDownloadHttpTool.getFileSize(); downloadedSize = mDownloadHttpTool.getCompeleteSize(); Log.w("Tag", "downloadedSize::" + downloadedSize); if (onDownloadListener != null) { onDownloadListener.downloadStart(fileSize); } mDownloadHttpTool.start(); } }.execute(); } public void pause() { mDownloadHttpTool.pause(); } public void delete(){ mDownloadHttpTool.delete(); } public void reset(){ mDownloadHttpTool.delete(); start(); } public void setOnDownloadListener(OnDownloadListener onDownloadListener) { this.onDownloadListener = onDownloadListener; } //下载回调接口 public interface OnDownloadListener { public void downloadStart(int fileSize); public void downloadProgress(int downloadedSize);//记录当前所有线程下总和 public void downloadEnd(); } }以上便是
package com.baway.admin.yuekaolianxi.utils; import com.baway.admin.yuekaolianxi.bean.MyBean; import retrofit2.Call; import retrofit2.http.GET; public interface MyIn { @GET("front/columns/getVideoList.do?catalogId=402834815584e463015584e539330016") Call<MyBean> getCall(); }以上是ee
package com.baway.admin.yuekaolianxi.view; import com.baway.admin.yuekaolianxi.bean.MyBean; /** * 类的用途: * 实现思路: * 时间:2017/11/22 * 作者:董金金 */ public interface MyView { void getIn(MyBean.RetBean ret); }以上ssspackage com.baway.admin.yuekaolianxi.model; import com.baway.admin.yuekaolianxi.bean.MyBean; import com.baway.admin.yuekaolianxi.utils.MyIn; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class MyModel { private GetIn getIn; public void setGetIn(GetIn getIn) { this.getIn = getIn; } public void getData(){ Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://api.svipmovie.com/") //设置网络请求的Url地址 .addConverterFactory(GsonConverterFactory.create()) //设置数据解析器 .build(); // 步骤5:创建 网络请求接口 的实例 MyIn request = retrofit.create(MyIn.class); //对 发送请求 进行封装 Call<MyBean> call = request.getCall(); call.enqueue(new Callback<MyBean>() { @Override public void onResponse(Call<MyBean> call, Response<MyBean> response) { if(response.isSuccessful()){ MyBean.RetBean ret = response.body().getRet(); getIn.getIn(ret); } } @Override public void onFailure(Call<MyBean> call, Throwable t) { } }); } public interface GetIn{ void getIn(MyBean.RetBean ret); } }以上便是sisisispackage com.baway.admin.yuekaolianxi.presenter; import android.content.Context; import com.baway.admin.yuekaolianxi.bean.MyBean; import com.baway.admin.yuekaolianxi.model.MyModel; import com.baway.admin.yuekaolianxi.view.MyView; public class MyPresenter implements MyModel.GetIn { private MyView myView; private Context context; private final MyModel myModel; public MyPresenter(MyView myView, Context context) { this.myView = myView; this.context = context; myModel = new MyModel(); myModel.setGetIn(this); } @Override public void getIn(MyBean.RetBean ret) { myView.getIn(ret); } public void QQ(){ myModel.getData(); } }以上package com.baway.admin.yuekaolianxi.bean; import org.greenrobot.greendao.annotation.Entity; import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Generated; @Entity public class User { @Id private Long id; private Integer thread_id; private Integer start_pos; private Integer end_pos; private Integer compelete_size; private String url; @Generated(hash = 2041931179) public User(Long id, Integer thread_id, Integer start_pos, Integer end_pos, Integer compelete_size, String url) { this.id = id; this.thread_id = thread_id; this.start_pos = start_pos; this.end_pos = end_pos; this.compelete_size = compelete_size; this.url = url; } @Generated(hash = 586692638) public User() { } public Long getId() { return this.id; } public void setId(Long id) { this.id = id; } public Integer getThread_id() { return this.thread_id; } public void setThread_id(Integer thread_id) { this.thread_id = thread_id; } public Integer getStart_pos() { return this.start_pos; } public void setStart_pos(Integer start_pos) { this.start_pos = start_pos; } public Integer getEnd_pos() { return this.end_pos; } public void setEnd_pos(Integer end_pos) { this.end_pos = end_pos; } public Integer getCompelete_size() { return this.compelete_size; } public void setCompelete_size(Integer compelete_size) { this.compelete_size = compelete_size; } public String getUrl() { return this.url; } public void setUrl(String url) { this.url = url; } }以上是userrpackage com.baway.admin.yuekaolianxi.adapter; import android.content.Context; import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.baway.admin.yuekaolianxi.HomeActivity; import com.baway.admin.yuekaolianxi.R; import com.baway.admin.yuekaolianxi.bean.MyBean; import com.bumptech.glide.Glide; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> { private Context context; private MyBean.RetBean ret; private ImageView img; private TextView tv; private JCVideoPlayerStandard player; public MyAdapter(Context context, MyBean.RetBean ret) { this.context = context; this.ret = ret; } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view=View.inflate(context, R.layout.item,null); MyViewHolder holder=new MyViewHolder(view); return holder; } @Override public void onBindViewHolder(MyViewHolder holder, int position) { //Picasso.with(context).load(ret.getList().get(position).getPic()).into(img); Glide.with(context).load(ret.getList().get(position).getPic()).into(player.thumbImageView); //tv.setText(ret.getList().get(position).getTitle()); tv.setText(ret.getList().get(position).getTitle()); System.out.println("=======tv======="+ret.getList().get(position).getTitle()); System.out.println("=========ret========="+ret.getList().get(position).getLoadURL()); } @Override public int getItemCount() { if(ret.getList()!=null){ return ret.getList().size(); } return 0; } public class MyViewHolder extends RecyclerView.ViewHolder{ public MyViewHolder(View itemView) { super(itemView); //img = itemView.findViewById(R.id.img); tv = itemView.findViewById(R.id.tv); player = (JCVideoPlayerStandard)itemView.findViewById(R.id.player_list_video); //给Item设置点击事件 itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Toast.makeText(context,"点击了吗?",Toast.LENGTH_SHORT).show(); Intent intent=new Intent(context,HomeActivity.class); System.out.println("=====到底有没有走这儿?====="); context.startActivity(intent); } }); } } }以上package com.baway.admin.yuekaolianxi; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import com.baway.admin.yuekaolianxi.adapter.MyAdapter; import com.baway.admin.yuekaolianxi.bean.MyBean; import com.baway.admin.yuekaolianxi.presenter.MyPresenter; import com.baway.admin.yuekaolianxi.view.MyView; import rx.Observable; import rx.Observer; import rx.Subscriber; public class MainActivity extends AppCompatActivity implements MyView { private RecyclerView rv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); MyPresenter myPresenter=new MyPresenter(this,this); myPresenter.QQ(); } private void initView() { rv = (RecyclerView) findViewById(R.id.rv); } @Override public void getIn(final MyBean.RetBean ret) { if(this!=null){ runOnUiThread(new Runnable() { @Override public void run() { GridLayoutManager manager=new GridLayoutManager(MainActivity.this,1); rv.setLayoutManager(manager); MyAdapter myAdapter=new MyAdapter(MainActivity.this,ret); rv.setAdapter(myAdapter); } }); Observer<String> observer = new Observer<String>() { @Override public void onNext(String s) { Log.i("========最后输出的=========",s); } @Override public void onCompleted() { Log.d("Tag", "Completed!"); } @Override public void onError(Throwable e) { Log.d("Tag", "Error!"); } }; Observable observable = Observable.create(new Observable.OnSubscribe<String>() { @Override public void call(Subscriber<? super String> subscriber) { subscriber.onNext(ret.getList()+""); subscriber.onCompleted(); } }); observable.subscribe(observer); } } }package com.baway.admin.yuekaolianxi; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; import com.baway.admin.yuekaolianxi.utils.DownloadUtil; import com.bumptech.glide.Glide; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; public class HomeActivity extends AppCompatActivity { private static final String TAG = MainActivity.class.getSimpleName(); private ProgressBar mProgressBar; private Button start; private Button pause; private TextView total; private int max; private DownloadUtil mDownloadUtil; private JCVideoPlayerStandard player2; private String localPath; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); total = (TextView) findViewById(R.id.tvtv); start = (Button) findViewById(R.id.start); pause = (Button) findViewById(R.id.delete); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); player2 = (JCVideoPlayerStandard) findViewById(R.id.player_list_video2); String urlString = "http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4"; localPath = getCacheDir() + "/local2"; mDownloadUtil = new DownloadUtil(2, localPath, "adc.mp4", urlString,this); mDownloadUtil.setOnDownloadListener(new DownloadUtil.OnDownloadListener() { @Override public void downloadStart(int fileSize) { // TODO Auto-generated method stub Log.w(TAG, "fileSize::" + fileSize); max = fileSize; mProgressBar.setMax(fileSize); } @Override public void downloadProgress(int downloadedSize) { // TODO Auto-generated method stub Log.w(TAG, "Compelete::" + downloadedSize); mProgressBar.setProgress(downloadedSize); total.setText((int) downloadedSize * 100 / max + "%"); System.out.println("========total.getText()========"+total.getText()); //System.out.println("==========localPath==========="+ localPath); } @Override public void downloadEnd() { // TODO Auto-generated method stub System.out.println("=====12345走这儿了吗?====="); boolean setUp = player2.setUp(localPath+"/adc.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, ""); if (setUp) { Glide.with(HomeActivity.this).load("http://a4.att.hudong.com/05/71/01300000057455120185716259013.jpg").into(player2.thumbImageView); } Log.w(TAG, "ENd"); } }); start.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDownloadUtil.start(); } }); pause.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDownloadUtil.pause(); } }); } }<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.baway.admin.yuekaolianxi.HomeActivity"> <TextView android:id="@+id/tvtv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginLeft="23dp" android:layout_marginStart="23dp" android:layout_marginTop="18dp" android:text="TextView" /> <ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent" android:layout_height="7.5dp" android:layout_below="@+id/tvtv" android:layout_marginRight="8dp" android:max="100" android:progress="100" android:visibility="visible" /> <Button android:id="@+id/start" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_toEndOf="@+id/tvtv" android:layout_toRightOf="@+id/tvtv" android:text="下载" /> <Button android:id="@+id/delete" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginLeft="48dp" android:layout_marginStart="48dp" android:layout_toEndOf="@+id/start" android:layout_toRightOf="@+id/start" android:text="暂停" /> <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard android:id="@+id/player_list_video2" android:layout_width="match_parent" android:layout_below="@+id/progressBar" android:layout_height="220dp" /> </RelativeLayout>========<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.baway.admin.yuekaolianxi.MainActivity"> <android.support.v7.widget.RecyclerView android:id="@+id/rv" android:layout_width="match_parent" android:layout_height="match_parent"></android.support.v7.widget.RecyclerView> </LinearLayout>频【pop【频【<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard android:id="@+id/player_list_video" android:layout_width="150dp" android:layout_height="150dp" android:layout_gravity="center"/> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="20sp" android:text="标题"/> </LinearLayout>