Android之电商Demo模块

 本次实现的就是 登录注册,商品列表 ,商品详情 购物车,以及视频ijkplayer的简单实用:


  先来看登录注册 : 这里用的网络请求是:Retorfit+Rxjava Mvp的模式

  bean类就不用说了 大多都是自动生成的

  因为整个模块都是mvp架构和Retorfit+Rxjava组成的所以简单做了个基类,减少代码的复用

Retrofit:的工具类
主要实现:

获取拼接接口的共同部分

实现添加拦截器

实现动态代理模式

默认Gson解析

设置支持Rxjava2

public class RetrofitManager {
    public static final String BASE_URL = "http://120.27.23.105/";
    private final Retrofit mRetrofit;

    public static class SINGLE_HOLDER {
        public static final RetrofitManager INSTANCE = new RetrofitManager(BASE_URL);
    }

    public static RetrofitManager getInstance() {
        return SINGLE_HOLDER.INSTANCE;
    }


    private RetrofitManager(String baseUrl) {
        mRetrofit = buildRetrofit();
    }

    private OkHttpClient buildOkHttpClient() {
       return new OkHttpClient.Builder()
                .connectTimeout(10000, TimeUnit.MILLISECONDS)
                .build();
    }

    private Retrofit buildRetrofit() {
        return new Retrofit.Builder()
                .client(buildOkHttpClient())
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
    }

    public <T> T create(Class<T> clazz) {
        return mRetrofit.create(clazz);
    }
}
下面是 M V层的父类接口
这里就定义一个空接口即可,为了配合P层的基类

public interface Iview {
 }
public interface Imodel {
}
重点P层
抽取所操作的共同点
public abstract  class Ipresenter <T extends Iview>{

    protected  T  view;

    public Ipresenter(T view) {
        this.view = view;
        init();
    }

    protected abstract void init();
}
下面的登录注册的模块
bean都是通过接口自动提取的
V层:
public interface Login_view extends Iview {
    void getYs(bean bean);
    void  getNo(Throwable throwable);
}
M层:
public interface Login_model {
    @GET("user/login?source=android")
    ObservablesetLoginData(@Query("mobile")String mobile,@Query("password")String password);
}
public class LoginModel implements Imodel {
    public Observable setData(String mobile,String password){
        Login_model login_model = RetrofitManager.getInstance().create(Login_model.class);
        return  login_model.setLoginData(mobile,password);
    }
}
P层:
public class LoginPresenter extends Ipresenter {

    private LoginModel loginModel;

    public LoginPresenter(Login_view view) {
        super(view);
    }

    @Override
    protected void init() {
        loginModel = new LoginModel();
    }

    public void  getLoginJs(String mobile,String password){
        Observable beanObservable = loginModel.setData(mobile, password);
        beanObservable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                               @Override
                               public void accept(bean bean) throws Exception {
                                   view.getYs(bean);
                               }
                           }
                        , new Consumer() {
                            @Override
                            public void accept(Throwable throwable) throws Exception {
                                view.getNo(throwable);
                            }
                        }
                );
    }

}
登录主类:
public class MainActivity extends AppCompatActivity implements Login_view {

    @InjectView(R.id.mobile)
    EditText mobile;
    @InjectView(R.id.password)
    EditText password;
    @InjectView(R.id.register)
    TextView register;
    @InjectView(R.id.login_but)
    Button loginBut;
    PlayerView playerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
    }


    @Override
    public void getYs(bean bean) {
        Log.e("login", bean.getMsg() );
        UidBean uidBean = new UidBean(bean.getData().getUid());
        Log.e("login","uid=="+uidBean.getUid()+"");
        EventBus.getDefault().postSticky(uidBean);
        startActivity(new Intent(this, Shop_listActivity.class));
    }
    @Override
    public void getNo(Throwable throwable) {
        Log.e("login", throwable.getMessage() );
    }

    @OnClick({R.id.register, R.id.login_but})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.register:
                startActivity(new Intent(MainActivity.this, RegisterActivity.class));
                break;
            case R.id.login_but:
                mobile.setText("18236019866");
                password.setText("123654");
                String mobil= mobile.getText().toString();
                String pass = password.getText().toString();
                LoginPresenter loginPresenter = new LoginPresenter(this);
                loginPresenter.getLoginJs(mobil,pass);
                Log.e("login", mobil+"***"+pass );
                break;
        }
    }
}
注册:
V层:
public interface Reg_View extends Iview{
    void getYs(RegisterBean bean);
    void  getNo(Throwable throwable);
}
M层:
public interface Reg_Model {
    @GET("user/reg?source=android")
    Observable setRegnData(@Query("mobile")String mobile, @Query("password")String password);
}
public class RegModel implements Imodel {
    public Observable setData(String mobile, String password){
        Reg_Model Reg_Model = RetrofitManager.getInstance().create(Reg_Model.class);
        return  Reg_Model.setRegnData(mobile,password);
    }
}
P层:
public class RegPresenter extends Ipresenter {

    private RegModel regModel;

    public RegPresenter(Reg_View view) {
        super(view);
    }

    @Override
    protected void init() {
        regModel = new RegModel();
    }
    public  void  setRegbeanJs(String mobile,String password){
        Observable registerBeanObservable = regModel.setData(mobile, password);
        registerBeanObservable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                               @Override
                               public void accept(RegisterBean registerBean) throws Exception {
                                   view.getYs(registerBean);
                               }
                           }
                        , new Consumer() {
                            @Override
                            public void accept(Throwable throwable) throws Exception {
                                view.getNo(throwable);
                            }
                        }
                );
    }
}
注册的主类代码:
public class RegisterActivity extends AppCompatActivity implements Reg_View{

    @InjectView(R.id.back)
    ImageView back;
    @InjectView(R.id.mobile)
    EditText mobile;
    @InjectView(R.id.password)
    EditText password;
    @InjectView(R.id.repassword)
    EditText repassword;
    @InjectView(R.id.regiser_but)
    Button regiserBut;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        ButterKnife.inject(this);
    }

    @OnClick({R.id.back, R.id.regiser_but})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.regiser_but:
                String smobile = mobile.getText().toString();
                String spass = password.getText().toString();
                String repass = repassword.getText().toString();
                if (spass.equals(repass)){
                    RegPresenter regPresenter = new RegPresenter(this);
                    regPresenter.setRegbeanJs(smobile,spass);
                }else {
                    Toast.makeText(RegisterActivity.this,"两次密码不一致",Toast.LENGTH_LONG).show();
                    return;
                }

                break;
        }
    }

    @Override
    public void getYs(RegisterBean bean) {
        Log.e("Register", bean.getMsg() );
        if (bean.getCode().equals("0")){
            finish();
        }
    }

    @Override
    public void getNo(Throwable throwable) {
        Log.e("Register", throwable.getMessage() );
    }
}
下面是商品分类的:
V层:
public interface Shoplist_View extends Iview {
    void  getShopListBean(ShoplistBean bean);
}
M层:
public interface Shoplist_Model {
    @GET("product/getProducts?pscid=39&source=android")
    ObservablesetShoplistData(@Query("page")String page);
}
public class ShoplistModel implements Imodel {
    public ObservablesetShoplistData(String page){
        Shoplist_Model shoplist_model = RetrofitManager.getInstance().create(Shoplist_Model.class);
        return  shoplist_model.setShoplistData(page);

    }
}
P层:
public class ShoplistPresenter extends Ipresenter {

    private ShoplistModel shoplistModel;

    public ShoplistPresenter(Shoplist_View view) {
        super(view);
    }

    @Override
    protected void init() {
        shoplistModel = new ShoplistModel();
    }
    public void setShoplistData(String page){
        Observable shoplistBeanObservable = shoplistModel.setShoplistData(page);
        shoplistBeanObservable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                    @Override
                    public void accept(ShoplistBean bean) throws Exception {
                        view.getShopListBean(bean);
                    }
                });
    }
}
适配器:
public class ShoplistAdapter extends XRecyclerView.Adapter<ShoplistAdapter.Myhoder> {
    Context context;
    List list;
    setOnclickitem onclickitem;

    public void setOnclickitem(setOnclickitem onclickitem) {
        this.onclickitem = onclickitem;
    }

    public ShoplistAdapter(Context context, List list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public Myhoder onCreateViewHolder(ViewGroup parent, int viewType) {
        Fresco.initialize(context);
        View inflate = View.inflate(context, R.layout.shoplist_item, null);
        Myhoder myhoder = new Myhoder(inflate);
        return myhoder;
    }

    @Override
    public void onBindViewHolder(Myhoder holder, final int position) {
        final ShoplistBean.DataBean dataBean = list.get(position);
        holder.shoplist_price.setText(dataBean.getBargainPrice()+"");
        holder.shoplist_title.setText(dataBean.getTitle()+"");
        Uri parse = Uri.parse(dataBean.getImages().split("!")[0]);
        holder.shoplist_simp.setImageURI(parse);
        holder.shoplist_title.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onclickitem.setitemClick(v,position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    public interface setOnclickitem{
        void  setitemClick(View v ,int position);
    }

    public class Myhoder extends RecyclerView.ViewHolder {
        SimpleDraweeView shoplist_simp;
        TextView shoplist_title,shoplist_price;
        public Myhoder(View itemView) {
            super(itemView);
            shoplist_simp=itemView.findViewById(R.id.shoplist_simp);
            shoplist_title=itemView.findViewById(R.id.shoplist_title);
            shoplist_price=itemView.findViewById(R.id.shoplist_price);
        }
    }
}

商品分类主类代码:
public class Shop_listActivity extends AppCompatActivity implements Shoplist_View{

    @InjectView(R.id.shoplist_xlv)
    XRecyclerView shoplistXlv;
  int page=1;
    private ShoplistPresenter shoplistPresenter;
    private ShoplistAdapter shoplistAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_list);
        ButterKnife.inject(this);
        shoplistPresenter = new ShoplistPresenter(this);
        shoplistPresenter.setShoplistData(page+"");
    }

    @Override
    public void getShopListBean(final ShoplistBean bean) {
        Log.e("shoplist", bean.getMsg() );
        shoplistXlv.setLayoutManager(new LinearLayoutManager(this));
        shoplistAdapter = new ShoplistAdapter(Shop_listActivity.this, bean.getData());
        if (bean.getData()!=null) {
            shoplistXlv.setAdapter(shoplistAdapter);
        }
        shoplistAdapter.setOnclickitem(new ShoplistAdapter.setOnclickitem() {
            @Override
            public void setitemClick(View v, int position) {
                int pid = bean.getData().get(position).getPid();
                EventBus.getDefault().postSticky(new Pidbean(pid));
                startActivity(new Intent(Shop_listActivity.this,DetailsActivity.class));
            }
        });
        shoplistXlv.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                page=1;
                bean.getData().clear();
                shoplistPresenter.setShoplistData(page+"");
                shoplistXlv.refreshComplete();
            }

            @Override
            public void onLoadMore() {
                page=page++;
                shoplistPresenter.setShoplistData(page+"");
                shoplistXlv.refreshComplete();
            }
        });
    }
}

商品详情:
V层:
public interface Details_view extends Iview {

    void getDetailsData(DetailsBean bean);
    void addYes(AddBean addBean);
}
M层:
public interface Details_model  {
    @GET("product/getProductDetail?source=android")
    Observable setShoplistData(@Query("pid")String pid);

    @GET("product/addCart?source=android")
    ObservableAddShopcart(@Query("uid")String uid,@Query("pid")String pid);
}
public class DetailsModel implements Imodel {
    public Observable setDetailsData(String pid){
        Details_model details_model = RetrofitManager.getInstance().create(Details_model.class);
        return  details_model.setShoplistData(pid);
    }

    public  ObservableAddshopcart(String uid ,String pid){
        Details_model details_model = RetrofitManager.getInstance().create(Details_model.class);
         return details_model.AddShopcart(uid,pid);
    }
}
P层:
public class DetailsPresent extends Ipresenter {

    private DetailsModel detailsModel;

    public DetailsPresent(Details_view view) {
        super(view);
    }

    @Override
    protected void init() {
        detailsModel = new DetailsModel();
    }
    public void getDetails(String pid){
        Observable detailsBeanObservable = detailsModel.setDetailsData(pid);
        detailsBeanObservable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                    @Override
                    public void accept(DetailsBean bean) throws Exception {
                      view.getDetailsData(bean);
                    }
                });
    }
    public void AddShopcart(String uid,String pid){
        Observable addshopcart = detailsModel.Addshopcart(uid, pid);
        addshopcart
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                    @Override
                    public void accept(AddBean addBean) throws Exception {
                        view.addYes(addBean);
                    }
                });

    }
}
详情的主类:
public class DetailsActivity extends AppCompatActivity implements Details_view {

    @InjectView(R.id.details_img)
    SimpleDraweeView detailsImg;
    @InjectView(R.id.details_title)
    TextView detailsTitle;
    @InjectView(R.id.details_price)
    TextView detailsPrice;
    @InjectView(R.id.details_shoper)
    TextView detailsShoper;
    @InjectView(R.id.details_add)
    Button detailsAdd;
    @InjectView(R.id.details_buy)
    Button detailsBuy;
    PlayerView playerView;
    private int uid;
    private int pid;
    private DetailsPresent detailsPresent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fresco.initialize(this);
        setContentView(R.layout.activity_details);
        ButterKnife.inject(this);
        EventBus.getDefault().register(this);
        playerView = new PlayerView(this)
                //创建视频容器
                .setTitle("周考3")
                .setScaleType(PlayStateParams.fitparent)
                .hideMenu(true)
                .forbidTouch(false)
                .setPlaySource("http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4");
        playerView.startPlay();
    }

    @Subscribe(sticky = true)
    public void getid(Pidbean bean) {
        int pid = bean.getPid();
        detailsPresent = new DetailsPresent(this);
        detailsPresent.getDetails(pid + "");
        Log.e("pid", bean.getPid() + "");
    }

    @Subscribe(sticky = true)
    public void getUid(UidBean bean) {
        uid = bean.getUid();
        Log.e("Details", uid + "=uid***");
    }

    @Override
    public void getDetailsData(DetailsBean bean) {

        Log.e("Details", bean.getMsg());
        DetailsBean.DataBean data = bean.getData();
        Uri parse = Uri.parse(data.getImages().split("!")[0]);
        detailsImg.setImageURI(parse);
        detailsTitle.setText(data.getTitle() + "");
        detailsPrice.setText("" + data.getBargainPrice() + "");
        detailsShoper.setText(bean.getSeller().getName());
        pid = data.getPid();
    }
    @Override
    public void addYes(AddBean addBean) {
        Toast.makeText(DetailsActivity.this, addBean.getMsg(), Toast.LENGTH_LONG).show();
        if (addBean.getMsg().equals("加购成功")){
            startActivity(new Intent(DetailsActivity.this,ShopcarActivity.class));

        }
    }

    @Override
    public void onStop() {
        super.onStop();
        playerView.stopPlay();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
    @OnClick(R.id.details_add)
    public void onViewClicked() {
        Log.e("Details", uid + "***" + pid + "");
        detailsPresent.AddShopcart(uid+"",pid+"");
    }
}

登录的布局:
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.bwei.ssp.yuekao.MainActivity"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:gravity="center"
        >

        <ImageView
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="@mipmap/loge" />
    LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:orientation="vertical">
        >
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="手机号/会员号/邮箱"
            android:layout_marginTop="10dp"
            android:id="@+id/mobile"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="请输入密码"
            android:layout_marginTop="10dp"
            android:id="@+id/password"
            android:password="true"
            />
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="忘记密码"
                />
            <TextView
                android:layout_alignParentRight="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="点击注册"
                android:id="@+id/register"
                />
        RelativeLayout>
    LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:orientation="vertical"
        android:gravity="center_horizontal"
        >
        <Button
            android:id="@+id/login_but"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="登录"
            android:textColor="#FFFFFF"
            android:textSize="35sp"
            android:background="@drawable/buttton"
            android:layout_margin="10dp"
            />
        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@mipmap/qq"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="qq登录"
            />
    LinearLayout>
LinearLayout>
注册的布局:
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.bwei.ssp.yuekao.acticity.RegisterActivity"
    android:orientation="vertical">
  <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      android:background="#ff3300"
      >
      <ImageView
          android:layout_width="32dp"
          android:layout_height="32dp"
          android:background="@mipmap/back"
          android:layout_centerVertical="true"
          android:id="@+id/back"
          />
  <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="新用户注册"
      android:textSize="20dp"
      android:textColor="#FFFFFF"
      android:layout_centerInParent="true"
      />
  RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9"
        android:orientation="vertical">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:hint="请输入用户名"
            android:id="@+id/mobile"
            />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:hint="请输入密码"
            android:id="@+id/password"
            android:password="true"
            />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:hint="请再次输入密码"
            android:id="@+id/repassword"
            android:password="true"
            />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:hint="请填写邮箱" />

        <Button
            android:id="@+id/regiser_but"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="注册"
            android:textColor="#FFFFFF"
            android:textSize="35sp"
            android:background="@drawable/buttton"
            android:layout_margin="10dp"
            />
    LinearLayout>

LinearLayout>

商品列表的布局:

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.bwei.ssp.yuekao.acticity.Shop_listActivity"
    android:orientation="vertical">
    <com.jcodecraeer.xrecyclerview.XRecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/shoplist_xlv"
        >com.jcodecraeer.xrecyclerview.XRecyclerView>
LinearLayout>

子布局 
xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:fresco="http://schemas.android.com/apk/res-auto"
    android:gravity="center_vertical">
  <com.facebook.drawee.view.SimpleDraweeView
      android:layout_width="140dp"
      android:layout_height="140dp"
      android:id="@+id/shoplist_simp"
      fresco:progressBarImage="@mipmap/lll"
      />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
        <TextView
            android:id="@+id/shoplist_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="31231321213131313"
            />
        <TextView
            android:id="@+id/shoplist_price"
            android:layout_marginTop="50dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="123.0"
            />
    LinearLayout>
LinearLayout>
商品的详情:

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:fresco="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.bwei.ssp.yuekao.acticity.DetailsActivity"
    android:orientation="vertical">
    <include
        layout="@layout/video_play"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        >include>
    <com.facebook.drawee.view.SimpleDraweeView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="4"
        android:id="@+id/details_img"
        fresco:progressBarImage="@mipmap/lll"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:orientation="vertical"
        >
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:text="标题"
                android:id="@+id/details_title"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:gravity="center_horizontal"
                android:layout_alignParentRight="true"
                >
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@mipmap/fenxiang"
                    />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="分享"

                    />
            LinearLayout>
        RelativeLayout>
      <TextView
          android:layout_marginTop="40dp"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="12036"
          android:textSize="25sp"
          android:textColor="#ff6600"
          android:id="@+id/details_price"
          />
        <TextView
            android:layout_marginTop="10dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="我是商家1"
            android:textSize="25sp"
            android:id="@+id/details_shoper"
            />
    LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"

        >
        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >

            <LinearLayout
                android:layout_marginLeft="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
               android:orientation="vertical"
                android:gravity="center_horizontal"
                >
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@mipmap/kefu"
                    />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="客服"
                    />
            LinearLayout>
            <LinearLayout
                android:layout_marginLeft="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:gravity="center_horizontal"
                >
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@mipmap/dianpu"
                    />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="店铺"
                    />
            LinearLayout>
            <LinearLayout
                android:layout_marginLeft="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:gravity="center_horizontal"
                >
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@mipmap/sca"
                    />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="收藏"
                    />
            LinearLayout>
        LinearLayout>
      <LinearLayout
          android:layout_width="0dp"
          android:layout_weight="1"
          android:layout_height="match_parent">
          <Button
          android:layout_width="0dp"
          android:layout_weight="1"
          android:layout_height="match_parent"
          android:text="加入购物车"
              android:textSize="20sp"
              android:textColor="#FFFFFF"
              android:background="#ffcc33"
              android:id="@+id/details_add"
          />
          <Button
              android:layout_width="0dp"
              android:layout_weight="1"
              android:layout_height="match_parent"
              android:text="立即购买"
              android:textSize="20sp"
              android:textColor="#FFFFFF"
              android:background="#ff6633"
              android:id="@+id/details_buy"
              />
      LinearLayout>
    LinearLayout>
LinearLayout>
插入的Includ布局:

xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/app_video_box"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:orientation="vertical">
    <com.dou361.ijkplayer.widget.IjkVideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <LinearLayout
        android:id="@+id/ll_bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black"
        android:orientation="vertical">

        
        <ImageView
            android:id="@+id/iv_trumb"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            android:visibility="visible"/>
    LinearLayout>

    
    <LinearLayout
        android:id="@+id/app_video_replay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#33000000"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="gone">
        
        <TextView
            android:id="@+id/app_video_status_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/small_problem"
            android:textColor="@android:color/white"
            android:textSize="14dp"/>

        <ImageView
            android:id="@+id/app_video_replay_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="8dp"
            android:src="@drawable/simple_player_circle_outline_white_36dp"/>
    LinearLayout>
    
    <LinearLayout
        android:id="@+id/app_video_netTie"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#33000000"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="gone">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:gravity="center"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:text="您正在使用移动网络播放视频\n可能产生较高流量费用"
            android:textColor="@android:color/white"/>

        <TextView
            android:id="@+id/app_video_netTie_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/simple_player_btn"
            android:gravity="center"
            android:paddingLeft="8dp"
            android:paddingRight="8dp"
            android:text="继续"
            android:textColor="@android:color/white"/>
    LinearLayout>

    
    <LinearLayout
        android:id="@+id/app_video_loading"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="gone">

        <ProgressBar
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:indeterminateBehavior="repeat"
            android:indeterminateOnly="true"/>
        <TextView
            android:id="@+id/app_video_speed"
            android:layout_width="wrap_content"
            android:layout_marginTop="4dp"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:visibility="gone"
            android:text="188Kb/s"
            android:textColor="@android:color/white"/>
    LinearLayout>

    
    <include
        layout="@layout/simple_player_touch_gestures"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"/>

    
    <include layout="@layout/simple_player_topbar"/>
    
    <include
        layout="@layout/simple_player_controlbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"/>

    
    <LinearLayout
        android:id="@+id/simple_player_settings_container"
        android:layout_width="250dp"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:background="#80000000"
        android:gravity="center_vertical"
        android:orientation="vertical"
        android:visibility="visible">

        <LinearLayout
            android:id="@+id/simple_player_volume_controller_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:src="@drawable/qcloud_player_icon_audio_vol_mute"/>

            <SeekBar
                android:id="@+id/simple_player_volume_controller"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="150dp"
                android:layout_height="wrap_content"/>
            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:src="@drawable/qcloud_player_icon_audio_vol"/>
        LinearLayout>
        <LinearLayout
            android:id="@+id/simple_player_brightness_controller_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:padding="5dp"
                android:src="@drawable/qcloud_player_icon_brightness"/>

            <SeekBar
                android:id="@+id/simple_player_brightness_controller"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="150dp"
                android:layout_height="wrap_content"/>

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:src="@drawable/qcloud_player_icon_brightness"/>
        LinearLayout>

    LinearLayout>
    
    <LinearLayout
        android:id="@+id/simple_player_select_stream_container"
        android:layout_width="150dp"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:background="#80000000"
        android:gravity="center_vertical"
        android:visibility="gone">

        <ListView
            android:id="@+id/simple_player_select_streams_list"
            android:layout_width="150dp"
            android:layout_height="wrap_content"/>
    LinearLayout>


    <ImageView
        android:id="@+id/play_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginTop="8dp"
        android:src="@drawable/simple_player_center_play"/>
RelativeLayout>

你可能感兴趣的:(Android之电商Demo模块)