dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.facebook.fresco:fresco:1.5.0' compile 'com.facebook.fresco:animated-gif:1.5.0' compile 'com.android.support:design:26.0.0-alpha1' compile 'com.hjm:BottomTabBar:1.1.1' compile 'com.squareup.okio:okio:1.5.0' compile 'com.squareup.okhttp3:okhttp:3.4.2' compile 'com.xhb:xbanner:1.0.0' compile 'org.greenrobot:eventbus:3.0.0' compile 'com.youth.banner:banner:1.4.9' compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' compile 'com.github.bumptech.glide:glide:4.0.0' compile 'com.google.code.gson:gson:2.8.2' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-scalars:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.0.2' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxjava:2.1.7' compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' compile 'com.github.bumptech.glide:glide:4.0.0' compile 'com.jakewharton:butterknife:8.8.1' compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' compile 'com.jcodecraeer:xrecyclerview:1.3.2' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' testCompile 'junit:junit:4.12' compile 'fm.jiecao:jiecaovideoplayer:4.8.3'annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.hp.zhoukao2.MainActivity"> <com.hjm.bottomtabbar.BottomTabBar android:id="@+id/bottom_tab_bar" android:layout_width="match_parent" android:layout_height="match_parent" app:tab_unselected_color="#000000" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> </LinearLayout>/主界面fragment的控件<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <com.stx.xhb.xbanner.XBanner android:id="@+id/xb" android:layout_width="match_parent" android:layout_height="150dp"></com.stx.xhb.xbanner.XBanner> <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><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent"> <TextView android:id="@+id/tt" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="标题" android:textSize="30sp" /> <fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard android:id="@+id/player_list_video" android:layout_width="match_parent" android:layout_height="150dp" /> <!--<ImageView--> <!--android:id="@+id/img"--> <!--android:layout_width="150dp"--> <!--android:layout_height="150dp" />--> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/ct" android:gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="内容"/> </LinearLayout> </LinearLayout>item的布局package com.example.hp.zhoukao2.view; import com.example.hp.zhoukao2.bean.MyBean; import java.util.List; /** * Created by HP on 2017/12/13. */ public interface MyView { void getIn(List<MyBean.DataBean> data); }以上是view层package com.example.hp.zhoukao2; import com.example.hp.zhoukao2.bean.MyBean; import retrofit2.Call; import retrofit2.http.GET; /** * Created by HP on 2017/12/13. */ public interface MyInterface { @GET("iYXEPGn4e9c6dafce6e5cdd23287d2bb136ee7e9194d3e9?uri=vedio") Call<MyBean> getCall(); }以上是自己接口的文件
OkHttp3Utils
是自己写的
package com.example.hp.zhoukao2.model; import com.example.hp.zhoukao2.MyInterface; import com.example.hp.zhoukao2.bean.MyBean; import java.util.List; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; /** * Created by HP on 2017/12/13. */ public class MyModel { private GetIn getIn; private String image_url; public void setGetIn(GetIn getIn) { this.getIn = getIn; } public void getData(){ Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://result.eolinker.com/") //设置网络请求的Url地址 .addConverterFactory(GsonConverterFactory.create()) //设置数据解析器 .build(); MyInterface request = retrofit.create(MyInterface.class); Call<MyBean> call = request.getCall(); call.enqueue(new Callback<MyBean>() { @Override public void onResponse(Call<MyBean> call, Response<MyBean> response) { // if(response.isSuccessful()){ List<MyBean.DataBean> data = response.body().getData(); System.out.println("====data=="+data.size()); getIn.getIn(data); // } } @Override public void onFailure(Call<MyBean> call, Throwable t) { System.out.println("======连接失败======"); } }); } public interface GetIn{ void getIn(List<MyBean.DataBean> data); } }以上是model层package com.example.hp.zhoukao2.presenter; import android.content.Context; import com.example.hp.zhoukao2.bean.MyBean; import com.example.hp.zhoukao2.model.MyModel; import com.example.hp.zhoukao2.view.MyView; import java.util.List; /** * Created by HP on 2017/12/13. */ public class MyPresenter implements MyModel.GetIn { private Context context; private MyView myView; private final MyModel myModel; public MyPresenter(Context context, MyView myView) { this.context = context; this.myView = myView; myModel = new MyModel(); myModel.setGetIn(this); } public void QQ(){ myModel.getData(); } @Override public void getIn(List<MyBean.DataBean> data) { myView.getIn(data); } }以上是自己的p层package com.example.hp.zhoukao2; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.hjm.bottomtabbar.BottomTabBar; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportActionBar().hide(); BottomTabBar mBottomTabBar = (BottomTabBar) findViewById(R.id.bottom_tab_bar); mBottomTabBar.init(getSupportFragmentManager()) .addTabItem("yi",R.mipmap.faxian2,R.mipmap.faxian1, Fragment1.class) .addTabItem("er",R.mipmap.faxian2,R.mipmap.faxian1, Fragment2.class) .addTabItem("san",R.mipmap.faxian2,R.mipmap.faxian1, Fragment3.class); } }这个边是main的布局package com.example.hp.zhoukao2; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.example.hp.zhoukao2.bean.MyBean; import com.example.hp.zhoukao2.presenter.MyPresenter; import com.example.hp.zhoukao2.view.MyView; import com.stx.xhb.xbanner.XBanner; import java.util.List; /** * Created by HP on 2017/12/13. */ public class Fragment3 extends Fragment implements MyView{ private View view; private XBanner xb; private RecyclerView rv; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view=inflater.inflate(R.layout.fragment3,container,false); //获取控件信息 initView(view); //实例化p层 MyPresenter myPresenter=new MyPresenter(getActivity(),this); myPresenter.QQ(); return view; } @Override public void onResume() { super.onResume(); } private void initView(View view) { xb = (XBanner)view. findViewById(R.id.xb); rv = (RecyclerView) view.findViewById(R.id.rv); } @Override public void getIn(final List<MyBean.DataBean> data) { GridLayoutManager manager=new GridLayoutManager(getActivity(),1); rv.setLayoutManager(manager); MyAdapter myadapter=new MyAdapter(getActivity(),data); rv.setAdapter(myadapter); xb.setData(data); xb.setmAdapter(new XBanner.XBannerAdapter(){ @Override public void loadBanner(XBanner banner, View view, int position) { Glide.with(getActivity()).load(data.get(position).getImage_url()).into((ImageView) view); } }); } }以上是framgne的代码package com.example.hp.zhoukao2; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.bumptech.glide.Glide; import com.example.hp.zhoukao2.bean.MyBean; import java.util.List; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard; /** * Created by HP on 2017/12/13. */ public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> { private Context context; private List<MyBean.DataBean> data; private TextView tt; private TextView ct; //private ImageView img; private JCVideoPlayerStandard player; public MyAdapter(Context context, List<MyBean.DataBean> data) { this.context = context; this.data = data; } @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) { boolean setUp = player.setUp(data.get(position).getVedio_url(), JCVideoPlayer.SCREEN_LAYOUT_NORMAL, ""); if (setUp) { Glide.with(context).load(data.get(position).getVedio_url()).into(player.thumbImageView); } //Glide.with(context).load(data.get(position).getImage_url()).into(img); //System.out.println("=========img========="+img); tt.setText(data.get(position).getTitle()); System.out.println("=======title=======" + data.get(position).getTitle()); ct.setText(data.get(position).getContent()); System.out.println("========content=========" + data.get(position).getContent()); System.out.println("======data1111========" + data); //直接进入全屏 //player.startFullscreen(this, JCVideoPlayerStandard.class,, ""); //模拟用户点击开始按钮,NORMAL状态下点击开始播放视频,播放中点击暂停视频 //player.startButton.performClick(); } @Override public int getItemCount() { if (data != null) { return data.size(); } return data.size(); } public class MyViewHolder extends RecyclerView.ViewHolder { public MyViewHolder(View itemView) { super(itemView); //img = itemView.findViewById(R.id.img); tt = itemView.findViewById(R.id.tt); ct = itemView.findViewById(R.id.ct); player = itemView.findViewById(R.id.player_list_video); } } }以上是适配器的文件
简单的节操视屏播放
最新推荐文章于 2021-02-22 05:22:17 发布