<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/bigphotobrows/ImageBrowsePresenter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.bigphotobrows;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.Target;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/5/24 9:45
 * 描述	      ${TODO}
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class ImageBrowsePresenter implements Runnable{

    private ImageBrowseView view;
    private List<String> images;
    private int position;
    private String[] imageTypes = new String[] { ".jpg",".png", ".jpeg","webp"};
    public ImageBrowsePresenter(ImageBrowseView view) {
        this.view = view;
    }

    public void loadImage(){
        Intent intent = view.getDataIntent();
        images = intent.getStringArrayListExtra("images");
        position = intent.getIntExtra("position",0);
        view.setImageBrowse(images,position);
    }

    /**
     * 利用glide加载图片时,一定要放在线程中,不然会报错
     */
    @Override
    public void run() {
        final String imageUrl = getPositionImage();
        Bitmap bitmap = null;
        try {
             bitmap = Glide.with(view.getMyContext()).asBitmap().load(imageUrl).into(Target.SIZE_ORIGINAL, Target
                    .SIZE_ORIGINAL).get();
            if (bitmap!=null){
                saveBitmap(bitmap,imageUrl);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    private void saveBitmap(Bitmap bitmap,String url) {
        // 创建目录
        //获取内部存储状态  
        String state =Environment.getExternalStorageState();
        //如果状态不是mounted，无法读写  
        if(!state.equals(Environment.MEDIA_MOUNTED)){
            return;
        }
        //String sdCardDir=Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/";
        // TODO: 2017/8/8 暂时改动 
        String sdCardDir=Environment.getExternalStorageDirectory().getAbsolutePath();
        File appDir = new File(sdCardDir, "DAYU");
        if (!appDir.exists()) {
            appDir.mkdir();
        }
        String imageType = getImageType(url); //获取图片类型
        String fileName = "DAYU"+System.currentTimeMillis() + "." + imageType;
        File file = new File(appDir, fileName);
        //保存图片
        try {
            FileOutputStream fos = new FileOutputStream(file);
            if(TextUtils.equals(imageType,"jpg")) imageType = "jpeg";
            imageType = imageType.toUpperCase();
            bitmap.compress(Bitmap.CompressFormat.valueOf(imageType), 100, fos);
            fos.flush();
            fos.close();
            Toast.makeText(view.getMyContext(),"保存成功",Toast.LENGTH_SHORT).show(); //Toast
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        // 其次把文件插入到系统图库
        try {
            MediaStore.Images.Media.insertImage(view.getMyContext().getContentResolver(), file.getAbsolutePath(), fileName, null);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        // 最后通知图库更新
        view.getMyContext().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file.getPath())));
    }

    public String getPositionImage(){
        return images.get(position);
    }

    public List<String> getImages() {
        return images;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public String getImageType(String imageUrl){
        String imageType = "";
        if(imageUrl.endsWith(imageTypes[0])){
            imageType = "jpg";
        }else if(imageUrl.endsWith(imageTypes[1])){
            imageType = "png";
        }else{
            imageType = "jpeg";
        }
        return imageType;
    }
}



<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/dialog/ConfirmDialog.java<|end_filename|>
package com.example.lwd18.pictureselecotor.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.example.lwd18.pictureselecotor.R;

/**
 * Created by EtherealPatrick on 2017/3/27.
 */

public class ConfirmDialog extends Dialog {

  @BindView(R.id.tv_confirm_title) TextView tvConfirmTitle;
  @BindView(R.id.tv_confirm_cancel) TextView tvConfirmCancel;
  @BindView(R.id.tv_confirm_ensure) TextView tvConfirmEnsure;
  private Context context;
  private String msg;

  public ConfirmDialog(@NonNull Context context) {
    super(context, R.style.MyDialog);
    this.context = context;
  }

  public ConfirmDialog(@NonNull Context context,String msg) {
    super(context, R.style.MyDialog);
    this.context = context;
    this.msg = msg;
  }

  @Override public void show() {
    super.show();
    Window dialogWindow = getWindow();
    WindowManager.LayoutParams lp = dialogWindow.getAttributes();
    dialogWindow.setGravity(Gravity.CENTER);
    dialogWindow.setAttributes(lp);
  }

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog_confirm_center);
    ButterKnife.bind(this);
    if (msg == null){
      tvConfirmTitle.setText("是否删除所有历史记录?");
    }else {
      tvConfirmTitle.setText(msg);
    }

    tvConfirmCancel.setText("取消");
    tvConfirmEnsure.setText("确定");
  }

  private DeepConfirmListener mDeepConfirmListener;
  public void setOnDeepConfirmListener(DeepConfirmListener deepConfirmListener){
    this.mDeepConfirmListener = deepConfirmListener;

  }

  @OnClick({ R.id.tv_confirm_cancel, R.id.tv_confirm_ensure }) public void onClick(View view) {
    switch (view.getId()) {
      case R.id.tv_confirm_cancel:
        mDeepConfirmListener.onSelectCancel();
        break;
      case R.id.tv_confirm_ensure:
        mDeepConfirmListener.onSelectEnsure();
        break;
    }
  }

  public interface DeepConfirmListener{
    void onSelectCancel();
    void onSelectEnsure();
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/bigphotobrows/utils/WindowUtil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.bigphotobrows.utils;

import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.view.View;

/**
 * 创建者     李文东
 * 创建时间   2017/5/24 9:45
 * 描述	      窗体操作工具
 * 界面背景颜色的修改，控件x,y坐标的获取，屏幕宽和高的获取
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class WindowUtil {
    /**
     * 屏幕宽度
     */
    private int screenWidth;
    /**
     * 屏幕宽度
     */
    private int screenHeight;

    private static class WindowUtilInstance{

        private static WindowUtil instance = new WindowUtil();

    }

    /**
     * 获得单例对象
     * @return
     */
    public static WindowUtil getInstance(){
        return WindowUtilInstance.instance;
    }


    private WindowUtil(){}

    /**
     * 获取屏幕的宽
     * @param context Context
     * @return 屏幕的宽
     */
    public int getScreenWidth(Activity context){
        if(context == null){
            return 0;
        }
        if(screenWidth != 0){
            return screenWidth;
        }
        DisplayMetrics dm = new DisplayMetrics();
        context.getWindowManager().getDefaultDisplay().getMetrics(dm);
        screenWidth = dm.widthPixels;
        return screenWidth;
    }

    /**
     * 获取屏幕的高
     * @param context Context
     * @return 屏幕的高
     */
    public int getScreenHeight(Activity context){
        if(context == null){
            return 0;
        }
        if(screenHeight != 0){
            return  screenHeight;
        }
        DisplayMetrics dm = new DisplayMetrics();
        context.getWindowManager().getDefaultDisplay().getMetrics(dm);
        screenHeight = dm.heightPixels;
        return screenHeight;
    }

    /**
     * 获取控件的位置
     * @param view 控件View
     * @return int[] x,y
     */
    public int[] getViewLocation(View view){
        int[] location = new int[2]; //获取筛选按钮的x坐标
        view.getLocationOnScreen(location);
        return location;
    }


    public int getStateBarHeight(Context context){
        Rect rect= new Rect();
        Activity activity = (Activity) context;
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
        int statusBarHeight = rect.top;
        return  statusBarHeight;
    }

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/itemadapter/GoodSAttrRvFAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.itemadapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.textsearch.vo.SaleAttributeVo;
import java.util.ArrayList;
import java.util.List;



/**
 * 创建者     李文东
 * 创建时间   2017/7/10 15:38
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class GoodSAttrRvFAdapter extends RecyclerView.Adapter<GoodSAttrRvFAdapter.MyAdapter> {
  private Context context;
  private List<SaleAttributeVo> data = new ArrayList<>();

  public GoodSAttrRvFAdapter(Context context) {
    this.context = context;
  }

  @Override
  public GoodSAttrRvFAdapter.MyAdapter onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = View.inflate(parent.getContext(), R.layout.gv_right_sideslip_child_layout, null);
    return new MyAdapter(view);
  }

  @Override public void onBindViewHolder(GoodSAttrRvFAdapter.MyAdapter holder, final int position) {
    holder.attr.setText(data.get(position).getValue());
    /**
     * 根据选中状态来设置item的背景和字体颜色
     */
    if (data.get(position).isChecked()) {
      holder.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
      holder.attr.setTextColor(Color.WHITE);
    } else {
      holder.attr.setBackgroundResource(R.drawable.goods_attr_unselected_shape);
      holder.attr.setTextColor(Color.GRAY);
    }
    holder.attr.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        if (onClickListener!=null){
          onClickListener.itemClick(position);
        }
      }
    });
  }

  @Override public int getItemCount() {
    return data == null ? 0 : data.size();
  }

  public class MyAdapter extends RecyclerView.ViewHolder {
    public TextView attr;

    public MyAdapter(View itemView) {
      super(itemView);
      attr = (TextView) itemView.findViewById(R.id.item_frameRb);
    }
  }

  public void notifyDataSetChanged(boolean isUnfold, final List<SaleAttributeVo> tempData) {
    if (tempData == null || 0 == tempData.size()) {
      return;
    }
    data.clear();
    // 如果是展开的，则加入全部data，反之则只显示3条
    if (isUnfold) {
      data.addAll(tempData);
    } else {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
    }
    notifyDataSetChanged();
  }

  private OnClickListener onClickListener;
  public void setOnClickListeners(OnClickListener clickListener){
    this.onClickListener=clickListener;
  }
  public interface OnClickListener {
    void itemClick(int position);
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/TextPriceEventUtil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

/**
 * 创建者     李文东
 * 创建时间   2017/7/12 11:16
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class TextPriceEventUtil {
  private int sort;
  public TextPriceEventUtil(){

  }
  public TextPriceEventUtil(int  sort){
    this.sort=sort;
  }
  public int getSort(){
    return this.sort;
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/BaseDeepActivity.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import android.os.Bundle;

/**
 * Created by EtherealPatrick on 2017/2/13.
 */

public abstract class BaseDeepActivity extends BaseActivity {

  /**
   * hook listener
   */
  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {
      initActivity();
    } catch (Exception e) {
      e.printStackTrace();
    }

  }


  protected abstract void initActivity();


  @Override protected void onDestroy() {
    super.onDestroy();
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/MeasureSpecUtil.java<|end_filename|>
package com.deepbaytech.deeplibrary;

import android.view.View.MeasureSpec;

public class MeasureSpecUtil {

	/**
	 * 打印宽和高测量规格的具体信息（大小和模式)
	 * @param widthMeasureSpec 宽度测量规格
	 * @param heightMeasureSpec 宽度测量规格
	 */
	public static void printMeasureSpec(int widthMeasureSpec, int heightMeasureSpec) {
		String widthModeStr = getMode(widthMeasureSpec);
		String heightModeStr = getMode(heightMeasureSpec);
//		Log.i("MeasureSpecUtil", "宽模式：" + widthModeStr + ", 宽：" + MeasureSpec.getSize(widthMeasureSpec));
//		Log.i("MeasureSpecUtil", "高模式：" + heightModeStr+ ", 高：" + MeasureSpec.getSize(heightMeasureSpec));
	}

	/** 获取字符串模式 */
	private static String getMode(int measureSpec) {
		int mode = MeasureSpec.getMode(measureSpec);
		String modeStr = (mode == MeasureSpec.EXACTLY) 
				         ? "EXACTLY" : (mode == MeasureSpec.AT_MOST) ? "AT_MOST" : "UNSPECIFIED";
		return modeStr;
	}

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/bigphotobrows/ImageBrowseView.java<|end_filename|>
package com.example.lwd18.pictureselecotor.bigphotobrows;

import android.content.Context;
import android.content.Intent;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/5/24 9:45
 * 描述	      ${TODO}
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public interface ImageBrowseView {

    Intent getDataIntent();

    void setImageBrowse(List<String> images, int position);

    Context getMyContext();
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/utils/ImageCacheUtils.java<|end_filename|>
package com.deepbaytech.deeplibrary.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaScannerConnection;
import android.os.Handler;
import android.os.Message;
import android.support.v4.util.LruCache;
import android.util.Log;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by EtherealPatrick on 2016/7/11.
 */
public class ImageCacheUtils {


    private static final int SUCCESS = 100;
    private static final int FAIL = 101;
    private LruCache<String, Bitmap> lruCache;
    private File cacheDir;
    private ExecutorService newFixedThreadPool;

    private Handler mHandler;


    public ImageCacheUtils(Context context, Handler handler){
        int maxSize = (int) (Runtime.getRuntime().maxMemory()/8);
        //maxSize : 缓存的最大空间，一般都是内存的八分之一
        lruCache = new LruCache<String, Bitmap>(maxSize){
            //获取移除图片的大小
            protected int sizeOf(String key, Bitmap value) {
                //getRowBytes() : 图片一行占用的空间
                return value.getRowBytes()*value.getHeight();
            }
        };
        cacheDir = context.getCacheDir();
        //nThreads : 线程池中的线程的数量
        newFixedThreadPool = Executors.newFixedThreadPool(5);
        this.mHandler = handler;
    }

    /**
     * 根据图片的路径获取相应的图片
     * @return
     */
    public Bitmap getBitmap(String url,int position){
        //1.从内存获取图片
        //LruCache<K, V> ;//key：表示图片的名称，value：图片
        //lruCache.put(key, value);//保存图片到缓存中，key:表示图片的名称，value：图片
        Bitmap bitmap = lruCache.get(url);//根据key获取对应的bitmap图片
        if (bitmap!=null) {
            return bitmap;
        }
        //2.从本地缓存中获取图片，并保存到内存中
        bitmap = getBitmapFromLocal(url);
        if (bitmap!=null) {
            return bitmap;
        }
        //3.从网络获取图片，并保存到本地缓存和内存中
        getBitmapFromNet(url,position);
        return null;
    }
    /**
     * 从网络获取图片
     * @param url
     */
    private void getBitmapFromNet(String url,int position) {
        newFixedThreadPool.execute(new RunnableTask(url,position));
    }

    private class RunnableTask implements Runnable{

        private String mUrl;
        private int mPosition;

        public RunnableTask(String url,int position){
            this.mUrl = url;
            this.mPosition = position;
        }

        @Override
        public void run() {
            Message message = Message.obtain();
            try {
                //根据图片的url路径获取图片
                URL url = new URL(mUrl);
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                con.setConnectTimeout(3000);//连接超时时间
                con.setReadTimeout(3000);//读取超时时间
                InputStream inputStream = con.getInputStream();//服务返回的数据，是以流的形式返回的
                Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
                //将获取的图片保存到本地缓存和内存中
                setBitmapToLocal(mUrl, bitmap);
                lruCache.put(mUrl, bitmap);

                message.what=SUCCESS;
                message.obj=bitmap;
                message.arg1 = mPosition;
                mHandler.sendMessage(message);

                return;//表示线程结束
            } catch (Exception e) {
                e.printStackTrace();
            }
            message.what=FAIL;
            mHandler.sendMessage(message);
        }
    }

    /**
     * 获取本地缓存的图片
     * @param url
     */
    private Bitmap getBitmapFromLocal(String url) {
        try {
            //从本地缓存获取了图片
            File file = new File(cacheDir, MD5Utils.md5(url).substring(10));
            Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
            //保存到内存中
            lruCache.put(url, bitmap);
            return bitmap;
        } catch (Exception e) {
        }
        return null;
    }
    /**
     * 将图片保存到本地缓存中
     * @param url
     * @param bitmap
     */
    private void setBitmapToLocal(String url,Bitmap bitmap){
        try {

            File file = new File(cacheDir, MD5Utils.md5(url).substring(10));
            FileOutputStream outputStream = new FileOutputStream(file);
            //format : 图片的格式
            //quality : 图片质量，百分比，png格式，参数失效
            //stream : 将图片保存到本地的什么位置
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


    public static Bitmap convertToBitmap(String path) {
        int w = 500;
        int h = 500;
        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inJustDecodeBounds = true;
        opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
        BitmapFactory.decodeFile(path, opts);
        int width = opts.outWidth;
        int height = opts.outHeight;
        Log.i("***************bitmap", "width = " + width + "height=" + height);
        float scaleWidth = 0.f, scaleHeight = 0.f;
        if (width > w || height > h) {
            scaleWidth = ((float) width) / w;
            scaleHeight = ((float) height) / h;
        }
        opts.inJustDecodeBounds = false;
        opts.inDither = false;
        opts.inPreferredConfig = null;
        opts.inPurgeable = true;
        opts.inInputShareable = true;
        float scale = Math.max(scaleWidth, scaleHeight);
        Log.i("*******daxiao*", (int) scale + "");
        opts.inSampleSize = (int) scale;
        Bitmap mBt = BitmapFactory.decodeFile(path, opts);
        if (mBt==null)
            return null;
        return Bitmap.createScaledBitmap(mBt, w, h, true);
    }




    public static String saveToSDCard(byte[] data,Context context,String path) throws IOException {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
        String filename = "IMG_" + format.format(date) + ".jpg";
        File fileFolder = new File(path);
        if (!fileFolder.exists()) {
            fileFolder.mkdirs();
        }
        File jpgFile = new File(fileFolder, filename);
        FileOutputStream outputStream = new FileOutputStream(jpgFile); //
        //刷新相册
        MediaScannerConnection.scanFile(context,
                new String[]{jpgFile.getAbsolutePath()}, null, null);

        outputStream.write(data);
        outputStream.close();
//        Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
//        Uri uri = Uri.fromFile(new File(Environment
//                .getExternalStorageDirectory() + "/DeepbayPicture/" + filename));
//        intent.setData(uri);
//        mContext.sendBroadcast(intent);
        return jpgFile.getAbsolutePath();
    }












}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/dialog/QuickOptionDialog.java<|end_filename|>
package com.example.lwd18.pictureselecotor.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.bigphotobrows.ImageBrowsePresenter;


/**
 * 创建者     李文东
 * 创建时间   2017/8/11 18:39
 * 描述	      ${TODO}
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */

public class QuickOptionDialog extends Dialog implements View.OnClickListener {

  private LinearLayout mShare, saveLocal, collection;
  private ImageBrowsePresenter mPresent;
  private Context              mContext;
  private Activity mActivity;
  private Animation mOperatingAnim;

  public QuickOptionDialog(Activity activity, Context context) {
    this(context, R.style.quick_option_dialog);
    this.mContext = context;
    this.mActivity = activity;
  }

  private QuickOptionDialog(Context context, int theme) {

    super(context, theme);

    View contentView = getLayoutInflater().inflate(R.layout.quick_option_dialog, null);

    mShare = (LinearLayout) contentView.findViewById(R.id.share_friend);
    saveLocal = (LinearLayout) contentView.findViewById(R.id.save_phone);
    collection = (LinearLayout) contentView.findViewById(R.id.collection);


    mOperatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.quick_option_close);

    LinearInterpolator lin = new LinearInterpolator();

    mOperatingAnim.setInterpolator(lin);

    contentView.setOnTouchListener(new View.OnTouchListener() {

      @Override

      public boolean onTouch(View v, MotionEvent event) {

        QuickOptionDialog.this.dismiss();

        return true;

      }

    });

    super.setContentView(contentView);

  }


  @Override

  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    getWindow().setGravity(Gravity.BOTTOM);
    //getWindow().setNavigationBarColor(Color.TRANSPARENT);
    WindowManager windowManager = getWindow().getWindowManager();

    Display display = windowManager.getDefaultDisplay();
    WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
    layoutParams.width = display.getWidth();
    getWindow().setAttributes(layoutParams);

    mShare.setOnClickListener(this);
    saveLocal.setOnClickListener(this);
    collection.setOnClickListener(this);
    // mPresent = new ImageBrowsePresenter(this);
  }

  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.share_friend:
        mShare.startAnimation(mOperatingAnim);
        QuickOptionDialog.this.dismiss();
        //弹出分享界面
        Toast.makeText(getContext(), "分享", Toast.LENGTH_SHORT).show();
        break;
      case R.id.save_phone:
        if(mOnClick!=null)
          mOnClick.saveclick();
        saveLocal.startAnimation(mOperatingAnim);
        QuickOptionDialog.this.dismiss();
        break;
      case R.id.collection:
        collection.startAnimation(mOperatingAnim);
        QuickOptionDialog.this.dismiss();
        break;
    }
  }

  private OnClick mOnClick;

  public void setOnClick(OnClick onClick) {
    this.mOnClick = onClick;
  }

  public interface OnClick {
    void saveclick();
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/BaseActivity.java<|end_filename|>
package com.deepbaytech.deeplibrary;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public abstract class BaseActivity extends AppCompatActivity {

    /**
     * hook listener
     * @param savedInstanceState
     */
//    @Override
//    public void onWindowFocusChanged(boolean hasFocus) {
//        super.onWindowFocusChanged(hasFocus);
//
//        ListenerManager.Builer builer = new ListenerManager.Builer();
//        builer.buildOnClickListener(new HookListenerContract.OnClickListener() {
//            @Override
//            public void doInListener(View v) {
//                Toast.makeText(BaseActivity.this, "单击时我执行", Toast.LENGTH_SHORT).show();
//            }
//        }).buildOnLongClickListener(new HookListenerContract.OnLongClickListener() {
//            @Override
//            public void doInListener(View v) {
//                Toast.makeText(BaseActivity.this, "长按时我执行", Toast.LENGTH_SHORT).show();
//            }
//        }).buildOnFocusChangeListener(new HookListenerContract.OnFocusChangeListener() {
//            @Override
//            public void doInListener(View v, boolean hasFocus) {
//                Toast.makeText(BaseActivity.this, "焦点变化时我执行", Toast.LENGTH_SHORT).show();
//            }
//        });
//        HookCore.getInstance().startHook(this, ListenerManager.create(builer));
//    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityManager.getInstance().addActivity(this);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityManager.getInstance().finishActivity(this);
    }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/manager/CacheManager.java<|end_filename|>
package com.deepbaytech.deeplibrary.manager;

import com.deepbaytech.deeplibrary.utils.SharedPreferencesUtil;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by EtherealPatrick on 2016/10/9.
 */

public class CacheManager {
  private static CacheManager manager;
    private  static List<String> list = new ArrayList<>();

  public static CacheManager getInstance() {
   list.add("牛奶");
    return manager == null ? (manager = new CacheManager()) : manager;
  }



  /**
   * 搜索历史
   */
  public List<String> getSearchHistory() {

      return SharedPreferencesUtil.getInstance().getObject(getSearchHistoryKey(), List.class)==null?list:SharedPreferencesUtil.getInstance().getObject(getSearchHistoryKey(), List.class);
  }

  public void saveSearchHistory(Object obj) {
      SharedPreferencesUtil.getInstance().putObject(getSearchHistoryKey(), obj);
  }

  private String getSearchHistoryKey() {
    return "searchHistory";
  }

  ///**
  // * 话题选择历史
  // */
  //public List<String> getTopicHistory(){
  //    return SharedPreferencesUtil.getInstance().getObject(getTopicHistoryKey(), List.class);
  //}

  public void saveTopicHistory(Object obj) {
    SharedPreferencesUtil.getInstance().putObject(getTopicHistoryKey(), obj);
  }

  private String getTopicHistoryKey() {
    return "topicHistory";
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/ProductDetailActivity.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.alibaba.fastjson.JSON;
import com.deepbaytech.deeplibrary.ActivityManager;
import com.example.lwd18.pictureselecotor.ApiConstants;
import com.example.lwd18.pictureselecotor.BaseDeepActivity;
import com.example.lwd18.pictureselecotor.BaseFragment;
import com.example.lwd18.pictureselecotor.NoScrollViewPager;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.FinishEventUtil;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.SecondEventil;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.TextEventUtil;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.TranstEventil;
import com.example.lwd18.pictureselecotor.textsearch.fragment.ComprehensiveFragment;
import com.example.lwd18.pictureselecotor.textsearch.fragment.PriceFragment;
import com.example.lwd18.pictureselecotor.textsearch.fragment.SaleNumberFragment;
import com.example.lwd18.pictureselecotor.textsearch.resultadapter.ViewPagerAdapter;
import com.example.lwd18.pictureselecotor.textsearch.view.FilterFragments;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import de.greenrobot.event.EventBus;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Call;



public class ProductDetailActivity extends BaseDeepActivity implements View.OnClickListener {

  @BindView(R.id.tv_search_text_result) TextView tvSearchTextResult;
  @BindView(R.id.ll_search_text_result) LinearLayout llSearchTextResult;
  @BindView(R.id.rl_search_text_result) RelativeLayout rlSearchTextResult;
  @BindView(R.id.tv_search_text_result_back) TextView tvSearchTextResultBack;
  @BindView(R.id.search_toolbar_product_detail) Toolbar searchToolbarProductDetail;
  @BindView(R.id.topic_tabLayout) TabLayout topicTabLayout;
  @BindView(R.id.textsearch_filter) TextView textsearchFilter;
  @BindView(R.id.textsearch_filter_out) RelativeLayout textsearchFilterOut;
  @BindView(R.id.vp_topic) NoScrollViewPager vpTopic;
  @BindView(R.id.topic_zero_contain_product_detail) FrameLayout topicZeroContainProductDetail;
  @BindView(R.id.topic_zero_content_new_out) LinearLayout topicZeroContentNewOut;
  @BindView(R.id.nav_view) LinearLayout navView;
  @BindView(R.id.drawer_layout) DrawerLayout drawerLayout;
  private ViewPagerAdapter adapter;
  private int priceSortMode = 0;
  private TextsSearchEntity textSearch;
  private List<TextsSearchEntity.DataBean.FiltersBean> filterlist;
  List<BaseFragment> list_fragment;
  List<String> list_table;
  private FilterFragments filterFragment;
  private String mSearchkey;
  private ImageView img_title;

  @Override protected void initActivity() {
    setContentView(R.layout.activity_product_details);
    ButterKnife.bind(this);
    EventBus.getDefault().register(this);
    if (getIntent() != null && getIntent().getStringExtra("searchKey") != null) {
      mSearchkey = getIntent().getStringExtra("searchKey");
    }

    if (tvSearchTextResult != null) tvSearchTextResult.setText(mSearchkey);
    /**
     * 刚进来隐藏软键盘
     */
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    list_fragment = new ArrayList<>();
    list_table = new ArrayList<>();
    filterlist = new ArrayList<>();

    rlSearchTextResult.setOnClickListener(this);
    tvSearchTextResultBack.setOnClickListener(this);
    getData(mSearchkey);
    initTab();
    initEvent();
    vpTopic.setOffscreenPageLimit(4);
    vpTopic.setNoScroll(true);
    textsearchFilterOut.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        textsearchFilter.setTextColor(getResources().getColor(R.color.colorB3));
        Drawable drawable = getResources().getDrawable(R.drawable.img_search_filter_n);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        textsearchFilter.setCompoundDrawables(null, null, drawable, null);
        openMenu();
      }
    });
    drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
    filterFragment = new FilterFragments(ProductDetailActivity.this,mSearchkey);
    navView.addView(filterFragment);
  }

  /**
   * 操作软键盘
   */
  @Override public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
      InputMethodManager inputMethodManager =
          (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      if (inputMethodManager.isActive()) {
        //EventBus.getDefault().post(new EventUtil(keyword));
        inputMethodManager.hideSoftInputFromWindow(
            ProductDetailActivity.this.getCurrentFocus().getWindowToken(), 0);
      }
      //通知接受
      return true;
    }

    return super.dispatchKeyEvent(event);
  }

  public void closeMenu() {
    drawerLayout.closeDrawer(GravityCompat.END);
  }

  public void openMenu() {
    //刷新筛选框中的数据
    EventBus.getDefault().post(new TranstEventil());
    drawerLayout.openDrawer(GravityCompat.END);
  }

  private void getData(String mExittext) {
    OkHttpUtils.get()
        .url(ApiConstants.TEXTSEARCHS)
        .addParams("text", mExittext)
        .addParams("pageId", 1 + "")
        .addParams("sortId", 0 + "")
        .build()
        .execute(new StringCallback() {

          @Override public void onError(Call call, Exception e, int id) {
            e.printStackTrace();
          }

          @Override public void onResponse(String response, int id) {
            textSearch = JSON.parseObject(response, TextsSearchEntity.class);
            //记录总页数
            if (textSearch.getData() != null && textSearch.getState() == 0) {
              filterlist.clear();
              filterlist.addAll(textSearch.getData().getFilters());
              DataPresenter.getSingleTon().saveData(filterlist);
              //保存数据
            } else if (textSearch.getState() == 3) {

            } else {

            }
          }
        });
  }

  @Override public void onClick(View v) {
    switch (v.getId()) {
      case R.id.tv_search_text_result_back:
        ActivityManager.getInstance().finishActivity(ProductDetailActivity.class);
        break;
      case R.id.rl_search_text_result:
        ActivityManager.getInstance().finishActivity(ProductDetailActivity.class);
        break;
    }
  }
  private void initTab() {
    list_fragment = new ArrayList<>();
    ComprehensiveFragment comprehensiveFragment = ComprehensiveFragment.newInstance(mSearchkey);
    SaleNumberFragment saleNumberFragment = SaleNumberFragment.newInstance(mSearchkey);
    PriceFragment priceFragment = PriceFragment.newInstance(mSearchkey);
    list_fragment.add(comprehensiveFragment);
    list_fragment.add(saleNumberFragment);
    list_fragment.add(priceFragment);
    list_table = new ArrayList<>();
    list_table.add("综合");
    list_table.add("销量");
    list_table.add("价格");
    topicTabLayout.setTabMode(TabLayout.MODE_FIXED);
    topicTabLayout.setSelectedTabIndicatorHeight(0);
    adapter = new ViewPagerAdapter(this, getSupportFragmentManager(), list_fragment, list_table);
    vpTopic.setAdapter(adapter);
    topicTabLayout.setupWithViewPager(vpTopic);
    /**
     * 调用本方法中的gettabview
     */
    for (int i = 0; i < topicTabLayout.getTabCount(); i++) {
      TabLayout.Tab tab = topicTabLayout.getTabAt(i);
      if (tab != null) {
        /**
         * 调用adapter中的gettabview
         */
        tab.setCustomView(adapter.getTabView(i));
        if (tab.getCustomView() != null) {
          View tabView = (View) tab.getCustomView().getParent();
          tabView.setTag(i);
          tabView.setOnClickListener(mTabOnClickListener);
        }
      }
    }

    vpTopic.setCurrentItem(1);
    vpTopic.setCurrentItem(0);
  }

  private View.OnClickListener mTabOnClickListener = new View.OnClickListener() {
    @Override public void onClick(View view) {
      int pos = (int) view.getTag();
      if (pos == 2) {
        TabLayout.Tab tab = topicTabLayout.getTabAt(pos);
        /**
         * 设置升序和降序的数据
         */
        setImage(tab);
      } else {
        TabLayout.Tab tab = topicTabLayout.getTabAt(pos);
        if (tab != null) {
          tab.select();
        }
        if (img_title!=null)
        img_title.setImageResource(R.drawable.search_icon_price_normal);
      }
    }
  };

  private void setImage(TabLayout.Tab tab) {

    switch (priceSortMode) {
      /** 从低到高的排序 */
      case 0:
        priceSortMode = 1;
        break;
      /** 当mode为1说明其已被选中，那么选择2，及从高到低 */
      case 1:
        priceSortMode = 2;
        break;
      /** 当mode为2说明其处于从高到低，那么选择1，从低到高 */
      case 2:
        priceSortMode = 1;
        break;
    }
    setPriceSortDrawable(priceSortMode, tab);
  }

  private void setPriceSortDrawable(int priceSortMode, TabLayout.Tab tab) {
    View view = tab.getCustomView();
    img_title = (ImageView) view.findViewById(R.id.title_iv);
    switch (priceSortMode) {
      case 0:
        img_title.setImageResource(R.drawable.search_icon_price_normal);
        break;
      case 1:
        img_title.setImageResource(R.drawable.search_icon_price_down);
        break;
      case 2:
        img_title.setImageResource(R.drawable.search_icon_price_up);
        break;
    }
  }

  private void initEvent() {
    topicTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
      @Override public void onTabSelected(TabLayout.Tab tab) {
        changeTabSelect(tab);
        vpTopic.setCurrentItem(tab.getPosition());
      }

      @Override public void onTabUnselected(TabLayout.Tab tab) {
        changeTabNormal(tab);
      }

      @Override public void onTabReselected(TabLayout.Tab tab) {

      }
    });
  }

  private void changeTabSelect(TabLayout.Tab tab) {
    View view = tab.getCustomView();
    ImageView img_title = (ImageView) view.findViewById(R.id.title_iv);
    TextView txt_title = (TextView) view.findViewById(R.id.title_tv);
    txt_title.setTextColor(this.getResources().getColor(R.color.deep_main_color));
    if (txt_title.getText().toString().equals("综合")) {
      vpTopic.setCurrentItem(0);
      priceSortMode=0;
    } else if (txt_title.getText().toString().equals("销量")) {
      vpTopic.setCurrentItem(1);
      priceSortMode=0;
    } else if (txt_title.getText().toString().equals("价格")) {
      vpTopic.setCurrentItem(2);
    }else {
      priceSortMode=0;
    }
  }

  private void changeTabNormal(TabLayout.Tab tab) {
    View view = tab.getCustomView();
    ImageView img_title = (ImageView) view.findViewById(R.id.title_iv);
    TextView txt_title = (TextView) view.findViewById(R.id.title_tv);
    txt_title.setTextColor(Color.BLACK);
    if (txt_title.getText().toString().equals("价格")) {

    } else {

    }
  }

  @Override protected void onDestroy() {
    super.onDestroy();
    EventBus.getDefault().unregister(this);
  }

  public void onEventMainThread(TextEventUtil event) {
    String msglog = event.getMsgs();
    if ("".equals(msglog)) {
      openMenu();
    }
  }

  /**
   * 完成监听
   */
  public void onEventMainThread(FinishEventUtil event) {
    closeMenu();
  }
  /**
   * 完成监听,筛选变化
   */
  public void onEventMainThread(SecondEventil event) {
    List<String> filter = event.getFilter();
    if (filter.size()>0){
      textsearchFilter.setTextColor(getResources().getColor(R.color.deep_main_color));
      Drawable drawable = getResources().getDrawable(R.drawable.img_search_filter_f);
      drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
      textsearchFilter.setCompoundDrawables(null, null, drawable, null);
    }else {
      textsearchFilter.setTextColor(getResources().getColor(R.color.colorB3));
      Drawable drawable = getResources().getDrawable(R.drawable.img_search_filter_n);
      drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
      textsearchFilter.setCompoundDrawables(null, null, drawable, null);
    }
  }

  @Override protected void onStop() {
    super.onStop();
    //清空被选中的集合
    System.out.println("文字搜索的onstop走了");
    DataPresenter.getSingleTon().getSelectList().clear();
    DataPresenter.getSingleTon().getSearchlist().clear();
  }

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // TODO: add setContentView(...) invocation
    ButterKnife.bind(this);
  }
}



<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/crash/DeepQuitException.java<|end_filename|>
package com.deepbaytech.deeplibrary.crash;

/**
 * Created by EtherealPatrick on 2017/5/20.
 */

public class DeepQuitException extends RuntimeException {
  /**
   * Constructs a new {@code RuntimeException} that includes the current stack
   * trace.
   */
  public DeepQuitException(String msg) {
    super(msg);
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/NetEvevt.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

/**
 * Created by EtherealPatrick on 2017/6/29.
 */

// 自定义接口
public interface NetEvevt {
  void onNetChange(int netMobile);
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/HttpMethodLogin.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch;
import com.example.lwd18.pictureselecotor.TextSearchRecomdEntity;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.fastjson.FastJsonConverterFactory;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * 创建者     李文东
 * 创建时间   2017/7/13 15:17
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class HttpMethodLogin {
  //正式环境
  public static final String BASE_URL="http://api.deepbaytech.com/mobile/api/v0.0.1/";
  //测试环境
  //public static final String BASE_URL="http://beta.deepbaytech.com/mobile/api/v0.0.1/";
  private static final int DEFAULT_TIMEOUT=10;
  private Retrofit mRetrofit;
  private ApiNet mApiNet;

  private HttpMethodLogin(){
    OkHttpClient.Builder httpClientBuilder = new OkHttpClient().newBuilder();
    httpClientBuilder.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);

    mRetrofit = new Retrofit.Builder()
        .client(httpClientBuilder.build())
        //.addConverterFactory(GsonConverterFactory.create())
        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
        .addConverterFactory(FastJsonConverterFactory.create())
        .baseUrl(BASE_URL)
        .build();

    mApiNet=mRetrofit.create(ApiNet.class);

  }

  private static class singletonHolder{
    private static final HttpMethodLogin INSTANCE = new HttpMethodLogin();
  }

  public static HttpMethodLogin getInstance(){
    return singletonHolder.INSTANCE;
  }


  public void getTextSearchRecomd(Subscriber<TextSearchRecomdEntity> subscriber,String pid,Integer pageId){
    mApiNet.getRecomProduct(pid,pageId)
        .subscribeOn(Schedulers.io())
        .unsubscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(subscriber);
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/bigphotobrows/ViewPageAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.bigphotobrows;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.bigphotobrows.utils.WindowUtil;
import com.example.lwd18.pictureselecotor.dialog.QuickOptionDialog;
import java.util.List;
import uk.co.senab.photoview.PhotoViewAttacher;



/**
 * 创建者     李文东
 * 创建时间   2017/5/24 9:45
 * 描述	      ${TODO}
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class ViewPageAdapter extends PagerAdapter {
    private Context context;
    private List<String> images;
    private SparseArray<View> cacheView;
    private ViewGroup containerTemp;
    private Activity mActivity;
    public ViewPageAdapter(Activity activity,Context context, List<String> images) {
        this.context = context;
        this.images = images;
        this.mActivity=activity;
        cacheView = new SparseArray<>(images.size());
    }

    @Override
    public Object instantiateItem(final ViewGroup container, int position) {
        if(containerTemp == null) containerTemp = container;

        View view = cacheView.get(position);

        if(view == null){
            view = LayoutInflater.from(context).inflate(R.layout.vp_item_image,container,false);
            view.setTag(position);
            ImageView image = (ImageView) view.findViewById(R.id.image);
            PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(image);


            Glide.with(context).asBitmap().load(images.get(position)).into(new MyTarget(photoViewAttacher));
            photoViewAttacher.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    /**
                     * 长按之后弹出dialog
                     */
                    //showQuickOption();
                    mShowDialog.show();
                    return true;
                }
            });
            photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
                @Override
                public void onPhotoTap(View view, float x, float y) {
                    Activity activity = (Activity) context;
                    activity.finish();
                }
            });
            cacheView.put(position,view);
        }
        container.addView(view);
        return view;
    }
    private void showQuickOption() {
        final QuickOptionDialog dialog = new QuickOptionDialog(mActivity,context);
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
        dialog.show();
    }
    @Override
    public int getCount() {
        return images.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

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

    private class MyTarget extends SimpleTarget<Bitmap>{

        private PhotoViewAttacher viewAttacher;

        public MyTarget(PhotoViewAttacher viewAttacher){
            this.viewAttacher = viewAttacher;
        }

        @Override
        public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
            int width = resource.getWidth();
            int height = resource.getHeight();

            int newWidth = width;
            int newHeight = height;

            int screenWidth = WindowUtil.getInstance().getScreenWidth((Activity) context);
            int screenHeight = WindowUtil.getInstance().getScreenHeight((Activity) context);

            if(width > screenWidth){
                newWidth = screenWidth;
            }

            if(height > screenHeight){
                newHeight = screenHeight;
            }


            if(newWidth == width && newHeight == height){
                viewAttacher.getImageView().setImageBitmap(resource);
                viewAttacher.update();
                return;
            }

            //计算缩放比例
            float scaleWidth = ((float) newWidth) / width;
            float scaleHeight = ((float)newHeight) / height;

            Matrix matrix = new Matrix();
            matrix.postScale(scaleWidth,scaleHeight);

            Log.v("size",width + "");
            Log.v("size",height + "");

            Bitmap resizeBitmap = Bitmap.createBitmap(resource,0,0,width,height,matrix,true);

            viewAttacher.getImageView().setImageBitmap(resizeBitmap);
            viewAttacher.update();
        }
    }
    private ShowDialog mShowDialog;
    public void setShowDialog(ShowDialog showDialog){
        this.mShowDialog=showDialog;
    }
    public interface ShowDialog{
        void show();
    }

}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/utils/MonthOfDayUtils.java<|end_filename|>
package com.deepbaytech.deeplibrary.utils;

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

/**
 * Created by x on 2016/9/22.
 */

public class MonthOfDayUtils {
    // TODO: 2016/9/22 根据月份获取该月一共有多少天
    public static int byMonthToDay(int month){
        switch (month){
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                return 31;
            case 4:
            case 6:
            case 9:
            case 11:
                return 30;
            case 2:
                return getYear();
        }
        return 0;
    }

    // TODO: 2016/9/22 判断今年是否是闰年，并获取其中二月的天数
    private static int getYear(){
        Calendar c = Calendar.getInstance();
        int year = c.get(Calendar.YEAR);
        if (year%100==0){
            if (year%400==0){
                return 29;
            }else{
                return 28;
            }
        }
        if (year%4==0){
            return 29;
        }else
            return 28;
    }

    /**
     *
     * @param startMonth 开始的月份
     * @param startDay 开始的日期
     * @param endMonth 结束的月份
     * @param endDay    结束的日期
     * @return 返回这段时间内一共有多少天
     */

    // TODO: 2016/9/22 获取时间段中一共有多少天 
    public static int getAllMonthDay(int startMonth, int startDay, int endMonth, int endDay) {
        int allDay = 0;
        if (endMonth < startMonth) {
            for (int i = startMonth; i <= 12; i++) {
                allDay = allDay+byMonthToDay(i);
            }
            allDay = allDay-startDay;
            int i = 1;
            while(i<endMonth){
                allDay = allDay+byMonthToDay(i);
                i++;
            }
            allDay = allDay+endDay;
        }
        if (startMonth==endMonth){
            allDay = endDay-startDay;
        }
        if (startMonth<endMonth){
            for (int i = startMonth;i<endMonth;i++){
                allDay = allDay+byMonthToDay(i);
            }
            allDay = allDay-startDay+endDay;
        }
        return allDay;
    }

    /**
     * 余数如何处理
     * @param startMonth 开始的月份
     * @param startDay  开始的日期
     * @param endMonth  结束的月份
     * @param endDay    结束的日期
     * @param intervalNum 一共需要分为多少段
     * @return
     */
    public static List<String> getInterval(int startMonth, int startDay, int endMonth, int endDay, int intervalNum){
        List<String> list = new ArrayList<>();
        // TODO: 2016/9/26 先获取到该段时间内一共有多少天
        int allDays = getAllMonthDay(startMonth, startDay, endMonth, endDay);
        if (intervalNum>allDays){
            return null;
        }
        //取时间间隔为多少天，判断余数，四舍五入
        int interval = (int) Math.round(allDays * 1.0 / intervalNum);
        // TODO: 2016/9/26 当这段时间属于两年的
        if (endMonth < startMonth) {
            // TODO: 2016/9/26 先计算第一年中的时间段
            for (int i = startMonth; i <= 12; i++) {
                list.add(i+"-"+startDay);
                int monthDay = byMonthToDay(i);
                int surplusDay = monthDay-startDay;
                //该月剩余天数是否大于时间间隔
                if (surplusDay>=interval){
                    int nextMonthStartDay = surplusDay%interval;
                    int surplusDayTimes = surplusDay/interval;
                    for (int y = 1;y<=surplusDayTimes;y++){
                        list.add(i+"-"+(y*interval+startDay));
                    }
                    if (nextMonthStartDay==0){
                        startDay = interval;
                    }else
                        startDay = interval-nextMonthStartDay;
                }else{
                    startDay = interval-surplusDay;
                }
            }
            int i = 1;
            // TODO: 2016/9/26 计算第二年的时间段
            while(i<endMonth){
                list.add(i+"-"+startDay);
                int monthDay = byMonthToDay(i);
                int surplusDay = monthDay-startDay;
                //该月剩余天数是否大于时间间隔
                if (surplusDay>=interval){
                    int nextMonthStartDay = surplusDay%interval;
                    int surplusDayTimes = surplusDay/interval;
                    for (int y = 1;y<=surplusDayTimes;y++){
                        list.add(i+"-"+(y*interval+startDay));
                    }
                    if (nextMonthStartDay==0){
                        startDay = interval;
                    }else
                        startDay = interval-nextMonthStartDay;
                }else{
                    startDay = interval-surplusDay;
                }
                i++;
            }
            // TODO: 2016/9/26 判断最后一个月的时间段
            // TODO: 2016/9/26 当上个月到最后一个月中剩余的时间大于最后的日期时
            if (endDay<=startDay){
                list.add(endMonth + "-" + endDay);
            }else{
                int endInterval = endDay-startDay;
                list.add(endMonth + "-" + startDay);
                if (endInterval<=interval){
                    list.add(endMonth + "-" + endDay);
                }else{
                    int endSurplus = endInterval/interval;
                    int endSurplusDay = endInterval%interval;
                    for (int y = 1;y <= endSurplus;y++){
                        list.add(endMonth+"-"+(startDay+y*interval));
                    }
                    if (endSurplusDay>0){
                        list.add(endMonth+"-"+endDay);
                    }
                }
            }
        }
        // TODO: 2016/9/26 当开始的月份和结束的月份属于同一个月时
        if (startMonth==endMonth){
            list.add(startMonth+"-"+startDay);
            int num = allDays/interval;
            for (int i = 1;i<=num;i++){
                list.add(startMonth+"-"+(startDay+i*interval));
            }
            if (allDays%interval>0){
                list.add(endMonth+"-"+endDay);
            }
        }
        // TODO: 2016/9/26 当时间段属于同一年时
        if (startMonth<endMonth){
            // TODO: 2016/9/26 计算开始月份和日期到结束月份中的时间段
            for (int i = startMonth;i<endMonth;i++){
                    list.add(i+"-"+startDay);
                    int monthDay = byMonthToDay(i);
                    int surplusDay = monthDay-startDay;
                    //该月剩余天数是否大于时间间隔
                    if (surplusDay>=interval){
                        int nextMonthStartDay = surplusDay%interval;
                        int surplusDayTimes = surplusDay/interval;
                        for (int y = 1;y<=surplusDayTimes;y++){
                            list.add(i+"-"+(y*interval+startDay));
                        }
                        if (nextMonthStartDay==0){
                            startDay = interval;
                        }else{
                            startDay = interval-nextMonthStartDay;
                        }
                }else{
                        startDay = interval-surplusDay;
                    }
            }
            // TODO: 2016/9/26 计算最后一个月份的时间段
            if (endDay<=startDay){
                list.add(endMonth + "-" + endDay);
            }else{
                int endInterval = endDay-startDay;
                list.add(endMonth + "-" + startDay);
                if (endInterval<=interval){
                    list.add(endMonth + "-" + endDay);
                }else{
                    int endSurplus = endInterval/interval;
                    int endSurplusDay = endInterval%interval;
                    for (int y = 1;y <= endSurplus;y++){
                        list.add(endMonth+"-"+(startDay+y*interval));
                    }
                    if (endSurplusDay>0){
                        list.add(endMonth+"-"+endDay);
                    }
                }
            }
        }
        return list;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/ApiNet.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch;

import com.example.lwd18.pictureselecotor.TextSearchRecomdEntity;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable;

/**
 * 创建者     李文东
 * 创建时间   2017/7/13 15:24
 * 更新描述
 */

public interface ApiNet {


 /**
  * 聚类商品推荐
  * @param pid
  * @param pageId
  * @return
  */
 @GET("product-recommend-search")
 Observable<TextSearchRecomdEntity> getRecomProduct(@Query("pid") String pid,
     @Query("pageId") int pageId);
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/BaseFragment.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.deepbaytech.deeplibrary.utils.InternetUtils;
import me.yokeyword.fragmentation.SupportFragment;
import rx.Subscription;

/**
 * Created by EtherealPatrick on 2017/2/23.
 */

public class BaseFragment extends SupportFragment implements NetEvevt{
  private Activity activity;
  protected Subscription subscription;
    private int netMobile;
  @Override public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  }

  @Override public void onDestroy() {
    super.onDestroy();
  }

  public Context getMContext() {
    if (activity == null) {
      return MyApplication.getContext();
    }
    return activity;
  }

  @Override public void onAttach(Activity activity) {
    super.onAttach(activity);
    activity = getActivity();
  }

  @Override public void onDestroyView() {
    super.onDestroyView();
    unsubscribe();
  }

  protected void unsubscribe() {
    if (subscription != null && !subscription.isUnsubscribed()) {
      subscription.unsubscribe();
    }
  }

  /**
   * 初始化时判断有没有网络
   */

  public boolean inspectNet() {
    this.netMobile = InternetUtils.getNetWorkState(getContext());

    return isNetConnect();

    // if (netMobile == NetUtil.NETWORK_WIFI) {
    // System.out.println("inspectNet：连接wifi");
    // } else if (netMobile == NetUtil.NETWORK_MOBILE) {
    // System.out.println("inspectNet:连接移动数据");
    // } else if (netMobile == NetUtil.NETWORK_NONE) {
    // System.out.println("inspectNet:当前没有网络");
    //
    // }
  }
  /**
   * 判断有无网络 。
   *
   * @return true 有网, false 没有网络.
   */
  public boolean isNetConnect() {
    if (netMobile == InternetUtils.NETWORK_WIFI) {
      return true;
    } else if (netMobile == InternetUtils.NETWORK_MOBILE) {
      return true;
    } else if (netMobile == InternetUtils.NETWORK_NONE) {
      return false;

    }
    return false;
  }

  @Override
  public void onNetChange(int netMobile) {
    this.netMobile = netMobile;
    isNetConnect();
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/adapter/GoodSAttrRvAdatper.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.textsearch.DataPresenter;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvFAdapter;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter1;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter10;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter11;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter12;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter2;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter3;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter4;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter5;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter6;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter7;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter8;
import com.example.lwd18.pictureselecotor.textsearch.itemadapter.GoodSAttrRvNAdapter9;
import com.example.lwd18.pictureselecotor.textsearch.vo.SaleAttributeVo;
import java.util.ArrayList;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/7/10 12:41
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class GoodSAttrRvAdatper extends RecyclerView.Adapter<RecyclerView.ViewHolder>
    implements GoodSAttrRvFAdapter.OnClickListener{
  private Context context;
  private List<TextsSearchEntity.DataBean.FiltersBean> data;
  private String[] serviceStr = new String[] { "淘宝", "天猫", "京东", "国美", "苏宁", "当当", "亚马逊", "一号店" };
  private List<SaleAttributeVo> serviceList;
  private int HEAD = 0;
  private int Normal = 1;
  private int Foot = 2;
  private GoodSAttrRvFAdapter serviceAdapter;
  private GoodSAttrRvNAdapter normalAdapter;
  private GoodSAttrRvNAdapter1 normalAdapter1;
  private GoodSAttrRvNAdapter2 normalAdapter2;
  private GoodSAttrRvNAdapter3 normalAdapter3;
  private GoodSAttrRvNAdapter4 normalAdapter4;
  private GoodSAttrRvNAdapter5 normalAdapter5;
  private GoodSAttrRvNAdapter6 normalAdapter6;
  private GoodSAttrRvNAdapter7 normalAdapter7;
  private GoodSAttrRvNAdapter8 normalAdapter8;
  private GoodSAttrRvNAdapter9 normalAdapter9;
  private GoodSAttrRvNAdapter10 normalAdapter10;
  private GoodSAttrRvNAdapter11 normalAdapter11;
  private GoodSAttrRvNAdapter12 normalAdapter12;

  public GoodSAttrRvAdatper(Context context) {
    this.context = context;
    data = new ArrayList<>();
    if (DataPresenter.getSingleTon().getData().size()>0){
      data.clear();
      DataPresenter.getSingleTon().getData().addAll(data);
      data.removeAll(data);
      data.addAll(DataPresenter.getSingleTon().getData());
      for (int i = 0; i < data.size(); i++) {
        for (int j = 0; j < data.get(i).getFilterOption().size(); j++) {
          data.get(i).setChick(false);
        }
      }
      //清空被选中的集合
      DataPresenter.getSingleTon().getSelectList().clear();
      notifyDataSetChanged();
    }
  }

  @Override public int getItemViewType(int position) {
    //暂时不要商城和价格区间,so将头部和尾部动态注销
    if (position == -1) {
      return HEAD;
    } else if (position == data.size()) {
      return Foot;
    } else {
      return Normal;
    }
  }

  @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v;
    if (viewType == HEAD) {
      v = View.inflate(context, R.layout.item_goods_attrs_head, null);
      return new HeadViewHolder(v);
    } else if (viewType == Normal) {
      v = View.inflate(context, R.layout.item_goods_attr_list, null);
      return new NormalViewHolder(v);
    } else if (viewType == Foot) {
      v = View.inflate(context, R.layout.item_goods_attr_foot, null);
      return new FootViewHolder(v);
    }
    return null;
  }

  @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
    /**
     * 正常
     */
    // TODO: 2017/7/23 recycleview嵌套recycleview,由于每一个item都是一个recycleview,因此都有各自对应的adapte,如果设置一个adapter,每次数据变化时会有一系列的冲突
    // TODO: 2017/7/23 目前尚未找到更好的解决办法,因此只能使用最笨的办法以求稳定,索幸所选条目最多不会超过20条,因此此方法只能在group数量有限的情况下使用
    if (holder instanceof NormalViewHolder) {
      if (position==0){
        //第一条全部展开
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter==null) {
          normalAdapter = new GoodSAttrRvNAdapter(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter);
            //normalAdapter.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          normalAdapter.notifyDataSetChanged(true, data.get(position).getFilterOption(),position);
          ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          //if (data.get(position).isChick()) {
          //  ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          //} else {
          //  ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
          //  data.get(position).setChick(true);
          //}
        }else {
          //normalAdapter.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          normalAdapter.notifyDataSetChanged(true, data.get(position).getFilterOption(),position);
        }
        ////点击将
        //((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
        //  @Override public void onClick(View v) {
        //    System.out.println("被点击的position==="+position);
        //    if (data.get(position).isChick()) {
        //      ((ImageView) v).setImageResource(R.drawable.sort_common_up);
        //    } else {
        //      ((ImageView) v).setImageResource(R.drawable.sort_common_down);
        //    }
        //      normalAdapter.notifyDataSetChanged(data.get(position).isChick(), data.get(position ).getFilterOption(),position);
        //    data.get(position).setChick(!data.get(position).isChick());
        //  }
        //});
      }else if (position==1){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter1==null) {
          normalAdapter1 = new GoodSAttrRvNAdapter1(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter1);
          normalAdapter1.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter1.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter1.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==2){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter2==null) {
          normalAdapter2 = new GoodSAttrRvNAdapter2(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter2);
          normalAdapter2.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter2.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter2.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==3){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter3==null) {
          normalAdapter3 = new GoodSAttrRvNAdapter3(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter3);
          normalAdapter3.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter3.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter3.notifyDataSetChanged(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==4){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter4==null) {
          normalAdapter4 = new GoodSAttrRvNAdapter4(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter4);
          normalAdapter4.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter4.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter4.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==5){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter5==null) {
          normalAdapter5 = new GoodSAttrRvNAdapter5(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter5);
          normalAdapter5.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter5.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter5.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==6){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter6==null) {
          normalAdapter6 = new GoodSAttrRvNAdapter6(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter6);
          normalAdapter6.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter6.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter6.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==7){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter7==null) {
          normalAdapter7 = new GoodSAttrRvNAdapter7(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter7);
          normalAdapter7.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter7.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter7.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==8){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter8==null) {
          normalAdapter8 = new GoodSAttrRvNAdapter8(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter8);
          normalAdapter8.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter8.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter8.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==9){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter9==null) {
          normalAdapter9 = new GoodSAttrRvNAdapter9(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter9);
          normalAdapter9.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter9.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter4.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==10){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter10==null) {
          normalAdapter10 = new GoodSAttrRvNAdapter10(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter10);
          normalAdapter10.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter10.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position - 1).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter10.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==11){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter11==null) {
          normalAdapter11 = new GoodSAttrRvNAdapter11(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter11);
          normalAdapter11.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter11.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter11.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }else if (position==12){
        GridLayoutManager gridLayoutManager = new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL, false);
        ((NormalViewHolder) holder).Rv.setLayoutManager(gridLayoutManager);
        ((NormalViewHolder) holder).name.setText(data.get(position).getFilterName());
        if (normalAdapter12==null) {
          normalAdapter12 = new GoodSAttrRvNAdapter12(context);
          ((NormalViewHolder) holder).Rv.setAdapter(normalAdapter12);
          normalAdapter12.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
          if (data.get(position).isChick()) {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_up);
          } else {
            ((NormalViewHolder) holder).img.setImageResource(R.drawable.sort_common_down);
            data.get(position).setChick(true);
          }
        }else {
          normalAdapter12.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
        }
        //点击将
        ((NormalViewHolder) holder).img.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            System.out.println("被点击的position==="+position);
            if (data.get(position).isChick()) {
              ((ImageView) v).setImageResource(R.drawable.sort_common_up);
            } else {
              ((ImageView) v).setImageResource(R.drawable.sort_common_down);
            }
            normalAdapter12.notifyDataSetChangeds(data.get(position).isChick(), data.get(position).getFilterOption(),position);
            data.get(position).setChick(!data.get(position).isChick());
          }
        });
      }

      /**
       * 头部
       */
    } else if (holder instanceof HeadViewHolder) {
      serviceList = new ArrayList<>();
      for (int i = 0; i < serviceStr.length; i++) {
        SaleAttributeVo vo = new SaleAttributeVo();
        vo.setValue(serviceStr[i]);
        serviceList.add(vo);
      }
      GridLayoutManager gridLayoutManager =
          new GridLayoutManager(holder.itemView.getContext(), 3, LinearLayoutManager.VERTICAL,
              false);
      ((HeadViewHolder) holder).serviceGrid.setLayoutManager(gridLayoutManager);
      serviceAdapter = new GoodSAttrRvFAdapter(context);
      serviceAdapter.setOnClickListeners(this);
      ((HeadViewHolder) holder).serviceGrid.setAdapter(serviceAdapter);
      serviceAdapter.notifyDataSetChanged(true, serviceList);
      /**
       * 尾部
       */
    } else if (holder instanceof FootViewHolder) {

    }
  }

  @Override public int getItemCount() {
    //return data.size() == 0 ? 2 : data.size() + 2;
    return data.size()==0?0:data.size();
  }

  /**
   * 头部中的view的点击事件
   * @param position
   */
  @Override public void itemClick(int position) {
    //设置当前选中的位置的状态为非。
    serviceList.get(position).setChecked(!serviceList.get(position).isChecked());
    /**
     * 单选
     */
   for (int i = 0; i < serviceList.size(); i++) {
     //跳过已设置的选中的位置的状态
     if (i == position) {
       continue;
     }
     serviceList.get(i).setChecked(false);

   }
   serviceAdapter.notifyDataSetChanged(true, serviceList);
    /**
     * 多选
     */
    //serviceAdapter.notifyDataSetChanged(serviceList.get(position).isChecked(),serviceList);
  }

  public class HeadViewHolder extends RecyclerView.ViewHolder {
    private RecyclerView serviceGrid;

    public HeadViewHolder(View itemView) {
      super(itemView);
      serviceGrid = (RecyclerView) itemView.findViewById(R.id.yuguo_service);
    }
  }

  public class NormalViewHolder extends RecyclerView.ViewHolder {
    public TextView name,select;
    public ImageView img;
    public RecyclerView Rv;

    public NormalViewHolder(View itemView) {
      super(itemView);
      name = (TextView) itemView.findViewById(R.id.attr_list_name);
      img = (ImageView) itemView.findViewById(R.id.attr_list_img);
      Rv = (RecyclerView) itemView.findViewById(R.id.attr_list_grid);
      select = (TextView) itemView.findViewById(R.id.attr_list_select);
    }
  }

  public class FootViewHolder extends RecyclerView.ViewHolder {

    public FootViewHolder(View itemView) {
      super(itemView);
    }
  }

  //添加数据
  public void addItem(List<TextsSearchEntity.DataBean.FiltersBean> newDatas) {
    data.clear();
    newDatas.addAll(data);
    data.removeAll(data);
    data.addAll(newDatas);
    notifyDataSetChanged();
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/TextSearchEntity.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import java.util.ArrayList;

/**
 * Created by x on 2016/11/4.
 */

public class TextSearchEntity {
  private int id;

  private int state;

  private int updateTime;

  private int sortType;

  private int pageTotal;


  private ArrayList<SortItem> sortItem;

  private ArrayList<ProductItemBean> productItems;

  public int getPageTotal() {
    return pageTotal;
  }

  public void setPageTotal(int pageTotal) {
    this.pageTotal = pageTotal;
  }


  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public ArrayList<ProductItemBean> getProductItems() {
    return productItems;
  }

  public void setProductItems(ArrayList<ProductItemBean> productItems) {
    this.productItems = productItems;
  }

  public ArrayList<SortItem> getSortItem() {
    return sortItem;
  }

  public void setSortItem(ArrayList<SortItem> sortItem) {
    this.sortItem = sortItem;
  }

  public int getSortType() {
    return sortType;
  }

  public void setSortType(int sortType) {
    this.sortType = sortType;
  }

  public int getState() {
    return state;
  }

  public void setState(int state) {
    this.state = state;
  }

  public int getUpdateTime() {
    return updateTime;
  }

  public void setUpdateTime(int updateTime) {
    this.updateTime = updateTime;
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/RollViewPager.java<|end_filename|>
package com.deepbaytech.deeplibrary;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

/**
 * @author EtherealPatrick
 *         Created at 2016/8/11.
 * @email <EMAIL>
 */
public class RollViewPager extends ViewPager {
    //传递过来的图片数组，这个必须更换，真实项目中有可能是一个集合
    private String[] imageUrls;
    private static final int NEXT=99;//切换下一张图片的标志
    private boolean isRunning=false;//是否自动轮播的标志，默认不自动轮播
    private Context mContext;
    //    private BitmapUtils bitmapUtils;
    public RollViewPager(Context context) {
        super(context);
        mContext = context;
    }

    public RollViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
    }

    public void setImageUrls(String[] imageUrls) {
        this.imageUrls = imageUrls;
        setAdapter(new MyRollViePagerAdatper());
    }

    private Handler handler=new Handler(){
        @Override
        public void handleMessage(Message msg) {

            switch (msg.what){

                case NEXT:
                    if(isRunning==true){
                        //设置当前item+1；相当于设置下一个item，然后余图片数量；
                        setCurrentItem(getCurrentItem()+1);
                        //然后发送空消息延时3秒
                        handler.sendEmptyMessageDelayed(NEXT,3000);
                    }
                    break;
            }
        }
    };

    //开始轮播
    public void startRoll(){
        //开启轮播
        isRunning=true;
        //发送handler延时3秒
        handler.sendEmptyMessageDelayed(NEXT,3000);
    }

    class MyRollViePagerAdatper extends PagerAdapter {

        @Override
        public int getCount() {
            return Integer.MAX_VALUE;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            //这个必须取余数，不然会下标越界
            position=position%imageUrls.length;
            ImageView imageView = (ImageView) View.inflate(getContext(), R.layout.viewpager_item, null);
            //先获取网络中图片的url
//           在真实项目中使用谷歌官方提供的Glide加载图片
//            Glide.with(context).load(new File(path)).diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().into(vh.imageView);
//            imageView.setImageResource(imageUrls[position]);
            Picasso.with(mContext).load(imageUrls[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 view, Object object) {
            return view==object;
        }
    }

    private int downTime=0;//按下时间
    //按下的XY坐标
    private int downX=0;
    private int downY=0;

    @Override
    public boolean onTouchEvent(MotionEvent ev) {

        switch (ev.getAction()){

            case MotionEvent.ACTION_DOWN:
                downX= (int) ev.getX();
                downY= (int) ev.getY();
                downTime= (int) System.currentTimeMillis();
                //停止轮播
                isRunning=false;
                handler.removeMessages(NEXT);
                break;

            case MotionEvent.ACTION_UP:
                int upX= (int) ev.getX();
                int upY= (int) ev.getY();
                int disX=Math.abs(upX - downX);
                int disY=Math.abs(upY - downY);
                int upTime=(int) System.currentTimeMillis();
                if(upTime-downTime<500 && disX-disY<5 ){
                    if(onItemClickListener!=null){
                        onItemClickListener.onItemClick(getCurrentItem()%imageUrls.length);//当前位置就是显示的条目
                    }
                }

                //开启轮播
                startRoll();
                break;

            case MotionEvent.ACTION_CANCEL:
                startRoll();
                break;

            default:
                break;
        }

        return super.onTouchEvent(ev);
    }

    @Override
    //当控件挂载到页面上会调用此方法
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
    }

    @Override
    //当控件从页面上移除的时候会调用此方法
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        isRunning=false;
        handler.removeMessages(NEXT);
    }

    //banner添加点击监听
    private OnItemClickListener onItemClickListener;

    public interface OnItemClickListener{
        public void onItemClick(int position);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.onItemClickListener=onItemClickListener;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/vo/SaleAttributeNameVo.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.vo;

import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import java.io.Serializable;
import java.util.List;

public class SaleAttributeNameVo implements Serializable {

	private String name;
	private String nameId;
	private List<SaleAttributeVo> saleVo;
	private String saleAttr;
	private boolean nameIsChecked;
	private List<TextsSearchEntity.DataBean.FiltersBean> saleVos;

	public String getName() {
		return name;
	}

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

	public String getNameId() {
		return nameId;
	}

	public void setNameId(String nameId) {
		this.nameId = nameId;
	}

	public List<SaleAttributeVo> getSaleVo() {
		return saleVo;
	}
	public List<TextsSearchEntity.DataBean.FiltersBean> getSaleVos() {
		return saleVos;
	}
	public void setSaleVos(List<TextsSearchEntity.DataBean.FiltersBean> saleVos) {
		this.saleVos = saleVos;
	}
	public void setSaleVo(List<SaleAttributeVo> saleVo) {
		this.saleVo = saleVo;
	}

	public String getSaleAttr() {
		return saleAttr;
	}

	public void setSaleAttr(String saleAttr) {
		this.saleAttr = saleAttr;
	}

	public boolean isNameIsChecked() {
		return nameIsChecked;
	}

	public void setNameIsChecked(boolean nameIsChecked) {
		this.nameIsChecked = nameIsChecked;
	}

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/OneKeyClearEditText.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.AppCompatEditText;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
 * 一键清除的EditText
 */
public class OneKeyClearEditText extends AppCompatEditText
    implements View.OnFocusChangeListener, TextWatcher {

  private Drawable mClearDrawable;// 一键删除的按钮
  private int colorAccent;// 获得主题的颜色
  private int DrawableColor = 0;
  private boolean hasFocus;// 控件是否有焦点

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

  public OneKeyClearEditText(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.editTextStyle);
  }

  @SuppressLint("InlinedApi")
  public OneKeyClearEditText(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray array =
        context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.colorAccent });
    colorAccent = array.getColor(0, 0x999999);
    array.recycle();
    TypedArray array2 = context.obtainStyledAttributes(attrs, R.styleable.OneKeyClearEditText);
    DrawableColor = array2.getColor(R.styleable.OneKeyClearEditText_deletecolor, colorAccent);
    array2.recycle();
    initClearDrawable(context);
  }

  //	@SuppressLint("NewApi")
  private void initClearDrawable(Context context) {
    mClearDrawable = getCompoundDrawables()[2];// 获取EditText的DrawableRight,假如没有设置我们就使用默认的图片
    if (mClearDrawable == null) {
      //			mClearDrawable = getResources().getDrawable(R.drawable.search_cancel, context.getTheme());
      mClearDrawable = getResources().getDrawable(R.drawable.search_cancel);
    }
    DrawableCompat.setTint(mClearDrawable, DrawableColor);// 设置删除按钮的颜色和TextColor的颜色一致
    mClearDrawable.setBounds(0, 0, (int) getTextSize(),
        (int) getTextSize());// 设置Drawable的宽高和TextSize的大小一致
    setClearIconVisible(false);
    // 设置焦点改变的监听
    setOnFocusChangeListener(this);
    // 设置输入框里面内容发生改变的监听
    addTextChangedListener(this);
  }

  /**
   * 设置清除图标的显示与隐藏，调用setCompoundDrawables为EditText绘制上去
   */
  private void setClearIconVisible(boolean visible) {
    Drawable right = visible ? mClearDrawable : null;
    setCompoundDrawables(getCompoundDrawables()[0], getCompoundDrawables()[1], right,
        getCompoundDrawables()[3]);
  }

  @Override public boolean onTouchEvent(MotionEvent event) {

    if (mClearDrawable != null && event.getAction() == MotionEvent.ACTION_UP) {
      int x = (int) event.getX();
      // 判断触摸点是否在水平范围内
      boolean isInnerWidth =
          (x > (getWidth() - getTotalPaddingRight())) && (x < (getWidth() - getPaddingRight()));
      // 获取删除图标的边界，返回一个Rect对象
      Rect rect = mClearDrawable.getBounds();
      // 获取删除图标的高度
      int height = rect.height();
      int y = (int) event.getY();
      // 计算图标底部到控件底部的距离
      int distance = (getHeight() - height) / 2;
      // 判断触摸点是否在竖直范围内(可能会有点误差)
      // 触摸点的纵坐标在distance到（distance+图标自身的高度）之内，则视为点中删除图标
      boolean isInnerHeight = (y > distance) && (y < (distance + height));
      if (isInnerHeight && isInnerWidth) {
        this.setText("");
      }
    }
    return super.onTouchEvent(event);
  }

  /**
   * 当输入框里面内容发生变化的时候回调的方法
   */
  @Override public void onTextChanged(CharSequence text, int start, int lengthBefore,
      int lengthAfter) {
    if (hasFocus) {
      setClearIconVisible(text.length() > 0);
      //if (onEditFocusChangedListener != null){
      //  onEditFocusChangedListener.onEditHasFocus();
      //}
    }
  }

  @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    // TODO Auto-generated method stub

  }

  @Override public void afterTextChanged(Editable s) {
    // TODO Auto-generated method stub

  }

  @Override public void onFocusChange(View v, boolean hasFocus) {
    this.hasFocus = hasFocus;
    if (hasFocus) {
      setClearIconVisible(getText().length() > 0);
      //if (onEditFocusChangedListener != null){
      //  onEditFocusChangedListener.onEditHasFocus();
      //}

    } else {
      setClearIconVisible(false);
    }
  }

  //private OnEditFocusChangedListener onEditFocusChangedListener;
  //
  //public void setOnEditFocusChangedListener(OnEditFocusChangedListener onEditFocusChangedListener){
  //	this.onEditFocusChangedListener = onEditFocusChangedListener;
  //}
  //
  //public interface OnEditFocusChangedListener{
  //	void onEditHasFocus();
  //}
}



<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/PopularText.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import android.support.annotation.Keep;
import java.util.List;

/**
 * Created by EtherealPatrick on 2017/4/17.
 */
@Keep
public class PopularText {

  /**
   * id : -1708299264
   * updateTime : 24555017
   * state : 0
   * stateMsg : 成功
   * data : {"popularText":"纯牛奶","texts":["人字拖","大裤衩","花衬衫","黑色","薄外套","春季新款"]}
   */

  private int id;
  private int updateTime;
  private int state;
  private String stateMsg;
  private DataBean data;

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public int getUpdateTime() {
    return updateTime;
  }

  public void setUpdateTime(int updateTime) {
    this.updateTime = updateTime;
  }

  public int getState() {
    return state;
  }

  public void setState(int state) {
    this.state = state;
  }

  public String getStateMsg() {
    return stateMsg;
  }

  public void setStateMsg(String stateMsg) {
    this.stateMsg = stateMsg;
  }

  public DataBean getData() {
    return data;
  }

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

  public static class DataBean {
    /**
     * popularText : 纯牛奶
     * texts : ["人字拖","大裤衩","花衬衫","黑色","薄外套","春季新款"]
     */

    private String popularText;
    private List<String> texts;

    public String getPopularText() {
      return popularText;
    }

    public void setPopularText(String popularText) {
      this.popularText = popularText;
    }

    public List<String> getTexts() {
      return texts;
    }

    public void setTexts(List<String> texts) {
      this.texts = texts;
    }
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/FilterUtils.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.textsearch.vo.SaleAttributeVo;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/7/7 16:16
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class FilterUtils {
  public static int getIndex(List<TextsSearchEntity.DataBean.FiltersBean> filterlist,
      int position) {
    int index = position;
    if (filterlist.size() == 1) {
      index = position - 1;
    } else if (filterlist.size() == 2) {
      if (position < 6) {
        index = position - 1;
      } else {
        index = position - 2;
      }
    } else if (filterlist.size() == 3) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else {
        index = position - 3;
      }
    } else if (filterlist.size() == 4) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else if (position > 12 && position < 18) {
        index = position - 3;
      } else {
        index = position - 4;
      }
    } else if (filterlist.size() == 5) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else if (position > 12 && position < 18) {
        index = position - 3;
      } else if (position > 18 && position < 24) {
        index = position - 4;
      } else {
        index = position - 5;
      }
    } else if (filterlist.size() == 6) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else if (position > 12 && position < 18) {
        index = position - 3;
      } else if (position > 18 && position < 24) {
        index = position - 4;
      } else if (position > 24 && position < 30) {
        index = position - 5;
      } else {
        index = position - 6;
      }
    } else if (filterlist.size() == 7) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else if (position > 12 && position < 18) {
        index = position - 3;
      } else if (position > 18 && position < 24) {
        index = position - 4;
      } else if (position > 24 && position < 30) {
        index = position - 5;
      } else if (position > 30 && position < 36) {
        index = position - 6;
      } else {
        index = position - 7;
      }
    } else if (filterlist.size() == 8) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else if (position > 12 && position < 18) {
        index = position - 3;
      } else if (position > 18 && position < 24) {
        index = position - 4;
      } else if (position > 24 && position < 30) {
        index = position - 5;
      } else if (position > 30 && position < 36) {
        index = position - 6;
      } else if (position > 36 && position < 42) {
        index = position - 7;
      } else {
        index = position - 8;
      }
    } else if (filterlist.size() == 9) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else if (position > 12 && position < 18) {
        index = position - 3;
      } else if (position > 18 && position < 24) {
        index = position - 4;
      } else if (position > 24 && position < 30) {
        index = position - 5;
      } else if (position > 30 && position < 36) {
        index = position - 6;
      } else if (position > 36 && position < 42) {
        index = position - 7;
      } else if (position > 42 && position < 48) {
        index = position - 8;
      } else {
        index = position - 9;
      }
    } else if (filterlist.size() == 10) {
      if (position < 6) {
        index = position - 1;
      } else if (position > 6 && position < 12) {
        index = position - 2;
      } else if (position > 12 && position < 18) {
        index = position - 3;
      } else if (position > 18 && position < 24) {
        index = position - 4;
      } else if (position > 24 && position < 30) {
        index = position - 5;
      } else if (position > 30 && position < 36) {
        index = position - 6;
      } else if (position > 36 && position < 42) {
        index = position - 7;
      } else if (position > 42 && position < 48) {
        index = position - 8;
      } else if (position > 48 && position < 54) {
        index = position - 9;
      } else {
        index = position - 10;
      }
    }
    return index;
  }

  public static int getSize(List<TextsSearchEntity.DataBean.ItemsBean> list) {
    if (list.size() > 0 && list.size() < 5) {
      return list.size()+1;
    } else if (list.size() < 10 && list.size() >= 5) {
      return list.size() + 2;
    } else if (list.size() >= 10 && list.size() < 15) {
      return list.size() + 3;
    } else if (list.size() >= 15 && list.size() < 20) {
      return list.size() + 4;
    } else if (list.size() >= 20 && list.size() < 25) {
      return list.size() + 5;
    } else if (list.size() >= 25 && list.size() < 30) {
      return list.size() + 6;
    } else if (list.size() >= 30 && list.size() < 35) {
      return list.size() + 7;
    } else if (list.size() >= 35 && list.size() < 40) {
      return list.size() + 8;
    } else if (list.size() >= 40 && list.size() < 45) {
      return list.size() + 9;
    } else if (list.size() >= 45 && list.size() < 50) {
      return list.size() + 10;
    } else {
      return list.size() + 11;
    }
  }

  //public static void setVisibile(RecyclerView.ViewHolder holder, int newpositions,
  //    List<TextsSearchEntity.DataBean.FiltersBean> filterlist, final List<String> filters) {
  //  filters.clear();
  //  filters.addAll(filterlist.get(newpositions).getFilterOption());
  //  if (filters.size() >= 5) {
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).five.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setText(filters.get(0));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setText(filters.get(1));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setText(filters.get(2));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setText(filters.get(3));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).five.setText("更多");
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  //      @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
  //        switch (checkedId){
  //          case R.id.first:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //            break;
  //          case R.id.second:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //            break;
  //          case R.id.thrid:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(2)));
  //            break;
  //          case R.id.four:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(3)));
  //            break;
  //          case R.id.five:
  //            EventBus.getDefault().post(new TextEventUtil(""));
  //            break;
  //        }
  //      }
  //    });
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).first.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).second.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(2)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).four.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(3)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).five.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(""));
  //    //
  //    //  }
  //    //});
  //  } else if (filters.size() >= 4 && filters.size() < 5) {
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
  //
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setText(filters.get(0));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setText(filters.get(1));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setText(filters.get(2));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setText(filters.get(3));
  //
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  //      @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
  //        switch (checkedId){
  //          case R.id.first:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //            break;
  //          case R.id.second:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //            break;
  //          case R.id.thrid:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(2)));
  //            break;
  //          case R.id.four:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(3)));
  //            break;
  //        }
  //      }
  //    });
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).first.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).second.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(2)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).four.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(3)));
  //    //  }
  //    //});
  //
  //  } else if (filters.size() >= 3 && filters.size() < 4) {
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
  //
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setText(filters.get(0));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setText(filters.get(1));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setText(filters.get(2));
  //
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  //      @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
  //        switch (checkedId){
  //          case R.id.first:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //            break;
  //          case R.id.second:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //            break;
  //          case R.id.thrid:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(2)));
  //            break;
  //        }
  //      }
  //    });
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).first.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).second.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(2)));
  //    //  }
  //    //});
  //
  //  } else if (filters.size() >= 2 && filters.size() < 3) {
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setVisibility(View.VISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
  //
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setText(filters.get(0));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setText(filters.get(1));
  //
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  //      @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
  //        switch (checkedId){
  //          case R.id.first:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //            break;
  //          case R.id.second:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //            break;
  //        }
  //      }
  //    });
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).first.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //    //  }
  //    //});
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).second.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(1)));
  //    //  }
  //    //});
  //
  //  } else if (filters.size() >= 1 && filters.size() < 2) {
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
  //
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setText(filters.get(0));
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
  //      @Override public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
  //        switch (checkedId){
  //          case R.id.first:
  //            EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //            break;
  //        }
  //      }
  //    });
  //    //
  //    //((ComprehensiveAdapter.HeadViewHolder) holder).first.setOnClickListener(new View.OnClickListener() {
  //    //  @Override public void onClick(View v) {
  //    //    EventBus.getDefault().post(new TextEventUtil(filters.get(0)));
  //    //  }
  //    //});
  //  } else if (filters.size() < 1) {
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).thrid.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).second.setVisibility(View.INVISIBLE);
  //    ((ComprehensiveAdapter.HeadViewHolder) holder).first.setVisibility(View.INVISIBLE);
  //  }
  //}

  public static void setNumber(List<SaleAttributeVo> tempData, List<SaleAttributeVo> data) {
    if (tempData.size() == 1) {
      data.add(tempData.get(0));
    } else if (tempData.size() == 2) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
    } else if (tempData.size() == 3) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
    } else if (tempData.size() == 4) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
    } else if (tempData.size() == 5) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
      data.add(tempData.get(4));
    } else if (tempData.size() == 6) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
      data.add(tempData.get(4));
      data.add(tempData.get(5));
    } else {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
      data.add(tempData.get(4));
      data.add(tempData.get(5));
    }
  }
  public static void setNumberFilter(List<String> tempData, List<String> data) {
    if (tempData.size() == 1) {
      data.add(tempData.get(0));
    } else if (tempData.size() == 2) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
    } else if (tempData.size() == 3) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
    } else if (tempData.size() == 4) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
    } else if (tempData.size() == 5) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
      data.add(tempData.get(4));
    } else if (tempData.size() == 6) {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
      data.add(tempData.get(4));
      data.add(tempData.get(5));
    } else {
      data.add(tempData.get(0));
      data.add(tempData.get(1));
      data.add(tempData.get(2));
      data.add(tempData.get(3));
      data.add(tempData.get(4));
      data.add(tempData.get(5));
    }
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/TipButton.java<|end_filename|>
package com.deepbaytech.deeplibrary;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.RadioButton;

/**
 * Created by EtherealPatrick on 2016/9/19.
 */
public class TipButton extends RadioButton {

    private boolean mTipOn = false;

    private Dot mDot;

    private class Dot {

        int color;

        int radius;

        int marginTop;
        int marginRight;

        Dot() {
            float density = getContext().getResources().getDisplayMetrics().density;
            radius = (int) (5 * density);
            marginTop = (int) (3 * density);
            marginRight = (int) (3 * density);

            color = getContext().getResources().getColor(R.color.colorPrimaryDark);
        }

    }

    public TipButton(Context context) {
        super(context);
        init();
    }

    public TipButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public TipButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    private void init() {
        mDot = new Dot();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        if (mTipOn) {
            float cx = getWidth() - mDot.marginRight - mDot.radius;
            float cy = mDot.marginTop + mDot.radius;

            Drawable drawableTop = getCompoundDrawables()[1];
            if (drawableTop != null) {
                int drawableTopWidth = drawableTop.getIntrinsicWidth();
                if (drawableTopWidth > 0) {
                    int dotLeft = getWidth() / 2 + drawableTopWidth / 2;
                    cx = dotLeft + mDot.radius;
                }
            }


            Paint paint = getPaint();
            //save
            int tempColor = paint.getColor();

            paint.setColor(mDot.color);
            paint.setStyle(Paint.Style.FILL);
            canvas.drawCircle(cx, cy, mDot.radius, paint);

            //restore
            paint.setColor(tempColor);
        }
    }

    public void setTipOn(boolean tip) {
        this.mTipOn = tip;

        invalidate();
    }

    public boolean isTipOn() {
        return mTipOn;
    }
}

<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/view/FilterFragments.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.view;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.example.lwd18.pictureselecotor.ApiConstants;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.Eventil;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.FinishEventUtil;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.SecondEventil;
import com.example.lwd18.pictureselecotor.textsearch.adapter.GoodSAttrRvAdatper;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import de.greenrobot.event.EventBus;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Call;

/**
 * 筛选商品属性选择的popupwindow
 */
public class FilterFragments extends FrameLayout {
  private View contentView;
  private RecyclerView selectionList;
  private TextView filterReset;
  private TextView filterSure;
  private GoodSAttrRvAdatper adapter;
  private LinearLayoutManager linearLayoutManager;
  private List<String> filtelist;
  List<String> newlist;
  private List<TextsSearchEntity.DataBean.FiltersBean> mlist = new ArrayList<>();
  private List<TextsSearchEntity.DataBean.FiltersBean> newlists = new ArrayList<>();
  //关键词
  String keyword;

  /**
   * 商品属性选择的popupwindow
   */
  public FilterFragments(Context context, String edditx) {
    super(context);
    EventBus.getDefault().registerSticky(this);
    keyword = edditx;
    init(context);
  }

  public FilterFragments(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    EventBus.getDefault().registerSticky(this);
    init(context);
  }

  public FilterFragments(@NonNull Context context, @Nullable AttributeSet attrs,
      @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    EventBus.getDefault().registerSticky(this);
    init(context);
  }

  private void init(final Context context) {
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    contentView = inflater.inflate(R.layout.popup_goods_details, null);
    selectionList = (RecyclerView) contentView.findViewById(R.id.selection_list);
    filterReset = (TextView) contentView.findViewById(R.id.filter_reset);
    filterSure = (TextView) contentView.findViewById(R.id.filter_sure);

    contentView.setOnKeyListener(new OnKeyListener() {
      @Override public boolean onKey(View v, int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
        }
        return true;
      }
    });
    //初始化筛选框的list
    filtelist = new ArrayList<>();
    newlist = new ArrayList<>();
    getData(keyword);
    linearLayoutManager =
        new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    selectionList.setLayoutManager(linearLayoutManager);
    adapter = new GoodSAttrRvAdatper(context);
    selectionList.setAdapter(adapter);

    // 重置的点击监听，将所有选项全设为false
    filterReset.setOnClickListener(new OnClickListener() {
      @Override public void onClick(View v) {
        adapter = new GoodSAttrRvAdatper(context);
        selectionList.setAdapter(adapter);
        //通知综合界面刷新
        EventBus.getDefault().post(new SecondEventil(filtelist));
      }
    });
    // 确定的点击监听，将所有已选中项列出
    filterSure.setOnClickListener(new OnClickListener() {
      @Override public void onClick(View v) {
        //将筛选项发送过去
        EventBus.getDefault().post(new SecondEventil(filtelist));
        EventBus.getDefault().post(new FinishEventUtil());
        filtelist.clear();
      }
    });
    this.addView(contentView);
    ColorDrawable dw = new ColorDrawable(00000000);
    this.setBackgroundDrawable(dw);
    this.setFocusable(true);
  }

  /**
   * 用来接收筛选框中的消息
   */
  public void onEventMainThread(Eventil event) {
    String filter = event.getProviceName();
    System.out.println("接收到筛选框传递到fragment中的消息了==" + filter);
    if (filtelist.size() <= 0) {
      filtelist.clear();
      filtelist.add(filter);
    } else {
      if (!filtelist.contains(filter)) {
        filtelist.add(filter);
      } else {
        filtelist.remove(filter);
      }
    }
  }

  private void getData(String keyword) {
    OkHttpUtils.get()
        .url(ApiConstants.TEXTSEARCHS)
        .addParams("text", keyword)
        .addParams("pageId", 1 + "")
        .addParams("sortId", 0 + "")
        .addParams("params", "")
        .build()
        .execute(new StringCallback() {
          @Override public void onError(Call call, Exception e, int id) {

          }
          @Override public void onResponse(String response, int id) {
            TextsSearchEntity textSearch = JSON.parseObject(response, TextsSearchEntity.class);
            if (textSearch.getData() != null && textSearch.getData().getFilters() != null) {
              mlist.clear();
              newlists.clear();
              mlist.addAll(textSearch.getData().getFilters());
              newlists.addAll(mlist);
              adapter.addItem(mlist);
            }
          }
        });
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/resultadapter/FilterAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.resultadapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.FilterUtils;
import java.util.ArrayList;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/6/19 11:29
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class FilterAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
  private int HEAD = 1;
  private int NORMAL = 2;
  private List<TextsSearchEntity.DataBean.ItemsBean> list;
  private List<TextsSearchEntity.DataBean.FiltersBean> filterlist;
  private List<String> filters;

  public FilterAdapter() {
    list = new ArrayList<>();
    filterlist = new ArrayList<>();
    filters = new ArrayList<>();
  }

  @Override public int getItemViewType(int position) {
    if (filterlist.size() == 0) {
      return NORMAL;
    } else {
      int positions = (filterlist.size() - 1) * 6;
      if (position == 0) {
        return HEAD;
      } else {
        if (position > positions) {
          return NORMAL;
        } else {
          if (position % 6 == 0) {
            return HEAD;
          } else {
            return NORMAL;
          }
        }
      }
    }
  }

  @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == HEAD) {
      View view = View.inflate(parent.getContext(), R.layout.item_product_head, null);
      return new HeadViewHolder(view);
    } else if (viewType == NORMAL) {
      View view = View.inflate(parent.getContext(), R.layout.item_product_normal, null);
      return new NormalViewHolder(view);
    }
    return null;
  }

  @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    int positions = (filterlist.size() - 1) * 6;

    if (holder instanceof NormalViewHolder) {
      //如果filst为空,不会出现越界异常情况//最多两个
      int index = FilterUtils.getIndex(filterlist,position);
      ((NormalViewHolder) holder).titleProduct.setText(list.get(index).getTitle());
      Glide.with(holder.itemView.getContext())
          .load(list.get(index).getPicUrl())
          .into(((NormalViewHolder) holder).iconProduct);
      ((NormalViewHolder) holder).price.setText("¥" + list.get(index).getPrice());
      ((NormalViewHolder) holder).priceAllNet.setText(
          "全网销量" + list.get(index).getViewSales() + "万");
      ((NormalViewHolder) holder).priceTaobao.setText("¥" + list.get(index).getFromat());
      ((NormalViewHolder) holder).priceMecheat.setText(
          list.get(index).getShopCount() + "电商100商家比价");
    } else if (holder instanceof HeadViewHolder) {
      //int newpositions = position / 6;
      //filters.clear();
      //filters.addAll(filterlist.get(newpositions).getFilterOption());
      //if (filters.size() >= 5) {
      //  ((HeadViewHolder) holder).five.setVisibility(View.VISIBLE);
      //} else if (filters.size() >= 4 && filters.size() < 5) {
      //  ((HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).four.setVisibility(View.VISIBLE);
      //  ((HeadViewHolder) holder).thrid.setVisibility(View.VISIBLE);
      //  ((HeadViewHolder) holder).second.setVisibility(View.VISIBLE);
      //  ((HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
      //
      //  ((HeadViewHolder) holder).first.setText(filters.get(0));
      //  ((HeadViewHolder) holder).second.setText(filters.get(1));
      //  ((HeadViewHolder) holder).thrid.setText(filters.get(2));
      //  ((HeadViewHolder) holder).four.setText(filters.get(3));
      //} else if (filters.size() >= 3 && filters.size() < 4) {
      //  ((HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).thrid.setVisibility(View.VISIBLE);
      //  ((HeadViewHolder) holder).second.setVisibility(View.VISIBLE);
      //  ((HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
      //
      //  ((HeadViewHolder) holder).first.setText(filters.get(0));
      //  ((HeadViewHolder) holder).second.setText(filters.get(1));
      //  ((HeadViewHolder) holder).thrid.setText(filters.get(2));
      //} else if (filters.size() >= 2 && filters.size() < 3) {
      //  ((HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).thrid.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).second.setVisibility(View.VISIBLE);
      //  ((HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
      //
      //  ((HeadViewHolder) holder).first.setText(filters.get(0));
      //  ((HeadViewHolder) holder).second.setText(filters.get(1));
      //} else if (filters.size() >= 1 && filters.size() < 2) {
      //  ((HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).thrid.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).second.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).first.setVisibility(View.VISIBLE);
      //
      //  ((HeadViewHolder) holder).first.setText(filters.get(0));
      //} else if (filters.size() < 1) {
      //  ((HeadViewHolder) holder).five.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).four.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).thrid.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).second.setVisibility(View.INVISIBLE);
      //  ((HeadViewHolder) holder).first.setVisibility(View.INVISIBLE);
      //}
    }
  }

  @Override public int getItemCount() {
    int positions = (filterlist.size() - 1) * 6;
    if (filterlist.size() == 0) {
      return list.size();
    } else if (list.size()<positions){
      return FilterUtils.getSize(list);
    }else {
      return filterlist.size() + list.size();
    }
  }

  public class NormalViewHolder extends RecyclerView.ViewHolder {
    ImageView iconProduct;
    TextView titleProduct;
    TextView priceTvMin;
    TextView price;
    TextView priceAllNet;
    ImageView priceIv;
    TextView priceTaobao;
    TextView priceMecheat;

    public NormalViewHolder(View itemView) {
      super(itemView);
      iconProduct = (ImageView) itemView.findViewById(R.id.icon_product);
      titleProduct = (TextView) itemView.findViewById(R.id.title_product);
      priceTvMin = (TextView) itemView.findViewById(R.id.price_tv_min);
      price = (TextView) itemView.findViewById(R.id.price);
      priceAllNet = (TextView) itemView.findViewById(R.id.price_all_net);
      priceIv = (ImageView) itemView.findViewById(R.id.price_iv);
      priceTaobao = (TextView) itemView.findViewById(R.id.price_taobao);
      priceMecheat = (TextView) itemView.findViewById(R.id.price_mecheat);
    }
  }

  public class HeadViewHolder extends RecyclerView.ViewHolder {
   // Button first, second, thrid, four, five;

    public HeadViewHolder(View itemView) {
      super(itemView);
      //first = (Button) itemView.findViewById(R.id.first);
      //second = (Button) itemView.findViewById(R.id.second);
      //thrid = (Button) itemView.findViewById(R.id.thrid);
      //four = (Button) itemView.findViewById(R.id.four);
      //five = (Button) itemView.findViewById(R.id.five);
    }
  }

  //添加数据
  public void addItem(List<TextsSearchEntity.DataBean.ItemsBean> newDatas) {
    list.clear();
    newDatas.addAll(list);
    list.removeAll(list);
    list.addAll(newDatas);
    notifyDataSetChanged();
  }

  public void addMoreItem(List<TextsSearchEntity.DataBean.ItemsBean> newDatas) {
    list.addAll(newDatas);
    notifyDataSetChanged();
  }

  public void addFilterItem(List<TextsSearchEntity.DataBean.FiltersBean> mlists) {
    filterlist.clear();
    mlists.addAll(filterlist);
    filterlist.removeAll(filterlist);
    filterlist.addAll(mlists);
    notifyDataSetChanged();
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/TextEventUtil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

/**
 * 创建者     李文东
 * 创建时间   2017/7/12 11:16
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class TextEventUtil {
  private String msg;

  public TextEventUtil(){

  }
  public TextEventUtil(String msg){
    this.msg=msg;
  }
  public String getMsgs(){
    return this.msg;
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/TranstRevaEventil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

/**
 * 创建者     李文东
 * 创建时间   2017/8/3 18:26
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class TranstRevaEventil {
  private String filter;
  public TranstRevaEventil() {
  }

  public TranstRevaEventil(String filter) {
   this.filter=filter;
  }

  public String getFilter() {
    return filter;
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/view/FilterView.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.view;

import android.content.Context;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.FrameLayout;

/**
 * 创建者     李文东
 * 创建时间   2017/7/8 17:47
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class FilterView extends FrameLayout {
  public FilterView(@NonNull Context context) {
    super(context);
  }

  public FilterView(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
  }

  public FilterView(@NonNull Context context, @Nullable AttributeSet attrs,
      @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/SortItem.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

/**
 * Created by x on 2016/11/4.
 */

public class SortItem {
    private int key;

    private String value;

    public void setKey(int key){
        this.key = key;
    }
    public int getKey(){
        return this.key;
    }
    public void setValue(String value){
        this.value = value;
    }
    public String getValue(){
        return this.value;
    }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/utils/MD5Utils.java<|end_filename|>
package com.deepbaytech.deeplibrary.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created by deepbayter on 2016/7/6.
 */
public class MD5Utils {
    //传一个字符串获取其MD5加密
    public static   String getMD5(String key) {
        String cacheKey;
        try {
            MessageDigest mDigest = MessageDigest.getInstance("MD5");
            mDigest.update(key.getBytes("UTF-8"));
            cacheKey = bytesToHexString(mDigest.digest());
        } catch (Exception e) {
            cacheKey = String.valueOf(key.hashCode());
        }
        return cacheKey;
    }

    private static   String bytesToHexString(byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < bytes.length; i++) {
            String hex = Integer.toHexString(0xFF & bytes[i]);
            if (hex.length() == 1) {
                sb.append('0');
            }
            sb.append(hex);
        }
        return sb.toString();
    }


    /**
     * md5加密
     * @param psw
     * @return
     */
    public static String md5(String psw){
        StringBuilder sb = new StringBuilder();
        try {
            //数据摘要器
            //algorithm : 加密方式
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            //第一次加密，将一个byte数组进行加密，返回一个加密过的byte数据，二进制哈希算法
            byte[] digest = messageDigest.digest(psw.getBytes());
            for (int i = 0; i < digest.length; i++) {
                //byte:-128--127
                //将负数转化成正整数
                int reuslt = digest[i] & 0xff;
                //将int类型的数据转化成十六进制的字符串
                //String hexString = Integer.toHexString(reuslt)+1;//不规则加密，加盐操作
                String hexString = Integer.toHexString(reuslt);
                if (hexString.length() < 2) {
                    //System.out.print("0");
                    sb.append("0");
                }
                //System.out.println(hexString);
                sb.append(hexString);
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return psw;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/FilterEventUtil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/7/11 9:18
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class FilterEventUtil {
  private List<TextsSearchEntity.DataBean.FiltersBean> list;
  public FilterEventUtil(){

  }
  public FilterEventUtil(List<TextsSearchEntity.DataBean.FiltersBean> list){
    this.list=list;
  }
  public List<TextsSearchEntity.DataBean.FiltersBean> getList(){
    return this.list;
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/bigphotobrows/ImageBrowseActivity.java<|end_filename|>
package com.example.lwd18.pictureselecotor.bigphotobrows;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.dialog.QuickOptionDialog;
import java.util.ArrayList;
import java.util.List;



public class ImageBrowseActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener, View
        .OnClickListener, ImageBrowseView,QuickOptionDialog.OnClick,ViewPageAdapter.ShowDialog {

    private ViewPager            vp;
    private TextView             hint;
    private TextView             save;
    private ViewPageAdapter      adapter;
    private ImageBrowsePresenter presenter;
    private QuickOptionDialog mDialog;
    private boolean isShow=false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_image_browse);
        vp = (ViewPager) this.findViewById(R.id.viewPager);
        hint = (TextView) this.findViewById(R.id.hint);
        save = (TextView) this.findViewById(R.id.save);
        save.setOnClickListener(this);
        initPresenter();
        presenter.loadImage();

    }

    public void initPresenter() {
        presenter = new ImageBrowsePresenter(this);
    }

    @Override
    public Intent getDataIntent() {
        return getIntent();
    }

    @Override
    public Context getMyContext() {
        return this;
    }

    @Override
    public void setImageBrowse(List<String> images, int position) {
        if (adapter == null && images != null && images.size() != 0) {
            adapter = new ViewPageAdapter(ImageBrowseActivity.this,this, images);
            vp.setAdapter(adapter);
            vp.setCurrentItem(position);
            vp.addOnPageChangeListener(this);
            hint.setText(position + 1 + "/" + images.size());
            adapter.setShowDialog(this);
        }
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        presenter.setPosition(position);
        hint.setText(position + 1 + "/" + presenter.getImages().size());
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }

    @Override
    public void onClick(View v) {
        new Thread(presenter).start();
        Toast.makeText(ImageBrowseActivity.this, "图片已经保存", Toast.LENGTH_SHORT).show();
    }


    public static void startActivity(Context context, ArrayList<String> images, int position) {
        Intent intent = new Intent(context, ImageBrowseActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putStringArrayListExtra("images", images);
        intent.putExtra("position", position);
        context.startActivity(intent);
    }

    @Override
    public void saveclick() {
        if (isShow) {
            new Thread(presenter).start();
        }
    }

    @Override
    public void show() {
        showQuickOption();
        isShow=true;
        if (mDialog!=null) {
            mDialog.setOnClick(this);
        }
    }

    private void showQuickOption() {
        mDialog = new QuickOptionDialog(ImageBrowseActivity.this,this);
        mDialog.setCancelable(true);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.show();
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/TextsSearchEntity.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import java.io.Serializable;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/7/5 18:52
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class TextsSearchEntity {

  /**
   * id : -1139915730
   * updateTime : 12020568
   * state : 0
   * stateSmg : 成功
   * data : {"filters":[{"filterName":"国产&进口","filterOption":["国产","进口","其他"]},{"filterName":"脂肪含量","filterOption":["低脂","全脂","脱脂","其他"]}],"pageCurr":1,"pageTotal":25,"items":[{"id":"AV0IiqSROFuQj7og1tjh","title":"伊利
   * 牛奶 金典 250ml*12","price":18,"viewSales":16257,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IiqSROFuQj7og1tjh","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i2/2668770299/TB2KrNEmSBjpuFjSsplXXa5MVXa_!!2668770299.png","shopCount":59},{"id":"AV0IillKOFuQj7og1tjX","title":"伊利
   * 牛奶 谷粒多 250ml*12","price":22,"viewSales":221,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IillKOFuQj7og1tjX","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i3/2573755540/TB2WpbJX9BjpuFjSsplXXa5MVXa_!!2573755540.jpg","shopCount":44},{"id":"AV0IioQROFuQj7og1tjd","title":"伊利
   * 牛奶 味可滋 240ml*12","price":32,"viewSales":293,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IioQROFuQj7og1tjd","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i1/2854765902/TB248JHb4uI.eBjy0FdXXXgbVXa_!!2854765902.jpg","shopCount":46},{"id":"AV0Iizr3OFuQj7og1tj0","title":"安佳
   * 牛奶 190ml*12","price":49,"viewSales":1,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Iizr3OFuQj7og1tj0","keywords":"牛奶","fromat":"0.02/ml","picUrl":"//g-search2.alicdn.com/img/bao/uploaded/i4/i1/130676651/TB2zWYmlYFkpuFjy1XcXXclapXa_!!130676651.png","shopCount":6},{"id":"AV0IirasOFuQj7og1tjj","title":"伊利
   * 牛奶 安慕希 205g*12","price":40,"viewSales":2,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IirasOFuQj7og1tjj","keywords":"牛奶","fromat":"0.02/g","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i1/2117207672/TB2WPIknolnpuFjSZFjXXXTaVXa_!!2117207672.jpg","shopCount":5},{"id":"AV0Ii6MPOFuQj7og1tj9","title":"蒙牛
   * 谷粒 早餐 250ml*12","price":25,"viewSales":80,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Ii6MPOFuQj7og1tj9","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i2/3249552775/TB2xtM4qwNlpuFjy0FfXXX3CpXa_!!3249552775.jpg","shopCount":9},{"id":"AV0Ii98yOFuQj7og1tkF","title":"蒙牛
   * 奶特 180ml*16","price":25,"viewSales":5,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Ii98yOFuQj7og1tkF","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i2/TB1BUP4KpXXXXa3XXXXXXXXXXXX_!!0-item_pic.jpg","shopCount":3},{"id":"AV0IilM5OFuQj7og1tjW","title":"伊利
   * 牛奶 谷粒多 250ml*4","price":32,"viewSales":66,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IilM5OFuQj7og1tjW","keywords":"牛奶","fromat":"0.03/ml","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i1/2570721531/TB2miCJprtlpuFjSspoXXbcDpXa_!!2570721531.jpg","shopCount":3},{"id":"AV0Iiu7TOFuQj7og1tjp","title":"伊利
   * 牛奶 纯牛奶 1L*6","price":56,"viewSales":7,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Iiu7TOFuQj7og1tjp","keywords":"牛奶","fromat":"9.33/L","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i4/T1ZBRnFtRkXXXXXXXX_!!0-item_pic.jpg","shopCount":10},{"id":"AV0IitamOFuQj7og1tjn","title":"伊利
   * 牛奶 QQ星 190ml*4","price":45,"viewSales":2,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IitamOFuQj7og1tjn","keywords":"牛奶","fromat":"0.06/ml","picUrl":"//g-search2.alicdn.com/img/bao/uploaded/i4/i3/2700445815/TB26HWXhb_0UKFjy1XaXXbKfXXa_!!2700445815.jpg","shopCount":3}]}
   */

  private int id=-1;
  private int updateTime;
  private int state;
  private String stateSmg;
  private DataBean data;

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public int getUpdateTime() {
    return updateTime;
  }

  public void setUpdateTime(int updateTime) {
    this.updateTime = updateTime;
  }

  public int getState() {
    return state;
  }

  public void setState(int state) {
    this.state = state;
  }

  public String getStateSmg() {
    return stateSmg;
  }

  public void setStateSmg(String stateSmg) {
    this.stateSmg = stateSmg;
  }

  public DataBean getData() {
    return data;
  }

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

  public static class DataBean {
    /**
     * filters : [{"filterName":"国产&进口","filterOption":["国产","进口","其他"]},{"filterName":"脂肪含量","filterOption":["低脂","全脂","脱脂","其他"]}]
     * pageCurr : 1
     * pageTotal : 25
     * items : [{"id":"AV0IiqSROFuQj7og1tjh","title":"伊利 牛奶 金典 250ml*12","price":18,"viewSales":16257,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IiqSROFuQj7og1tjh","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i2/2668770299/TB2KrNEmSBjpuFjSsplXXa5MVXa_!!2668770299.png","shopCount":59},{"id":"AV0IillKOFuQj7og1tjX","title":"伊利
     * 牛奶 谷粒多 250ml*12","price":22,"viewSales":221,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IillKOFuQj7og1tjX","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i3/2573755540/TB2WpbJX9BjpuFjSsplXXa5MVXa_!!2573755540.jpg","shopCount":44},{"id":"AV0IioQROFuQj7og1tjd","title":"伊利
     * 牛奶 味可滋 240ml*12","price":32,"viewSales":293,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IioQROFuQj7og1tjd","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i1/2854765902/TB248JHb4uI.eBjy0FdXXXgbVXa_!!2854765902.jpg","shopCount":46},{"id":"AV0Iizr3OFuQj7og1tj0","title":"安佳
     * 牛奶 190ml*12","price":49,"viewSales":1,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Iizr3OFuQj7og1tj0","keywords":"牛奶","fromat":"0.02/ml","picUrl":"//g-search2.alicdn.com/img/bao/uploaded/i4/i1/130676651/TB2zWYmlYFkpuFjy1XcXXclapXa_!!130676651.png","shopCount":6},{"id":"AV0IirasOFuQj7og1tjj","title":"伊利
     * 牛奶 安慕希 205g*12","price":40,"viewSales":2,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IirasOFuQj7og1tjj","keywords":"牛奶","fromat":"0.02/g","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i1/2117207672/TB2WPIknolnpuFjSZFjXXXTaVXa_!!2117207672.jpg","shopCount":5},{"id":"AV0Ii6MPOFuQj7og1tj9","title":"蒙牛
     * 谷粒 早餐 250ml*12","price":25,"viewSales":80,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Ii6MPOFuQj7og1tj9","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i2/3249552775/TB2xtM4qwNlpuFjy0FfXXX3CpXa_!!3249552775.jpg","shopCount":9},{"id":"AV0Ii98yOFuQj7og1tkF","title":"蒙牛
     * 奶特 180ml*16","price":25,"viewSales":5,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Ii98yOFuQj7og1tkF","keywords":"牛奶","fromat":"0.01/ml","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i2/TB1BUP4KpXXXXa3XXXXXXXXXXXX_!!0-item_pic.jpg","shopCount":3},{"id":"AV0IilM5OFuQj7og1tjW","title":"伊利
     * 牛奶 谷粒多 250ml*4","price":32,"viewSales":66,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IilM5OFuQj7og1tjW","keywords":"牛奶","fromat":"0.03/ml","picUrl":"//g-search1.alicdn.com/img/bao/uploaded/i4/i1/2570721531/TB2miCJprtlpuFjSspoXXbcDpXa_!!2570721531.jpg","shopCount":3},{"id":"AV0Iiu7TOFuQj7og1tjp","title":"伊利
     * 牛奶 纯牛奶 1L*6","price":56,"viewSales":7,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0Iiu7TOFuQj7og1tjp","keywords":"牛奶","fromat":"9.33/L","picUrl":"//g-search3.alicdn.com/img/bao/uploaded/i4/i4/T1ZBRnFtRkXXXXXXXX_!!0-item_pic.jpg","shopCount":10},{"id":"AV0IitamOFuQj7og1tjn","title":"伊利
     * 牛奶 QQ星 190ml*4","price":45,"viewSales":2,"platform":"淘宝","platformCount":1,"detailUrl":"group-detail?id=AV0IitamOFuQj7og1tjn","keywords":"牛奶","fromat":"0.06/ml","picUrl":"//g-search2.alicdn.com/img/bao/uploaded/i4/i3/2700445815/TB26HWXhb_0UKFjy1XaXXbKfXXa_!!2700445815.jpg","shopCount":3}]
     */

    private int pageCurr;
    private int pageTotal;
    private List<FiltersBean> filters;
    private List<ItemsBean> items;

    public int getPageCurr() {
      return pageCurr;
    }

    public void setPageCurr(int pageCurr) {
      this.pageCurr = pageCurr;
    }

    public int getPageTotal() {
      return pageTotal;
    }

    public void setPageTotal(int pageTotal) {
      this.pageTotal = pageTotal;
    }

    public List<FiltersBean> getFilters() {
      return filters;
    }

    public void setFilters(List<FiltersBean> filters) {
      this.filters = filters;
    }

    public List<ItemsBean> getItems() {
      return items;
    }

    public void setItems(List<ItemsBean> items) {
      this.items = items;
    }

    public static class FiltersBean implements Serializable {

      private boolean isoPen = false;
      private String showStr = "";
      private String filterName;

      private List<String> filterOption;
      private List<String> SelectFilterOption;
      public List<String> getFilterOption() {
        return filterOption;
      }

      public void setFilterOption(List<String> filterOption) {
        this.filterOption = filterOption;
      }

      public List<String> getSelectFilterOption() {
        return SelectFilterOption;
      }

      public void setSelectFilterOption(List<String> selectFilterOption) {
        SelectFilterOption = selectFilterOption;
      }
      public boolean isoPen() {
        return isoPen;
      }

      public void setIsoPen(boolean isoPen) {
        this.isoPen = isoPen;
      }

      public String getShowStr() {
        return showStr;
      }

      public void setShowStr(String showStr) {
        this.showStr = showStr;
      }

      public String getFilterName() {
        return filterName;
      }

      public void setFilterName(String filterName) {
        this.filterName = filterName;
      }

        private boolean isChick;

        public boolean isChick() {
          return isChick;
        }

        public void setChick(boolean chick) {
          isChick = chick;
        }

    }

    public static class ItemsBean {
      /**
       * id : AV0IiqSROFuQj7og1tjh
       * title : 伊利 牛奶 金典 250ml*12
       * price : 18
       * viewSales : 16257
       * platform : 淘宝
       * platformCount : 1
       * detailUrl : group-detail?id=AV0IiqSROFuQj7og1tjh
       * keywords : 牛奶
       * fromat : 0.01/ml
       * picUrl : //g-search1.alicdn.com/img/bao/uploaded/i4/i2/2668770299/TB2KrNEmSBjpuFjSsplXXa5MVXa_!!2668770299.png
       * shopCount : 59
       */

      private String id;
      private String title;
      private int price;
      private int viewSales;
      private String platform;
      private int platformCount;
      private String detailUrl;
      private String keywords;
      private String fromat;
      private String picUrl;
      private int shopCount;
      private String pfromId;
      private int type;
      private int amountType;
      private double amountMoney;

      public String getPfromId() {
        return pfromId;
      }

      public void setPfromId(String pfromId) {
        this.pfromId = pfromId;
      }

      public int getType() {
        return type;
      }

      public void setType(int type) {
        this.type = type;
      }

      public int getAmountType() {
        return amountType;
      }

      public void setAmountType(int amountType) {
        this.amountType = amountType;
      }

      public double getAmountMoney() {
        return amountMoney;
      }

      public void setAmountMoney(double amountMoney) {
        this.amountMoney = amountMoney;
      }

      public String getId() {
        return id;
      }

      public void setId(String id) {
        this.id = id;
      }

      public String getTitle() {
        return title;
      }

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

      public int getPrice() {
        return price;
      }

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

      public int getViewSales() {
        return viewSales;
      }

      public void setViewSales(int viewSales) {
        this.viewSales = viewSales;
      }

      public String getPlatform() {
        return platform;
      }

      public void setPlatform(String platform) {
        this.platform = platform;
      }

      public int getPlatformCount() {
        return platformCount;
      }

      public void setPlatformCount(int platformCount) {
        this.platformCount = platformCount;
      }

      public String getDetailUrl() {
        return detailUrl;
      }

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

      public String getKeywords() {
        return keywords;
      }

      public void setKeywords(String keywords) {
        this.keywords = keywords;
      }

      public String getFromat() {
        return fromat;
      }

      public void setFromat(String fromat) {
        this.fromat = fromat;
      }

      public String getPicUrl() {
        return picUrl;
      }

      public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
      }

      public int getShopCount() {
        return shopCount;
      }

      public void setShopCount(int shopCount) {
        this.shopCount = shopCount;
      }
    }
  }
}



<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/crash/DeepCrash.java<|end_filename|>
package com.deepbaytech.deeplibrary.crash;

import android.os.Handler;
import android.os.Looper;

/**
 * Created by EtherealPatrick on 2017/5/20.
 */

public final class DeepCrash {
  public interface ExceptionHandler{
    void handlerException(Thread thread,Throwable throwable);

  }

  public DeepCrash() {
  }

  private static ExceptionHandler exceptionHandler;
  private static Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
  private static boolean isInstalled;
  public static synchronized void install(ExceptionHandler eh){
    if (isInstalled) return;
    isInstalled = true;
    exceptionHandler = eh;
    new Handler(Looper.getMainLooper()).post(new Runnable() {
      @Override public void run() {
        while (true){
          try {
            Looper.loop();
          }catch (Throwable e){
            if (e instanceof DeepQuitException){
              return;
            }
            if (exceptionHandler != null){
              exceptionHandler.handlerException(Looper.getMainLooper().getThread(),e);
            }

          }
        }
      }
    });

    uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
      @Override public void uncaughtException(Thread thread, Throwable ex) {
        if (exceptionHandler != null){
          exceptionHandler.handlerException(thread,ex);
        }
      }
    });
  }

  public static synchronized void uninstall(){
    if (!isInstalled) return;
    isInstalled = false;
    exceptionHandler = null;
    Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler);
    new Handler(Looper.getMainLooper()).post(new Runnable() {
      @Override public void run() {
        throw new DeepQuitException("deep crash quit...");
      }
    });
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/RangleTransform.java<|end_filename|>
package com.deepbaytech.deeplibrary;

import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;

import com.squareup.picasso.Transformation;

/**
 * @author EtherealPatrick
 *         Created at 2016/8/11.
 * @email <EMAIL>
 */
public class RangleTransform implements Transformation {
    //设置圆角的角度
    private int rangle = 0;

    public RangleTransform(int rangle) {
        this.rangle = rangle;
    }

    @Override
    public Bitmap transform(Bitmap source) {
        Bitmap bitmap = Bitmap.createBitmap(source.getWidth(),source.getHeight(),source.getConfig());
        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint();
        BitmapShader shader = new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
        paint.setShader(shader);
        paint.setAntiAlias(true);
        RectF rectF = new RectF(0,0,source.getWidth(),source.getHeight());
        canvas.drawRoundRect(rectF,rangle,rangle,paint);
        source.recycle();
        return bitmap;
    }

    @Override
    public String key() {
        return "rangle";
    }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/utils/Base64Utils.java<|end_filename|>
package com.deepbaytech.deeplibrary.utils;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * Created by deepbayter on 2016/7/6.
 */
public class Base64Utils {

    public static String BitmapToBase64(Bitmap bit) {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bit.compress(Bitmap.CompressFormat.JPEG, 95, bos);
        try {
            bos.flush();
            bos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        byte[] bytes = bos.toByteArray();
        System.out.println(bytes.length+"----------------------------------------------");
        return Base64.encodeToString(bytes, Base64.DEFAULT);
    }

    public static Bitmap Base64ToBitmap(String base64){
        byte[] bytes = Base64.decode(base64,Base64.DEFAULT);
        Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0,
                bytes.length);
        return bitmap;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/resultadapter/ViewPagerAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.resultadapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.lwd18.pictureselecotor.BaseFragment;
import com.example.lwd18.pictureselecotor.R;
import java.util.List;



/**
 * 创建者     李文东
 * 创建时间   2017/6/16 17:24
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class ViewPagerAdapter extends FragmentPagerAdapter {
    private List<BaseFragment> mBaseFragmentList;
    private List<String> tablist;
    private Context mContext;
    private int[] imageResId = {
            0,0,
            R.drawable.search_icon_price_normal,
            R.mipmap.cate_filter
    };

    public ViewPagerAdapter(Context context, FragmentManager fm, List<BaseFragment> fragmentList, List<String> tablist) {
        super(fm);
        this.mContext =context;
        this.mBaseFragmentList = fragmentList;
        this.tablist = tablist;
    }

    @Override
    public Fragment getItem(int position) {
        return mBaseFragmentList.get(position);
    }

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

    @Override
    public CharSequence getPageTitle(int position) {
        return tablist.get(position % tablist.size());
    }

    public View getTabView(int position){
        View view = LayoutInflater.from(mContext).inflate(R.layout.custom_tabtitle, null);
        TextView txt_title = (TextView) view.findViewById(R.id.title_tv);
        txt_title.setText(tablist.get(position));
        ImageView img_title = (ImageView) view.findViewById(R.id.title_iv);
        img_title.setImageResource(imageResId[position]);

        if (position == 0) {
            txt_title.setTextColor(mContext.getResources().getColor(R.color.deep_main_color));
            img_title.setImageResource(imageResId[position]);
        } else {
            txt_title.setTextColor(Color.BLACK);
            img_title.setImageResource(imageResId[position]);
        }
        return view;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/ProductItemBean.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import android.os.Parcel;
import android.os.Parcelable;
import java.math.BigDecimal;

/**
 * Created by x on 2016/10/17.
 */

public class ProductItemBean implements Parcelable {
    
    private int id;

    private String pname;

    private String pfrom;

    private String pfromId;

    private String fromUrl;

    private String detailUrl;

    private String detailAppUrl;

    private String image;

    private String htmlUrl;

    public String getHtmlUrl() {
        return htmlUrl;
    }

    public void setHtmlUrl(String htmlUrl) {
        this.htmlUrl = htmlUrl;
    }

    private String pfromImage;

    private int type;

    private String typeVal;

    private BigDecimal price;

    private String symbol;

    private String description;

    private String remarkCount;

    private int goodCount;

    private int brandId;

    private int familyId;

    private int categoryId;

    private int amountType;

    private double amountMoney;

    public int getAmountType() {
        return amountType;
    }

    public void setAmountType(int amountType) {
        this.amountType = amountType;
    }

    public double getAmountMoney() {
        return amountMoney;
    }

    public void setAmountMoney(double amountMoney) {
        this.amountMoney = amountMoney;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public int getBrandId() {
        return brandId;
    }

    public void setBrandId(int brandId) {
        this.brandId = brandId;
    }

    public String getDescription() {
        return description;
    }

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

    public String getDetailAppUrl() {
        return detailAppUrl;
    }

    public void setDetailAppUrl(String detailAppUrl) {
        this.detailAppUrl = detailAppUrl;
    }

    public String getDetailUrl() {
        return detailUrl;
    }

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

    public String getFromUrl() {
        return fromUrl;
    }

    public void setFromUrl(String fromUrl) {
        this.fromUrl = fromUrl;
    }

    public int getFamilyId() {
        return familyId;
    }

    public void setFamilyId(int familyId) {
        this.familyId = familyId;
    }

    public int getGoodCount() {
        return goodCount;
    }

    public void setGoodCount(int goodCount) {
        this.goodCount = goodCount;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getPfrom() {
        return pfrom;
    }

    public void setPfrom(String pfrom) {
        this.pfrom = pfrom;
    }

    public String getPfromId() {
        return pfromId;
    }

    public void setPfromId(String pfromId) {
        this.pfromId = pfromId;
    }

    public String getPfromImage() {
        return pfromImage;
    }

    public void setPfromImage(String pfromImage) {
        this.pfromImage = pfromImage;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }

    public BigDecimal getPrice() {
        return price;
    }

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

    public String getRemarkCount() {
        return remarkCount;
    }

    public void setRemarkCount(String remarkCount) {
        this.remarkCount = remarkCount;
    }

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTypeVal() {
        return typeVal;
    }

    public void setTypeVal(String typeVal) {
        this.typeVal = typeVal;
    }



    @Override
    public String toString() {
        return "ProductItemBean{" +
                "id=" + id +
                ", pname='" + pname + '\'' +
                ", pfrom='" + pfrom + '\'' +
                ", pfromId='" + pfromId + '\'' +
                ", fromUrl='" + fromUrl + '\'' +
                ", detailUrl='" + detailUrl + '\'' +
                ", detailAppUrl='" + detailAppUrl + '\'' +
                ", image='" + image + '\'' +
                ", pfromImage='" + pfromImage + '\'' +
                ", type=" + type +
                ", typeVal='" + typeVal + '\'' +
                ", price=" + price +
                ", symbol='" + symbol + '\'' +
                ", description='" + description + '\'' +
                ", remarkCount=" + remarkCount +
                ", goodCount=" + goodCount +
                ", brandId=" + brandId +
                ", familyId=" + familyId +
                ", categoryId=" + categoryId +
                '}';
    }

    @Override public int describeContents() {
        return 0;
    }

    @Override public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeString(this.pname);
        dest.writeString(this.pfrom);
        dest.writeString(this.pfromId);
        dest.writeString(this.fromUrl);
        dest.writeString(this.detailUrl);
        dest.writeString(this.detailAppUrl);
        dest.writeString(this.image);
        dest.writeString(this.htmlUrl);
        dest.writeString(this.pfromImage);
        dest.writeInt(this.type);
        dest.writeString(this.typeVal);
        dest.writeSerializable(this.price);
        dest.writeString(this.symbol);
        dest.writeString(this.description);
        dest.writeString(this.remarkCount);
        dest.writeInt(this.goodCount);
        dest.writeInt(this.brandId);
        dest.writeInt(this.familyId);
        dest.writeInt(this.categoryId);
        dest.writeInt(this.amountType);
        dest.writeDouble(this.amountMoney);
    }

    public ProductItemBean() {
    }

    protected ProductItemBean(Parcel in) {
        this.id = in.readInt();
        this.pname = in.readString();
        this.pfrom = in.readString();
        this.pfromId = in.readString();
        this.fromUrl = in.readString();
        this.detailUrl = in.readString();
        this.detailAppUrl = in.readString();
        this.image = in.readString();
        this.htmlUrl = in.readString();
        this.pfromImage = in.readString();
        this.type = in.readInt();
        this.typeVal = in.readString();
        this.price = (BigDecimal) in.readSerializable();
        this.symbol = in.readString();
        this.description = in.readString();
        this.remarkCount = in.readString();
        this.goodCount = in.readInt();
        this.brandId = in.readInt();
        this.familyId = in.readInt();
        this.categoryId = in.readInt();
        this.amountType = in.readInt();
        this.amountMoney = in.readDouble();
    }

    public static final Parcelable.Creator<ProductItemBean> CREATOR =
        new Parcelable.Creator<ProductItemBean>() {
            @Override public ProductItemBean createFromParcel(Parcel source) {
                return new ProductItemBean(source);
            }

            @Override public ProductItemBean[] newArray(int size) {
                return new ProductItemBean[size];
            }
        };
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/productdetail/SecondAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.productdetail;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextSearchRecomdEntity;
import java.util.ArrayList;
import java.util.List;



/**
 * 创建者     李文东
 * 创建时间   2017/6/19 18:21
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class SecondAdapter extends RecyclerView.Adapter<SecondAdapter.MyViewHolder> {
  private List<TextSearchRecomdEntity.DataBean.ItemsBean> list;
  public SecondAdapter(){
    list=new ArrayList<>();
  }
  @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = View.inflate(parent.getContext(), R.layout.good_item_second, null);
    return new MyViewHolder(view);
  }

  @Override public void onBindViewHolder(final MyViewHolder holder, final int position) {
    holder.priceTvMin.setText(list.get(position).getTitle());
    holder.titleProductFirst.setText(list.get(position).getPlatform());
    holder.prices.setText("¥"+list.get(position).getPrice());
    Glide.with(holder.itemView.getContext()).load(list.get(position).getPicUrl()).into(holder.iconProduct);
    holder.linout.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        //Uri uri = Uri.parse(list.get(position).getDetailUrl());
        //Intent it = new Intent(Intent.ACTION_VIEW,uri);
        //holder.itemView.getContext().startActivity(it);
        //holder.itemView.getContext().startActivity(
        //    new Intent(holder.itemView.getContext(), WareActivity.class).putExtra("productId", list.get(position).getPfromId())
        //        .putExtra("productType", 2));
      }
    });
  }

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

  public class MyViewHolder extends RecyclerView.ViewHolder {
    ImageView iconProduct;
    TextView titleProductFirst;
    TextView titleProductComment;
    TextView priceTvMin;
    TextView prices;
    TextView pricesingle;
    TextView priceMecheat;
    LinearLayout linout;
    RelativeLayout dpyhj;
    TextView dpyhjtv;
    LinearLayout llAmount;
    TextView amountPrice;

    public MyViewHolder(View itemView) {
      super(itemView);
      iconProduct = (ImageView) itemView.findViewById(R.id.icon_product);
      titleProductFirst = (TextView) itemView.findViewById(R.id.title_product_first);
      titleProductComment = (TextView) itemView.findViewById(R.id.title_product_comment);
      prices = (TextView) itemView.findViewById(R.id.prices);
      priceTvMin = (TextView) itemView.findViewById(R.id.price_tv_min);
      pricesingle = (TextView) itemView.findViewById(R.id.price_single);
      priceMecheat = (TextView) itemView.findViewById(R.id.price_mecheat);
      linout= (LinearLayout) itemView.findViewById(R.id.li_out);
      llAmount = (LinearLayout) itemView.findViewById(R.id.ll_ware_item_amount);
      amountPrice = (TextView) itemView.findViewById(R.id.tv_amount_price);
      dpyhj= (RelativeLayout) itemView.findViewById(R.id.ll_ware_item_textsearch);
      dpyhjtv= (TextView) itemView.findViewById(R.id.tv_rebate_price_textsearch);
    }
  }

  public void addMoreItem(List<TextSearchRecomdEntity.DataBean.ItemsBean> newDatas) {
    list.addAll(newDatas);
    notifyDataSetChanged();
  }

  public void addItem(List<TextSearchRecomdEntity.DataBean.ItemsBean> mlists) {
    list.clear();
    mlists.addAll(list);
    list.removeAll(list);
    list.addAll(mlists);
    notifyDataSetChanged();
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/vo/SaleAttributeVo.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.vo;

import java.io.Serializable;

public class SaleAttributeVo implements Serializable {

	@Override
	public String toString() {
		return "SaleAttributeVo [goods=" + goods + ", value=" + value
				+ ", goodsAndValId=" + goodsAndValId + "]";
	}

	private String goods;
	private String value;
	private String goodsAndValId;
	private boolean isChecked;

	public String getGoodsAndValId() {
		return goodsAndValId;
	}

	public void setGoodsAndValId(String goodsAndValId) {
		this.goodsAndValId = goodsAndValId;
	}

	public String getGoods() {
		return goods;
	}

	public void setGoods(String goods) {
		this.goods = goods;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public boolean isChecked() {
		return isChecked;
	}

	public void setChecked(boolean isChecked) {
		this.isChecked = isChecked;
	}

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/ApiConstants.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

/**
 * Created by EtherealPatrick on 2016/11/23.
 */

public class ApiConstants {
  public static final String BASE_URI = "http://api.deepbaytech.com/mobile/api";
  public static final String API_VERSION = "/v0.0.1";
  /**
   * 文字搜索接口
   */
  public static final String TEXTSEARCHS="http://api.deepbaytech.com/mobile/api/v0.0.1/group-search-text";
  /**
   * 商品搜索详情接口
   */
  public static final String PRODUCTSEARCH="http://api.deepbaytech.com/mobile/api/v0.0.1/product-search";

  public static final  String POPULAR_TEXT = BASE_URI+API_VERSION+"/popular-text";

  /**
   * 商品搜索聚类相同产品接口
   */
  public static final String PRODUCTSAMESEARCH="http://api.deepbaytech.com/mobile/api/v0.0.1/product-same-search";
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/utils/ImgCompress.java<|end_filename|>
package com.deepbaytech.deeplibrary.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
import top.zibin.luban.Luban;
import top.zibin.luban.OnCompressListener;

/**
 * Created by deepbayter on 2016/7/7.
 */
public class ImgCompress {

    //saveBitmap中图片保存的路径
    public static String SDPATH = Environment.getExternalStorageDirectory().getAbsolutePath()
            + "/deepbay/picture";

    /**
     * 通过参数out对bm进行输出
     * @param bm --被输出的图片
     * @param out --指定图片输出的输出流
     */
    public static void outputBitmap(Bitmap bm, OutputStream out) {
        try {
            if(out!=null){
                bm.compress(Bitmap.CompressFormat.JPEG, 90, out);
                out.flush();
                out.close();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 对图片进行本地保存
     * @param bm --被保存的图片
     * @param picName --图片保存后的文件名
     */
    public static String saveBitmap(Bitmap bm, String picName) {
        try {
            if (!isFileExist("")) {
                System.out.println("创建文件");
                File tempf = createSDDir("");
            }
            File f = null;
            //定义图片被保存的路径
            if(picName.equals("cutphoto")){
                f = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/deepbay"
                        , picName + ".jpeg");
                try {
                    f.mkdirs();
                }catch(Exception e){

                }
            }else{
                f = new File(SDPATH, picName + ".jpeg");
            }

            if (f.exists()) {
                f.delete();
            }
            FileOutputStream out = new FileOutputStream(f);
            //需要对图片进行10%的压缩，否则图片莫名较大
            bm.compress(Bitmap.CompressFormat.JPEG, 100, out);
//            ByteArrayOutputStream baos = new ByteArrayOutputStream();
//            bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
//            int ImgSize = baos.toByteArray().length/1024;
//            Log.e("sampSize---",ImgSize+"");
//            int sample = 100;
//            if ( ImgSize>100) {
//                sample =  Math.round(((float)100/(float)ImgSize*(float)100));
//            }
//            baos.reset();//重置bas即清空bas
//            Log.e("sampSI---",sample+"");
//            bm.compress(Bitmap.CompressFormat.JPEG, 90, baos);//这里压缩options%，把压缩后的数据存放到baos中
//            out.write(baos.toByteArray());
            out.flush();
            out.close();
            return f.getAbsolutePath();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    //创建文件夹
    public static File createSDDir(String dirName) throws IOException {
        File dir = new File(SDPATH,dirName);
        if (Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED)) {

            System.out.println("createSDDir:" + dir.getAbsolutePath());
            System.out.println("createSDDir:" + dir.mkdir());
        }
        return dir;
    }

    //判断文件是否已经创建
    public static boolean isFileExist(String fileName) {
        File file = new File(SDPATH,fileName);
        file.isFile();
        System.out.println(file.exists());
        return file.exists();
    }

    //-----------------------------------------------------------------

    /**
     * 根据设定的期望宽高计算图片压缩的比例
     *
     * @param options--压缩图片的参数
     * @param reqWidth--期望压缩后的宽，与压缩后的实际值有一点的差距
     * @param reqHeight--期望压缩后的高
     * @return
     */
    public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {

        final int height = options.outHeight;
        final int width = options.outWidth;
        int inSampleSize = 1;
        if (height > reqHeight || width > reqWidth) {
            final int heightRatio = Math.round((float) height
                    / (float) reqHeight);
            final int widthRatio = Math.round((float) width / (float) reqWidth);

            //选择期望宽高与原始宽高中差距比较大的比例，从而保证有一边是期望宽高。
            inSampleSize = heightRatio > widthRatio ? heightRatio : widthRatio;
        }
        Log.e("sampleSize------",inSampleSize+"");
        if(inSampleSize%2!=0 && inSampleSize!=1)
            inSampleSize++;
        return inSampleSize;
    }

    /**
     * 根据路径获得图片并压缩返回bitmap
     * @param filePath  图片的路径
     * @return
     *
     * 注意：此处宽高已被设置为压缩到固定800x800的比列
     */
    public static Bitmap getSmallBitmap(String filePath) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        //设置为true不获取图片，并不为其分配内存，只返回图片的宽高信息
        options.inJustDecodeBounds = true;
        //获取位图，把该图片的参数存到options中
        BitmapFactory.decodeFile(filePath, options);

        //图片压缩时期望的宽高固定为 800x800
        options.inSampleSize = calculateInSampleSize(options, 800, 800);

        options.inJustDecodeBounds = false;

        return BitmapFactory.decodeFile(filePath, options);
    }

    public static Bitmap getSmallBitmapFromBitmap(Bitmap bitmap) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.outHeight = bitmap.getHeight();
        options.outWidth = bitmap.getWidth();
//        options.inPreferredConfig = Bitmap.Config.RGB_565;
        //获取位图，把该图片的参数存到options中

        //图片压缩时期望的宽高固定为 800x800
        options.inSampleSize = calculateInSampleSize(options, 800, 800);


        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, baos);
        bitmap.recycle();

        return BitmapFactory.decodeByteArray(baos.toByteArray(),0,baos.toByteArray().length,options);
    }

    public static void zipImg(Context context,File file,OnCompressListener compressListener){
        Luban.get(context)
                .load(file)                     //传人要压缩的图片
                .putGear(Luban.THIRD_GEAR)      //设定压缩档次，默认三挡
                .setCompressListener(compressListener).launch();
    }

    public static String zipRxImg(final Context context, final File file) {
        final String imgPath = null;
        Luban.get(context)
                .load(file)
                .putGear(Luban.THIRD_GEAR)
                .asObservable()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnError(new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwable.printStackTrace();
                    }
                })
                .onErrorResumeNext(new Func1<Throwable, Observable<? extends File>>() {
                    @Override
                    public Observable<? extends File> call(Throwable throwable) {
                        zipRxImg(context, file);
                        return Observable.empty();
                    }
                })
                .subscribe(new Action1<File>() {
                    @Override
                    public void call(File file) {
                        // TODO 压缩成功后调用，返回压缩后的图片文件
                        System.out.println(file.getAbsolutePath());
                        File file1 = new File(SDPATH,file.getName()+".jpg");
                        try {
                            FileInputStream inputStream = new FileInputStream(file);
                            byte[] by = new byte[1024*1024];
                            FileOutputStream outputStream =  new FileOutputStream(file1);
                            int total = 0;
                            while ((total=inputStream.read(by))!=-1){
                                outputStream.write(by, 0, total);
                            }
                            inputStream.close();
                            outputStream.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        file.delete();
                    }
                });
        return imgPath;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/TranstEventil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

/**
 * 创建者     李文东
 * 创建时间   2017/8/3 18:26
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class TranstEventil {
  private String filter;
  public TranstEventil() {
  }

  public TranstEventil(String filter) {
   this.filter=filter;
  }

  public String getFilter() {
    return filter;
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/BaseActivity.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import android.os.Bundle;
import android.support.annotation.Nullable;
import com.deepbaytech.deeplibrary.utils.InternetUtils;
import me.yokeyword.fragmentation.SupportActivity;

/**
 * Created by EtherealPatrick on 2017/2/23.
 */

public class BaseActivity extends SupportActivity implements NetEvevt{
  private int netMobile;
  /**
   * 网络类型
   */
  @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  }

  @Override protected void onDestroy() {
    super.onDestroy();
  }
  /**
   * 初始化时判断有没有网络
   */

  public boolean inspectNet() {
    this.netMobile = InternetUtils.getNetWorkState(this);

    return isNetConnect();

    // if (netMobile == NetUtil.NETWORK_WIFI) {
    // System.out.println("inspectNet：连接wifi");
    // } else if (netMobile == NetUtil.NETWORK_MOBILE) {
    // System.out.println("inspectNet:连接移动数据");
    // } else if (netMobile == NetUtil.NETWORK_NONE) {
    // System.out.println("inspectNet:当前没有网络");
    //
    // }
  }
  /**
  /**
   * 判断有无网络 。
   *
   * @return true 有网, false 没有网络.
   */
  public boolean isNetConnect() {
    if (netMobile == InternetUtils.NETWORK_WIFI) {
      return true;
    } else if (netMobile == InternetUtils.NETWORK_MOBILE) {
      return true;
    } else if (netMobile == InternetUtils.NETWORK_NONE) {
      return false;

    }
    return false;
  }

  @Override
  public void onNetChange(int netMobile) {
    this.netMobile = netMobile;
    isNetConnect();
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/adapter/FilterHeadAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.adapter;

import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.textsearch.DataPresenter;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.TextEventUtil;
import de.greenrobot.event.EventBus;
import java.util.ArrayList;
import java.util.List;



/**
 * 创建者     李文东
 * 创建时间   2017/7/12 16:53
 * 描述	      文字搜索综合界面筛选项的adapter
 * 更新描述
 */

public class FilterHeadAdapter extends RecyclerView.Adapter<FilterHeadAdapter.MyAdapter> {

  private List<String> list;
  private final List<String> selectList;

  public FilterHeadAdapter(List<String> mlist) {
    list = new ArrayList<>();
    list.clear();
    list.addAll(mlist);
    selectList = DataPresenter.getSingleTon().getSelectList();
  }

  @Override public MyAdapter onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = View.inflate(parent.getContext(), R.layout.filter_head, null);
    return new MyAdapter(view);
  }

  @Override public void onBindViewHolder(final MyAdapter holder, final int position) {
    for (int i = 0; i < selectList.size(); i++) {
      System.out.println("被点击的数据有==="+selectList.size()+"====分别为===="+selectList.get(i));
      if (selectList.contains(list.get(position))&&position<4) {
        holder.button.setBackgroundResource(R.drawable.goods_attr_selected_shape);
        holder.button.setTextColor(Color.WHITE);
      }
    }

    if (position == 4) {
      holder.button.setText("更多");
      holder.button.setPadding(0, 0, 10, 0);
      Drawable drawable =
          holder.itemView.getContext().getResources().getDrawable(R.mipmap.cat_more_11);
      drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
      holder.button.setCompoundDrawables(null, null, drawable, null);
      holder.button.setCompoundDrawablePadding(-30);
      holder.button.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
          EventBus.getDefault().post(new TextEventUtil(""));
        }
      });
    } else {
      holder.button.setText(list.get(position));
      holder.button.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
          if (selectList.size() <= 0) {
            holder.button.setBackgroundResource(R.drawable.goods_attr_selected_shape);
            holder.button.setTextColor(Color.WHITE);
            EventBus.getDefault().post(new TextEventUtil(list.get(position)));
          } else {
            if (!selectList.contains(list.get(position))) {
              holder.button.setBackgroundResource(R.drawable.goods_attr_selected_shape);
              holder.button.setTextColor(Color.WHITE);
              EventBus.getDefault().post(new TextEventUtil(list.get(position)));

            } else {
              holder.button.setBackgroundResource(R.drawable.goods_attr_unselected_shape);
              holder.button.setTextColor(Color.BLACK);
            }
          }
          //保存
          DataPresenter.getSingleTon().saveSelect(list.get(position));
        }
      });
    }
  }

  @Override public int getItemCount() {
    return list.size() > 5 ? 5 : list.size();
  }

  public class MyAdapter extends RecyclerView.ViewHolder {
    Button button;

    public MyAdapter(View itemView) {
      super(itemView);
      button = (Button) itemView.findViewById(R.id.first_button);
    }
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/utils/InternetUtils.java<|end_filename|>
package com.deepbaytech.deeplibrary.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import static android.content.Context.CONNECTIVITY_SERVICE;

/**
 * Created by x on 2017/1/10.
 */

public class InternetUtils {

    /**
     * 没有连接网络
     */
    public static final int NETWORK_NONE = -1;
    /**
     * 移动网络
     */
    public static final int NETWORK_MOBILE = 0;
    /**
     * 无线网络
     */
    public static final int NETWORK_WIFI = 1;

    public static int getNetWorkState(Context context) {
        // 得到连接管理器对象
        ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);

        NetworkInfo activeNetworkInfo = connectivityManager
            .getActiveNetworkInfo();
        if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {

            if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_WIFI)) {
                return NETWORK_WIFI;
            } else if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_MOBILE)) {
                return NETWORK_MOBILE;
            }
        } else {
            return NETWORK_NONE;
        }
        return NETWORK_NONE;
    }

    public static boolean checkInternet(Context context){
        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE);
        // 检查网络连接，如果无网络可用，就不需要进行连网操作等
        NetworkInfo info = manager.getActiveNetworkInfo();
        if (info == null || !manager.getBackgroundDataSetting()) {
            return false;
        }
        return true;
    }

    /**
     * 检查网络是否可用
     *
     * @param context
     * @return
     */
    public static boolean isNetworkConnected(Context context) {
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
            if (mNetworkInfo != null) {
                return mNetworkInfo.isAvailable();
            }
        }
        return false;
    }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/chart/Spline.java<|end_filename|>
// Spline.java
//   Functions for setting up and evaluating a cubic interpolatory spline.
//   AUTHORS:   <NAME>, <NAME>, <NAME>  for 
//              the text  Fundamentals of Numerical Computing
//   DATE:      February 27, 1996
//              minimal change convertion to Java August 11, 2003

package com.deepbaytech.deeplibrary.chart;

public class Spline {
    int n, last_interval;
    double x[], f[], b[], c[], d[];
    boolean uniform;

    public Spline(double xx[], double ff[]) {
        // Calculate coefficients defining a smooth cubic interpolatory spline.
        //
        // Input parameters:
        // xx = vector of values of the independent variable ordered
        // so that x[i] < x[i+1] for all i.
        // ff = vector of values of the dependent variable.
        // class values constructed:
        // n = number of data points.
        // b = vector of S'(x[i]) values.
        // c = vector of S"(x[i])/2 values.
        // d = vector of S'''(x[i]+)/6 values (i < n).
        // x = xx
        // f = ff
        // Local variables:
        double fp1, fpn, h, p;
        final double zero = 0.0, two = 2.0, three = 3.0;
        boolean sorted = true;

        uniform = true;
        last_interval = 0;
        n = xx.length;
        if (n <= 3) {
            System.out.println("not enough points to build spline, n=" + n);
            return;
        }
        if (n != ff.length) {
            System.out.println("not same number of x and f(x)");
            return;
        }
        x = new double[n];
        f = new double[n];
        b = new double[n];
        c = new double[n];
        d = new double[n];
        for (int i = 0; i < n; i++) {
            x[i] = xx[i];
            f[i] = ff[i];
            if (i >= 1 && x[i] < x[i - 1]) sorted = false;
        }
        // sort if necessary
        if (!sorted) {
            dHeapSort(x, f);
        }

        // Calculate coefficients for the tri-diagonal system: store
        // sub-diagonal in b, diagonal in d, difference quotient in c.
        b[0] = x[1] - x[0];
        c[0] = (f[1] - f[0]) / b[0];
        if (n == 2) {
            b[0] = c[0];
            c[0] = zero;
            d[0] = zero;
            b[1] = b[0];
            c[1] = zero;
            return;
        }
        d[0] = two * b[0];
        for (int i = 1; i < n - 1; i++) {
            b[i] = x[i + 1] - x[i];
            if (Math.abs(b[i] - b[0]) / b[0] > 1.0E-5) uniform = false;
            c[i] = (f[i + 1] - f[i]) / b[i];
            d[i] = two * (b[i] + b[i - 1]);
        }
        d[n - 1] = two * b[n - 2];

        // Calculate estimates for the end slopes. Use polynomials
        // interpolating data nearest the end.
        fp1 = c[0] - b[0] * (c[1] - c[0]) / (b[0] + b[1]);
        if (n > 3) fp1 = fp1 + b[0] * ((b[0] + b[1]) * (c[2] - c[1]) / (b[1] + b[2]) - c[1] + c[0]) / (x[3] - x[0]);
        fpn = c[n - 2] + b[n - 2] * (c[n - 2] - c[n - 3]) / (b[n - 3] + b[n - 2]);
        if (n > 3) fpn = fpn + b[n - 2]
                         * (c[n - 2] - c[n - 3] - (b[n - 3] + b[n - 2]) * (c[n - 3] - c[n - 4]) / (b[n - 3] + b[n - 4]))
                         / (x[n - 1] - x[n - 4]);

        // Calculate the right-hand-side and store it in c.
        c[n - 1] = three * (fpn - c[n - 2]);
        for (int i = n - 2; i > 0; i--)
            c[i] = three * (c[i] - c[i - 1]);
        c[0] = three * (c[0] - fp1);

        // Solve the tridiagonal system.
        for (int k = 1; k < n; k++) {
            p = b[k - 1] / d[k - 1];
            d[k] = d[k] - p * b[k - 1];
            c[k] = c[k] - p * c[k - 1];
        }
        c[n - 1] = c[n - 1] / d[n - 1];
        for (int k = n - 2; k >= 0; k--)
            c[k] = (c[k] - b[k] * c[k + 1]) / d[k];

        // Calculate the coefficients defining the spline.
        h = x[1] - x[0];
        for (int i = 0; i < n - 1; i++) {
            h = x[i + 1] - x[i];
            d[i] = (c[i + 1] - c[i]) / (three * h);
            b[i] = (f[i + 1] - f[i]) / h - h * (c[i] + h * d[i]);
        }
        b[n - 1] = b[n - 2] + h * (two * c[n - 2] + h * three * d[n - 2]);
 
       
    } // end Spline

    public double spline_value(double t) {
        // Evaluate the spline s at t using coefficients from Spline constructor
        //
        // Input parameters
        // class variables
        // t = point where spline is to be evaluated.
        // Output:
        // s = value of spline at t.
        // Local variables:
        double dt, s;
        int interval; // index such that t>=x[interval] and t<x[interval+1]

        if (n <= 1) {
            System.out.println("not enough points to compute value");
            return 0.0; // should throw exception
        }
        // Search for correct interval for t.
        interval = last_interval; // heuristic
        if (t < x[0]) {
            System.out.println("requested point below Spline region");
            return 0.0; // should throw exception
        }
        if (t > x[n - 1]) {
            System.out.println("requested point above Spline region");
            return 0.0; // should throw exception
        }
        if (t > x[n - 2]) interval = n - 2;
        else if (t >= x[last_interval]) for (int j = last_interval; j < n && t >= x[j]; j++)
            interval = j;
        else for (int j = last_interval; t < x[j]; j--)
            interval = j - 1;
        last_interval = interval; // class variable for next call
        // Evaluate cubic polynomial on [x[interval] , x[interval+1]].
        dt = t - x[interval];
        s = f[interval] + dt * (b[interval] + dt * (c[interval] + dt * d[interval]));
        return s;
    } // end spline_value

    public double integrate() {
        double suma, sumb, sumc, sumd;
        double dx, t;
        if (n <= 3) {
            System.out.println("not enough data to integrate");
            return 0.0;
        }
        if (!uniform) {
            t = 0.0;
            for (int i = 0; i < n - 1; i++) {
                dx = x[i + 1] - x[i];
                t = t + (f[i] + (b[i] / 2.0 + (c[i] / 3.0 + dx * d[i] / 4.0) * dx) * dx) * dx;
            }
            return t;
        }
        // compute uniform integral of spline fit
        suma = 0.0;
        sumb = 0.0;
        sumc = 0.0;
        sumd = 0.0;
        for (int i = 0; i < n; i++) {
            suma = suma + d[i];
            sumb = sumb + c[i];
            sumc = sumc + b[i];
            sumd = sumd + f[i];
        }
        dx = x[1] - x[0]; // assumes equally spaced points
        t = (sumd + (sumc / 2.0 + (sumb / 3.0 + dx * suma / 4.0) * dx) * dx) * dx;
       return t;
    } // end integral

    static void dHeapSort(double key[], double trail[]) {
        int nkey = key.length;
        int last_parent_pos = (nkey - 2) / 2;
        int last_parent_index = last_parent_pos;
        double tkey, ttrail;
        int index_val;

        if (nkey <= 1) return;
        for (index_val = last_parent_index; index_val >= 0; index_val--)
            dremake_heap(key, trail, index_val, nkey - 1);

        tkey = key[0];
        key[0] = key[nkey - 1];
        key[nkey - 1] = tkey;
        ttrail = trail[0];
        trail[0] = trail[nkey - 1];
        trail[nkey - 1] = ttrail;

        for (index_val = nkey - 2; index_val > 0; index_val--) {
            dremake_heap(key, trail, 0, index_val);
            tkey = key[0];
            key[0] = key[index_val];
            key[index_val] = tkey;
            ttrail = trail[0];
            trail[0] = trail[index_val];
            trail[index_val] = ttrail;
        }
    } // end dHeapSort

    static void dremake_heap(double key[], double trail[], int parent_index, int last_index) {
        int last_parent_pos = (last_index - 1) / 2;
        int last_parent_index = last_parent_pos;
        int l_child;
        int r_child;
        int max_child_index;
        int parent_temp = parent_index;
        double tkey, ttrail;

        while (true) {
            if (parent_temp > last_parent_index) break;
            l_child = parent_temp * 2 + 1;
            if (l_child == last_index) {
                max_child_index = l_child;
            } else {
                r_child = l_child + 1;
                if (key[l_child] > key[r_child]) {
                    max_child_index = l_child;
                } else {
                    max_child_index = r_child;
                }
            }
            if (key[max_child_index] > key[parent_temp]) {
                tkey = key[max_child_index];
                key[max_child_index] = key[parent_temp];
                key[parent_temp] = tkey;
                ttrail = trail[max_child_index];
                trail[max_child_index] = trail[parent_temp];
                trail[parent_temp] = ttrail;
                parent_temp = max_child_index;
            } else {
                break;
            }
        }
    } // end dremake_heap

} // end class Spline

<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/bigphotobrows/MainPresenter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.bigphotobrows;

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

/**
 * 创建者     李文东
 * 创建时间   2017/5/24 9:45
 * 描述	      ${TODO}
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class MainPresenter {

    private MainView view;
    private List<String> images;

    public MainPresenter(MainView view) {
        this.view = view;
    }

    public void loadImage() {

        if (images == null) images = new ArrayList<>();

        images.add("http://img3.imgtn.bdimg.com/it/u=3993672553,267575750&fm=21&gp=0.jpg");
        images.add("http://img5.imgtn.bdimg.com/it/u=2652905594,2769975769&fm=21&gp=0.jpg");
        images.add("http://i.zeze.com/attachment/forum/201511/06/180208mwwxx8oer7wirv89.jpg");
        images.add("http://imgsrc.baidu.com/forum/w%3D580/sign=fe8a7e7f78ec54e741ec1a1689399bfd/4b3f9682d158ccbfb334467b1ad8bc3eb33541cd.jpg");
        images.add("http://static.wgpet.com/editor/attached/image/20141124/20141124225933_71813.jpg");
        images.add("http://v1.qzone.cc/pic/201405/25/13/57/5381864e3b8af886.jpg%21600x600.jpg");
        images.add("http://wanzao2.b0.upaiyun.com/system/pictures/23660313/original/8d4f08e50be02ae3.png");
        images.add("http://zyline-photo.qiniudn.com/1392705051156.jpg");
        view.setImages(images);
        view.initRecycler();

    }

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/resultadapter/SaleNumberAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.resultadapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.productdetail.GoodsDetailActivity;
import com.example.lwd18.pictureselecotor.textsearch.DataPresenter;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.FilterUtils;
import com.example.lwd18.pictureselecotor.textsearch.adapter.FilterHeadAdapter;
import java.util.ArrayList;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/6/19 11:29
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class SaleNumberAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
  private int HEAD = 1;
  private int NORMAL = 2;
  private List<TextsSearchEntity.DataBean.ItemsBean> list;
  private List<TextsSearchEntity.DataBean.FiltersBean> filterlist;
  private List<String> filters;
  private Context context;
  private FilterHeadAdapter adapter;
  public SaleNumberAdapter() {
    list = new ArrayList<>();
    filterlist = new ArrayList<>();
    filters = new ArrayList<>();
    if (DataPresenter.getSingleTon().getData().size()>0){
      filterlist.clear();
      filterlist.addAll(DataPresenter.getSingleTon().getData());
      notifyDataSetChanged();
    }
  }

  @Override public int getItemViewType(int position) {
    if (filterlist.size() == 0) {
      return NORMAL;
    } else {
      int positions = (filterlist.size() - 1) * 6;
      if (position == 0) {
        return HEAD;
      } else {
        if (position > positions) {
          return NORMAL;
        } else {
          if (position % 6 == 0) {
            return HEAD;
          } else {
            return NORMAL;
          }
        }
      }
    }
  }

  @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    context = parent.getContext();
    if (viewType == HEAD) {
      View view = View.inflate(parent.getContext(), R.layout.item_product_head, null);
      return new HeadViewHolder(view);
    } else if (viewType == NORMAL) {
      View view = View.inflate(parent.getContext(), R.layout.item_product_normal, null);
      return new NormalViewHolder(view);
    }
    return null;
  }

  @Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
    int positions = (filterlist.size() - 1) * 6;

    if (holder instanceof NormalViewHolder) {
      //如果filst为空,不会出现越界异常情况//最多两个
      final int index = FilterUtils.getIndex(filterlist,position);
      final TextsSearchEntity.DataBean.ItemsBean ware = list.get(index);
     NormalViewHolder wareHolder = (NormalViewHolder) holder;
      //单品
      if (ware.getType() == 2) {
        wareHolder.dpout.setVisibility(View.VISIBLE);
        wareHolder.lineout.setVisibility(View.GONE);
        if (ware.getAmountType() == 1) {
          wareHolder.llAmount.setVisibility(View.VISIBLE);
          wareHolder.dpyhj.setVisibility(View.GONE);
          wareHolder.amountPrice.setText(ware.getAmountMoney() + "");
        }else if (ware.getAmountType()==2){
          wareHolder.llAmount.setVisibility(View.GONE);
          wareHolder.dpyhj.setVisibility(View.VISIBLE);
         // wareHolder.dpyhjtv.setText(ware.getAmountMoney()+"");
          wareHolder.dpyhjtv.setText("满100减50");
        }
        ((NormalViewHolder) holder).titleProduct.setText(list.get(index).getTitle());
        Glide.with(holder.itemView.getContext())
            .load(list.get(index).getPicUrl())
            .into(((NormalViewHolder) holder).dPIV);
        wareHolder.dpfrom.setText(list.get(index).getPlatform());
        wareHolder.dpEvaluate.setText("好评率98%");
        wareHolder.dpjianjie.setText(list.get(index).getTitle());
        wareHolder.dpPrice.setText("¥" + list.get(index).getPrice());
        wareHolder.dpsingPrice.setText("¥100/L");
        wareHolder.dpcount.setText("销量" + list.get(index).getViewSales() + "万");

        wareHolder.dpout.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            //context.startActivity(
            //    new Intent(context, WareActivity.class).putExtra("productId", ware.getPfromId())
            //        .putExtra("productType", 2));
          }
        });
        //聚类
      }else if (ware.getType() == 1){
        wareHolder.dpout.setVisibility(View.GONE);
        wareHolder.lineout.setVisibility(View.VISIBLE);
        ((NormalViewHolder) holder).titleProduct.setText(list.get(index).getTitle());
        Glide.with(holder.itemView.getContext())
            .load(list.get(index).getPicUrl())
            .into(((NormalViewHolder) holder).iconProduct);
        ((NormalViewHolder) holder).price.setText("¥" + list.get(index).getPrice());
        ((NormalViewHolder) holder).priceAllNet.setText(
            "全网销量" + list.get(index).getViewSales() + "万");
        ((NormalViewHolder) holder).priceTaobao.setText("¥" + list.get(index).getFromat());
        ((NormalViewHolder) holder).priceMecheat.setText(list.get(index).getShopCount() + "商家比价");

        wareHolder.lineout.setOnClickListener(new View.OnClickListener() {
          @Override public void onClick(View v) {
            Intent intent = new Intent(holder.itemView.getContext(), GoodsDetailActivity.class);
            intent.putExtra("productId", list.get(index).getId());
            intent.putExtra("price", list.get(position).getPrice());
            intent.putExtra("lv", list.get(index).getFromat());
            holder.itemView.getContext().startActivity(intent);
          }
        });
      }
    } else if (holder instanceof HeadViewHolder) {
      //int newpositions = position / 6;
      //filters.clear();
      //filters.addAll(filterlist.get(newpositions).getFilterOption());
      //LinearLayoutManager
      //    line = new LinearLayoutManager(holder.itemView.getContext(), LinearLayoutManager.HORIZONTAL, false);
      //((HeadViewHolder) holder).rv.setLayoutManager(line);
      //adapter = new FilterHeadAdapter(filters);
      //((HeadViewHolder) holder).rv.setAdapter(adapter);
    }
  }

  @Override public int getItemCount() {
    int positions = (filterlist.size() - 1) * 6;
    if (filterlist.size() == 0) {
      return list.size();
    } else if (list.size()<positions){
      return FilterUtils.getSize(list);
    }else {
      return filterlist.size() + list.size();
    }
  }

  public class NormalViewHolder extends RecyclerView.ViewHolder {
    ImageView iconProduct;
    TextView titleProduct;
    TextView priceTvMin;
    TextView price;
    TextView priceAllNet;
    ImageView priceIv;
    TextView priceTaobao;
    TextView priceMecheat;
    LinearLayout lineout;
    LinearLayout llAmount;
    TextView amountPrice;
    //单品局部
    //单品最外层
    LinearLayout dpout;
    ImageView dPIV;
    TextView dpfrom,dpEvaluate,dpjianjie,dpPrice,dpsingPrice,dpcount;
    RelativeLayout dpyhj;
    TextView dpyhjtv;
    public NormalViewHolder(View itemView) {
      super(itemView);
      iconProduct = (ImageView) itemView.findViewById(R.id.icon_product);
      titleProduct = (TextView) itemView.findViewById(R.id.title_product);
      priceTvMin = (TextView) itemView.findViewById(R.id.price_tv_min);
      price = (TextView) itemView.findViewById(R.id.price);
      priceAllNet = (TextView) itemView.findViewById(R.id.price_all_net);
      priceIv = (ImageView) itemView.findViewById(R.id.price_iv);
      priceTaobao = (TextView) itemView.findViewById(R.id.price_taobao);
      priceMecheat = (TextView) itemView.findViewById(R.id.price_mecheat);
      lineout = (LinearLayout) itemView.findViewById(R.id.com_out_ll);
      llAmount = (LinearLayout) itemView.findViewById(R.id.ll_ware_item_amount);
      amountPrice = (TextView) itemView.findViewById(R.id.tv_amount_price);
      //单品布局
      dpout= (LinearLayout) itemView.findViewById(R.id.li_out_dp);
      dPIV = (ImageView) itemView.findViewById(R.id.icon_product_dp);
      dpfrom= (TextView) itemView.findViewById(R.id.title_product_dp);
      dpEvaluate=(TextView) itemView.findViewById(R.id.title_product_comment_dp);
      dpjianjie=(TextView) itemView.findViewById(R.id.price_tv_min_dp);
      dpPrice=(TextView) itemView.findViewById(R.id.prices_dp);
      dpsingPrice=(TextView) itemView.findViewById(R.id.price_single_dp);
      dpcount=(TextView) itemView.findViewById(R.id.price_mecheat_dp);
      llAmount = (LinearLayout) itemView.findViewById(R.id.ll_ware_item_amount);
      amountPrice = (TextView) itemView.findViewById(R.id.tv_amount_price);
      dpyhj= (RelativeLayout) itemView.findViewById(R.id.ll_ware_item_textsearch);
      dpyhjtv= (TextView) itemView.findViewById(R.id.tv_rebate_price_textsearch);
    }
  }

  public class HeadViewHolder extends RecyclerView.ViewHolder {
    public RecyclerView rv;
    public HeadViewHolder(View itemView) {
      super(itemView);
      rv = (RecyclerView) itemView.findViewById(R.id.filter_rv);
    }
  }

  //添加数据
  public void addItem(List<TextsSearchEntity.DataBean.ItemsBean> newDatas) {
    list.clear();
    newDatas.addAll(list);
    list.removeAll(list);
    list.addAll(newDatas);
    notifyDataSetChanged();
  }

  public void addMoreItem(List<TextsSearchEntity.DataBean.ItemsBean> newDatas) {
    list.addAll(newDatas);
    notifyDataSetChanged();
  }

  public void addFilterItem(List<TextsSearchEntity.DataBean.FiltersBean> mlists) {
    filterlist.clear();
    mlists.addAll(filterlist);
    filterlist.removeAll(filterlist);
    filterlist.addAll(mlists);
    notifyDataSetChanged();
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/AutoScaleHeightImageView.java<|end_filename|>
package com.deepbaytech.deeplibrary;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

public class AutoScaleHeightImageView extends ImageView {

	public AutoScaleHeightImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// 创建一个测量规格
		// int measureSpec = MeasureSpec.makeMeasureSpec(100, MeasureSpec.EXACTLY);
		
		// 打印一下父容器传过来的测量规格
//		System.out.println("父容器传过来的测量规格");
		MeasureSpecUtil.printMeasureSpec(widthMeasureSpec, heightMeasureSpec);
		
		Drawable drawable = getDrawable();
		
		if (drawable != null) {
			int picWidth = drawable.getMinimumWidth();	// 获取图片的宽
			int picHeight = drawable.getMinimumHeight();// 获取图片的高
			float scale = (float) picHeight / picWidth;	// 最终要算什么样的值，这个值做为被除数
			
			int width = MeasureSpec.getSize(widthMeasureSpec);
			int height = (int) (width * scale);
			heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
		}
		
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		
//		System.out.println("ImageView测量出来的自己的宽高为：" + getMeasuredWidth() + " x " + getMeasuredHeight());
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
//		System.out.println("ImageView的真实的宽和高：" + getWidth() + "x" + getHeight());
		super.onDraw(canvas);
	}

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/Eventil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

/**
 * 创建者     李文东
 * 创建时间   2017/8/3 18:26
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class Eventil {
  private String filter;
  private int position;
  public Eventil() {
  }

  public Eventil(String filter) {
   this.filter=filter;
  }

  public String getProviceName(){
    return this.filter;
  }

  public int getPosition() {
    return this.position;
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/event/SearchHistoryEvent.java<|end_filename|>
package com.example.lwd18.pictureselecotor.event;

/**
 * Created by EtherealPatrick on 2016/10/8.
 */

public class SearchHistoryEvent {
    private String mMsg;
    public SearchHistoryEvent(String msg) {

        mMsg = msg;
    }
    public String getMsg(){
        return mMsg;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/MyApplication.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import android.content.Context;
import android.graphics.Point;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.util.Log;
import android.view.WindowManager;
import com.deepbaytech.deeplibrary.utils.SharedPreferencesUtil;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.cookie.CookieJarImpl;
import com.zhy.http.okhttp.cookie.store.MemoryCookieStore;
import com.zhy.http.okhttp.log.LoggerInterceptor;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;

/**
 * Created by EtherealPatrick on 2016/9/8.
 */
public class MyApplication extends MultiDexApplication {
    private static  int windowWidth;
    private static  int windowHeight;

    private static Context context;
    @Override
    public void onCreate() {
        super.onCreate();
        context = this.getApplicationContext();
        Fresco.initialize(this);
        CookieJarImpl cookieJar1 = new CookieJarImpl(new MemoryCookieStore());
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                .addInterceptor(new LoggerInterceptor("TAG"))
                .cookieJar(cookieJar1)
                .build();
        OkHttpUtils.initClient(okHttpClient);




        MultiDex.install(this);

        //开启debug模式，方便定位错误，具体错误检查方式可以查看http://dev.umeng.com/social/android/quick-integration的报错必看，正式发布，请关闭该模式
        //Config.DEBUG = true;

        initXY(context);
        //Thread.setDefaultUncaughtExceptionHandler(crashHandler);
        SharedPreferencesUtil.init(context,"deepSP",MODE_PRIVATE);
        /**
         * 初始化imageloader
         */
        ImageLoaderConfiguration configuration = ImageLoaderConfiguration.createDefault(this);
        ImageLoader.getInstance().init(configuration);
    }

    private void initXY(Context context) {
        Point size = new Point();
        WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        manager.getDefaultDisplay().getSize(size);
        windowWidth = size.x;
        windowHeight = size.y;
    }

    public static int getWindowWidth(){
        return windowWidth;
    }

    public static int getWindowHeight(){
        return windowHeight;
    }

    public static Context getContext(){
        return context;
    }

    private Thread.UncaughtExceptionHandler crashHandler = new Thread.UncaughtExceptionHandler(){
        @Override public void uncaughtException(Thread thread, Throwable ex) {
            Log.i("UncaughtException","未能捕获的异常:,Thread"+ thread.getName()+",Threadable:"+ex);
        }
    };

}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/chart/Line.java<|end_filename|>
package com.deepbaytech.deeplibrary.chart;

import android.content.Context;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PathEffect;
import android.util.DisplayMetrics;
import android.util.TypedValue;

import com.deepbaytech.deeplibrary.R;
import com.deepbaytech.deeplibrary.utils.DisplayUrils;

import java.util.ArrayList;
public class Line {

    private ArrayList<LinePoint> mPoints = new ArrayList<LinePoint>();
    private Paint mPaint;
    private Paint mFilledPaint;
    private Path mPath = new Path();
    private boolean isFilled = false;
    private Path mFilledPath = new Path();
    private DisplayMetrics displayMetrics;
    private String mName = "Default";

    /**
     * get line name
     * @return name
     */
    public String getName() {
        return mName;
    }

    /**
     * Set line name
     * @param name
     */
    public void setName(String name) {
        this.mName = name;
    }

    /**
     * Getter for points which creates line.
     * 
     * @return points
     */
    public ArrayList<LinePoint> getPoints() {
        return mPoints;
    }

    /**
     * Instantiates a new line.
     * 
     * @param context
     *            context
     */
    public Line(Context context) {
        init(context);
    }

    private void init(Context context) {
        if (mPaint == null) {
            mPaint = new Paint();
            mPaint.setColor(context.getResources().getColor(R.color.chart_point_line_color));
            // TODO: 2016/10/9 增加阴影效果 下一行控制线的粗细
            mPaint.setShadowLayer(DisplayUrils.dip2px(context,3), 0, DisplayUrils.dip2px(context,2), context.getResources().getColor(R.color.chart_shade_color));
            mPaint.setStyle(Style.STROKE);
            mPaint.setStrokeWidth(DisplayUrils.dip2px(context,2));
            mPaint.setAntiAlias(true);
//            mPaint.setStrokeWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, context.getResources()
//                                                                                                   .getDisplayMetrics()));
        }
        if (mFilledPaint == null) {
            mFilledPaint = new Paint();
            mFilledPaint.setColor(0x440099cc);
            mFilledPaint.setStyle(Style.FILL);
        }
        displayMetrics = context.getResources().getDisplayMetrics();
    }

    private void buildPath() {
        mPath.reset();
        mPath.moveTo(mPoints.get(0).getX(), mPoints.get(0).getY());
        for (int i = 1; i < mPoints.size(); i += 1) {
            // mPath.quadTo(mPoints.get(i).getX(), mPoints.get(i).getY(),
            // (mPoints.get(i).getX() + mPoints.get(i + 1)
            // .getX()) / 2, ( mPoints.get(i).getY()+mPoints.get(i +
            // 1).getY())/2);
            mPath.lineTo(mPoints.get(i).getX(), mPoints.get(i).getY());
        }
        if (isFilled) {
            mFilledPath = new Path(mPath);
            mFilledPath.lineTo(mPoints.get(mPoints.size() - 1).getX(), 0);
            mFilledPath.lineTo(mPoints.get(0).getX(), 0);
            mFilledPath.close();
        }
    }

    /**
     * Smooth line with spline interpolation. Don't adds new points to line, just smooth path for drawing.
     * 
     * @param subPoints
     *            count of sub points
     * @return this
     */
    public Line smoothLine(int subPoints) {
        double[] dataX = new double[mPoints.size()];
        double[] dataY = new double[mPoints.size()];
        for (int i = 0; i < mPoints.size(); i++) {
            dataX[i] = mPoints.get(i).getX();
            dataY[i] = mPoints.get(i).getY();
        }
        mPath.reset();
        mPath.moveTo(mPoints.get(0).getX(), mPoints.get(0).getY());
        Spline sp = new Spline(dataX, dataY);
        for (int i = 0; i < mPoints.size() - 1; i += 1) {
            double step = (dataX[i + 1] - dataX[i]) / (subPoints + 1);
            for (int j = 1; j <= subPoints; j++) {
                double x = dataX[i] + step * j;
                mPath.lineTo((float) x, (float) sp.spline_value(x));
            }
            mPath.lineTo((float) dataX[i + 1], (float) dataY[i + 1]);
        }
        if (isFilled) {
            mFilledPath = new Path(mPath);
            mFilledPath.lineTo(mPoints.get(mPoints.size() - 1).getX(), 0);
            mFilledPath.lineTo(mPoints.get(0).getX(), 0);
            mFilledPath.close();
        }
        return this;
    }

    /**
     * Gets the {@link {@link Path Path}. For line drawing.
     * 
     * @return path
     */
    Path getPath() {
        return mPath;
    }

    /**
     * Gets {@link {@link Path Path} for filling underline space.
     * 
     * @return the filled path
     */
    Path getFilledPath() {
        return mFilledPath;
    }

    /**
     * Sets the points.
     * 
     * @param points
     *            points
     * @return this
     */
    public Line setPoints(ArrayList<LinePoint> points) {
        this.mPoints = points;
        buildPath();
        return this;
    }

    /**
     * Adds the point at the end of the line.
     * 
     * @param point
     *            the point
     * @return this
     */
    public Line addPoint(LinePoint point) {
        LinePoint p;
        for (int i = 0; i < mPoints.size(); i++) {
            p = mPoints.get(i);
            if (point.getX() < p.getX()) {
                mPoints.add(i, point);
                return this;
            }
        }
        mPoints.add(point);
        buildPath();
        return this;

    }

    /**
     * Removes the point.
     * 
     * @param point
     *            point from line
     * @return this
     */
    public Line removePoint(LinePoint point) {
        mPoints.remove(point);
        buildPath();
        return this;
    }

    /**
     * Gets the point by index.
     * 
     * @param index
     *            index of the point
     * @return point with <i>index</i>
     */
    public LinePoint getPoint(int index) {
        return mPoints.get(index);
    }

    /**
     * Gets the point with coords.
     * 
     * @param x
     *            x
     * @param y
     *            y
     * @return point
     */
    public LinePoint getPoint(float x, float y) {
        LinePoint p;
        for (int i = 0; i < mPoints.size(); i++) {
            p = mPoints.get(i);
            if (p.getX() == x && p.getY() == y) return p;
        }
        return null;
    }

    /**
     * Points count.
     * 
     * @return count
     */
    public int getPointsCount() {
        return mPoints.size();
    }

    /**
     * {@link Paint Paint} for line drawing.
     * 
     * @return paint
     */
    public Paint getPaint() {
        return mPaint;
    }

    /**
     * Sets {@link Paint Paint} for line drawing.
     * 
     * @param paint
     *            paint
     * @return this
     */
    public Line setPaint(Paint paint) {
        this.mPaint = paint;
        return this;
    }

    /**
     * Show or hide underline space fill with {@link Paint Paint} setted by {@link #setFilledPaint}.
     * 
     * @param isFilled
     *            is need fill underline space.
     * @return this
     */
    public Line setFilled(boolean isFilled) {
        this.isFilled = isFilled;
        buildPath();
        return this;
    }

    /**
     * Checks if underline space filled.
     * 
     * @return true, if need fill underline space
     */
    public boolean isFilled() {
        return isFilled;
    }

    /**
     * @return {@link Paint Paint} to underline space fill
     */
    public Paint getFilledPaint() {
        return mFilledPaint;
    }

    /**
     * Sets {@link Paint Paint} for underline space fill.
     * 
     * @param paint
     *            the paint
     * @return the line
     */
    public Line setFilledPaint(Paint paint) {
        this.mFilledPaint = paint;
        return this;
    }

    /**
     * Sets the color for Line.
     * 
     * @param color
     *            color in #AARRGGBB
     * @return this
     */
    public Line setColor(int color) {
        getPaint().setColor(color);
        return this;
    }

    /**
     * Sets color for underline fill.
     * 
     * @param color
     *            color in #AARRGGBB
     * @return this
     */
    public Line setFilledColor(int color) {
        mFilledPaint.setColor(color);
        return this;
    }

    /**
     * Sets the path effect.
     * 
     * @param pe
     *            {@link PathEffect PathEffect} for line drawing
     * @return this
     */
    public Line setPathEffect(PathEffect pe) {
        mPaint.setPathEffect(pe);
        return this;
    }

    /**
     * Sets line stroke width.
     * 
     * @param widthDp
     *            width in dp
     * @return this
     */
    public Line setStrokeWidth(float widthDp) {
        mPaint.setStrokeWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, widthDp, displayMetrics));
        return this;
    }

    private static double[] linSolve(double[][] matrix) {
        double[] results = new double[matrix.length];
        int[] order = new int[matrix.length];
        for (int i = 0; i < order.length; ++i) {
            order[i] = i;
        }
        for (int i = 0; i < matrix.length; ++i) {
            // partial pivot
            int maxIndex = i;
            for (int j = i + 1; j < matrix.length; ++j) {
                if (Math.abs(matrix[maxIndex][i]) < Math.abs(matrix[j][i])) {
                    maxIndex = j;
                }
            }
            if (maxIndex != i) {
                // swap order
                {
                    int temp = order[i];
                    order[i] = order[maxIndex];
                    order[maxIndex] = temp;
                }
                // swap matrix
                for (int j = 0; j < matrix[0].length; ++j) {
                    double temp = matrix[i][j];
                    matrix[i][j] = matrix[maxIndex][j];
                    matrix[maxIndex][j] = temp;
                }
            }
            if (Math.abs(matrix[i][i]) < 1e-15) {
                throw new RuntimeException("Singularity detected");
            }
            for (int j = i + 1; j < matrix.length; ++j) {
                double factor = matrix[j][i] / matrix[i][i];
                for (int k = i; k < matrix[0].length; ++k) {
                    matrix[j][k] -= matrix[i][k] * factor;
                }
            }
        }
        for (int i = matrix.length - 1; i >= 0; --i) {
            // back substitute
            results[i] = matrix[i][matrix.length];
            for (int j = i + 1; j < matrix.length; ++j) {
                results[i] -= results[j] * matrix[i][j];
            }
            results[i] /= matrix[i][i];
        }
        double[] correctResults = new double[results.length];
        for (int i = 0; i < order.length; ++i) {
            // switch the order around back to the original order
            correctResults[order[i]] = results[i];
        }
        return results;
    }

    public static float polyInterpolate(float[] dataX, float[] dataY, double x, int power) {
        int xIndex = 0;
        while (xIndex < dataX.length - (1 + power + (dataX.length - 1) % power) && dataX[xIndex + power] < x) {
            xIndex += power;
        }

        double matrix[][] = new double[power + 1][power + 2];
        for (int i = 0; i < power + 1; ++i) {
            for (int j = 0; j < power; ++j) {
                matrix[i][j] = Math.pow(dataX[xIndex + i], (power - j));
            }
            matrix[i][power] = 1;
            matrix[i][power + 1] = dataY[xIndex + i];
        }
        double[] coefficients = linSolve(matrix);
        double answer = 0;
        for (int i = 0; i < coefficients.length; ++i) {
            answer += coefficients[i] * Math.pow(x, (power - i));
        }
        return (float) answer;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/DuTextSearchActivity.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch;

import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.alibaba.fastjson.JSON;
import com.deepbaytech.deeplibrary.ActivityManager;
import com.deepbaytech.deeplibrary.OneKeyClearEditText;
import com.deepbaytech.deeplibrary.manager.CacheManager;
import com.example.lwd18.pictureselecotor.ApiConstants;
import com.example.lwd18.pictureselecotor.BaseDeepActivity;
import com.example.lwd18.pictureselecotor.FlowLayout;
import com.example.lwd18.pictureselecotor.PopularText;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.dialog.ConfirmDialog;
import com.example.lwd18.pictureselecotor.event.SearchHistoryEvent;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.SearchEvent;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import de.greenrobot.event.EventBus;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import okhttp3.Call;



public class DuTextSearchActivity extends BaseDeepActivity {

  @BindView(R.id.et_search) OneKeyClearEditText etSearch;
  @BindView(R.id.tv_search_back) TextView tvSearchBack;
  @BindView(R.id.search_toolbar) Toolbar searchToolbar;
  @BindView(R.id.iv_search_history) ImageView ivSearchHistory;
  @BindView(R.id.iv_del_history) ImageView ivDelHistory;
  @BindView(R.id.fl_history) FlowLayout flHistory;
  @BindView(R.id.iv_search_hot) ImageView ivSearchHot;
  @BindView(R.id.fl_hot) FlowLayout flHot;
  @BindView(R.id.ll_search_text_ware) LinearLayout llSearchTextWare;
  @BindView(R.id.activity_text_search) RelativeLayout activityTextSearch;
  @BindView(R.id.rl_search_history) RelativeLayout rlSearchHistory;
  @BindView(R.id.ll_search_history) LinearLayout llSearchHistory;

  //edit 输入的搜索词
  private String query;

  private List<String> hotList;
  private List<String> historyList;
  int fragmentTab;

  private boolean hisFlag = false;

  private ConfirmDialog dialog;
  private int margin;
  @Override protected void initActivity() {
    setContentView(R.layout.activity_text_search);
    ButterKnife.bind(this);
    EventBus.getDefault().register(this);
    fragmentTab = getIntent().getIntExtra("fragmentTab", 0);
    initToolBar();
    initFlowLayout();
  }

  private void initFlowLayout() {
    OkHttpUtils.get()
        .url(ApiConstants.POPULAR_TEXT)
        .addParams("type",1+"")
        .build().execute(new StringCallback() {
      @Override public void onError(Call call, Exception e, int id) {

      }

      @Override public void onResponse(String response, int id) {
        PopularText popularText = JSON.parseObject(response, PopularText.class);
        if (popularText.getState() == 0) {
          hotList = popularText.getData().getTexts();
          addChildText(flHot, hotList);
        }
      }
    });
    historyList = CacheManager.getInstance().getSearchHistory();
    if (historyList != null && historyList.size() > 0) {
      rlSearchHistory.setVisibility(View.VISIBLE);
      llSearchHistory.setVisibility(View.VISIBLE);
      hisFlag = true;
      addChildText(flHistory, historyList);
    }
  }

  /**
   *
   * @param flowLayout
   * @param list
   */
  private void addChildText(FlowLayout flowLayout, List<String> list) {
    if (list != null) {
      Iterator<String> iterator = list.iterator();
      while (iterator.hasNext()) {
        String text = iterator.next();
        addText(flowLayout, text, false);
      }
    }
  }

  /**
   * 向FlowLayout中添加数据
   * xx 是否添加在最前面
   */
  private void addText(FlowLayout flowLayout, String text, boolean xx) {
    final TextView tvChild = (TextView) LayoutInflater.from(this)
        .inflate(R.layout.view_textview_flowflag, flowLayout, false);
    tvChild.setText(text);
    tvChild.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        String flowKey = tvChild.getText().toString();
        EventBus.getDefault().post(new SearchHistoryEvent(flowKey));
      }
    });
    if (xx) {
      flowLayout.addView(tvChild, 0);
    } else {
      flowLayout.addView(tvChild);
    }
  }

  /**
   * Toolbar
   * OneKeyClearEditText
   */
  private void initToolBar() {
    searchToolbar.setTitle("");
    setSupportActionBar(searchToolbar);

    if (getIntent() != null && getIntent().getStringExtra("searchKey") != null) {
      String searchKey = getIntent().getStringExtra("searchKey");
      etSearch.setText(searchKey);
      etSearch.setSelection(searchKey.length());
    }
    etSearch.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    etSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
      @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
          query = etSearch.getText().toString().trim();
          if (!query.isEmpty()) {
            EventBus.getDefault().post(new SearchEvent(query));
            //goTextSearchResultActivity(query);
          } else {
            EventBus.getDefault().post(new SearchEvent(etSearch.getHint().toString()));
          }
        }
        return false;
      }
    });
  }

  private void goTextSearchResultActivity(String query) {
    //1.0版本的搜索结果页面(先注销掉)
    //Intent intent = new Intent(DuTextSearchActivity.this, TextSearchResultActivity.class);
    Intent intent = new Intent(DuTextSearchActivity.this, ProductDetailActivity.class);
    intent.putExtra("searchKey", query);
    startActivity(intent);
  }

  /**
   * 获取搜索历史
   */
  private void initSearchHistory(List<String> list) {

    if (list != null && list.size() > 0) {
      rlSearchHistory.setVisibility(View.VISIBLE);
      llSearchHistory.setVisibility(View.VISIBLE);
      hisFlag = true;
    } else {
      rlSearchHistory.setVisibility(View.GONE);
      llSearchHistory.setVisibility(View.GONE);
      hisFlag = false;
    }
  }

  /**
   * 删除搜索历史
   */
  private void clearSearchHistory() {
    CacheManager.getInstance().saveSearchHistory(null);
    initSearchHistory(null);
  }

  /**
   * 先添加flowlayout
   * 后保存搜索历史
   */
  private void saveSearchHistory(String query) {
    List<String> list = CacheManager.getInstance().getSearchHistory();

    boolean flag = false;

    if (list == null) {

      list = new ArrayList<>();
      list.add(0, query);
    } else {
      Iterator<String> iterator = list.iterator();
      while (iterator.hasNext()) {
        String item = iterator.next();
        if (TextUtils.equals(query, item)) {
          iterator.remove();
          flag = true;
        }
      }
      list.add(0, query);
    }

    if (flag == false) {
      addText(flHistory, query, true);
    }

    int size = list.size();
    if (size > 10) { // 最多保存20条
      for (int i = size - 1; i >= 10; i--) {
        list.remove(i);
      }
    }
    CacheManager.getInstance().saveSearchHistory(list);

    initSearchHistory(list);

    goTextSearchResultActivity(query);
  }

  /**
   * 点击flowlayout
   */
  public void onEvent(SearchHistoryEvent event) {
    etSearch.setText(event.getMsg());
    etSearch.setSelection(event.getMsg().toString().length());
    saveSearchHistory(event.getMsg());
  }

  /**
   * 键盘搜索按钮
   */
  public void onEvent(SearchEvent event) {
    //去重
    //List<String> list = CacheManager.getInstance().getSearchHistory();
    //Iterator<String> iterator = list.iterator();
    //boolean flag = false;
    //while (iterator.hasNext()) {
    //  String item = iterator.next();
    //  if (TextUtils.equals(event.getMsg(), item)) {
    //    flag = true;
    //  }
    //}
    //if (flag == false) {
    //  addText(flHistory, event.getMsg());
    //}

    saveSearchHistory(event.getMsg());
  }

  @OnClick({ R.id.tv_search_back, R.id.iv_del_history }) public void onClick(View view) {
    switch (view.getId()) {
      case R.id.tv_search_back:
        //Intent intent = new Intent(DuTextSearchActivity.this, MainActivity.class);
        //intent.putExtra("currentTab", fragmentTab);
        //startActivity(intent);
        ActivityManager.getInstance().finishActivity(DuTextSearchActivity.class);
        break;
      //删除搜索历史
      case R.id.iv_del_history:
        dialog = new ConfirmDialog(DuTextSearchActivity.this);
        dialog.setOnDeepConfirmListener(new ConfirmDialog.DeepConfirmListener() {
          @Override public void onSelectCancel() {
            dialog.dismiss();
          }

          @Override public void onSelectEnsure() {
            clearSearchHistory();
            flHistory.removeAllViews();
            dialog.dismiss();
          }
        });
        dialog.show();
        break;
    }
  }

  @Override protected void onDestroy() {
    super.onDestroy();
    EventBus.getDefault().unregister(this);
  }

  /**
   * 该方法回调时机为,Activity回退栈内Fragment的数量 小于等于1 时,默认finish Activity
   * 请尽量复写该方法,避免复写onBackPress(),以保证SupportFragment内的onBackPressedSupport()回退事件正常执行
   */
  @Override public void onBackPressedSupport() {
    super.onBackPressedSupport();
  }

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/bigphotobrows/MainView.java<|end_filename|>
package com.example.lwd18.pictureselecotor.bigphotobrows;

import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/5/24 9:45
 * 描述	      ${TODO}
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public interface MainView {

    void setImages(List<String> images);

    void initRecycler();

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/productdetail/GoodsDetailActivity.java<|end_filename|>
package com.example.lwd18.pictureselecotor.productdetail;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.alibaba.fastjson.JSON;
import com.deepbaytech.deeplibrary.utils.InternetUtils;
import com.ethereal.deepstatelayout.DStateLayout;
import com.example.lwd18.pictureselecotor.ApiConstants;
import com.example.lwd18.pictureselecotor.BaseDeepActivity;
import com.example.lwd18.pictureselecotor.ProductDetailEntity;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextSearchRecomdEntity;
import com.example.lwd18.pictureselecotor.TextSearchSameEntity;
import com.example.lwd18.pictureselecotor.bigphotobrows.ImageBrowseActivity;
import com.example.lwd18.pictureselecotor.textsearch.HttpMethodLogin;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Call;
import rx.Subscriber;



public class GoodsDetailActivity extends BaseDeepActivity
    implements View.OnClickListener , NestedScrollView.OnScrollChangeListener{

  @BindView(R.id.top_news_viewpager_ll) LinearLayout mTopNewsViewpagerLl;
  @BindView(R.id.dots_ll) LinearLayout mDotsLl;
  @BindView(R.id.appbar) AppBarLayout mAppbar;
  @BindView(R.id.comment_simple) TextView mCommentSimple;
  @BindView(R.id.comment_min) TextView mCommentMin;
  @BindView(R.id.comment_simple_price) TextView mCommentSimplePrice;
  @BindView(R.id.comment_simple_prices) TextView mCommentSimplePrices;
  @BindView(R.id.look) TextView mLook;
  @BindView(R.id.taobao) TextView mTaobao;
  @BindView(R.id.tao_price) TextView mTaoPrice;
  @BindView(R.id.tianmao) TextView mTianmao;
  @BindView(R.id.tm_price) TextView mTmPrice;
  @BindView(R.id.jd) TextView mJd;
  @BindView(R.id.jd_price) TextView mJdPrice;
  @BindView(R.id.guomei) TextView mGuomei;
  @BindView(R.id.guomei_price) TextView mGuomeiPrice;
  @BindView(R.id.SUnin) TextView mSUnin;
  @BindView(R.id.SUnin_price) TextView mSUninPrice;
  @BindView(R.id.dd) TextView mDd;
  @BindView(R.id.dd_price) TextView mDdPrice;
  @BindView(R.id.yamaxun) TextView mYamaxun;
  @BindView(R.id.yamaxun_price) TextView mYamaxunPrice;
  @BindView(R.id.yihaodian) TextView mYihaodian;
  @BindView(R.id.yihaodian_price) TextView mYihaodianPrice;
  @BindView(R.id.rv_goods) RecyclerView mRvGoods;
  @BindView(R.id.rv_goods_commend) RecyclerView mRvGoodsCommend;
  @BindView(R.id.click_more) TextView mMore;
  @BindView(R.id.webview) WebView mWebview;
  @BindView(R.id.scrollview_first) ScrollView scrollviewFirst;
  @BindView(R.id.tv_net_state_wifi) TextView tvNetStateWifi;
  @BindView(R.id.rl_net_states) RelativeLayout rlNetStates;
  @BindView(R.id.tv_amount_price) TextView tvAmountPrice;
  @BindView(R.id.ll_ware_item_amount) LinearLayout llWareItemAmount;
  @BindView(R.id.tv_rebate_price_textsearch) TextView tvRebatePriceTextsearch;
  @BindView(R.id.ll_ware_item_textsearch) RelativeLayout llWareItemTextsearch;
  @BindView(R.id.scroll1) NestedScrollView scroll1;
  @BindView(R.id.ware_toolbar_back) TextView wareToolbarBack;
  @BindView(R.id.tv_good_detail_title_good) TextView tvGoodDetailTitleGood;
  @BindView(R.id.view_line) View line;
  @BindView(R.id.ll_good_detail) RelativeLayout llGoodDetail;
  //存放指示点的集合
  private List<ImageView> pointList = new ArrayList<>();
  //上一个指示点
  private int lastPosition = 0;
  private RollViewPagers rollViewPager;
  private List<String> list;
  private List<TextSearchSameEntity.DataBean.ItemsBean> proList;
  private List<TextSearchSameEntity.DataBean.ItemsBean> newlist;
  private FirstAdapter mFirstAdapter;
  private String productId;
  private DStateLayout stateLayout;
  boolean isNetCollect = true;
  private int position = 1;
  private int price;
  private String lv;
  private int height=180;
  private SecondAdapter secondAdapter;

  @Override protected void initActivity() {
    setContentView(R.layout.activity_goods_detail);
    ButterKnife.bind(this);
    Intent intent = getIntent();
    productId = intent.getStringExtra("productId");
    price = intent.getIntExtra("price", 0);
    lv = intent.getStringExtra("lv");
    initAppBar();
    //获取商品基本信息
    getData();
    //获取相同商品数据
    getRecomdData(1);
    //获取推荐商品数据
    getRecommendData(1);
    proList = new ArrayList<>();
    newlist = new ArrayList<>();
    scroll1.setOnScrollChangeListener(GoodsDetailActivity.this);
    initFirstRv();
    //initSecondRv();
    mCommentSimplePrices.setText("¥" + lv);
    initClick();
  }



  private void initAppBar() {
    list = new ArrayList<>();
    wareToolbarBack.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        finish();
      }
    });
    mWebview.getSettings().setJavaScriptEnabled(true);
    mWebview.loadUrl("http://api.deepbaytech.com/mobile/prod-detail-chart.html");
  }

  private void initFirstRv() {
    LinearLayoutManager line = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    mFirstAdapter = new FirstAdapter();
    mRvGoods.setLayoutManager(line);
    mRvGoods.setAdapter(mFirstAdapter);
  }

  private void initClick() {
    mMore.setOnClickListener(this);
    mTaobao.setOnClickListener(this);
    mTianmao.setOnClickListener(this);
    mJd.setOnClickListener(this);
    mGuomei.setOnClickListener(this);
    mSUnin.setOnClickListener(this);
    mDd.setOnClickListener(this);
    mYamaxun.setOnClickListener(this);
    mYihaodian.setOnClickListener(this);
  }

  private void initSecondRv() {
    GridLayoutManager line = new GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false);
    secondAdapter = new SecondAdapter();
    mRvGoodsCommend.setLayoutManager(line);
    mRvGoodsCommend.setAdapter(secondAdapter);
  }

  private void initview() {
    lastPosition = 0;
    //第一步：添加轮播图（也可以直接将布局写成咱们自定义的viewpager）
    rollViewPager = new RollViewPagers(GoodsDetailActivity.this);
    mTopNewsViewpagerLl.addView(rollViewPager);
    //第二步：传递轮播图需要的图片url集合或者数组
    //List<SpecialDetailEntity> list = entity.getItems();
    rollViewPager.setImageUrlsList(list);

    //第三步：添加指示点
    addPoints();
  }

  private void initlistener() {
    //第四步：给轮播图添加界面改变监听，切换指示点
    rollViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
      @Override public void onPageSelected(int position) {
        position = position % list.size();
        //切换指示点
        pointList.get(lastPosition).setImageResource(R.mipmap.dot_normal);
        pointList.get(position).setImageResource(R.mipmap.dot_focus);
        lastPosition = position;
      }

      @Override
      public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
      }

      @Override public void onPageScrollStateChanged(int state) {
      }
    });

    //第六步：设置当前页面，最好不要写最大数除以2，其实写了50就足够了，谁没事无聊到打开app二话不说直接对着轮播图往相反方向不停的划几十下
    rollViewPager.setCurrentItem(50 - 50 % list.size());

    //第七步：设置完之后就可以轮播了：开启自动轮播
    rollViewPager.startRoll();
  }

  //        //第五步：轮播图点击监听
  private void onclickvp(final List<String> lists) {
    final List<String> list = new ArrayList<>();
    rollViewPager.setOnItemClickListener(new RollViewPagers.OnItemClickListener() {
      @Override public void onItemClick(int position) {
        //进入photoview
        for (int i = 0; i < lists.size(); i++) {
          list.add(lists.get(i));
        }
        ImageBrowseActivity.startActivity(getBaseContext(), (ArrayList<String>) list, position);
      }
    });
  }

  private void addPoints() {
    pointList.clear();
    mDotsLl.removeAllViews();
    for (int x = 0; x < list.size(); x++) {
      ImageView imageView = new ImageView(getBaseContext());
      imageView.setImageResource(R.mipmap.img_02_03);
      //导报的时候指示点的父View是什么布局就导什么布局的params,这里导的是线性布局
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
              LinearLayout.LayoutParams.WRAP_CONTENT);
      //设置间隔
      params.leftMargin = 36;
      //添加到线性布局;params指定布局参数，不然点就按在一起了
      mDotsLl.addView(imageView, params);
      //把指示点存放到集合中
      pointList.add(imageView);
    }
  }

  /**
   * 网络状态
   */
  private void initStatu() {
    stateLayout = DStateLayout.wrap(scrollviewFirst);
    stateLayout.setRetryListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        //initData(productId);
        getData();
      }
    });
    stateLayout.showLoading();

    isNetCollect = inspectNet();
    if (!isNetCollect) {
      rlNetStates.setVisibility(View.VISIBLE);
    } else {
      rlNetStates.setVisibility(View.GONE);
    }
  }

  @Override public void onNetChange(int netMobile) {
    super.onNetChange(netMobile);
    //网络状态变化时的操作
    if (netMobile == InternetUtils.NETWORK_NONE) {
      rlNetStates.setVisibility(View.VISIBLE);
      isNetCollect = false;
    } else {
      rlNetStates.setVisibility(View.GONE);
      isNetCollect = true;
    }
  }

  private void getData() {
    OkHttpUtils.get().url(ApiConstants.PRODUCTSEARCH)
        .addParams("pid", productId)
        .build().execute(new StringCallback() {

      @Override public void onError(Call call, Exception e, int id) {
        if (isNetCollect) {
          stateLayout.showEmpty();
        } else {
          stateLayout.showError();
        }
      }

      @Override public void onResponse(String response, int id) {
        final ProductDetailEntity productDetailEntity =
            JSON.parseObject(response, ProductDetailEntity.class);
        //记录总页数
        if (productDetailEntity.getState() == 0) {
          //stateLayout.showContent();
          rlNetStates.setVisibility(View.GONE);
          list.clear();
          proList.clear();
          list.addAll(productDetailEntity.getData().getPicUrl());
          initview();
          initlistener();
          onclickvp(list);
          String s = "推荐商家 [ "
              + productDetailEntity.getData().getPlatform()
              + " ] "
              + productDetailEntity.getData().getTitle();
          SpannableStringBuilder style = new SpannableStringBuilder(s);
          style.setSpan(
              new ForegroundColorSpan(getResources().getColor(R.color.main_tab_select_color)), 0,
              productDetailEntity.getData().getPlatform().length() + 10,
              Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
          mCommentSimple.setText(style);
          ProductDetailEntity.DataBean ware = productDetailEntity.getData();
          mCommentSimplePrice.setText("¥" + ware.getPrice());
          if (ware.getAmountType() > 0) {
            //1 返利  2 优惠券
            if (ware.getAmountType() == 1) {
              llWareItemAmount.setVisibility(View.VISIBLE);
              llWareItemTextsearch.setVisibility(View.GONE);
              tvAmountPrice.setText(ware.getAmountMoney() + "");
            } else if (ware.getAmountType() == 2) {
              llWareItemAmount.setVisibility(View.GONE);
              llWareItemTextsearch.setVisibility(View.VISIBLE);
             // tvRebatePriceTextsearch.setText(ware.getAmountMoney() + "");
              tvRebatePriceTextsearch.setText("满100减50");
            }
          }
          {
            mLook.setOnClickListener(new View.OnClickListener() {
              @Override public void onClick(View v) {
                //startActivity(
                //    new Intent(GoodsDetailActivity.this, WareActivity.class).putExtra("productId", productDetailEntity.getData().getPfromId())
                //        .putExtra("productType", 2));
              }
            });
          }
        } else if (productDetailEntity.getState() == 3) {
        } else {
        }
      }
    });
  }
  //获取相同商品
  private void getRecomdData(final int i) {
    OkHttpUtils.get().url(ApiConstants.PRODUCTSAMESEARCH)
        .addParams("pid", productId)
        .addParams("pageId",i+"")
        .build().execute(new StringCallback() {

      @Override public void onError(Call call, Exception e, int id) {
        if (isNetCollect) {
          stateLayout.showEmpty();
        } else {
          stateLayout.showError();
        }
        e.printStackTrace();
      }

      @Override public void onResponse(String response, int id) {
        final TextSearchSameEntity textSearchSameEntity =
            JSON.parseObject(response, TextSearchSameEntity.class);
        if (textSearchSameEntity.getState()==0){
          if (textSearchSameEntity.getData().getItems().size()>0){
            proList.clear();
            newlist.clear();
            proList.addAll(textSearchSameEntity.getData().getItems());
            newlist.addAll(proList);
            if (textSearchSameEntity.getData().getPageTotal()<=1) {
              mMore.setVisibility(View.GONE);
            }else {
              if (i<=textSearchSameEntity.getData().getPageTotal()) {
                mFirstAdapter.addMoreItem(newlist);
                if (i<textSearchSameEntity.getData().getPageTotal()){
                  mMore.setVisibility(View.VISIBLE);
                }else {
                  mMore.setVisibility(View.GONE);
                }
              }else {
                mMore.setVisibility(View.GONE);
                return;
              }
            }
          }else {
            mMore.setVisibility(View.GONE);
            return;
          }
        }else {
          mMore.setVisibility(View.GONE);
          return;
        }

      }
    });


  }

  //用来记录被点击的位置
  private int type = -1;

  @Override public void onClick(View v) {
    switch (v.getId()) {
      //case R.id.more:
      //  break;
      //淘宝
      case R.id.taobao:
        type = 0;
        toggle0();
        break;
      //天猫
      case R.id.tianmao:
        type = 1;
        toggle1();
        break;
      //京东
      case R.id.jd:
        type = 2;
        toggle2();
        break;
      //国美
      case R.id.guomei:
        type = 3;
        toggle3();
        break;
      //苏宁
      case R.id.SUnin:
        type = 4;
        toggle4();
        break;
      //当当
      case R.id.dd:
        type = 5;
        toggle5();
        break;
      //亚马逊
      case R.id.yamaxun:
        type = 6;
        toggle6();
        break;
      //一号店
      case R.id.yihaodian:
        type = 7;
        toggle7();
        break;
      //加载更多的点击事件
      case R.id.click_more:
        getRecomdData(++position);
        break;
    }
  }

  //设置淘宝的点击事件
  public boolean mIsToggle0;

  public void setToggleOn0(boolean isToggle) {
    mIsToggle0 = isToggle;
    if (isToggle) {
      mTaobao.setBackgroundResource(R.drawable.select_taobao);
      mTaobao.setTextColor(getResources().getColor(R.color.taobao));
    } else {
      mTaobao.setBackgroundResource(R.drawable.select_text_normal);
      mTaobao.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle0() {
    return mIsToggle0;
  }

  public void toggle0() {
    setToggleOn0(!mIsToggle0);
  }

  //设置天猫的点击事件
  public boolean mIsToggle1;

  public void setToggleOn1(boolean isToggle) {
    mIsToggle1 = isToggle;
    if (isToggle) {
      mTianmao.setBackgroundResource(R.drawable.select_tianmao);
      mTianmao.setTextColor(getResources().getColor(R.color.tianmao));
    } else {
      mTianmao.setBackgroundResource(R.drawable.select_text_normal);
      mTianmao.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle1() {
    return mIsToggle0;
  }

  public void toggle1() {
    setToggleOn1(!mIsToggle1);
  }

  //设置京东的点击事件
  public boolean mIsToggle2;

  public void setToggleOn2(boolean isToggle) {
    mIsToggle2 = isToggle;
    if (isToggle) {
      mJd.setBackgroundResource(R.drawable.select_jd);
      mJd.setTextColor(getResources().getColor(R.color.jd));
    } else {
      mJd.setBackgroundResource(R.drawable.select_text_normal);
      mJd.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle2() {
    return mIsToggle2;
  }

  public void toggle2() {
    setToggleOn2(!mIsToggle2);
  }

  //设置国美的点击事件
  public boolean mIsToggle3;

  public void setToggleOn3(boolean isToggle) {
    mIsToggle3 = isToggle;
    if (isToggle) {
      mGuomei.setBackgroundResource(R.drawable.select_guomei);
      mGuomei.setTextColor(getResources().getColor(R.color.guomei));
    } else {
      mGuomei.setBackgroundResource(R.drawable.select_text_normal);
      mGuomei.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle3() {
    return mIsToggle3;
  }

  public void toggle3() {
    setToggleOn3(!mIsToggle3);
  }

  //设置苏宁的点击事件
  public boolean mIsToggle4;

  public void setToggleOn4(boolean isToggle) {
    mIsToggle4 = isToggle;
    if (isToggle) {
      mSUnin.setBackgroundResource(R.drawable.select_suning);
      mSUnin.setTextColor(getResources().getColor(R.color.suning));
    } else {
      mSUnin.setBackgroundResource(R.drawable.select_text_normal);
      mSUnin.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle4() {
    return mIsToggle4;
  }

  public void toggle4() {
    setToggleOn4(!mIsToggle4);
  }

  //设置当当的点击事件
  public boolean mIsToggle5;

  public void setToggleOn5(boolean isToggle) {
    mIsToggle5 = isToggle;
    if (isToggle) {
      mDd.setBackgroundResource(R.drawable.select_dangdang);
      mDd.setTextColor(getResources().getColor(R.color.dangdang));
    } else {
      mDd.setBackgroundResource(R.drawable.select_text_normal);
      mDd.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle5() {
    return mIsToggle5;
  }

  public void toggle5() {
    setToggleOn5(!mIsToggle5);
  }

  //设置亚马逊的点击事件
  public boolean mIsToggle6;

  public void setToggleOn6(boolean isToggle) {
    mIsToggle6 = isToggle;
    if (isToggle) {
      mYamaxun.setBackgroundResource(R.drawable.select_yamaxun);
      mYamaxun.setTextColor(getResources().getColor(R.color.yamasun));
    } else {
      mYamaxun.setBackgroundResource(R.drawable.select_text_normal);
      mYamaxun.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle6() {
    return mIsToggle6;
  }

  public void toggle6() {
    setToggleOn6(!mIsToggle6);
  }

  //设置一号店的点击事件
  public boolean mIsToggle7;

  public void setToggleOn7(boolean isToggle) {
    mIsToggle7 = isToggle;
    if (isToggle) {
      mYihaodian.setBackgroundResource(R.drawable.select_yihaodian);
      mYihaodian.setTextColor(getResources().getColor(R.color.yihaodian));
    } else {
      mYihaodian.setBackgroundResource(R.drawable.select_text_normal);
      mYihaodian.setTextColor(getResources().getColor(R.color.normal));
    }
  }

  public boolean isToggle7() {
    return mIsToggle7;
  }

  public void toggle7() {
    setToggleOn7(!mIsToggle7);
  }

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // TODO: add setContentView(...) invocation
    ButterKnife.bind(this);
  }

  @Override public void onScrollChange(NestedScrollView v, int x, int y, int oldx, int oldy) {
    if (y <= 0) {   //设置标题的背景颜色
      llGoodDetail.setBackgroundColor(Color.argb(0, 255, 255, 255));
      line.setVisibility(View.GONE);
      tvGoodDetailTitleGood.setTextColor(Color.TRANSPARENT);
    } else if (y > 0 && y <= height) { //滑动距离小于banner图的高度时，设置背景和字体颜色颜色透明度渐变
      float scale = (float) y / height;
      float alpha = (255 * scale);
      tvGoodDetailTitleGood.setTextColor(Color.argb((int) alpha, 1, 24, 28));
      llGoodDetail.setBackgroundColor(Color.argb((int) alpha, 255, 255, 255));
      line.setVisibility(View.GONE);
    } else {    //滑动到banner下面设置普通颜色
      llGoodDetail.setBackgroundColor(Color.argb(255, 255, 255, 255));
      line.setVisibility(View.VISIBLE);
    }
  }


  //获取推荐商品数据
  public void getRecommendData(int pageId) {
    Subscriber subscriber = new Subscriber<TextSearchRecomdEntity>() {
      @Override public void onCompleted() {

      }

      @Override public void onError(Throwable e) {
        e.printStackTrace();
      }

      @Override public void onNext(TextSearchRecomdEntity s) {
        System.out.println("response==="+s);
        if (s.getState()==0){
          //secondAdapter.addItem(s.getData().getItems());
        }
      }
    };
    HttpMethodLogin.getInstance().getTextSearchRecomd(subscriber, productId, pageId);
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/productdetail/RollViewPagers.java<|end_filename|>
package com.example.lwd18.pictureselecotor.productdetail;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.example.lwd18.pictureselecotor.R;
import java.util.ArrayList;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/6/19 19:37
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

    public class RollViewPagers extends ViewPager {
    //传递过来的图片数组，这个必须更换，真实项目中有可能是一个集合
    private int[] imageUrls;
    private List<String> mimageUrlslist;
    private static final int NEXT=99;//切换下一张图片的标志
    private boolean isRunning=false;//是否自动轮播的标志，默认不自动轮播

    //    private BitmapUtils bitmapUtils;
    public RollViewPagers(Context context) {
        super(context);
        mimageUrlslist=new ArrayList<>();
    }

    public RollViewPagers(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setImageUrls(int[] imageUrls) {
        this.imageUrls = imageUrls;
        setAdapter(new MyRollViePagerAdatper());
    }

    public void setImageUrlsList(List<String> imageUrlslist) {

        mimageUrlslist.clear();
        mimageUrlslist.addAll(imageUrlslist);
        setAdapter(new MyRollViePagerAdatper());
    }
    private Handler handler=new Handler(){
        @Override
        public void handleMessage(Message msg) {

            switch (msg.what){

                case NEXT:
                    if(isRunning==true){
                        //设置当前item+1；相当于设置下一个item，然后余图片数量；
                        // setCurrentItem(getCurrentItem()+1);
                        //然后发送空消息延时2秒
                        //handler.sendEmptyMessageDelayed(NEXT,2000);
                    }
                    break;
            }
        }
    };

    //开始轮播
    public void startRoll(){
        //开启轮播
        isRunning=true;
        //发送handler延时2秒
        handler.sendEmptyMessageDelayed(NEXT,2000);
    }

    class MyRollViePagerAdatper extends PagerAdapter {

        @Override
        public int getCount() {
            return Integer.MAX_VALUE;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            //这个必须取余数，不然会下标越界
            //position=position%imageUrls.length;
            position=position%mimageUrlslist.size();
            ImageView
                imageView = (ImageView) View.inflate(getContext(), R.layout.viewpager_item, null);
            //先获取网络中图片的url
            //           在真实项目中使用谷歌官方提供的Glide加载图片
            //            Glide.with(context).load(new File(path)).diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().into(vh.imageView);
            Glide.with(getContext())
                .load(mimageUrlslist.get(position))
                .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.loading_z))
                .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 view, Object object) {
            return view==object;
        }
    }

    private int downTime=0;//按下时间
    //按下的XY坐标
    private int downX=0;
    private int downY=0;

    @Override
    public boolean onTouchEvent(MotionEvent ev) {

        switch (ev.getAction()){

            case MotionEvent.ACTION_DOWN:
                downX= (int) ev.getX();
                downY= (int) ev.getY();
                downTime= (int) System.currentTimeMillis();
                //停止轮播
                isRunning=false;
                handler.removeMessages(NEXT);
                break;

            case MotionEvent.ACTION_UP:
                int upX= (int) ev.getX();
                int upY= (int) ev.getY();
                int disX= Math.abs(upX - downX);
                int disY= Math.abs(upY - downY);
                int upTime=(int) System.currentTimeMillis();
                if(upTime-downTime<500 && disX-disY<5 ){
                    if(onItemClickListener!=null){
                        onItemClickListener.onItemClick(getCurrentItem()%mimageUrlslist.size());//当前位置就是显示的条目
                    }
                }

                //开启轮播
                startRoll();
                break;

            case MotionEvent.ACTION_CANCEL:
                startRoll();
                break;

            default:
                break;
        }

        return super.onTouchEvent(ev);
    }

    @Override
    //当控件挂载到页面上会调用此方法
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
    }

    @Override
    //当控件从页面上移除的时候会调用此方法
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        isRunning=false;
        handler.removeMessages(NEXT);
    }

    private OnItemClickListener onItemClickListener;

    public interface OnItemClickListener{
      void onItemClick(int position);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.onItemClickListener=onItemClickListener;
    }

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/ProductDetailEntity.java<|end_filename|>
package com.example.lwd18.pictureselecotor;

import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/7/11 17:36
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class ProductDetailEntity {

  /**
   * id : -344997581
   * updateTime : 16536870
   * state : 0
   * stateSmg : 成功
   * data : {"id":"AV0IiqSROFuQj7og1tjh","title":"伊利金典纯牛奶/光明优+纯牛奶  250ml*12盒/箱全国包邮临期促销","price":18,"viewSales":0,"platform":"淘宝","detailUrl":"http://h5.m.taobao.com/awp/core/detail.htm?id=549237149629","picUrl":["//g-search1.alicdn.com/img/bao/uploaded/i4/i2/2668770299/TB2KrNEmSBjpuFjSsplXXa5MVXa_!!2668770299.png"],"sameProducts":[{"title":"伊利金典纯牛奶特价/250ml*12盒全国包邮2017年1月份生产日期*/

  private int id;
  private int updateTime;
  private int state;
  private String stateSmg;
  private DataBean data;

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public int getUpdateTime() {
    return updateTime;
  }

  public void setUpdateTime(int updateTime) {
    this.updateTime = updateTime;
  }

  public int getState() {
    return state;
  }

  public void setState(int state) {
    this.state = state;
  }

  public String getStateSmg() {
    return stateSmg;
  }

  public void setStateSmg(String stateSmg) {
    this.stateSmg = stateSmg;
  }

  public DataBean getData() {
    return data;
  }

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

  public static class DataBean {
    /**
     * id : AV0IiqSROFuQj7og1tjh
     * title : 伊利金典纯牛奶/光明优+纯牛奶  250ml*12盒/箱全国包邮临期促销
     * price : 18
     * viewSales : 0
     * platform : 淘宝
     * detailUrl : http://h5.m.taobao.com/awp/core/detail.htm?id=549237149629
     * picUrl : ["//g-search1.alicdn.com/img/bao/uploaded/i4/i2/2668770299/TB2KrNEmSBjpuFjSsplXXa5MVXa_!!2668770299.png"]
     * sameProducts : [{"title":"伊利金典纯牛奶特价/250ml*12盒全国包邮2017年1月份生产日期","price":26,"platform":"淘宝","detailUrl":"http://h5.m.taobao
     */

    private String id;
    private String title;
    private int price;
    private int viewSales;
    private String platform;
    private String detailUrl;
    private String pfromId;
    private String proCharts;
    private List<String> picUrl;
    private List<SameProductsBean> sameProducts;
    private int amountType;
    private double amountMoney;

    public String getPfromId() {
      return pfromId;
    }

    public void setPfromId(String pfromId) {
      this.pfromId = pfromId;
    }

    public int getAmountType() {
      return amountType;
    }

    public void setAmountType(int amountType) {
      this.amountType = amountType;
    }

    public double getAmountMoney() {
      return amountMoney;
    }

    public void setAmountMoney(double amountMoney) {
      this.amountMoney = amountMoney;
    }


    public String getId() {
      return id;
    }

    public void setId(String id) {
      this.id = id;
    }

    public String getTitle() {
      return title;
    }

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

    public int getPrice() {
      return price;
    }

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

    public int getViewSales() {
      return viewSales;
    }

    public void setViewSales(int viewSales) {
      this.viewSales = viewSales;
    }

    public String getPlatform() {
      return platform;
    }

    public void setPlatform(String platform) {
      this.platform = platform;
    }

    public String getDetailUrl() {
      return detailUrl;
    }

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

    public String getProCharts() {
      return proCharts;
    }

    public void setProCharts(String proCharts) {
      this.proCharts = proCharts;
    }

    public List<String> getPicUrl() {
      return picUrl;
    }

    public void setPicUrl(List<String> picUrl) {
      this.picUrl = picUrl;
    }

    public List<SameProductsBean> getSameProducts() {
      return sameProducts;
    }

    public void setSameProducts(List<SameProductsBean> sameProducts) {
      this.sameProducts = sameProducts;
    }

    public static class SameProductsBean {
      /**
       * title : 伊利金典纯牛奶特价/250ml*12盒全国包邮2017年1月份生产日期
       * price : 26
       * platform : 淘宝
       * detailUrl : http://h5.m.taobao.com/awp/core/detail.htm?id=540721743049
       * picUrl : //g-search3.alicdn.com/img/bao/uploaded/i4/i1/2851289470/TB23uBPaH5K.eBjy0FnXXaZzVXa_!!2851289470.jpg
       */
      private String id;
      private String title;
      private int price;
      private int viewSales;
      private String platform;
      private int platformCount;
      private String detailUrl;
      private String keywords;
      private String fromat;
      private String picUrl;
      private int shopCount;
      private String pfromId;
      private int type;
      private int amountType;
      private double amountMoney;


      public String getPfromId() {
        return pfromId;
      }

      public void setPfromId(String pfromId) {
        this.pfromId = pfromId;
      }

      public int getType() {
        return type;
      }

      public void setType(int type) {
        this.type = type;
      }

      public int getAmountType() {
        return amountType;
      }

      public void setAmountType(int amountType) {
        this.amountType = amountType;
      }

      public double getAmountMoney() {
        return amountMoney;
      }

      public void setAmountMoney(double amountMoney) {
        this.amountMoney = amountMoney;
      }

      public String getId() {
        return id;
      }

      public void setId(String id) {
        this.id = id;
      }

      public int getViewSales() {
        return viewSales;
      }

      public void setViewSales(int viewSales) {
        this.viewSales = viewSales;
      }

      public int getPlatformCount() {
        return platformCount;
      }

      public void setPlatformCount(int platformCount) {
        this.platformCount = platformCount;
      }

      public String getKeywords() {
        return keywords;
      }

      public void setKeywords(String keywords) {
        this.keywords = keywords;
      }

      public String getFromat() {
        return fromat;
      }

      public void setFromat(String fromat) {
        this.fromat = fromat;
      }

      public int getShopCount() {
        return shopCount;
      }

      public void setShopCount(int shopCount) {
        this.shopCount = shopCount;
      }

      public String getTitle() {
        return title;
      }

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

      public int getPrice() {
        return price;
      }

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

      public String getPlatform() {
        return platform;
      }

      public void setPlatform(String platform) {
        this.platform = platform;
      }

      public String getDetailUrl() {
        return detailUrl;
      }

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

      public String getPicUrl() {
        return picUrl;
      }

      public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
      }
    }
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/fragment/FilterFragment.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import com.alibaba.fastjson.JSON;
import com.deepbaytech.deeplibrary.utils.InternetUtils;
import com.ethereal.deepstatelayout.DStateLayout;
import com.example.lwd18.pictureselecotor.ApiConstants;
import com.example.lwd18.pictureselecotor.BaseFragment;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.textsearch.resultadapter.FilterAdapter;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import okhttp3.Call;

/**
 * 创建者     李文东
 * 创建时间   2017/6/19 11:09
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class FilterFragment extends BaseFragment {
  private static final String TAG = "ComprehensiveFragment";
  @BindView(R.id.rv_product_detail) RecyclerView mRvProductDetail;
  @BindView(R.id.sr_product_detail) SwipeRefreshLayout mSrProductDetail;
  @BindView(R.id.te_no_product_detail) TextView mTeNoProductDetail;
  @BindView(R.id.No_re_product_detail) RelativeLayout mNoReProductDetail;
  Unbinder unbinder;
  @BindView(R.id.tv_net_state_wifi) TextView tvNetStateWifi;
  @BindView(R.id.rl_net_states) RelativeLayout rlNetStates;
  private String mExittext;
  private LinearLayoutManager mLinearLayoutManager;
  /**
   * 下拉刷新相关
   */
  private int currentPage = 1;
  boolean isloading;
  private List<TextsSearchEntity.DataBean.ItemsBean> list;
  private List<Integer> sumpageid;
  //记录下拉刷新次数
  private int position = 1;
  private List<TextsSearchEntity.DataBean.ItemsBean> newlist;
  private Handler mHandler = new Handler();
  private DStateLayout stateLayout;
  boolean isNetCollect = true;
  private FilterAdapter adapter;
  private TextsSearchEntity textSearch;

  private List<TextsSearchEntity.DataBean.FiltersBean> filterlist;
  private List<TextsSearchEntity.DataBean.FiltersBean> newfilterlist;

  public static FilterFragment newInstance(String text) {
    Bundle args = new Bundle();
    args.putString("exittext", text);
    FilterFragment fragment = new FilterFragment();
    fragment.setArguments(args);
    return fragment;
  }

  @Override public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mExittext = getArguments().getString("exittext");
    /**
     * 注册eventbus用来接收搜索的关键字
     */
  }

  @Nullable @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
      @Nullable Bundle savedInstanceState) {
    View view = View.inflate(getContext(), R.layout.fragment_item_product, null);
    unbinder = ButterKnife.bind(this, view);
    initview();
    return view;
  }

  private void initview() {
    list = new ArrayList<>();
    newlist = new ArrayList<>();
    filterlist = new ArrayList<>();
    newfilterlist = new ArrayList<>();

    sumpageid = new Vector<>();
    getData(currentPage);
    list.clear();
    newlist.clear();
    filterlist.clear();
    newfilterlist.clear();
    //用来记录currentpage
    mSrProductDetail.setProgressBackgroundColorSchemeResource(android.R.color.white);
    mSrProductDetail.setColorSchemeResources(android.R.color.holo_blue_light,
        android.R.color.holo_red_light, android.R.color.holo_orange_light,
        android.R.color.holo_green_light);
    mSrProductDetail.setProgressViewOffset(false, 0,
        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24,
            getResources().getDisplayMetrics()));
    mLinearLayoutManager = new LinearLayoutManager(getContext());
    mLinearLayoutManager.setOrientation(OrientationHelper.VERTICAL);
    mRvProductDetail.setLayoutManager(mLinearLayoutManager);
    //添加分隔线
    //mUtc.addItemDecoration(new AdvanceDecoration(getContext(), OrientationHelper.VERTICAL));
    adapter = new FilterAdapter();
    mRvProductDetail.setAdapter(adapter);
    mSrProductDetail.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
      @Override public void onRefresh() {
        mHandler.postDelayed(new Runnable() {
          @Override public void run() {
            getData(1);
            mSrProductDetail.setRefreshing(false);//刷新完毕!
            isloading = false;
            currentPage = 1;
            position = 1;
          }
        }, 500);
      }
    });
    mRvProductDetail.addOnScrollListener(new RecyclerView.OnScrollListener() {
      @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);
      }

      @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);
        int lastVisibleItemPosition = mLinearLayoutManager.findLastVisibleItemPosition();
        Log.v("lastVisibleItemPosition", lastVisibleItemPosition + "");
        Log.v("mAdapter.getItemCount()", adapter.getItemCount() + "");

        if (lastVisibleItemPosition + 1 == adapter.getItemCount()) {
          boolean isRefreshing = mSrProductDetail.isRefreshing();
          if (isRefreshing) {
            adapter.notifyItemRemoved(adapter.getItemCount());
            return;
          }
          Log.v("isloading", isloading + "");
          if (isloading && dy >= 0) {
            //Toast.makeText(getContext(), "没有更多数据了", Toast.LENGTH_SHORT).show();
          }
          //搜索之后,关键字为空时,上拉加载
          System.out.println("isloadiong====" + isloading);
          if (!isloading) {
            Log.v("isloading2", isloading + "");
            Log.v("sumpageid", sumpageid.get(0) + "");
            isloading = true;
            currentPage++;

            if (currentPage > sumpageid.get(0)) {
              currentPage = sumpageid.get(0);
              return;
            }
            mHandler.postDelayed(new Runnable() {
              @Override public void run() {
                getData(currentPage);
                System.out.println("current111==" + currentPage);
                Log.v("currentpag++", currentPage + "");
                isloading = false;
                position = 2;
              }
            }, 1000);
          }
        }
      }
    });
    rlNetStates.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        Intent wifiSettingsIntent = new Intent(Settings.ACTION_SETTINGS);
        startActivity(wifiSettingsIntent);
      }
    });
    initStatu();
  }
  /**
   * 网络状态
   */
  private void initStatu() {
    stateLayout = DStateLayout.wrap(mSrProductDetail);
    stateLayout.setRetryListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        //initData(productId);
        getData(1);
      }
    });
    stateLayout.showLoading();

    isNetCollect = inspectNet();
    if (!isNetCollect) {
      rlNetStates.setVisibility(View.VISIBLE);
    } else {
      rlNetStates.setVisibility(View.GONE);
    }
  }

  @Override public void onNetChange(int netMobile) {
    super.onNetChange(netMobile);
    //网络状态变化时的操作
    if (netMobile == InternetUtils.NETWORK_NONE) {
      rlNetStates.setVisibility(View.VISIBLE);
      isNetCollect = false;
    } else {
      rlNetStates.setVisibility(View.GONE);
      isNetCollect = true;
    }
  }

  private void getData(int index) {
    Log.w(TAG, "开始重新请求数据");
    OkHttpUtils.get()
        .url(ApiConstants.TEXTSEARCHS)
        .addParams("text", mExittext)
        .addParams("pageId", index+"")
        .addParams("sortId",0+"")
        //.addParams("params","德国#全脂#进口")
        .build()
        .execute(new StringCallback() {

          @Override public void onError(Call call, Exception e, int id) {
            if (isNetCollect) {
              stateLayout.setEmptyImage(R.mipmap.wenzisousuo_v2_2x);
              stateLayout.setEmptyText("抱歉,没有找到相关商品请试试其他搜索词");
              stateLayout.showEmpty();
            } else {
              stateLayout.showError();
            }
          }

          @Override public void onResponse(String response, int id) {
            textSearch = JSON.parseObject(response, TextsSearchEntity.class);
            //记录总页数
            if (textSearch.getState() == 0) {
              sumpageid.clear();
              sumpageid.add(textSearch.getData().getPageTotal());
              stateLayout.showContent();
              rlNetStates.setVisibility(View.GONE);
              list.clear();
              newlist.clear();
              filterlist.clear();
              newfilterlist.clear();

              list.addAll(textSearch.getData().getItems());
              newlist.addAll(list);
              if (textSearch.getData().getFilters()!=null) {
                filterlist.addAll(textSearch.getData().getFilters());
                newfilterlist.addAll(filterlist);
              }
              if (position == 1) {
                adapter.addItem(newlist);
                adapter.addFilterItem(newfilterlist);
              } else {
                adapter.addMoreItem(newlist);
              }
            } else if (textSearch.getState() == 3) {
              stateLayout.setEmptyImage(R.mipmap.wenzisousuo_v2_2x);
              stateLayout.setEmptyText("抱歉,没有找到相关商品请试试其他搜索词");
              stateLayout.showEmpty();
            } else {
              stateLayout.showError();
            }
          }
        });
  }

  @Override public void onDestroyView() {
    super.onDestroyView();
    unbinder.unbind();
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/DataPresenter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch;

import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/9/27 10:26
 * 描述:用来保存数据降低耦合性
 */

public class DataPresenter {
  private static DataPresenter singleTon = null;
  //用来记录筛选框中的数据
  private List<TextsSearchEntity.DataBean.FiltersBean> list;
  //用来记录综合界面被选中的标签
  private List<String> selectList;
  //用来记录筛选框中被选中的标签
  private List<String> filterSelectlist;
  //用来记录搜索出来的数据
  private List<TextsSearchEntity.DataBean.ItemsBean> Searchlist;
  private DataPresenter() {
    list = new ArrayList<>();
    selectList = new ArrayList<>();
    filterSelectlist = new ArrayList<>();
    Searchlist=new ArrayList<>();
  }

  public static DataPresenter getSingleTon() {
    if (singleTon == null) {
      singleTon = new DataPresenter();
    }
    return singleTon;
  }

  /**
   * 用来记录筛选框中的数据
   */
  public void saveData(List<TextsSearchEntity.DataBean.FiltersBean> newDatas) {
    list.clear();
    list.addAll(newDatas);
  }

  public List<TextsSearchEntity.DataBean.FiltersBean> getData() {
    return list;
  }

  /**
   * 用来记录被选中的item
   */
  public void saveSelect(String s) {
    if (selectList.size() <= 0) {
      selectList.clear();
      selectList.add(s);
    } else {
      if (!selectList.contains(s)) {
        selectList.add(s);
      } else {
        selectList.remove(s);
      }
    }
  }

  public List<String> getSelectList() {
    return selectList;
  }

  /**
   * 用来记录搜素到的数据
   */
  public void saveSearch(List<TextsSearchEntity.DataBean.ItemsBean> list){
    HashSet h = new HashSet(list);
    list.clear();
    list.addAll(h);
    Searchlist.clear();
    Searchlist.addAll(list);
  }

  public List<TextsSearchEntity.DataBean.ItemsBean> getSearchlist(){
    return Searchlist;
  }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/adapter/GoodsAttrsAdapter.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.TextsSearchEntity;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.FilterUtils;
import com.example.lwd18.pictureselecotor.textsearch.vo.SaleAttributeVo;
import java.util.ArrayList;
import java.util.List;

/**
 * 子属性GridView的适配器
 */
public class GoodsAttrsAdapter extends BaseAdapter {

    private Context context;
    private List<SaleAttributeVo> data = new ArrayList<SaleAttributeVo>();
    private List<TextsSearchEntity.DataBean.FiltersBean> list = new ArrayList<>();
    public GoodsAttrsAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return data == null ? 0 : data.size();
        //return list==null?0:list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

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

    @Override
    public View getView(final int position, View v, ViewGroup parent) {
        final MyView myView;
        if (v == null) {
            myView = new MyView();
            v = View.inflate(context, R.layout.item_goods_attrs, null);
            myView.attr = (TextView) v.findViewById(R.id.attr_name);
            v.setTag(myView);
        } else {
            myView = (MyView) v.getTag();
        }
        myView.attr.setText(data.get(position).getValue());
        /**
         * 根据选中状态来设置item的背景和字体颜色
         */
        if (data.get(position).isChecked()) {
            myView.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
            myView.attr.setTextColor(Color.WHITE);
        } else {
            myView.attr.setBackgroundResource(R.drawable.goods_attr_unselected_shape);
            myView.attr.setTextColor(Color.GRAY);
        }
        return v;
    }

    static class MyView {
        public TextView attr;
    }

    @Override
    public void notifyDataSetChanged() {
        super.notifyDataSetChanged();
    }

    public void notifyDataSetChanged(boolean isUnfold, final List<SaleAttributeVo> tempData) {
        if (tempData == null || 0 == tempData.size()) {
            return;
        }
        data.clear();
        // 如果是展开的，则加入全部data，反之则只显示3条
        if (isUnfold) {
            data.addAll(tempData);
        } else {
            FilterUtils.setNumber(tempData,data);
        }
        notifyDataSetChanged();
    }

    public void notifyDataSetChangeds(boolean isUnfold, final List<SaleAttributeVo> tempData) {
        if (tempData == null || 0 == tempData.size()) {
            return;
        }
        data.clear();
        // 如果是展开的，则加入全部data，反之则只显示3条
        if (isUnfold) {
            data.addAll(tempData);
        } else {
            //不展示
            data.clear();
        }
        notifyDataSetChanged();
    }
    public void notifyDataSetChangedFilter(boolean isUnfold, final List<TextsSearchEntity.DataBean.FiltersBean> tempData) {
        if (tempData == null || 0 == tempData.size()) {
            return;
        }
        list.clear();
        // 如果是展开的，则加入全部data，反之则只显示3条
        if (isUnfold) {
            list.addAll(tempData);
        } else {
            //FilterUtils.setNumberFilter(tempData,list);
        }
        notifyDataSetChanged();
    }

    public void notifyDataSetChangedsFilter(boolean isUnfold, final List<TextsSearchEntity.DataBean.FiltersBean> tempData) {
        if (tempData == null || 0 == tempData.size()) {
            return;
        }
        list.clear();
        // 如果是展开的，则加入全部data，反之则只显示3条
        if (isUnfold) {
            list.addAll(tempData);
        } else {
            //不展示
            list.clear();
        }
        notifyDataSetChanged();
    }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/chart/ChartGrid.java<|end_filename|>
package com.deepbaytech.deeplibrary.chart;

import android.content.Context;
import android.graphics.Paint;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.util.TypedValue;

import com.deepbaytech.deeplibrary.R;
import com.deepbaytech.deeplibrary.utils.DisplayUrils;

class ChartGrid {

    /*
    切换横纵坐标间隔
     */
    int stepHor = 10;
    int stepVer = 10;

    int horSubLinesCount = 0;
    int verSubLinesCount = 0;

    boolean horMainLinesEnabled = true;
    boolean horSubLinesEnabled = true;
    boolean verMainLinesEnabled = true;
    boolean verSubLinesEnabled = true;
    boolean verMainValuesEnabled = true;
    boolean horMainValuesEnabled = true;

    Paint mainHorLinesPaint = new Paint();
    Paint mainVerLinesPaint = new Paint();
    Paint subHorLinesPaint = new Paint();
    Paint subVerLinesPaint = new Paint();

    Paint mainVerValuesPaint = new Paint();
    Paint mainHorValuesPaint = new Paint();

    int horValuesMarginBottom = 0;
    int horValuesMarginTop = 0;
    int horValuesMarginLeft = 0;
    int horValuesMarginRight = 0;

    int verValuesMarginBottom = 20;
    int verValuesMarginTop = 0;
    int verValuesMarginLeft = 10;
    int verValuesMarginRight = 10;

    int horValuesAlign = TextAlign.HORIZONTAL_CENTER | TextAlign.BOTTOM;
    int verValuesAlign = TextAlign.RIGHT | TextAlign.VERTICAL_CENTER;

    SparseArray<String> horValuesText = null;
    SparseArray<String> verValuesText = null;

    public ChartGrid(Context context) {
        mainVerLinesPaint.setColor(0xaa888888);
        subVerLinesPaint.setColor(0x44888888);
        mainHorLinesPaint.setColor(0xaa888888);
        subHorLinesPaint.setColor(0x44888888);

        // TODO: 2016/10/9 设置纵坐标值样式
        mainVerValuesPaint.setColor(context.getResources().getColor(R.color.chart_vh_text_color));
        mainVerValuesPaint.setAntiAlias(true);
        mainVerValuesPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
                10,
                                                                 context.getResources().getDisplayMetrics()));
        // TODO: 2016/10/9 设置横坐标值样式,其中字体大小已为sp
        mainHorValuesPaint.setColor(context.getResources().getColor(R.color.chart_vh_text_color));
        mainHorValuesPaint.setAntiAlias(true);
        mainHorValuesPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
                10,
                                                                 context.getResources().getDisplayMetrics()));
    }

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/vo/Vo.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.vo;

import java.io.Serializable;

/**
 * vo类
 */
public class Vo implements Serializable {
    private boolean isChecked;
    private String str1;
    private String str2;

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public String getStr1() {
        return str1;
    }

    public void setStr1(String str1) {
        this.str1 = str1;
    }

    public String getStr2() {
        return str2;
    }

    public void setStr2(String str2) {
        this.str2 = str2;
    }
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/FinishEventUtil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

/**
 * 创建者     李文东
 * 创建时间   2017/7/11 9:18
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class FinishEventUtil {
  public FinishEventUtil(){
  }
}


<|start_filename|>deepstatelayout/src/main/java/com/ethereal/deepstatelayout/DStateLayout.java<|end_filename|>
package com.ethereal.deepstatelayout;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.LayoutRes;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.HashMap;
import java.util.Map;

/**
 * 1.
 * <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
 * ...
 * <item name="styleDStateLayout">@style/DStateLayoutStyle</item>
 * </style>
 *
 * <style name="DStateLayoutStyle" parent="DStateLayout.Style">
 * <item name="llEmptyImage">@mipmap/empty</item>
 * <item name="llErrorImage">@mipmap/error</item>
 * ...
 * </style>
 *
 *
 * 2.1
 * 用法一：在布局中使用
 * <com.ethereal.deepstatelayout.DStateLayout
 * android:id="@+id/loading"
 * android:layout_width="match_parent"
 * android:layout_height="match_parent">
 * <TextView
 * android:layout_width="match_parent"
 * android:layout_height="match_parent"
 * android:gravity="center"
 * android:text="This is Content"/>
 * </com.ethereal.deepstatelayout.DStateLayout>
 *
 * 2.2
 * 用法二：包裹并替换内容元素
 * @Override protected void onCreate(Bundle savedInstanceState) {
 * super.onCreate(savedInstanceState);
 * setContentView(R.layout.activity_main);
 * // ...
 * dStateLayout = DStateLayout.wrap(this);
 * dStateLayout.showContent();
 * // ...
 * }
 *
 *
 * 3.API
 * // 显示 content/loading/empty/error 布局
 * showContent()
 * showLoading()
 * showEmpty()
 * showError()
 *
 *
 *
 * // 设置 loading/empty/error 布局
 * setLoading(int resId)
 * setEmpty(int resId)
 * setError(int resId)
 *
 * // 设置空布局的图片与文本
 * setEmptyImage(int resId)
 * setEmptyText(String value)
 *
 * // 设置错误布局的图片与文本，
 * setErrorImage(int resId)
 * setErrorText(String value)
 *
 * // 设置重试按钮文本
 * setRetryText(String value)
 *
 * // 设置重试按钮的监听回调
 * setRetryListener(OnClickListener listener)
 */

public class DStateLayout extends FrameLayout {
  public interface OnInflateListener {
    void onInflate(View inflated);
  }

  public static DStateLayout wrap(Activity activity) {
    return wrap(((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0));
  }

  public static DStateLayout wrap(Fragment fragment) {
    return wrap(fragment.getView());
  }

  public static DStateLayout wrap(View view) {
    if (view == null) {
      throw new RuntimeException("content view can not be null");
    }
    ViewGroup parent = (ViewGroup) view.getParent();
    if (parent == null) {
      throw new RuntimeException("parent view can not be null");
    }
    ViewGroup.LayoutParams lp = view.getLayoutParams();
    int index = parent.indexOfChild(view);
    parent.removeView(view);

    DStateLayout layout = new DStateLayout(view.getContext());
    parent.addView(layout, index, lp);
    layout.addView(view);
    layout.setContentView(view);
    return layout;
  }

  int mEmptyImage;
  CharSequence mEmptyText;

  int mErrorImage;
  CharSequence mErrorText, mRetryText;
  OnClickListener mRetryButtonClickListener = new OnClickListener() {
    @Override public void onClick(View v) {
      if (mRetryListener != null) {
        mRetryListener.onClick(v);
      }
    }
  };
  OnClickListener mRetryListener;

  OnInflateListener mOnEmptyInflateListener;
  OnInflateListener mOnErrorInflateListener;

  int mTextColor, mTextSize;
  int mButtonTextColor, mButtonTextSize;
  Drawable mButtonBackground;
  int mEmptyResId = NO_ID, mLoadingResId = NO_ID, mErrorResId = NO_ID;
  int mContentId = NO_ID;

  Map<Integer, View> mLayouts = new HashMap<>();

  public DStateLayout(Context context) {
    this(context, null, R.attr.styleDStateLayout);
  }

  public DStateLayout(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.styleDStateLayout);
  }

  public DStateLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mInflater = LayoutInflater.from(context);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DStateLayout, defStyleAttr,
        R.style.DStateLayout_Style);
    mEmptyImage = a.getResourceId(R.styleable.DStateLayout_llEmptyImage, NO_ID);
    mEmptyText = a.getString(R.styleable.DStateLayout_llEmptyText);

    mErrorImage = a.getResourceId(R.styleable.DStateLayout_llErrorImage, NO_ID);
    mErrorText = a.getString(R.styleable.DStateLayout_llErrorText);
    mRetryText = a.getString(R.styleable.DStateLayout_llRetryText);

    mTextColor = a.getColor(R.styleable.DStateLayout_llTextColor, 0xff999999);
    mTextSize = a.getDimensionPixelSize(R.styleable.DStateLayout_llTextSize, dp2px(16));

    mButtonTextColor = a.getColor(R.styleable.DStateLayout_llButtonTextColor, 0xff999999);
    mButtonTextSize = a.getDimensionPixelSize(R.styleable.DStateLayout_llButtonTextSize, dp2px(16));
    mButtonBackground = a.getDrawable(R.styleable.DStateLayout_llButtonBackground);

    mEmptyResId =
        a.getResourceId(R.styleable.DStateLayout_llEmptyResId, R.layout.d_state_layout_empty);
    mLoadingResId =
        a.getResourceId(R.styleable.DStateLayout_llLoadingResId, R.layout.d_state_layout_loading);
    mErrorResId =
        a.getResourceId(R.styleable.DStateLayout_llErrorResId, R.layout.d_state_layout_error);
    a.recycle();
  }

  int dp2px(float dp) {
    return (int) (getResources().getDisplayMetrics().density * dp);
  }

  LayoutInflater mInflater;

  @Override protected void onFinishInflate() {
    super.onFinishInflate();
    if (getChildCount() == 0) {
      return;
    }
    if (getChildCount() > 1) {
      removeViews(1, getChildCount() - 1);
    }
    View view = getChildAt(0);
    setContentView(view);
    showLoading();
  }

  private void setContentView(View view) {
    mContentId = view.getId();
    mLayouts.put(mContentId, view);
  }

  public DStateLayout setLoading(@LayoutRes int id) {
    if (mLoadingResId != id) {
      remove(mLoadingResId);
      mLoadingResId = id;
    }
    return this;
  }

  public DStateLayout setEmpty(@LayoutRes int id) {
    if (mEmptyResId != id) {
      remove(mEmptyResId);
      mEmptyResId = id;
    }
    return this;
  }

  public DStateLayout setOnEmptyInflateListener(OnInflateListener listener) {
    mOnEmptyInflateListener = listener;
    if (mOnEmptyInflateListener != null && mLayouts.containsKey(mEmptyResId)) {
      listener.onInflate(mLayouts.get(mEmptyResId));
    }
    return this;
  }

  public DStateLayout setOnErrorInflateListener(OnInflateListener listener) {
    mOnErrorInflateListener = listener;
    if (mOnErrorInflateListener != null && mLayouts.containsKey(mErrorResId)) {
      listener.onInflate(mLayouts.get(mErrorResId));
    }
    return this;
  }

  public DStateLayout setEmptyImage(@DrawableRes int resId) {
    mEmptyImage = resId;
    image(mEmptyResId, R.id.empty_image, mEmptyImage);
    return this;
  }

  public DStateLayout setEmptyText(CharSequence value) {
    mEmptyText = value;
    text(mEmptyResId, R.id.empty_text, mEmptyText);
    return this;
  }

  public DStateLayout setErrorImage(@DrawableRes int resId) {
    mErrorImage = resId;
    image(mErrorResId, R.id.error_image, mErrorImage);
    return this;
  }

  public DStateLayout setErrorText(CharSequence value) {
    mErrorText = value;
    text(mErrorResId, R.id.error_text, mErrorText);
    return this;
  }

  public DStateLayout setRetryText(CharSequence text) {
    mRetryText = text;
    text(mErrorResId, R.id.retry_button, mRetryText);
    return this;
  }

  public DStateLayout setRetryListener(OnClickListener listener) {
    mRetryListener = listener;
    return this;
  }

  //    public DStateLayout setTextColor(@ColorInt int color) {
  //        mTextColor = color;
  //        return this;
  //    }
  //    public DStateLayout setTextSize(@ColorInt int dp) {
  //        mTextColor = dp2px(dp);
  //        return this;
  //    }
  //    public DStateLayout setButtonTextColor(@ColorInt int color) {
  //        mButtonTextColor = color;
  //        return this;
  //    }
  //    public DStateLayout setButtonTextSize(@ColorInt int dp) {
  //        mButtonTextColor = dp2px(dp);
  //        return this;
  //    }
  //    public DStateLayout setButtonBackground(Drawable drawable) {
  //        mButtonBackground = drawable;
  //        return this;
  //    }

  public void showLoading() {
    show(mLoadingResId);
  }

  public void showEmpty() {
    show(mEmptyResId);
  }

  public void showError() {
    show(mErrorResId);
  }

  public void showContent() {
    show(mContentId);
  }

  private void show(int layoutId) {
    for (View view : mLayouts.values()) {
      view.setVisibility(GONE);
    }
    layout(layoutId).setVisibility(VISIBLE);
  }

  private void remove(int layoutId) {
    if (mLayouts.containsKey(layoutId)) {
      View vg = mLayouts.remove(layoutId);
      removeView(vg);
    }
  }

  @SuppressLint("NewApi") private View layout(int layoutId) {
    if (mLayouts.containsKey(layoutId)) {
      return mLayouts.get(layoutId);
    }
    View layout = mInflater.inflate(layoutId, this, false);
    layout.setVisibility(GONE);
    addView(layout);
    mLayouts.put(layoutId, layout);

    if (layoutId == mEmptyResId) {
      ImageView img = (ImageView) layout.findViewById(R.id.empty_image);
      if (img != null) {
        img.setImageResource(mEmptyImage);
      }
      TextView view = (TextView) layout.findViewById(R.id.empty_text);
      if (view != null) {
        view.setText(mEmptyText);
        view.setTextColor(mTextColor);
        view.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
      }
      if (mOnEmptyInflateListener != null) {
        mOnEmptyInflateListener.onInflate(layout);
      }
    } else if (layoutId == mErrorResId) {
      ImageView img = (ImageView) layout.findViewById(R.id.error_image);
      if (img != null) {
        img.setImageResource(mErrorImage);
      }
      TextView txt = (TextView) layout.findViewById(R.id.error_text);
      if (txt != null) {
        txt.setText(mErrorText);
        txt.setTextColor(mTextColor);
        txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
      }
      TextView btn = (TextView) layout.findViewById(R.id.retry_button);
      if (btn != null) {
        btn.setText(mRetryText);
        btn.setTextColor(mButtonTextColor);
        btn.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonTextSize);
        btn.setBackground(mButtonBackground);
        btn.setOnClickListener(mRetryButtonClickListener);
      }
      if (mOnErrorInflateListener != null) {
        mOnErrorInflateListener.onInflate(layout);
      }
    }
    return layout;
  }

  private void text(int layoutId, int ctrlId, CharSequence value) {
    if (mLayouts.containsKey(layoutId)) {
      TextView view = (TextView) mLayouts.get(layoutId).findViewById(ctrlId);
      if (view != null) {
        view.setText(value);
      }
    }
  }

  private void image(int layoutId, int ctrlId, int resId) {
    if (mLayouts.containsKey(layoutId)) {
      ImageView view = (ImageView) mLayouts.get(layoutId).findViewById(ctrlId);
      if (view != null) {
        view.setImageResource(resId);
      }
    }
  }
}


<|start_filename|>deeplibrary/src/main/java/com/deepbaytech/deeplibrary/chart/TextAlign.java<|end_filename|>
package com.deepbaytech.deeplibrary.chart;

public interface TextAlign {
    public final static int LEFT = 0x00000001;
    public final static int RIGHT = 0x00000002;
    public final static int TOP = 0x00000004;
    public final static int BOTTOM = 0x00000008;
    public final static int HORIZONTAL_CENTER = 0x00000010;
    public final static int VERTICAL_CENTER = 0x00000020;
}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/Eventutil/SecondEventil.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.Eventutil;

import java.util.List;

/**
 * 创建者     李文东
 * 创建时间   2017/8/3 18:26
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class SecondEventil {
  private List<String> filter;
  public SecondEventil() {
  }

  public SecondEventil(List<String> filter) {
   this.filter=filter;
  }

  public List<String> getFilter(){
    return this.filter;
  }

}


<|start_filename|>app/src/main/java/com/example/lwd18/pictureselecotor/textsearch/itemadapter/GoodSAttrRvNAdapter9.java<|end_filename|>
package com.example.lwd18.pictureselecotor.textsearch.itemadapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.lwd18.pictureselecotor.R;
import com.example.lwd18.pictureselecotor.textsearch.DataPresenter;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.Eventil;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.FilterUtils;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.SecondEventil;
import com.example.lwd18.pictureselecotor.textsearch.Eventutil.TranstEventil;
import de.greenrobot.event.EventBus;
import java.util.ArrayList;
import java.util.List;



/**
 * 创建者     李文东
 * 创建时间   2017/7/10 15:38
 * 描述
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述
 */

public class GoodSAttrRvNAdapter9 extends RecyclerView.Adapter<GoodSAttrRvNAdapter9.MyAdapter> {
  private Context context;
  private List<String> mlist;
  private List<String> selectedlist;
  public GoodSAttrRvNAdapter9(Context context) {
    this.context = context;
    mlist=new ArrayList<>();
    selectedlist = DataPresenter.getSingleTon().getSelectList();
    EventBus.getDefault().register(this);
  }

  @Override
  public GoodSAttrRvNAdapter9.MyAdapter onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = View.inflate(parent.getContext(), R.layout.item_goods_attrs, null);
    return new MyAdapter(view);
  }

  @Override public void onBindViewHolder(final GoodSAttrRvNAdapter9.MyAdapter holder, final int position) {
    holder.attr.setText(mlist.get(position));
    //强制禁止recycleview复用
    holder.setIsRecyclable(false);
    //用来接收综合界面传递过来的选择
    for (int i = 0; i < selectedlist.size(); i++) {
      if (selectedlist.contains(mlist.get(position))) {
        holder.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
        holder.attr.setTextColor(Color.WHITE);
      }
    }
    /**
     * 根据选中状态来设置item的背景和字体颜色
     */
    holder.attr.setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View v) {
        if (selectedlist.size() <= 0) {
          holder.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
          holder.attr.setTextColor(Color.WHITE);
          EventBus.getDefault().post(new Eventil(mlist.get(position)));

        } else {
          if (!selectedlist.contains(mlist.get(position))) {
            holder.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
            holder.attr.setTextColor(Color.WHITE);
            EventBus.getDefault().post(new Eventil(mlist.get(position)));
          } else {
            holder.attr.setBackgroundResource(R.drawable.goods_attr_unselected_shape);
            holder.attr.setTextColor(Color.BLACK);
          }
        }
        //保存
        DataPresenter.getSingleTon().saveSelect(mlist.get(position));
        EventBus.getDefault().post(new SecondEventil());
      }
    });
  }

  @Override public int getItemCount() {
    return mlist==null?0: mlist.size();
  }

  public class MyAdapter extends RecyclerView.ViewHolder {
    public TextView attr;

    public MyAdapter(View itemView) {
      super(itemView);
      attr = (TextView) itemView.findViewById(R.id.attr_name);
    }
  }
  public void notifyDataSetChanged(boolean isUnfold, final List<String> tempData,int position) {
    if (tempData == null || 0 == tempData.size()) {
      return;
    }
    // 如果是展开的，则加入全部data，反之则只显示3条
    mlist.clear();
    if (isUnfold) {
      mlist.addAll(tempData);
    } else {
      FilterUtils.setNumberFilter(tempData,mlist);
    }
   notifyDataSetChanged();
  }
  public void notifyDataSetChangeds(boolean isUnfold, final List<String> tempData,int position) {
    if (tempData == null || 0 == tempData.size()) {
      return;
    }
    // 如果是展开的，则加入全部data，反之删除
    if (isUnfold) {
      mlist.clear();
      mlist.addAll(tempData);
    } else {
      //不展示
     mlist.clear();
    }
    notifyDataSetChanged();
  }

  //添加数据
  public void addItem(List<String> newDatas) {
    mlist.clear();
    newDatas.addAll(mlist);
    mlist.removeAll(mlist);
    mlist.addAll(newDatas);
    notifyDataSetChanged();
  }
  /**
   * 用来接收筛选框中的消息
   */
  public void onEventMainThread(TranstEventil event) {
    notifyDataSetChanged();
  }
}
