登录+注册+跳转搜素+详情切换布局+详情点击图片双击放大

权限

<uses-permission android:name="android.permission.INTERNET" />
依赖

compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.jcodecraeer:xrecyclerview:1.3.2'
compile 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-7'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.youth.banner:banner:1.4.9'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

登录页面

public class LoginActivity extends AppCompatActivity implements ILoginView {

    EditText et_name,et_pass;
    ILgoinPresenter iLgoinPresenter;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        et_name= (EditText) findViewById(R.id.et_name);
        et_pass= (EditText) findViewById(R.id.et_pass);
        iLgoinPresenter=new ILgoinPresenter(this);

    }
    public void Login(View view)
    {
        iLgoinPresenter.DengLu(et_name.getText().toString(),et_pass.getText().toString());
    }

    public void zc(View view)
    {
        Intent intent=new Intent(this, ZhuceActivity.class);
        startActivity(intent);
    }

    @Override
    public void OnSuccess(final LoginBean loginBean)
    {
        runOnUiThread(new Runnable()
        {
            @Override
            public void run()
            {
                LoginBean.DataBean data=loginBean.getData();
                Intent intent = new Intent(LoginActivity.this,SousuoActivity.class);
               // Log.i("TAUDAD", "run: "+data.getUid());
                intent.putExtra("uid",data.getUid()+"");
                startActivity(intent);
                finish();
                Log.i("TAG", "登录V层接口穿回来的数据"+data.toString());
            }
        });
    }
}

登录M层
public class LoginModel
{
    public void DengLu(String user, String pass, final LoginPresenter loginPresenter)
    {
        OkHttp3Util.doGet("http://120.27.23.105/user/login?mobile=" + user + "&password=" + pass, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {

                if (response.isSuccessful())
                {
                    String json=response.body().string();
                    Log.i("TAG0000", "登录请求下来的数据: "+json);
                    Gson gson = new Gson();
                    LoginBean loginBean=gson.fromJson(json,LoginBean.class);
                    loginPresenter.OnSuccess(loginBean);
                }
            }
        });
    }
}
登录P层接口

public interface LoginPresenter
{
    void OnSuccess(LoginBean loginBean);
}
登录P层实体类
public class ILgoinPresenter implements LoginPresenter
{
    ILoginView iLoginView;
    LoginModel loginModel;

    public ILgoinPresenter(ILoginView iLoginView) {
        this.iLoginView = iLoginView;
        loginModel=new LoginModel();
    }
    public void DengLu(String user, String pass)
    {
        loginModel.DengLu( user,pass,this);
    }
    @Override
    public void OnSuccess(LoginBean loginBean)
    {
        iLoginView.OnSuccess(loginBean);
    }
}

登录View层
public interface ILoginView
{
    void OnSuccess(LoginBean loginBean);
}
注册页面
public class ZhuceActivity extends AppCompatActivity implements ZhuCeView{

    EditText et_user,et_mima;
    private ZhuCepresenter zhuCepresenter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhuce);
        et_mima= (EditText) findViewById(R.id.et_mima);
        et_user= (EditText) findViewById(R.id.et_user);
        zhuCepresenter=new ZhuCepresenter(this);

    }
    @Override
    public void OnSuccess(String msg) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Log.i("TAG", "注册成功");
                finish();
            }
        });
    }

    public void zhuce(View view)
    {
        zhuCepresenter.Netinfo(et_user.getText().toString(),et_mima.getText().toString());
        finish();
    }
}
注册M层
public class ZhuCeModel
{
    public void Netinfo(String user, final String pass, final IZhuCepresenter iZhuCepresenter)
    {
        OkHttp3Util.doGet("http://120.27.23.105/user/reg?mobile=" + user + "&password=" + pass, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException
            {
                if (response.isSuccessful())
                {
                    String string = response.body().string();
                    try
                    {
                        JSONObject jsonObject=new JSONObject(string);
                        String msg=jsonObject.getString("msg");
                        if ("注册成功".equals(msg))
                        {
                            iZhuCepresenter.OnSuccess(msg);
                        }

                    } catch (Exception e)
                    {
                        e.printStackTrace();
                    }


                }

            }
        });

    }
}

注册P层接口类
public interface IZhuCepresenter
{
    void OnSuccess(String msg);
}

注册P层实体类
public class ZhuCepresenter implements IZhuCepresenter
{
    ZhuCeView zhuCeView;
    ZhuCeModel zhuCeModel;
    public ZhuCepresenter(ZhuCeView zhuCeView)
    {
        zhuCeModel=new ZhuCeModel();
        this.zhuCeView = zhuCeView;
    }
    public void Netinfo(String user,String pass)
    {
        zhuCeModel.Netinfo(user,pass,this);
    }
    @Override
    public void OnSuccess(String msg)
    {
        zhuCeView.OnSuccess(msg);
    }
}
 
注册View层
public interface ZhuCeView
{
    void OnSuccess(String msg);
}

搜索页面
public class SousuoActivity extends AppCompatActivity {

    private EditText edit_sousuo;
    private ImageView btn_image;
    private TextView btn_sousuo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sousuo);
        btn_image = (ImageView) findViewById(R.id.btn_image);
        edit_sousuo = (EditText) findViewById(R.id.edit_sousuo);
        btn_sousuo = (TextView) findViewById(R.id.btn_sousuo);

        btn_sousuo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String s = edit_sousuo.getText().toString();
                if (!s.equals(""))
                {
                        Intent intent = new Intent(SousuoActivity.this, SouSuoLieBiaoActivity.class);
                        intent.putExtra("namesp",s);
                        startActivity(intent);
                        finish();
                    }
                }

        });

        btn_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}

搜索M层
public class SMoudel
{
    ISpresenter iSpresenter;
    public SMoudel(ISpresenter iSpresenter) {
        this.iSpresenter = iSpresenter;
    }
    public void getLieBiaoUrl(String s,String sousuoliebiao,int page)
    {
        Map<String, String> params=new HashMap<>();
        params.put("keywords", s);
        params.put("page", page + "");
        params.put("source", "android");
        OkHttp3Util.doPost(sousuoliebiao, params, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                if (response.isSuccessful()) {
                    String json = response.body().string();
                    MySouSuoLieBiaoBean mySouSuoLieBiaoBean = new Gson().fromJson(json, MySouSuoLieBiaoBean.class);
                    Log.e("zzz", "onResponse: "+json );
                   // Log.e("zzz", "onResponse: "+mySouSuoLieBiaoBean );
                    iSpresenter.getLieBiaoBean(mySouSuoLieBiaoBean);
                }
            }
        });
    }
}

搜索P层接口类
public interface ISpresenter
{
    void getLieBiaoBean(MySouSuoLieBiaoBean mySouSuoLieBiaoBean);
}

搜索P层实体类
public class Spresenter implements ISpresenter
{
    SMain sMain;
    SMoudel sMoudel;
    public Spresenter(SMain sMain)
    {
        this.sMain = sMain;
        sMoudel=new SMoudel(this);
    }
    @Override
    public void getLieBiaoBean(MySouSuoLieBiaoBean mySouSuoLieBiaoBean)
    {
          sMain.getLieBiaoBean(mySouSuoLieBiaoBean);
    }

    public void getLieBiaoUrl(String s,String sousuoliebiao, int page)
    {
        sMoudel.getLieBiaoUrl(sousuoliebiao,s,page);
    }
}
搜索View层
public interface SMain
{
    void getLieBiaoBean(MySouSuoLieBiaoBean mySouSuoLieBiaoBean);
}

搜索列表页面
public class SouSuoLieBiaoActivity extends AppCompatActivity implements SMain
{

    private List<MySouSuoLieBiaoBean.DataBean> listad=new ArrayList<>();
    private XRecyclerView recycler_view;
    private ImageView image_fanhuishouye;
    private RelativeLayout relative_sousuoliebiao;
    TextView sousuo_liebiao;
    private ImageView image_qiehuan;
    private int l=0;
    private int page=1;
    private String namesp;
    private SmartRefreshLayout smartrefresh_liebiao;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sou_suo_lie_biao);
        smartrefresh_liebiao = (SmartRefreshLayout) findViewById(R.id.smartrefresh_liebiao);
        image_fanhuishouye = (ImageView) findViewById(R.id.image_fanhuishouye);
        image_qiehuan = (ImageView) findViewById(R.id.image_qiehuan);
        relative_sousuoliebiao = (RelativeLayout) findViewById(R.id.relative_sousuoliebiao);
        recycler_view = (XRecyclerView) findViewById(R.id.xrecycler_view);
        sousuo_liebiao = (TextView) findViewById(R.id.sousuo_liebiao);
        final String namesp = getIntent().getStringExtra("namesp");
        sousuo_liebiao.setText(namesp);
        Spresenter spresenter = new Spresenter(SouSuoLieBiaoActivity.this);
        spresenter.getLieBiaoUrl(ApiUtil.sousuoliebiao,namesp,page);
        //返回首页
        image_fanhuishouye.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //搜索页面
        relative_sousuoliebiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SouSuoLieBiaoActivity.this, SouSuoLieBiaoActivity.class);
                startActivity(intent);
                finish();
            }
        });

        //切换布局
        image_qiehuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    if (l==0){
                        image_qiehuan.setImageResource(R.drawable.kind_liner);
                        l=1;
                    }else if (l==1){
                        image_qiehuan.setImageResource(R.drawable.kind_grid);
                        l=0;
                    }
                Spresenter spresenter = new Spresenter(SouSuoLieBiaoActivity.this);
                spresenter.getLieBiaoUrl(ApiUtil.sousuoliebiao,namesp,page);
                }
        });


    }

    @Override
    public void getLieBiaoBean(final MySouSuoLieBiaoBean mySouSuoLieBiaoBean) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (l==0){
                    final List<MySouSuoLieBiaoBean.DataBean> list = mySouSuoLieBiaoBean.getData();
                    listad.addAll(mySouSuoLieBiaoBean.getData());
                    recycler_view.setLayoutManager(new LinearLayoutManager(SouSuoLieBiaoActivity.this,LinearLayoutManager.VERTICAL,false));
                    MySouSuoLieBiaoAdapter adapter = new MySouSuoLieBiaoAdapter(SouSuoLieBiaoActivity.this, listad);
                    recycler_view.setAdapter(adapter);
                    smartrefresh_liebiao.setOnRefreshListener(new OnRefreshListener() {
                        @Override
                        public void onRefresh(RefreshLayout refreshlayout) {
                            smartrefresh_liebiao.finishRefresh(2000);
                        }
                    });
                    smartrefresh_liebiao.setOnLoadmoreListener(new OnLoadmoreListener() {
                        @Override
                        public void onLoadmore(RefreshLayout refreshlayout) {
                            page++;
                            Spresenter spresenter = new Spresenter(SouSuoLieBiaoActivity.this);
                            spresenter.getLieBiaoUrl(ApiUtil.sousuoliebiao,namesp,page);
                            recycler_view.setLayoutManager(new LinearLayoutManager(SouSuoLieBiaoActivity.this,LinearLayoutManager.VERTICAL,false));
                            MySouSuoLieBiaoAdapter adapter = new MySouSuoLieBiaoAdapter(SouSuoLieBiaoActivity.this, listad);
                            recycler_view.setAdapter(adapter);
                            smartrefresh_liebiao.finishLoadmore();
                        }
                    });

                    adapter.setItemListenner(new ItemListenner() {
                        @Override
                        public void OnItemClick(int position) {
                            Intent intent = new Intent(SouSuoLieBiaoActivity.this, JiaRuGouWuCheActivity.class);
                            intent.putExtra("pid",list.get(position).getPid());
                            startActivity(intent);
                        }

                        @Override
                        public void OnLongClick(int position) {
                            Toast.makeText(SouSuoLieBiaoActivity.this,"笨蛋该点击了!",Toast.LENGTH_LONG).show();
                        }
                    });

                }else {
                    listad.addAll(mySouSuoLieBiaoBean.getData());
                    final List<MySouSuoLieBiaoBean.DataBean> list = mySouSuoLieBiaoBean.getData();
                    recycler_view.setLayoutManager(new GridLayoutManager(SouSuoLieBiaoActivity.this,2,GridLayoutManager.VERTICAL,false));
                    MyGroupAdapter adapter = new MyGroupAdapter(SouSuoLieBiaoActivity.this, listad);
                    recycler_view.setAdapter(adapter);

                    smartrefresh_liebiao.setOnRefreshListener(new OnRefreshListener() {
                        @Override
                        public void onRefresh(RefreshLayout refreshlayout) {
                            smartrefresh_liebiao.finishRefresh(2000);
                        }
                    });

                    smartrefresh_liebiao.setOnLoadmoreListener(new OnLoadmoreListener() {
                        @Override
                        public void onLoadmore(RefreshLayout refreshlayout) {
                            page++;
                            Spresenter spresenter = new Spresenter(SouSuoLieBiaoActivity.this);
                            spresenter.getLieBiaoUrl(ApiUtil.sousuoliebiao,namesp,page);
                            recycler_view.setLayoutManager(new LinearLayoutManager(SouSuoLieBiaoActivity.this,LinearLayoutManager.VERTICAL,false));
                            MySouSuoLieBiaoAdapter adapter = new MySouSuoLieBiaoAdapter(SouSuoLieBiaoActivity.this, listad);
                            recycler_view.setAdapter(adapter);

                            smartrefresh_liebiao.finishLoadmore();
                        }
                    });

                    adapter.setItemClicked(new ItemListenner() {
                        @Override
                        public void OnItemClick(int position) {
                            Intent intent = new Intent(SouSuoLieBiaoActivity.this, JiaRuGouWuCheActivity.class);
                            intent.putExtra("pid",list.get(position).getPid());
                            startActivity(intent);
                        }

                        @Override
                        public void OnLongClick(int position) {
                            Toast.makeText(SouSuoLieBiaoActivity.this,"笨蛋该点击了!",Toast.LENGTH_LONG).show();
                        }
                    });
                }
            }
        });
    }
}

加入购物车页面
public class JiaRuGouWuCheActivity extends AppCompatActivity implements Gouwu{

    private ViewPager viewPager;
    private TextView jiaru_title;
    private TextView jiaru_price;
    private Button btn_jiaru;
    private int pid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jia_ru_gou_wu_che);
        jiaru_title = (TextView) findViewById(R.id.jiaru_title);
        jiaru_price = (TextView) findViewById(R.id.jiaru_price);
        btn_jiaru = (Button) findViewById(R.id.btn_jiaru);
        viewPager = (ViewPager) findViewById(R.id.view_pager);
        pid = getIntent().getIntExtra("pid",59);
        GuwuPresenter guwuPresenter = new GuwuPresenter(this);
        guwuPresenter.getJiaRuGouWuCheUrl(ApiUtil.jiarugouwuche, pid);


    }

    @Override
    public void getJiaRuGouWuCheBean(final MyJiaRuGouWuCheBean myJiaRuGouWuCheBean)
    {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {

               final MyJiaRuGouWuCheBean.DataBean data = myJiaRuGouWuCheBean.getData();
                Map<String, String> params = new HashMap<>();
                params.put("pid", String.valueOf(pid));
                OkHttp3Util.doPost("https://www.zhaoapi.cn/product/getProductDetail", params, new Callback() {
                    @Override
                    public void onFailure(Call call, IOException e) {

                    }

                    @Override
                    public void onResponse(Call call, Response response) throws IOException {
                        if (response.isSuccessful()){

                            String json = response.body().string();
                            final MyJiaRuGouWuCheBean detailBean = new Gson().fromJson(json,MyJiaRuGouWuCheBean.class);
                            if ("0".equals(detailBean.getCode())){

                                //展示轮播图...主线程
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        final ArrayList<String> imageUrls = new ArrayList<>();
                                        String[] split = detailBean.getData().getImages().split("\\|");
                                        for (int i =0;i<split.length;i++){
                                            imageUrls.add(split[i]);
                                        }

                                        viewPager.setAdapter(new PagerAdapter() {
                                            @Override
                                            public Object instantiateItem(ViewGroup container, int position) {
                                                ImageView imageView = new ImageView(JiaRuGouWuCheActivity.this);
                                                //加载图片显示
                                                Glide.with(JiaRuGouWuCheActivity.this).load(imageUrls.get(position)).into(imageView);

                                                //添加
                                                container.addView(imageView);

                                                imageView.setOnClickListener(new View.OnClickListener() {
                                                    @Override
                                                    public void onClick(View view) {
                                                        //跳转到下一个放大图片的页面,,,并传值过去
                                                        Intent intent = new Intent(JiaRuGouWuCheActivity.this,JiaRuGouWuCheLunBoTuTiaoZhuanActivity.class);

                                                        //直接传递string类型的arrayList
                                                        intent.putStringArrayListExtra("list",imageUrls);
                                                        startActivity(intent);
                                                    }
                                                });
                                                //返回
                                                return imageView;
                                            }

                                            @Override
                                            public void destroyItem(ViewGroup container, int position,
                                                                    Object object) {
                                                container.removeView((View) object);
                                            }

                                            @Override
                                            public boolean isViewFromObject(View arg0, Object arg1) {
                                                return arg0 == arg1;
                                            }

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


                                    }
                                });

                            }

                        }
                    }
                });


                jiaru_title.setText(data.getTitle());
                jiaru_price.setText("价格:"+data.getPrice());

                btn_jiaru.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(JiaRuGouWuCheActivity.this,"加入购物车了",Toast.LENGTH_LONG).show();
                    }
                });

            }
        });

    }
}

购物车展示数据M层
public class GuwuModel
{
     GuwuPresenter guwuPresenter;

    public GuwuModel(GuwuPresenter guwuPresenter) {
        this.guwuPresenter = guwuPresenter;
    }
    public void getJiaRuGouWuCheUrl(String jiarugouwuche, int pid) {
        Map<String, String> params=new HashMap<>();
        params.put("pid", String.valueOf(pid));
        OkHttp3Util.doPost(jiarugouwuche, params, new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                if (response.isSuccessful()){
                    String json = response.body().string();
                    Log.d("qqq11111111",json);
                    MyJiaRuGouWuCheBean myJiaRuGouWuCheBean = new Gson().fromJson(json, MyJiaRuGouWuCheBean.class);
                    guwuPresenter.getJiaRuGouWuCheBean(myJiaRuGouWuCheBean);
                }
            }
        });
    }
}

购物车P层接口
public interface IGuwuPresenter
{
    void getJiaRuGouWuCheBean(MyJiaRuGouWuCheBean myJiaRuGouWuCheBean);
}
购物车P层实体类
public class GuwuPresenter implements IGuwuPresenter
{
    GuwuModel guwuModel;
    Gouwu gouwu;

    public GuwuPresenter(Gouwu gouwu) {
        guwuModel=new GuwuModel(this);
        this.gouwu = gouwu;
    }
    public void getJiaRuGouWuCheUrl(String jiarugouwuche, int pid)
    {
          guwuModel.getJiaRuGouWuCheUrl(jiarugouwuche,pid);
    }
    public void getJiaRuGouWuCheBean(MyJiaRuGouWuCheBean myJiaRuGouWuCheBean)
    {
         gouwu.getJiaRuGouWuCheBean(myJiaRuGouWuCheBean);
    }
}
 
购物车View层
public interface Gouwu
{
    void getJiaRuGouWuCheBean(MyJiaRuGouWuCheBean myJiaRuGouWuCheBean);
}
点击详情图实现双击放大页面
public class JiaRuGouWuCheLunBoTuTiaoZhuanActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private ArrayList<String> imageUrls;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jia_ru_gou_wu_che_lun_bo_tu_tiao_zhuan);
        viewPager = (ViewPager) findViewById(R.id.view_pager);

        //获取导数据
        imageUrls = getIntent().getStringArrayListExtra("list");

        if (imageUrls != null){
            viewPager.setAdapter(new PagerAdapter() {
                @Override
                public Object instantiateItem(ViewGroup container, int position) {
                    ZoomImageView imageView = new ZoomImageView(JiaRuGouWuCheLunBoTuTiaoZhuanActivity.this);
                    //加载图片显示
                    Glide.with(JiaRuGouWuCheLunBoTuTiaoZhuanActivity.this).load(imageUrls.get(position)).into(imageView);

                    //添加
                    container.addView(imageView);
                    //返回
                    return imageView;
                }

                @Override
                public void destroyItem(ViewGroup container, int position,
                                        Object object) {
                    container.removeView((View) object);
                }

                @Override
                public boolean isViewFromObject(View arg0, Object arg1) {
                    return arg0 == arg1;
                }

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

    }
}

类别点击工具类
public interface ItemListenner {
    void OnItemClick(int position);
    void OnLongClick(int position);
}
工具类数据接口
public class ApiUtil
{
    public static String sousuoliebiao="https://www.zhaoapi.cn/product/searchProducts";

    public static String jiarugouwuche="https://www.zhaoapi.cn/product/getProductDetail";
}
Okhttp工具类
public class OkHttp3Util {

    /**
     * 懒汉 安全 加同步
     * 私有的静态成员变量 只声明不创建
     * 私有的构造方法
     * 提供返回实例的静态方法
     */
    private static OkHttpClient okHttpClient = null;


    private OkHttp3Util() {
    }

    public static OkHttpClient getInstance() {
        if (okHttpClient == null) {
            //加同步安全
            synchronized (OkHttp3Util.class) {
                if (okHttpClient == null) {
                    //okhttp可以缓存数据....指定缓存路径
                    File sdcache = new File(Environment.getExternalStorageDirectory(), "cache");
                    //指定缓存大小
                    int cacheSize = 10 * 1024 * 1024;

                    okHttpClient = new OkHttpClient.Builder()//构建器
                            .connectTimeout(15, TimeUnit.SECONDS)//连接超时
                            .writeTimeout(20, TimeUnit.SECONDS)//写入超时
                            .readTimeout(20, TimeUnit.SECONDS)//读取超时

                            //.addInterceptor(new CommonParamsInterceptor())//添加的是应用拦截器...公共参数
                            //.addNetworkInterceptor(new CacheInterceptor())//添加的网络拦截器
                            .cache(new Cache(sdcache.getAbsoluteFile(),cacheSize))//设置缓存
                            .build();
                }
            }

        }

        return okHttpClient;
    }

    /**
     * get请求
     * 参数1 url
     * 参数2 回调Callback
     */

    public static void doGet(String oldUrl, Callback callback) {

        //要添加的公共参数...map
        Map<String,String> map = new HashMap<>();
        map.put("source","android");

        StringBuilder stringBuilder = new StringBuilder();//创建一个stringBuilder

        stringBuilder.append(oldUrl);

        if (oldUrl.contains("?")){
            //?在最后面....2类型
            if (oldUrl.indexOf("?") == oldUrl.length()-1){

            }else {
                //3类型...拼接上&
                stringBuilder.append("&");
            }
        }else {
            //不包含? 属于1类型,,,先拼接上?号
            stringBuilder.append("?");
        }

        //添加公共参数....
        for (Map.Entry<String,String> entry: map.entrySet()) {
            //拼接
            stringBuilder.append(entry.getKey())
                    .append("=")
                    .append(entry.getValue())
                    .append("&");
        }

        //删掉最后一个&符号
        if (stringBuilder.indexOf("&") != -1){
            stringBuilder.deleteCharAt(stringBuilder.lastIndexOf("&"));
        }

        String newUrl = stringBuilder.toString();//新的路径

        //创建OkHttpClient请求对象
        OkHttpClient okHttpClient = getInstance();
        //创建Request
        Request request = new Request.Builder().url(newUrl).build();
        //得到Call对象
        Call call = okHttpClient.newCall(request);
        //执行异步请求
        call.enqueue(callback);


    }

    /**
     * post请求
     * 参数1 url
     * 参数2 Map<String, String> params post请求的时候给服务器传的数据
     *      add..("","")
     *      add()
     */

    public static void doPost(String url, Map<String, String> params, Callback callback) {
        //要添加的公共参数...map
        Map<String,String> map = new HashMap<>();
        map.put("source","android");


        //创建OkHttpClient请求对象
        OkHttpClient okHttpClient = getInstance();
        //3.x版本post请求换成FormBody 封装键值对参数

        FormBody.Builder builder = new FormBody.Builder();
        //遍历集合
        for (String key : params.keySet()) {
            builder.add(key, params.get(key));

        }

        //添加公共参数
        for (Map.Entry<String,String> entry: map.entrySet()) {
            builder.add(entry.getKey(),entry.getValue());
        }

        //创建Request
        Request request = new Request.Builder().url(url).post(builder.build()).build();

        Call call = okHttpClient.newCall(request);
        call.enqueue(callback);

    }

    /**
     * post请求上传文件....包括图片....流的形式传任意文件...
     * 参数1 url
     * file表示上传的文件
     * fileName....文件的名字,,例如aaa.jpg
     * params ....传递除了file文件 其他的参数放到map集合
     *
     */
    public static void uploadFile(String url, File file, String fileName,Map<String,String> params) {
        //创建OkHttpClient请求对象
        OkHttpClient okHttpClient = getInstance();

        MultipartBody.Builder builder = new MultipartBody.Builder();
        builder.setType(MultipartBody.FORM);

        //参数
        if (params != null){
            for (String key : params.keySet()){
                builder.addFormDataPart(key,params.get(key));
            }
        }
        //文件...参数name指的是请求路径中所接受的参数...如果路径接收参数键值是fileeeee,此处应该改变
        builder.addFormDataPart("file",fileName, RequestBody.create(MediaType.parse("application/octet-stream"),file));

        //构建
        MultipartBody multipartBody = builder.build();

        //创建Request
        Request request = new Request.Builder().url(url).post(multipartBody).build();

        //得到Call
        Call call = okHttpClient.newCall(request);
        //执行请求
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                Log.e("upload",e.getLocalizedMessage());
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException
            {
                //上传成功回调 目前不需要处理
                if (response.isSuccessful()){
                    String s = response.body().string();
                    Log.e("upload","上传--"+s);
                }
            }

        });

    }

    /**
     * Post请求发送JSON数据....{"name":"zhangsan","pwd":"123456"}
     * 参数一:请求Url
     * 参数二:请求的JSON
     * 参数三:请求回调
     */
    public static void doPostJson(String url, String jsonParams, Callback callback) {
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonParams);
        Request request = new Request.Builder().url(url).post(requestBody).build();
        Call call = getInstance().newCall(request);
        call.enqueue(callback);

    }

    /**
     * 下载文件 以流的形式把apk写入的指定文件 得到file后进行安装
     * 参数er:请求Url
     * 参数san:保存文件的文件夹....download
     */
    public static void download(final Activity context, final String url, final String saveDir) {
        Request request = new Request.Builder().url(url).build();
        Call call = getInstance().newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                //com.orhanobut.logger.Logger.e(e.getLocalizedMessage());
            }

            @Override
            public void onResponse(Call call, final Response response) throws IOException {

                InputStream is = null;
                byte[] buf = new byte[2048];
                int len = 0;
                FileOutputStream fos = null;
                try {
                    is = response.body().byteStream();//以字节流的形式拿回响应实体内容
                    //apk保存路径
                    final String fileDir = isExistDir(saveDir);
                    //文件
                    File file = new File(fileDir, getNameFromUrl(url));

                    fos = new FileOutputStream(file);
                    while ((len = is.read(buf)) != -1) {
                        fos.write(buf, 0, len);
                    }

                    fos.flush();

                    context.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(context, "下载成功:" + fileDir + "," + getNameFromUrl(url), Toast.LENGTH_SHORT).show();
                        }
                    });

                    //apk下载完成后 调用系统的安装方法
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
                    context.startActivity(intent);


                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    if (is != null) is.close();
                    if (fos != null) fos.close();


                }
            }
        });

    }

    /**
     * 判断下载目录是否存在......并返回绝对路径
     *
     * @param saveDir
     * @return
     * @throws IOException
     */
    public static String isExistDir(String saveDir) throws IOException {
        // 下载位置
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {

            File downloadFile = new File(Environment.getExternalStorageDirectory(), saveDir);
            if (!downloadFile.mkdirs()) {
                downloadFile.createNewFile();
            }
            String savePath = downloadFile.getAbsolutePath();
            Log.e("savePath", savePath);
            return savePath;
        }
        return null;
    }

    /**
     * @param url
     * @return 从下载连接中解析出文件名
     */
    private static String getNameFromUrl(String url) {
        return url.substring(url.lastIndexOf("/") + 1);
    }

    /**
     * 公共参数拦截器
     */
    private static class CommonParamsInterceptor implements Interceptor {

        //拦截的方法
        @Override
        public Response intercept(Chain chain) throws IOException {

            //获取到请求
            Request request = chain.request();
            //获取请求的方式
            String method = request.method();
            //获取请求的路径
            String oldUrl = request.url().toString();

            Log.e("---拦截器",request.url()+"---"+request.method()+"--"+request.header("User-agent"));

            //要添加的公共参数...map
            Map<String,String> map = new HashMap<>();
            map.put("source","android");

            if ("GET".equals(method)){
                // 1.http://www.baoidu.com/login                --------? key=value&key=value
                // 2.http://www.baoidu.com/login?               --------- key=value&key=value
                // 3.http://www.baoidu.com/login?mobile=11111    -----&key=value&key=value

                StringBuilder stringBuilder = new StringBuilder();//创建一个stringBuilder

                stringBuilder.append(oldUrl);

                if (oldUrl.contains("?")){
                    //?在最后面....2类型
                    if (oldUrl.indexOf("?") == oldUrl.length()-1){

                    }else {
                        //3类型...拼接上&
                        stringBuilder.append("&");
                    }
                }else {
                    //不包含? 属于1类型,,,先拼接上?号
                    stringBuilder.append("?");
                }

               //添加公共参数....
                for (Map.Entry<String,String> entry: map.entrySet()) {
                    //拼接
                    stringBuilder.append(entry.getKey())
                            .append("=")
                            .append(entry.getValue())
                            .append("&");
                }

                //删掉最后一个&符号
                if (stringBuilder.indexOf("&") != -1){
                    stringBuilder.deleteCharAt(stringBuilder.lastIndexOf("&"));
                }

                String newUrl = stringBuilder.toString();//新的路径

                //拿着新的路径重新构建请求
                request = request.newBuilder()
                        .url(newUrl)
                        .build();


            }else if ("POST".equals(method)){
                //先获取到老的请求的实体内容
                RequestBody oldRequestBody = request.body();//....之前的请求参数,,,需要放到新的请求实体内容中去

                //如果请求调用的是上面doPost方法
                if (oldRequestBody instanceof FormBody){
                    FormBody oldBody = (FormBody) oldRequestBody;

                    //构建一个新的请求实体内容
                    FormBody.Builder builder = new FormBody.Builder();
                    //1.添加老的参数
                    for (int i=0;i<oldBody.size();i++){
                        builder.add(oldBody.name(i),oldBody.value(i));
                    }
                    //2.添加公共参数
                    for (Map.Entry<String,String> entry:map.entrySet()) {

                        builder.add(entry.getKey(),entry.getValue());
                    }

                    FormBody newBody = builder.build();//新的请求实体内容

                    //构建一个新的请求
                    request = request.newBuilder()
                            .url(oldUrl)
                            .post(newBody)
                            .build();
                }


            }


            Response response = chain.proceed(request);

            return response;
        }
    }

    /**
     * 网络缓存的拦截器......注意在这里更改cache-control头是很危险的,一般客户端不进行更改,,,,服务器端直接指定
     *
     * 没网络取缓存的时候,一般都是在数据库或者sharedPerfernce中取出来的
     *
     *
     *
     */
    /*private static class CacheInterceptor implements Interceptor{

        @Override
        public Response intercept(Chain chain) throws IOException {
            //老的响应
            Response oldResponse = chain.proceed(chain.request());

            *//*if (NetUtils.isNetworkConnected(DashApplication.getAppContext())){
                int maxAge = 120; // 在线缓存在2分钟内可读取

                return oldResponse.newBuilder()
                        .removeHeader("Pragma")
                        .removeHeader("Cache-Control")
                        .header("Cache-Control", "public, max-age=" + maxAge)
                        .build();
            }else {
                int maxStale = 60 * 60 * 24 * 14; // 离线时缓存保存2周
                return oldResponse.newBuilder()
                        .removeHeader("Pragma")
                        .removeHeader("Cache-Control")
                        .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
                        .build();
            }*//*

        }
    }*/
}
自定义View空间图片轮播ZoomImageView
@SuppressLint("AppCompatCustomView")
public class ZoomImageView extends ImageView implements OnGlobalLayoutListener, OnScaleGestureListener, OnTouchListener {

    private boolean mOnce;

    /**
     * 初始化时缩放的值
     */
    private float mInitScale;

    /**
     * 双击放大值到达的值
     */
    private float mMidScale;

    /**
     * 放大的最大值
     */
    private float mMaxScale;

    private Matrix mScaleMatrix;

    /**
     * 捕获用户多指触控时缩放的比例
     */
    private ScaleGestureDetector mScaleGestureDetector;

    // **********自由移动的变量***********
    /**
     * 记录上一次多点触控的数量
     */
    private int mLastPointerCount;

    private float mLastX;
    private float mLastY;

    private int mTouchSlop;
    private boolean isCanDrag;

    private boolean isCheckLeftAndRight;
    private boolean isCheckTopAndBottom;

    // *********双击放大与缩小*********
    private GestureDetector mGestureDetector;

    private boolean isAutoScale;

    public ZoomImageView(Context context) {
        this(context, null);
    }

    public ZoomImageView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ZoomImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // init
        mScaleMatrix = new Matrix();
        setScaleType(ScaleType.MATRIX);
        setOnTouchListener(this);
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        mScaleGestureDetector = new ScaleGestureDetector(context, this);
        mGestureDetector = new GestureDetector(context,
                new GestureDetector.SimpleOnGestureListener() {
                    @Override
                    public boolean onDoubleTap(MotionEvent e) {

                        if (isAutoScale) {
                            return true;
                        }

                        float x = e.getX();
                        float y = e.getY();

                        if (getScale() < mMidScale) {
                            postDelayed(new AutoScaleRunnable(mMidScale, x, y), 16);
                            isAutoScale = true;
                        } else {
                            postDelayed(new AutoScaleRunnable(mInitScale, x, y), 16);
                            isAutoScale = true;
                        }
                        return true;
                    }
                });
    }

    /**
     * 自动放大与缩小
     *
     * @author zhangyan@lzt.com.cn
     *
     */
    private class AutoScaleRunnable implements Runnable {
        /**
         * 缩放的目标值
         */
        private float mTargetScale;
        // 缩放的中心点
        private float x;
        private float y;

        private final float BIGGER = 1.07f;
        private final float SMALL = 0.93f;

        private float tmpScale;

        /**
         * @param mTargetScale
         * @param x
         * @param y
         */
        public AutoScaleRunnable(float mTargetScale, float x, float y) {
            this.mTargetScale = mTargetScale;
            this.x = x;
            this.y = y;

            if (getScale() < mTargetScale) {
                tmpScale = BIGGER;
            }
            if (getScale() > mTargetScale) {
                tmpScale = SMALL;
            }
        }

        @Override
        public void run() {
            //进行缩放
            mScaleMatrix.postScale(tmpScale, tmpScale, x, y);
            checkBorderAndCenterWhenScale();
            setImageMatrix(mScaleMatrix);

            float currentScale = getScale();

            if ((tmpScale >1.0f && currentScale <mTargetScale) ||(tmpScale<1.0f &&currentScale>mTargetScale)) {
                //这个方法是重新调用run()方法
                postDelayed(this, 16);
            }else{
                //设置为我们的目标值
                float scale = mTargetScale/currentScale;
                mScaleMatrix.postScale(scale, scale, x, y);
                checkBorderAndCenterWhenScale();
                setImageMatrix(mScaleMatrix);

                isAutoScale = false;
            }
        }
    }

    /**
     * 获取ImageView加载完成的图片
     */
    @Override
    public void onGlobalLayout() {
        if (!mOnce) {
            // 得到控件的宽和高
            int width = getWidth();
            int height = getHeight();

            // 得到我们的图片,以及宽和高
            Drawable drawable = getDrawable();
            if (drawable == null) {
                return;
            }
            int dh = drawable.getIntrinsicHeight();
            int dw = drawable.getIntrinsicWidth();

            float scale = 0.5f;

            // 图片的宽度大于控件的宽度,图片的高度小于空间的高度,我们将其缩小
            if (dw > width && dh < height) {
                scale = width * 1.0f / dw;
            }

            // 图片的宽度小于控件的宽度,图片的高度大于空间的高度,我们将其缩小
            if (dh > height && dw < width) {
                scale = height * 1.0f / dh;
            }

            // 缩小值
            if (dw > width && dh > height) {
                scale = Math.min(width * 1.0f / dw, height * 1.0f / dh);
            }

            // 放大值
            if (dw < width && dh < height) {
                scale = Math.min(width * 1.0f / dw, height * 1.0f / dh);
            }

            /**
             * 得到了初始化时缩放的比例
             */
            mInitScale = scale;
            mMaxScale = mInitScale * 4;
            mMidScale = mInitScale * 2;

            // 将图片移动至控件的中间
            int dx = getWidth() / 2 - dw / 2;
            int dy = getHeight() / 2 - dh / 2;

            mScaleMatrix.postTranslate(dx, dy);
            mScaleMatrix.postScale(mInitScale, mInitScale, width / 2,
                    height / 2);
            setImageMatrix(mScaleMatrix);

            mOnce = true;
        }
    }

    /**
     * 注册OnGlobalLayoutListener这个接口
     */
    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        getViewTreeObserver().addOnGlobalLayoutListener(this);
    }

    /**
     * 取消OnGlobalLayoutListener这个接口
     */
    @SuppressWarnings("deprecation")
    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        getViewTreeObserver().removeGlobalOnLayoutListener(this);
    }

    /**
     * 获取当前图片的缩放值
     *
     * @return
     */
    public float getScale() {
        float[] values = new float[9];
        mScaleMatrix.getValues(values);
        return values[Matrix.MSCALE_X];
    }

    // 缩放区间时initScale maxScale
    @Override
    public boolean onScale(ScaleGestureDetector detector) {
        float scale = getScale();
        float scaleFactor = detector.getScaleFactor();

        if (getDrawable() == null) {
            return true;
        }

        // 缩放范围的控制
        if ((scale < mMaxScale && scaleFactor > 1.0f)
                || (scale > mInitScale && scaleFactor < 1.0f)) {
            if (scale * scaleFactor < mInitScale) {
                scaleFactor = mInitScale / scale;
            }

            if (scale * scaleFactor > mMaxScale) {
                scale = mMaxScale / scale;
            }

            // 缩放
            mScaleMatrix.postScale(scaleFactor, scaleFactor,
                    detector.getFocusX(), detector.getFocusY());

            checkBorderAndCenterWhenScale();

            setImageMatrix(mScaleMatrix);
        }

        return true;
    }

    /**
     * 获得图片放大缩小以后的宽和高,以及left,right,top,bottom
     *
     * @return
     */
    private RectF getMatrixRectF() {
        Matrix matrix = mScaleMatrix;
        RectF rectF = new RectF();
        Drawable d = getDrawable();
        if (d != null) {
            rectF.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
            matrix.mapRect(rectF);
        }
        return rectF;
    }

    /**
     * 在缩放的时候进行边界以及我们的位置的控制
     */
    private void checkBorderAndCenterWhenScale() {
        RectF rectF = getMatrixRectF();
        float deltaX = 0;
        float deltaY = 0;

        int width = getWidth();
        int height = getHeight();

        // 缩放时进行边界检测,防止出现白边
        if (rectF.width() >= width) {
            if (rectF.left > 0) {
                deltaX = -rectF.left;
            }
            if (rectF.right < width) {
                deltaX = width - rectF.right;
            }
        }

        if (rectF.height() >= height) {
            if (rectF.top > 0) {
                deltaY = -rectF.top;
            }
            if (rectF.bottom < height) {
                deltaY = height - rectF.bottom;
            }
        }

        /**
         * 如果宽度或高度小于空间的宽或者高,则让其居中
         */
        if (rectF.width() < width) {
            deltaX = width / 2f - rectF.right + rectF.width() / 2f;
        }

        if (rectF.height() < height) {
            deltaY = height / 2f - rectF.bottom + rectF.height() / 2f;
        }

        mScaleMatrix.postTranslate(deltaX, deltaY);
    }

    @Override
    public boolean onScaleBegin(ScaleGestureDetector detector) {

        return true;
    }

    @Override
    public void onScaleEnd(ScaleGestureDetector detector) {

    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {

        if (mGestureDetector.onTouchEvent(event)) {
            return true;
        }

        mScaleGestureDetector.onTouchEvent(event);

        float x = 0;
        float y = 0;
        // 拿到多点触控的数量
        int pointerCount = event.getPointerCount();
        for (int i = 0; i < pointerCount; i++) {
            x += event.getX(i);
            y += event.getY(i);
        }

        x /= pointerCount;
        y /= pointerCount;

        if (mLastPointerCount != pointerCount) {
            isCanDrag = false;
            mLastX = x;
            mLastY = y;
        }
        mLastPointerCount = pointerCount;
        RectF rectF = getMatrixRectF();
        switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:
                if (rectF.width()>getWidth() +0.01|| rectF.height()>getHeight()+0.01) {
                    if(getParent() instanceof ViewPager)
                        getParent().requestDisallowInterceptTouchEvent(true);
                }
                break;

            case MotionEvent.ACTION_MOVE:
                if (rectF.width()>getWidth()+0.01 || rectF.height()>getHeight()+0.01) {
                    if(getParent() instanceof ViewPager){
                        Log.e("---","----+++");
                        getParent().requestDisallowInterceptTouchEvent(true);
                    }
                }
                float dx = x - mLastX;
                float dy = y - mLastY;

                if (!isCanDrag) {
                    isCanDrag = isMoveAction(dx, dy);
                }

                if (isCanDrag) {
                    if (getDrawable() != null) {
                        isCheckLeftAndRight = isCheckTopAndBottom = true;
                        // 如果宽度小于控件宽度,不允许横向移动
                        if (rectF.width() < getWidth()) {
                            isCheckLeftAndRight = false;
                            dx = 0;
                        }
                        // 如果高度小于控件高度,不允许纵向移动
                        if (rectF.height() < getHeight()) {
                            isCheckTopAndBottom = false;
                            dy = 0;
                        }
                        mScaleMatrix.postTranslate(dx, dy);

                        checkBorderWhenTranslate();

                        setImageMatrix(mScaleMatrix);
                    }
                }
                mLastX = x;
                mLastY = y;
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mLastPointerCount = 0;
                break;

            default:
                break;
        }

        return true;
    }

    /**
     * 当移动时进行边界检查
     */
    private void checkBorderWhenTranslate() {
        RectF rectF = getMatrixRectF();
        float deltaX = 0;
        float deltaY = 0;

        int width = getWidth();
        int heigth = getHeight();

        if (rectF.top > 0 && isCheckTopAndBottom) {
            deltaY = -rectF.top;
        }
        if (rectF.bottom < heigth && isCheckTopAndBottom) {
            deltaY = heigth - rectF.bottom;
        }
        if (rectF.left > 0 && isCheckLeftAndRight) {
            deltaX = -rectF.left;
        }
        if (rectF.right < width && isCheckLeftAndRight) {
            deltaX = width - rectF.right;
        }
        mScaleMatrix.postTranslate(deltaX, deltaY);

    }

    /**
     * 判断是否是move
     *
     * @param dx
     * @param dy
     * @return
     */
    private boolean isMoveAction(float dx, float dy) {
        return Math.sqrt(dx * dx + dy * dy) > mTouchSlop;
    }
}

加载图片工具类
class GlideImageLoader extends ImageLoader {
    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        Glide.with(context).load(path).into(imageView);
    }
}

购物车适配器
public class MyGroupAdapter extends RecyclerView.Adapter<MyGroupAdapter.MyGridHolder>
{
    private final Context context;
    private final List<MySouSuoLieBiaoBean.DataBean> list;
    private ItemListenner itemListenner;
    public MyGroupAdapter(Context context, List<MySouSuoLieBiaoBean.DataBean> list) {

        this.context = context;
        this.list = list;
    }

    @Override
    public MyGridHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_grider, parent, false);
        MyGridHolder holder = new MyGridHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(MyGridHolder holder, final int position) {
        String[] split = list.get(position).getImages().split("\\|");
        Glide.with(context).load(split[0]).into(holder.image_grid);
        holder.grid_title.setText(list.get(position).getTitle());
        holder.grid_price.setText("折扣价:"+list.get(position).getPrice());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                itemListenner.OnItemClick(position);
            }
        });
        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                itemListenner.OnLongClick(position);
                return true;
            }
        });


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

    public void setItemClicked(ItemListenner itemListenner){

        this.itemListenner = itemListenner;
    }
    class MyGridHolder extends RecyclerView.ViewHolder{

        public ImageView image_grid;
        public TextView grid_title;
        public TextView grid_price;

        public MyGridHolder(View itemView) {
            super(itemView);
            image_grid = itemView.findViewById(R.id.image_grid);
            grid_title = itemView.findViewById(R.id.grid_title);
            grid_price = itemView.findViewById(R.id.grid_price);
        }
}
}

搜索列表适配器
public class MySouSuoLieBiaoAdapter extends RecyclerView.Adapter<MySouSuoLieBiaoAdapter.MyLieBiaoHolder>
{
    private final Context context;
    private final List<MySouSuoLieBiaoBean.DataBean> list;
    private ItemListenner itemListenner;

    public MySouSuoLieBiaoAdapter(Context context, List<MySouSuoLieBiaoBean.DataBean> list) {

        this.context = context;
        this.list = list;
    }

    @Override
    public MyLieBiaoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_linaer, parent, false);
        MyLieBiaoHolder holder = new MyLieBiaoHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyLieBiaoHolder holder, final int position) {
        String[] split = list.get(position).getImages().split("\\|");
        Glide.with(context).load(split[0]).into(holder.image_linaer);
        holder.text_title.setText(list.get(position).getTitle());
        holder.text_price.setText("折扣价:"+list.get(position).getPrice());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                itemListenner.OnItemClick(position);
            }
        });
        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                itemListenner.OnLongClick(position);
                return true;
            }
        });

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

    public void setItemListenner(ItemListenner itemListenner) {
        this.itemListenner = itemListenner;
    }

    class MyLieBiaoHolder extends RecyclerView.ViewHolder {

        public ImageView image_linaer;
        public TextView text_title;
        public TextView text_price;

        public MyLieBiaoHolder(View itemView) {
            super(itemView);
            image_linaer = itemView.findViewById(R.id.image_linaer);
            text_title = itemView.findViewById(R.id.text_title);
            text_price = itemView.findViewById(R.id.text_price);

        }
    }

}
登录解析Bean
public class LoginBean
{
    /**
     * msg : 登录成功
     * code : 0
     * data : {"age":null,"appkey":"47155d590883b93b","appsecret":"2B0B5A2B6DB8DC5A6396F9957C48DC16","createtime":"2018-01-08T09:53:50","email":null,"fans":null,"follow":null,"gender":null,"icon":null,"latitude":null,"longitude":null,"mobile":"13193929508","money":null,"nickname":null,"password":"8F669074CAF5513351A2DE5CC22AC04C","praiseNum":null,"token":"CBF39FD8E3CA8CEDC2ABECAF4F603D2F","uid":10163,"userId":null,"username":"13193929508"}
     */

    private String msg;
    private String code;
    private DataBean data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * age : null
         * appkey : 47155d590883b93b
         * appsecret : 2B0B5A2B6DB8DC5A6396F9957C48DC16
         * createtime : 2018-01-08T09:53:50
         * email : null
         * fans : null
         * follow : null
         * gender : null
         * icon : null
         * latitude : null
         * longitude : null
         * mobile : 13193929508
         * money : null
         * nickname : null
         * password : 8F669074CAF5513351A2DE5CC22AC04C
         * praiseNum : null
         * token : CBF39FD8E3CA8CEDC2ABECAF4F603D2F
         * uid : 10163
         * userId : null
         * username : 13193929508
         */

        private Object age;
        private String appkey;
        private String appsecret;
        private String createtime;
        private Object email;
        private Object fans;
        private Object follow;
        private Object gender;
        private Object icon;
        private Object latitude;
        private Object longitude;
        private String mobile;
        private Object money;
        private Object nickname;
        private String password;
        private Object praiseNum;
        private String token;
        private int uid;
        private Object userId;
        private String username;

        public Object getAge() {
            return age;
        }

        public void setAge(Object age) {
            this.age = age;
        }

        public String getAppkey() {
            return appkey;
        }

        public void setAppkey(String appkey) {
            this.appkey = appkey;
        }

        public String getAppsecret() {
            return appsecret;
        }

        public void setAppsecret(String appsecret) {
            this.appsecret = appsecret;
        }

        public String getCreatetime() {
            return createtime;
        }

        public void setCreatetime(String createtime) {
            this.createtime = createtime;
        }

        public Object getEmail() {
            return email;
        }

        public void setEmail(Object email) {
            this.email = email;
        }

        public Object getFans() {
            return fans;
        }

        public void setFans(Object fans) {
            this.fans = fans;
        }

        public Object getFollow() {
            return follow;
        }

        public void setFollow(Object follow) {
            this.follow = follow;
        }

        public Object getGender() {
            return gender;
        }

        public void setGender(Object gender) {
            this.gender = gender;
        }

        public Object getIcon() {
            return icon;
        }

        public void setIcon(Object icon) {
            this.icon = icon;
        }

        public Object getLatitude() {
            return latitude;
        }

        public void setLatitude(Object latitude) {
            this.latitude = latitude;
        }

        public Object getLongitude() {
            return longitude;
        }

        public void setLongitude(Object longitude) {
            this.longitude = longitude;
        }

        public String getMobile() {
            return mobile;
        }

        public void setMobile(String mobile) {
            this.mobile = mobile;
        }

        public Object getMoney() {
            return money;
        }

        public void setMoney(Object money) {
            this.money = money;
        }

        public Object getNickname() {
            return nickname;
        }

        public void setNickname(Object nickname) {
            this.nickname = nickname;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public Object getPraiseNum() {
            return praiseNum;
        }

        public void setPraiseNum(Object praiseNum) {
            this.praiseNum = praiseNum;
        }

        public String getToken() {
            return token;
        }

        public void setToken(String token) {
            this.token = token;
        }

        public int getUid() {
            return uid;
        }

        public void setUid(int uid) {
            this.uid = uid;
        }

        public Object getUserId() {
            return userId;
        }

        public void setUserId(Object userId) {
            this.userId = userId;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }
    }
}

加入购物车Bean
public class MyJiaRuGouWuCheBean {

    /**
     * msg :
     * seller : {"description":"我是商家12","icon":"http://120.27.23.105/images/icon.png","name":"商家12","productNums":999,"score":5,"sellerid":12}
     * code : 0
     * data : {"bargainPrice":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","itemtype":1,"pid":56,"price":99,"pscid":39,"salenum":757,"sellerid":12,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}
     */

    private String msg;
    private SellerBean seller;
    private String code;
    private DataBean data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public SellerBean getSeller() {
        return seller;
    }

    public void setSeller(SellerBean seller) {
        this.seller = seller;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class SellerBean {
        /**
         * description : 我是商家12
         * icon : http://120.27.23.105/images/icon.png
         * name : 商家12
         * productNums : 999
         * score : 5.0
         * sellerid : 12
         */

        private String description;
        private String icon;
        private String name;
        private int productNums;
        private double score;
        private int sellerid;

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getIcon() {
            return icon;
        }

        public void setIcon(String icon) {
            this.icon = icon;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getProductNums() {
            return productNums;
        }

        public void setProductNums(int productNums) {
            this.productNums = productNums;
        }

        public double getScore() {
            return score;
        }

        public void setScore(double score) {
            this.score = score;
        }

        public int getSellerid() {
            return sellerid;
        }

        public void setSellerid(int sellerid) {
            this.sellerid = sellerid;
        }
    }

    public static class DataBean {
        /**
         * bargainPrice : 3455.0
         * createtime : 2017-10-14T21:38:26
         * detailUrl : https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends
         * images : https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg
         * itemtype : 1
         * pid : 56
         * price : 99.0
         * pscid : 39
         * salenum : 757
         * sellerid : 12
         * subhead : 【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机
         * title : 小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】
         */

        private double bargainPrice;
        private String createtime;
        private String detailUrl;
        private String images;
        private int itemtype;
        private int pid;
        private double price;
        private int pscid;
        private int salenum;
        private int sellerid;
        private String subhead;
        private String title;

        public double getBargainPrice() {
            return bargainPrice;
        }

        public void setBargainPrice(double bargainPrice) {
            this.bargainPrice = bargainPrice;
        }

        public String getCreatetime() {
            return createtime;
        }

        public void setCreatetime(String createtime) {
            this.createtime = createtime;
        }

        public String getDetailUrl() {
            return detailUrl;
        }

        public void setDetailUrl(String detailUrl) {
            this.detailUrl = detailUrl;
        }

        public String getImages() {
            return images;
        }

        public void setImages(String images) {
            this.images = images;
        }

        public int getItemtype() {
            return itemtype;
        }

        public void setItemtype(int itemtype) {
            this.itemtype = itemtype;
        }

        public int getPid() {
            return pid;
        }

        public void setPid(int pid) {
            this.pid = pid;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public int getPscid() {
            return pscid;
        }

        public void setPscid(int pscid) {
            this.pscid = pscid;
        }

        public int getSalenum() {
            return salenum;
        }

        public void setSalenum(int salenum) {
            this.salenum = salenum;
        }

        public int getSellerid() {
            return sellerid;
        }

        public void setSellerid(int sellerid) {
            this.sellerid = sellerid;
        }

        public String getSubhead() {
            return subhead;
        }

        public void setSubhead(String subhead) {
            this.subhead = subhead;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}
搜索列表Bean
public class MySouSuoLieBiaoBean
{
    /**
     * msg : 查询成功
     * code : 0
     * data : [{"bargainPrice":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg","itemtype":0,"pid":57,"price":5199,"pscid":40,"salenum":4343,"sellerid":1,"subhead":"【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统","title":"小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银\r\n"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","itemtype":1,"pid":58,"price":6399,"pscid":40,"salenum":545,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"},{"bargainPrice":5599,"createtime":"2017-10-10T17:30:32","detailUrl":"https://item.m.jd.com/product/4824715.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n12/jfs/t7768/184/1153704394/148460/f42e1432/599a930fN8a85626b.jpg!q70.jpg","itemtype":0,"pid":59,"price":5599,"pscid":40,"salenum":675,"sellerid":3,"subhead":"游戏本选择4G独显,拒绝掉帧】升级版IPS全高清防眩光显示屏,WASD方向键颜色加持,三大出风口立体散热!","title":"戴尔DELL灵越游匣15PR-6648B GTX1050 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 128GSSD+1T 4G独显 IPS)黑"},{"bargainPrice":11800,"createtime":"2017-10-14T21:48:08","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":2,"pid":60,"price":13888,"pscid":40,"salenum":466,"sellerid":4,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":1,"pid":61,"price":14999,"pscid":40,"salenum":5535,"sellerid":5,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":0,"pid":62,"price":15999,"pscid":40,"salenum":43,"sellerid":6,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":1,"pid":63,"price":10000,"pscid":40,"salenum":3232,"sellerid":7,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-03T23:43:53","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":0,"pid":64,"price":11000,"pscid":40,"salenum":0,"sellerid":8,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:48:08","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":2,"pid":65,"price":12000,"pscid":40,"salenum":868,"sellerid":9,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","itemtype":1,"pid":66,"price":13000,"pscid":40,"salenum":7676,"sellerid":10,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}]
     * page : 1
     */

    private String msg;
    private String code;
    private String page;
    private List<DataBean> data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * bargainPrice : 11800.0
         * createtime : 2017-10-10T17:33:37
         * detailUrl : https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends
         * images : https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg
         * itemtype : 0
         * pid : 57
         * price : 5199.0
         * pscid : 40
         * salenum : 4343
         * sellerid : 1
         * subhead : 【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统
         * title : 小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银

         */

        private double bargainPrice;
        private String createtime;
        private String detailUrl;
        private String images;
        private int itemtype;
        private int pid;
        private double price;
        private int pscid;
        private int salenum;
        private int sellerid;
        private String subhead;
        private String title;

        public double getBargainPrice() {
            return bargainPrice;
        }

        public void setBargainPrice(double bargainPrice) {
            this.bargainPrice = bargainPrice;
        }

        public String getCreatetime() {
            return createtime;
        }

        public void setCreatetime(String createtime) {
            this.createtime = createtime;
        }

        public String getDetailUrl() {
            return detailUrl;
        }

        public void setDetailUrl(String detailUrl) {
            this.detailUrl = detailUrl;
        }

        public String getImages() {
            return images;
        }

        public void setImages(String images) {
            this.images = images;
        }

        public int getItemtype() {
            return itemtype;
        }

        public void setItemtype(int itemtype) {
            this.itemtype = itemtype;
        }

        public int getPid() {
            return pid;
        }

        public void setPid(int pid) {
            this.pid = pid;
        }

        public double getPrice() {
            return price;
        }

        public void setPrice(double price) {
            this.price = price;
        }

        public int getPscid() {
            return pscid;
        }

        public void setPscid(int pscid) {
            this.pscid = pscid;
        }

        public int getSalenum() {
            return salenum;
        }

        public void setSalenum(int salenum) {
            this.salenum = salenum;
        }

        public int getSellerid() {
            return sellerid;
        }

        public void setSellerid(int sellerid) {
            this.sellerid = sellerid;
        }

        public String getSubhead() {
            return subhead;
        }

        public void setSubhead(String subhead) {
            this.subhead = subhead;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}

登录注册

<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"
    android:orientation="vertical"
    tools:context=".Activity.LoginActivity">

    <TextView
        android:id="@+id/login"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:background="@android:color/white"
        android:gravity="center"
        android:text="登录"
        android:textSize="18dp" />

    <EditText
        android:id="@+id/et_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入手机号" />

    <EditText
        android:id="@+id/et_pass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >

        <Button
            android:id="@+id/button3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="Login"
            android:text="登录"
            android:background="@android:color/white"
            android:layout_margin="5dp"
            />

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:onClick="zc"
            android:text="注册"
            android:background="@android:color/white"
            android:layout_margin="5dp"
            />
    </LinearLayout>

</LinearLayout>

注册页面
<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"
    android:orientation="vertical"
    tools:context="com.example.ruiyonghui.yue_demo2.Activity.ZhuceActivity">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_user"
        android:hint="请输入账号"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_mima"
        android:hint="请输入密码"
        />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="zhuce"
        android:text="注册"
        />
</LinearLayout>

搜索布局
<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=".Activity.SousuoActivity">
    <LinearLayout
        android:id="@+id/linear_edit"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">
        <ImageView
            android:id="@+id/btn_image"
            android:src="@drawable/leftjiantou"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:layout_height="40dp" />
        <RelativeLayout
            android:id="@+id/relative_layout"
            android:clickable="true"
            android:layout_width="0dp"
            android:layout_weight="6"
            android:background="@drawable/sousuo"
            android:layout_height="40dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:orientation="horizontal">
                <ImageView
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_gravity="center"
                    android:layout_height="25dp"
                    android:src="@drawable/a_4"/>
                <EditText
                    android:id="@+id/edit_sousuo"
                    android:layout_width="0dp"
                    android:layout_weight="5"
                    android:gravity="center"
                    android:layout_height="40dp"
                    android:background="@null"
                    android:hint="鞋靴超级品类日 领券..."
                    />
                <ImageView
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_gravity="center"
                    android:layout_height="25dp"
                    android:src="@drawable/root"/>
            </LinearLayout>

        </RelativeLayout>
        <TextView
            android:id="@+id/btn_sousuo"
            android:clickable="true"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="50dp"
            android:gravity="center_vertical"
            android:layout_marginLeft="5dp"
            android:textSize="15sp"
            android:text="搜索"/>
    </LinearLayout>
</RelativeLayout>

搜索列表布局
<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"
    android:orientation="vertical"
    tools:context=".Activity.SouSuoLieBiaoActivity">
    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:id="@+id/smartrefresh_liebiao"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <LinearLayout
                    android:id="@+id/line"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:orientation="horizontal">

                    <ImageView
                        android:id="@+id/image_fanhuishouye"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:background="@drawable/leftjiantou"
                        android:clickable="true" />

                    <RelativeLayout
                        android:id="@+id/relative_sousuoliebiao"
                        android:clickable="true"
                        android:layout_width="0dp"
                        android:layout_weight="5"
                        android:background="@drawable/sousuo"
                        android:layout_height="40dp">
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="40dp"
                            android:orientation="horizontal">
                            <ImageView
                                android:layout_width="0dp"
                                android:layout_weight="1"
                                android:layout_gravity="center"
                                android:layout_height="25dp"
                                android:src="@drawable/a_4"/>

                            <TextView
                                android:id="@+id/sousuo_liebiao"
                                android:layout_width="0dp"
                                android:layout_height="40dp"
                                android:layout_weight="5"
                                android:gravity="center"
                                android:text="鞋靴超级品类日 领券满499减..." />

                            <ImageView
                                android:layout_width="0dp"
                                android:layout_weight="1"
                                android:layout_gravity="center"
                                android:layout_height="25dp"
                                android:src="@drawable/root"/>
                        </LinearLayout>

                    </RelativeLayout>
                    <ImageView
                        android:id="@+id/image_qiehuan"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="match_parent"
                        android:src="@drawable/kind_grid"/>
                </LinearLayout>

                <com.jcodecraeer.xrecyclerview.XRecyclerView
                    android:nestedScrollingEnabled="false"
                    android:id="@+id/xrecycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"></com.jcodecraeer.xrecyclerview.XRecyclerView>

            </LinearLayout>
        </ScrollView>
    </com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>

加入购物车详情页面布局
<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"
    android:orientation="vertical"
    tools:context=".Activity.JiaRuGouWuCheActivity">

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="200dp">

    </android.support.v4.view.ViewPager>
    <TextView
        android:id="@+id/jiaru_title"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLines="2"
        android:text="www"/>
    <TextView
        android:id="@+id/jiaru_price"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#ff0000"
        android:text="www"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn_jiaru"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="加入购物车" />
    </LinearLayout>
</LinearLayout>
加入购物车轮播的布局
<android.support.constraint.ConstraintLayout 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.example.ruiyonghui.yue_demo2.Activity.JiaRuGouWuCheLunBoTuTiaoZhuanActivity">
    <!--<com.youth.banner.Banner-->
        <!--android:id="@+id/Mybanner_dianjilunbotu"-->
        <!--android:layout_width="match_parent"-->
        <!--android:layout_height="200dp"-->
        <!--&gt;</com.youth.banner.Banner>-->
    <android.support.v4.view.ViewPager
        android:layout_centerInParent="true"
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </android.support.v4.view.ViewPager>
</android.support.constraint.ConstraintLayout>

item_linaer
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/image_linaer"
        android:layout_width="100dp"
        android:layout_height="100dp" />

    <TextView
        android:id="@+id/text_title"
        android:layout_toRightOf="@+id/image_linaer"
        android:layout_alignTop="@id/image_linaer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/text_price"
        android:textColor="#ff0000"
        android:layout_toRightOf="@+id/image_linaer"
        android:layout_alignBottom="@id/image_linaer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>

item_grider
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/image_grid"
        android:layout_width="220dp"
        android:layout_height="220dp" />

    <TextView
        android:id="@+id/grid_title"
        android:layout_below="@+id/image_grid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/grid_price"
        android:layout_below="@+id/grid_title"
        android:textColor="#ff0000"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>

drawable
sousuo
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="40dp" android:topLeftRadius="20dp" android:bottomLeftRadius="20dp" android:topRightRadius="20dp" android:bottomRightRadius="20dp"/>
    <solid android:color="#fff"/>
</shape>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现一个完整的登录注册登录跳转主页的项目,我们可以使用Bootstrap和jQuery来实现。 首先,我们需要创建一个登录页面和一个注册页面。使用Bootstrap可以快速构建一个具有响应式布局的页面,使用它的各种组件和样式可以使页面更加美观和易于使用。 在登录页面,我们可以创建一个包含输入框和提交按钮的表单。使用jQuery可以监听表单的提交事件,并获取用户输入的用户名和密码。 然后,我们可以通过Ajax技术将用户输入的用户名和密码发送给服务器端进行验证。在服务器端,我们可以使用后端语言(如PHP或Node.js)来处理登录请求,并验证用户的用户名和密码是否正确。如果验证成功,服务器可以返回一个成功的响应。 在客户端,我们可以根据服务器返回的响应来判断用户是否成功登录。如果登录成功,我们可以使用jQuery重定向用户到主页。可以通过修改window.location.href来实现页面的跳转。 对于注册页面,我们可以创建一个包含输入框和提交按钮的表单,类似于登录页面的处理方法,只是需要将用户输入的信息发送到服务器端进行注册。 在主页中,我们可以使用Bootstrap来构建一个漂亮的用户界面,并使用jQuery来处理用户在主页上的交互和事件。 总之,通过使用Bootstrap和jQuery,我们可以实现一个完整的登录注册登录跳转主页的项目。通过它们提供的功能和特性,可以使我们的项目更加易于使用和美观。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值