├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── DropDownViewLib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── louisgeek │ │ └── dropdownviewlib │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── louisgeek │ │ │ └── dropdownviewlib │ │ │ ├── ClassfiySeletPopupWindow.java │ │ │ ├── ClassfiySeletView.java │ │ │ ├── DateSelectPopupWindow.java │ │ │ ├── DateSelectView.java │ │ │ ├── DropDownPopupWindow.java │ │ │ ├── DropDownView.java │ │ │ ├── MultiSelectLayout.java │ │ │ ├── MultiSelectLayout_HasChild.java │ │ │ ├── MultiSelectView.java │ │ │ ├── MultiSelectView_HasChild.java │ │ │ ├── ProCateSelectView.java │ │ │ ├── ProvinceCityAreaSelectView.java │ │ │ ├── adapter │ │ │ ├── DropDownViewRecycleViewAdapter.java │ │ │ ├── MultiSelectViewContentBaseAdapter.java │ │ │ ├── MultiSelectViewContentBaseExpandableListAdapter.java │ │ │ ├── MultiSelectViewRecycleViewAdapter.java │ │ │ ├── MyRecylerViewLeftAdapter.java │ │ │ ├── MyRecylerViewOnlyOneAdapter.java │ │ │ └── MyRecylerViewRightAdapter.java │ │ │ ├── decoration │ │ │ ├── GridSpacingItemDecoration.java │ │ │ ├── ItemOffsetDecoration.java │ │ │ ├── ListSpacingDecoration.java │ │ │ ├── SpacesItemDecoration.java │ │ │ └── SpacesItemDecorationTwo.java │ │ │ ├── javabean │ │ │ ├── Area.java │ │ │ ├── City.java │ │ │ ├── ClassfiyBean.java │ │ │ ├── MultiSelectHasChildBean.java │ │ │ ├── ProCate.java │ │ │ └── Province.java │ │ │ ├── tools │ │ │ ├── DateTool.java │ │ │ ├── KeyBoardTool.java │ │ │ ├── MySSQTool.java │ │ │ ├── SizeTool.java │ │ │ └── StringTool.java │ │ │ └── ui │ │ │ └── MutiSelectDialogFragment.java │ └── res │ │ ├── anim │ │ ├── popupwindow_bottom_in.xml │ │ └── popupwindow_bottom_out.xml │ │ ├── drawable-hdpi │ │ ├── ic_check_grey_600_18dp.png │ │ ├── ic_check_grey_700_48dp.png │ │ ├── ic_check_light_green_600_18dp.png │ │ ├── ic_check_light_green_700_48dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_18dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_24dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_36dp.png │ │ └── ic_keyboard_arrow_down_blue_grey_400_48dp.png │ │ ├── drawable-mdpi │ │ ├── ic_check_grey_600_18dp.png │ │ ├── ic_check_grey_700_48dp.png │ │ ├── ic_check_light_green_600_18dp.png │ │ ├── ic_check_light_green_700_48dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_18dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_24dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_36dp.png │ │ └── ic_keyboard_arrow_down_blue_grey_400_48dp.png │ │ ├── drawable-xhdpi │ │ ├── ic_check_grey_600_18dp.png │ │ ├── ic_check_grey_700_48dp.png │ │ ├── ic_check_light_green_600_18dp.png │ │ ├── ic_check_light_green_700_48dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_18dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_24dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_36dp.png │ │ └── ic_keyboard_arrow_down_blue_grey_400_48dp.png │ │ ├── drawable-xxhdpi │ │ ├── ic_check_grey_600_18dp.png │ │ ├── ic_check_grey_700_48dp.png │ │ ├── ic_check_light_green_600_18dp.png │ │ ├── ic_check_light_green_700_48dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_18dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_24dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_36dp.png │ │ └── ic_keyboard_arrow_down_blue_grey_400_48dp.png │ │ ├── drawable-xxxhdpi │ │ ├── ic_check_grey_600_18dp.png │ │ ├── ic_check_grey_700_48dp.png │ │ ├── ic_check_light_green_600_18dp.png │ │ ├── ic_check_light_green_700_48dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_18dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_24dp.png │ │ ├── ic_keyboard_arrow_down_blue_grey_400_36dp.png │ │ └── ic_keyboard_arrow_down_blue_grey_400_48dp.png │ │ ├── drawable │ │ ├── selector_item_checked.xml │ │ ├── selector_item_text.xml │ │ ├── selector_left_item.xml │ │ ├── selector_shape_list_item_nobottom.xml │ │ ├── selector_shape_list_item_notop.xml │ │ ├── shape_list.xml │ │ └── shape_view.xml │ │ ├── layout │ │ ├── dropdown_item.xml │ │ ├── dropdown_item_muti.xml │ │ ├── item.xml │ │ ├── layout_mutiselect_dialog_frag.xml │ │ ├── layout_mutiselect_dialog_frag_content_list.xml │ │ ├── layout_mutiselect_dialog_frag_has_child.xml │ │ ├── layout_mutiselect_dialog_frag_list.xml │ │ ├── layout_mutiselect_enter.xml │ │ ├── layout_popupwindow_datepick.xml │ │ ├── layout_popupwindow_dropdown.xml │ │ ├── layout_popupwindow_selectview.xml │ │ ├── layout_procate_selectview.xml │ │ ├── layout_provincecityarea_selectview.xml │ │ ├── left_item.xml │ │ ├── mutiselect_dialog_frag_list_group_item.xml │ │ ├── mutiselect_dialog_frag_list_item.xml │ │ ├── mutiselect_enter_list_item.xml │ │ ├── right_item_all.xml │ │ └── right_item_normal.xml │ │ ├── raw │ │ ├── pro_cate.json │ │ ├── pro_cate_bak.json │ │ ├── ssq.json │ │ └── ssq_bak.json │ │ └── values │ │ ├── arrays.xml │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── ids.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── louisgeek │ └── dropdownviewlib │ └── ExampleUnitTest.java ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── louisgeek │ │ └── louisdropdownview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── louisgeek │ │ │ └── louisdropdownview │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── louisgeek │ └── louisdropdownview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── pic1.png ├── pic2.png ├── pic3.png ├── pic4.png ├── pic5.png └── pic6.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | LouisDropDownView -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 26 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 1.8 58 | 59 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DropDownViewLib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /DropDownViewLib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | testCompile 'junit:junit:4.12' 24 | compile 'com.android.support:appcompat-v7:23.3.0' 25 | compile 'com.android.support:recyclerview-v7:23.3.0' 26 | compile 'com.orhanobut:logger:1.13' 27 | compile 'com.alibaba:fastjson:1.1.52.android' 28 | compile 'com.yqritc:recyclerview-flexibledivider:1.4.0' 29 | } 30 | -------------------------------------------------------------------------------- /DropDownViewLib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\LouisIDE\Android\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /DropDownViewLib/src/androidTest/java/com/louisgeek/dropdownviewlib/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | public void testA(){ 14 | ProCateSelectView proCateSelectView=new ProCateSelectView(getContext()); 15 | } 16 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/DateSelectPopupWindow.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.ColorDrawable; 5 | import android.util.Log; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.DatePicker; 10 | import android.widget.PopupWindow; 11 | import android.widget.TextView; 12 | 13 | import com.louisgeek.dropdownviewlib.tools.DateTool; 14 | 15 | import java.util.Calendar; 16 | import java.util.Date; 17 | 18 | /** 19 | * Created by louisgeek on 2016/6/5. 20 | */ 21 | public class DateSelectPopupWindow extends PopupWindow{ 22 | 23 | private View view; 24 | private Context mContext; 25 | private TextView id_btn_date_ok; 26 | private TextView id_btn_date_cancel; 27 | private DateSelectPopupWindow dateSelectPopupWindow; 28 | private DatePicker datePick1; 29 | 30 | private int mYear; 31 | private int mMonthOfYear; 32 | private int mDayOfMonth; 33 | private static final String TAG = "DateSelectPopupWindow"; 34 | 35 | private String mNowDateTextInner; 36 | private String mStartDateTextInner; 37 | private String mEndDateTextInner; 38 | 39 | public DateSelectPopupWindow(Context context,String nowDateTextInner,String startDateTextInner,String endDateTextInner) { 40 | super(context); 41 | mContext = context; 42 | mNowDateTextInner=nowDateTextInner; 43 | mStartDateTextInner=startDateTextInner; 44 | mEndDateTextInner=endDateTextInner; 45 | initView(); 46 | dateSelectPopupWindow=this; 47 | } 48 | 49 | private void initView() { 50 | LayoutInflater inflater = (LayoutInflater) mContext 51 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 52 | view= inflater.inflate(R.layout.layout_popupwindow_datepick, null); 53 | 54 | datePick1= (DatePicker) view.findViewById(R.id.datePick1); 55 | 56 | initDatePicker(); 57 | 58 | id_btn_date_ok= (TextView) view.findViewById(R.id.id_btn_date_ok); 59 | id_btn_date_cancel= (TextView) view.findViewById(R.id.id_btn_date_cancel); 60 | id_btn_date_ok.setOnClickListener(new View.OnClickListener() { 61 | @Override 62 | public void onClick(View v) { 63 | dateSelectPopupWindow.dismiss(); 64 | mOnDateSelectListener.onDateSelect(mYear,mMonthOfYear,mDayOfMonth); 65 | } 66 | }); 67 | id_btn_date_cancel.setOnClickListener(new View.OnClickListener() { 68 | @Override 69 | public void onClick(View v) { 70 | dateSelectPopupWindow.dismiss(); 71 | } 72 | }); 73 | 74 | //设置PopupWindow的View 75 | this.setContentView(view); 76 | //设置PopupWindow弹出窗体的宽 77 | this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); 78 | //设置PopupWindow弹出窗体的高 79 | this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); 80 | this.setBackgroundDrawable(new ColorDrawable(0xffffffff));//必须设置 ps:xml bg和这个不冲突 81 | this.setAnimationStyle(R.style.selectDataViewAnimation); 82 | this.setFocusable(true);//设置后 达到返回按钮先消失popupWindow 83 | } 84 | 85 | private void initDatePicker() { 86 | Calendar calendar; 87 | if(mNowDateTextInner!=null&&!mNowDateTextInner.equals("")&&!mNowDateTextInner.equals("null") 88 | &&!mNowDateTextInner.contains(DateSelectView.DEFAULT_DATA)&&!mNowDateTextInner.equals(DateSelectView.DEFAULT_STR)){ 89 | //显示上一次选择数据 90 | Date date=DateTool.parseStr2Date(mNowDateTextInner,DateTool.FORMAT_DATE); 91 | calendar=DateTool.parseDate2Calendar(date); 92 | }else{ 93 | calendar=Calendar.getInstance();//初始化时间 94 | } 95 | int year=calendar.get(Calendar.YEAR); 96 | int monthOfYear=calendar.get(Calendar.MONTH); 97 | int dayOfMonth=calendar.get(Calendar.DAY_OF_MONTH); 98 | 99 | DatePicker.OnDateChangedListener dcl=new DatePicker.OnDateChangedListener() { 100 | @Override 101 | public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { 102 | mYear=year; 103 | mMonthOfYear=monthOfYear; 104 | mDayOfMonth=dayOfMonth; 105 | } 106 | }; 107 | // 108 | datePick1.init(year,monthOfYear,dayOfMonth,dcl); 109 | // 110 | Log.i(TAG, "initDatePicker: mNowDateTextInner:"+mNowDateTextInner); 111 | Log.i(TAG, "initDatePicker: mStartDateTextInner:"+mStartDateTextInner); 112 | if (mStartDateTextInner!=null){ 113 | Calendar calendar_s=DateTool.parseStr2Calendar(mStartDateTextInner,DateTool.FORMAT_DATE); 114 | long time_s=calendar_s.getTimeInMillis(); 115 | Log.i(TAG, "initDatePicker: time_s:"+time_s); 116 | datePick1.setMinDate(time_s); 117 | } 118 | Log.i(TAG, "initDatePicker: mEndDateTextInner:"+mEndDateTextInner); 119 | if (mEndDateTextInner!=null){ 120 | Calendar calendar_e=DateTool.parseStr2Calendar(mEndDateTextInner,DateTool.FORMAT_DATE); 121 | long time_e=calendar_e.getTimeInMillis(); 122 | Log.i(TAG, "initDatePicker: calendar_e:"+calendar_e); 123 | datePick1.setMaxDate(time_e); 124 | } 125 | 126 | 127 | } 128 | 129 | 130 | public interface OnDateSelectListener { 131 | void onDateSelect(int year, int monthOfYear, int dayOfMonth); 132 | } 133 | 134 | public void setOnDateSelectListener(OnDateSelectListener onDateSelectListener) { 135 | mOnDateSelectListener = onDateSelectListener; 136 | } 137 | 138 | private OnDateSelectListener mOnDateSelectListener; 139 | 140 | } 141 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/DateSelectView.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.util.Log; 6 | import android.view.Gravity; 7 | import android.view.View; 8 | import android.widget.TextView; 9 | 10 | import com.louisgeek.dropdownviewlib.tools.DateTool; 11 | import com.louisgeek.dropdownviewlib.tools.KeyBoardTool; 12 | import com.louisgeek.dropdownviewlib.tools.SizeTool; 13 | 14 | import java.util.Date; 15 | 16 | /** 17 | * Created by louisgeek on 2016/6/5. 18 | */ 19 | public class DateSelectView extends TextView implements View.OnClickListener { 20 | private Context mContext; 21 | private String mNowDateText; 22 | private String startDateText; 23 | private String endDateText; 24 | private final String DEFAULT_DATA_TIME="1970-01-01 00:00:00"; 25 | public static final String DEFAULT_DATA="1970-01-01"; 26 | public static final String DEFAULT_STR="请选择"; 27 | private static final String TAG = "DateSelectView"; 28 | public DateSelectView(Context context) { 29 | super(context); 30 | init(context); 31 | } 32 | 33 | public DateSelectView(Context context, AttributeSet attrs) { 34 | super(context, attrs); 35 | init(context); 36 | } 37 | 38 | public DateSelectView(Context context, AttributeSet attrs, int defStyleAttr) { 39 | super(context, attrs, defStyleAttr); 40 | init(context); 41 | } 42 | 43 | private void init(Context context) { 44 | mContext=context; 45 | 46 | initDate();//初始化 47 | 48 | if (this.getPaddingTop()==0&&this.getPaddingBottom()==0&&this.getPaddingLeft()==0&&this.getPaddingRight()==0) { 49 | int paddingLeft_Right = SizeTool.dp2px(mContext, 10); 50 | int paddingTop_Bottom = SizeTool.dp2px(mContext, 6); 51 | this.setPadding(paddingLeft_Right, paddingTop_Bottom, paddingLeft_Right, paddingTop_Bottom); 52 | } 53 | this.setOnClickListener(this); 54 | this.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_keyboard_arrow_down_blue_grey_400_18dp,0); 55 | this.setBackgroundResource(R.drawable.shape_list); 56 | } 57 | 58 | 59 | @Override 60 | public void onClick(final View v) { 61 | // 62 | KeyBoardTool.hideKeyboard(v); 63 | 64 | DateSelectPopupWindow myPopupwindow=new DateSelectPopupWindow(mContext,mNowDateText,startDateText,endDateText); 65 | myPopupwindow.showAtLocation(v, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,0,0); 66 | myPopupwindow.setOnDateSelectListener(new DateSelectPopupWindow.OnDateSelectListener() { 67 | @Override 68 | public void onDateSelect(int year, int monthOfYear, int dayOfMonth) { 69 | // SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); 70 | if (year==0&&monthOfYear==0&&dayOfMonth==0){ 71 | if (mNowDateText.trim().equals("")||mNowDateText.trim().equals(DEFAULT_STR)) { 72 | mNowDateText = DateTool.getChinaDate(); 73 | } 74 | }else{ 75 | mNowDateText=DateTool.getChinaDateFromCalendar(year,monthOfYear,dayOfMonth); 76 | } 77 | ((DateSelectView)v).setText(mNowDateText); 78 | } 79 | }); 80 | } 81 | 82 | /** 83 | * 84 | * @param nowDataText 85 | */ 86 | public void setupDateText(String nowDataText){ 87 | Log.i(TAG, "setupDateText nowDataText Only: nowDataText:"+nowDataText); 88 | setupDateText(nowDataText,null,null); 89 | } 90 | 91 | /** 92 | * 93 | * @param nowDateText 94 | * @param startDateText 95 | * @param endDateText 96 | */ 97 | public void setupDateText(String nowDateText,String startDateText,String endDateText){ 98 | Log.i(TAG, "setupDateText: nowDateText:"+nowDateText); 99 | Log.i(TAG, "setupDateText: startDateText:"+startDateText); 100 | Log.i(TAG, "setupDateText: endDateText:"+endDateText); 101 | if (nowDateText==null||nowDateText.trim().equals("")||nowDateText.trim().equals("null") 102 | ||nowDateText.contains(DEFAULT_DATA)||nowDateText.equals(DEFAULT_STR)) 103 | { 104 | mNowDateText=DEFAULT_STR; 105 | }else{ 106 | //先转 107 | Date date=DateTool.parseStr2Date(nowDateText,DateTool.FORMAT_DATE); 108 | if (date!=null) { 109 | mNowDateText = DateTool.parseDate2Str(date, DateTool.FORMAT_DATE); 110 | }else{ 111 | mNowDateText=DEFAULT_STR; 112 | } 113 | if (mNowDateText.contains(DEFAULT_DATA)){ 114 | mNowDateText=DEFAULT_STR; 115 | } 116 | } 117 | this.setText(mNowDateText); 118 | // 119 | this.startDateText=startDateText; 120 | this.endDateText=endDateText; 121 | } 122 | private void initDate(){ 123 | setupDateText(null); 124 | } 125 | 126 | @Deprecated 127 | public CharSequence getText() { 128 | return super.getText(); 129 | } 130 | 131 | public String getNowSelectData(){ 132 | String nowData=""; 133 | if (this.getText() != null){ 134 | nowData=this.getText().toString(); 135 | } 136 | return nowData.trim().equals("")||nowData.trim().equals(DEFAULT_STR)?DEFAULT_DATA:nowData; 137 | } 138 | 139 | /** 140 | * 未设置的返回当前时间 141 | * @return 142 | */ 143 | public String getNowSelectDataFixedNowData(){ 144 | return getNowSelectData()==null?DateTool.getChinaDate():getNowSelectData(); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/DropDownPopupWindow.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.ColorDrawable; 5 | import android.support.v7.widget.GridLayoutManager; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.util.Log; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.PopupWindow; 13 | 14 | import com.louisgeek.dropdownviewlib.adapter.DropDownViewRecycleViewAdapter; 15 | 16 | import java.lang.reflect.Method; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | /** 21 | * Created by louisgeek on 2016/6/3. 22 | */ 23 | public class DropDownPopupWindow extends PopupWindow implements DropDownViewRecycleViewAdapter.OnItemViewClickListener { 24 | private List> mDataList; 25 | private Context mContext; 26 | // TextView id_pop_tv; 27 | RecyclerView mRecyclerView; 28 | int gridColumns; 29 | int itemWidth; 30 | DropDownView dropDownView; 31 | private static final String TAG = "DropDownPopupWindow"; 32 | View view; 33 | DropDownViewRecycleViewAdapter myRecycleViewAdapter; 34 | 35 | public DropDownPopupWindow(Context context, List> dataList, int gridColumns) { 36 | super(context); 37 | mDataList = dataList; 38 | mContext = context; 39 | this.gridColumns = gridColumns; 40 | } 41 | 42 | public DropDownPopupWindow(Context context, List> dataList) { 43 | this(context, dataList, 0); 44 | } 45 | 46 | private void initView() { 47 | LayoutInflater inflater = (LayoutInflater) mContext 48 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 49 | view = inflater.inflate(R.layout.layout_popupwindow_dropdown, null); 50 | // id_pop_tv= (TextView) view.findViewById(R.id.id_pop_tv); 51 | 52 | mRecyclerView = (RecyclerView) view.findViewById(R.id.id_rv); 53 | 54 | 55 | myRecycleViewAdapter = new DropDownViewRecycleViewAdapter(mContext, mDataList, itemWidth); 56 | if (gridColumns == 0) { 57 | mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); 58 | } else { 59 | mRecyclerView.setLayoutManager(new GridLayoutManager(mContext, gridColumns)); 60 | } 61 | 62 | myRecycleViewAdapter.setOnItemViewClickListener(this); 63 | //设置Item增加、移除动画 64 | // mRecyclerView.setItemAnimator(new DefaultItemAnimator()); 65 | mRecyclerView.setAdapter(myRecycleViewAdapter); 66 | 67 | //设置PopupWindow的View 68 | this.setContentView(view); 69 | //设置PopupWindow弹出窗体的宽 70 | this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); 71 | //设置PopupWindow弹出窗体的高 72 | this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); 73 | this.setBackgroundDrawable(new ColorDrawable(0x00000000));//必须设置 ps:xml bg和这个不冲突 74 | this.setFocusable(true);//设置后 达到返回按钮先消失popupWindow 75 | //id_pop_tv.setOnClickListener(this); 76 | } 77 | 78 | 79 | 80 | @Override 81 | public void onItemViewClick(View v, int position, int realPosition) { 82 | this.dismiss(); 83 | if (position == 0) { 84 | onItemSelectListener.onItemSelect(null, position,realPosition); 85 | } else { 86 | Map nowMap = mDataList.get(realPosition); 87 | 88 | onItemSelectListener.onItemSelect(nowMap, position,realPosition); 89 | } 90 | 91 | 92 | } 93 | 94 | 95 | public interface OnItemSelectListener { 96 | void onItemSelect(Map map, int pos,int realPos); 97 | } 98 | 99 | public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) { 100 | this.onItemSelectListener = onItemSelectListener; 101 | } 102 | 103 | OnItemSelectListener onItemSelectListener; 104 | 105 | public void showAsDropDownBelwBtnView(View btnView) { 106 | int anchor_w = btnView.getWidth(); 107 | this.itemWidth = anchor_w; 108 | this.dropDownView = (DropDownView) btnView; 109 | initView(); 110 | 111 | int allHeight1 = this.getMaxAvailableHeight(view); 112 | int allHeight2 = this.getMaxAvailableHeight(btnView); 113 | Log.d(TAG, "showAsDropDownBelwBtnView: allHeight1:" + allHeight1);//1920 应该是屏幕高度 114 | Log.d(TAG, "showAsDropDownBelwBtnView: allHeight2:" + allHeight2);// 由上到下 先减小后增加 应该是popwindow动态判断是否显示在上面,然后可以的高度就会如此变化 115 | 116 | int btnViewHeight = btnView.getHeight(); 117 | Log.d(TAG, "showAsDropDownBelwBtnView: btnViewHeight:" + btnViewHeight); 118 | int mRecyclerViewHeight = getTargetHeight(mRecyclerView); 119 | Log.d(TAG, "showAsDropDownBelwBtnView: mRecyclerView:" + mRecyclerViewHeight); 120 | 121 | int[] position = new int[2]; 122 | btnView.getLocationInWindow(position); 123 | int x = position[0]; 124 | int y = position[1]; 125 | Log.d(TAG, "showAsDropDownBelwBtnView: BtnView x:" + x); 126 | Log.d(TAG, "showAsDropDownBelwBtnView: BtnView y:" + y); 127 | 128 | 129 | if ((allHeight1 - y - btnViewHeight) < mRecyclerViewHeight && y > mRecyclerViewHeight) { 130 | 131 | this.showAsDropDown(btnView, 0, -(mRecyclerViewHeight + btnViewHeight)); 132 | myRecycleViewAdapter.updateBackground(true, mRecyclerView); 133 | } else { 134 | 135 | this.showAsDropDown(btnView); 136 | myRecycleViewAdapter.updateBackground(false, mRecyclerView); 137 | 138 | } 139 | 140 | 141 | } 142 | 143 | /** 144 | * 利用反射来获取View未显示前的高度 145 | * 146 | * @param v 147 | * @return 148 | */ 149 | private int getTargetHeight(View v) { 150 | try { 151 | Method m = v.getClass().getDeclaredMethod("onMeasure", int.class, 152 | int.class); 153 | m.setAccessible(true); 154 | m.invoke(v, View.MeasureSpec.makeMeasureSpec( 155 | ((View) v.getParent()).getMeasuredWidth(), 156 | View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(0, 157 | View.MeasureSpec.UNSPECIFIED)); 158 | } catch (Exception e) { 159 | 160 | } 161 | return v.getMeasuredHeight(); 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/MultiSelectLayout.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.widget.AdapterView; 8 | import android.widget.ExpandableListView; 9 | import android.widget.ListView; 10 | import android.widget.RelativeLayout; 11 | import android.widget.TextView; 12 | 13 | import com.louisgeek.dropdownviewlib.adapter.MultiSelectViewContentBaseAdapter; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | 20 | public class MultiSelectLayout extends RelativeLayout { 21 | 22 | private Context mContext; 23 | 24 | ListView id_lv ; 25 | TextView id_tv_select_all ; 26 | TextView id_tv_back_select_all ; 27 | TextView id_tv_title ; 28 | 29 | MultiSelectViewContentBaseAdapter mMultiSelectViewAdapter; 30 | 31 | public MultiSelectLayout(Context context) { 32 | super(context); 33 | init(context); 34 | } 35 | public MultiSelectLayout(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | init(context); 38 | } 39 | 40 | public MultiSelectLayout(Context context, AttributeSet attrs, int defStyleAttr) { 41 | super(context, attrs, defStyleAttr); 42 | init(context); 43 | } 44 | 45 | private void init(Context context) { 46 | mContext=context; 47 | 48 | View view = LayoutInflater.from(mContext).inflate(R.layout.layout_mutiselect_dialog_frag_content_list, this); 49 | ExpandableListView id_elv = (ExpandableListView) view.findViewById(R.id.id_elv); 50 | id_elv.setVisibility(GONE); 51 | id_lv = (ListView) view.findViewById(R.id.id_lv); 52 | id_tv_select_all = (TextView) view.findViewById(R.id.id_tv_select_all); 53 | id_tv_back_select_all = (TextView) view.findViewById(R.id.id_tv_back_select_all); 54 | id_tv_title = (TextView) view.findViewById(R.id.id_tv_title); 55 | id_tv_title.setText("选项(0)"); 56 | 57 | 58 | initMultiSelectView(); 59 | 60 | id_tv_select_all.setOnClickListener(new OnClickListener() { 61 | @Override 62 | public void onClick(View v) { 63 | if (!mMultiSelectViewAdapter.isAllSeleted()) { 64 | mMultiSelectViewAdapter.seletAll(); 65 | }else{ 66 | mMultiSelectViewAdapter.unSeletAll(); 67 | } 68 | refreshTextData(); 69 | } 70 | }); 71 | id_tv_back_select_all.setOnClickListener(new OnClickListener() { 72 | @Override 73 | public void onClick(View v) { 74 | mMultiSelectViewAdapter.backSelet(); 75 | refreshTextData(); 76 | } 77 | }); 78 | 79 | 80 | 81 | TextView id_tv_ok= (TextView) view.findViewById(R.id.id_tv_ok); 82 | id_tv_ok.setOnClickListener(new View.OnClickListener() { 83 | @Override 84 | public void onClick(View v) { 85 | onBtnClickListener.onOkBtnClick(v,getMultiSelectMapList(),getSelectedMapList()); 86 | } 87 | }); 88 | TextView id_tv_cancel= (TextView) view.findViewById(R.id.id_tv_cancel); 89 | id_tv_cancel.setOnClickListener(new View.OnClickListener() { 90 | @Override 91 | public void onClick(View v) { 92 | onBtnClickListener.onCancelBtnClick(v); 93 | 94 | } 95 | }); 96 | 97 | } 98 | private void initMultiSelectView() { 99 | /** 100 | * 默认没有数据 101 | */ 102 | List> multiSelectMapList=new ArrayList<>(); 103 | mMultiSelectViewAdapter=new MultiSelectViewContentBaseAdapter(mContext,multiSelectMapList); 104 | id_lv.setAdapter(mMultiSelectViewAdapter); 105 | id_lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 106 | @Override 107 | public void onItemClick(AdapterView parent, View view, int position, long id) { 108 | mMultiSelectViewAdapter.seletOne(view,position); 109 | refreshTextData(); 110 | } 111 | }); 112 | } 113 | public void setupMultiSelectMapList(List> multiSelectMapList) { 114 | mMultiSelectViewAdapter.updateMultiSelectMapListInner(multiSelectMapList); 115 | refreshTextData(); 116 | } 117 | 118 | private void refreshTextData() { 119 | int count = mMultiSelectViewAdapter.getCheckNum(); 120 | id_tv_title.setText("选项("+count+")"); 121 | } 122 | 123 | /* public void setupSeletedItemMapList( List> seletedItemMapList){ 124 | mMapList.clear(); 125 | mMapList.addAll(seletedItemMapList); 126 | mMultiSelectViewAdapter.notifyDataSetChanged(); 127 | }*/ 128 | 129 | /** 130 | * 取到所有的(包括未选中的) 131 | * @return 132 | */ 133 | public List> getMultiSelectMapList(){ 134 | return mMultiSelectViewAdapter.getMultiSelectMapListInner(); 135 | } 136 | /** 137 | * 取到所有的选中的 138 | * @return 139 | */ 140 | public List> getSelectedMapList(){ 141 | List> multiSelectMapList=getMultiSelectMapList(); 142 | List> multiSelectMapListTemp=new ArrayList<>(); 143 | for (int i = 0; i < multiSelectMapList.size(); i++) { 144 | if(multiSelectMapList.get(i).get("checked")!=null){ 145 | if (Boolean.parseBoolean(multiSelectMapList.get(i).get("checked").toString())){ 146 | multiSelectMapListTemp.add(multiSelectMapList.get(i)); 147 | } 148 | } 149 | } 150 | return multiSelectMapListTemp; 151 | } 152 | 153 | public interface OnBtnClickListener{ 154 | /** 155 | * 156 | * @param v 157 | * @param multiSelectMapList 总的list 158 | * @param selectMapList 选中的list 159 | */ 160 | void onOkBtnClick(View v, List> multiSelectMapList,List> selectMapList); 161 | void onCancelBtnClick(View v); 162 | } 163 | 164 | public void setOnBtnClickListener(OnBtnClickListener onBtnClickListener) { 165 | this.onBtnClickListener = onBtnClickListener; 166 | } 167 | 168 | OnBtnClickListener onBtnClickListener; 169 | } 170 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/MultiSelectLayout_HasChild.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.widget.ExpandableListView; 8 | import android.widget.ListView; 9 | import android.widget.RelativeLayout; 10 | import android.widget.TextView; 11 | 12 | import com.louisgeek.dropdownviewlib.adapter.MultiSelectViewContentBaseExpandableListAdapter; 13 | import com.louisgeek.dropdownviewlib.javabean.MultiSelectHasChildBean; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | /** 20 | * Created by louisgeek on 2016/6/17. 21 | */ 22 | public class MultiSelectLayout_HasChild extends RelativeLayout { 23 | 24 | private Context mContext; 25 | 26 | private ExpandableListView id_elv ; 27 | private TextView id_tv_select_all ; 28 | private TextView id_tv_back_select_all ; 29 | private TextView id_tv_title ; 30 | 31 | //MultiSelectViewContentBaseAdapter mMultiSelectViewAdapter; 32 | private MultiSelectViewContentBaseExpandableListAdapter mMultiSelectViewContentBaseExpandableListAdapter; 33 | 34 | public MultiSelectLayout_HasChild(Context context) { 35 | super(context); 36 | init(context); 37 | } 38 | public MultiSelectLayout_HasChild(Context context, AttributeSet attrs) { 39 | super(context, attrs); 40 | init(context); 41 | } 42 | 43 | public MultiSelectLayout_HasChild(Context context, AttributeSet attrs, int defStyleAttr) { 44 | super(context, attrs, defStyleAttr); 45 | init(context); 46 | } 47 | 48 | private void init(Context context) { 49 | mContext=context; 50 | 51 | View view = LayoutInflater.from(mContext).inflate(R.layout.layout_mutiselect_dialog_frag_content_list, this); 52 | 53 | ListView id_lv = (ListView) view.findViewById(R.id.id_lv); 54 | id_lv.setVisibility(GONE); 55 | id_elv = (ExpandableListView) view.findViewById(R.id.id_elv); 56 | //设置 属性 GroupIndicator 去掉默认向下的箭头 57 | id_elv.setGroupIndicator(null); 58 | 59 | id_tv_select_all = (TextView) view.findViewById(R.id.id_tv_select_all); 60 | id_tv_back_select_all = (TextView) view.findViewById(R.id.id_tv_back_select_all); 61 | id_tv_title = (TextView) view.findViewById(R.id.id_tv_title); 62 | id_tv_title.setText("选项(0)"); 63 | 64 | 65 | initMultiSelectView(); 66 | 67 | id_tv_select_all.setOnClickListener(new OnClickListener() { 68 | @Override 69 | public void onClick(View v) { 70 | if (!mMultiSelectViewContentBaseExpandableListAdapter.isAllSeleted()) { 71 | mMultiSelectViewContentBaseExpandableListAdapter.seletAll(); 72 | }else{ 73 | mMultiSelectViewContentBaseExpandableListAdapter.unSeletAll(); 74 | } 75 | refreshTextData(); 76 | } 77 | }); 78 | id_tv_back_select_all.setOnClickListener(new OnClickListener() { 79 | @Override 80 | public void onClick(View v) { 81 | mMultiSelectViewContentBaseExpandableListAdapter.backSelet(); 82 | refreshTextData(); 83 | } 84 | }); 85 | 86 | 87 | 88 | TextView id_tv_ok= (TextView) view.findViewById(R.id.id_tv_ok); 89 | id_tv_ok.setOnClickListener(new OnClickListener() { 90 | @Override 91 | public void onClick(View v) { 92 | onBtnClickListener.onOkBtnClick(v,getMultiSelectMapListInnerGroupAndChildBeanList(),getSelectedMapGroupAndChildBeanListOnly()); 93 | } 94 | }); 95 | TextView id_tv_cancel= (TextView) view.findViewById(R.id.id_tv_cancel); 96 | id_tv_cancel.setOnClickListener(new OnClickListener() { 97 | @Override 98 | public void onClick(View v) { 99 | onBtnClickListener.onCancelBtnClick(v); 100 | 101 | } 102 | }); 103 | 104 | } 105 | private void initMultiSelectView() { 106 | /** 107 | * 默认没有数据 108 | */ 109 | List multiSelectHasChildBeanList=new ArrayList<>(); 110 | mMultiSelectViewContentBaseExpandableListAdapter=new MultiSelectViewContentBaseExpandableListAdapter(mContext,multiSelectHasChildBeanList); 111 | id_elv.setAdapter(mMultiSelectViewContentBaseExpandableListAdapter); 112 | /*id_elv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 113 | @Override 114 | public void onItemClick(AdapterView parent, View view, int position, long id) { 115 | mMultiSelectViewAdapter.seletOne(view,position); 116 | refreshTextData(); 117 | } 118 | });*/ 119 | id_elv.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { 120 | @Override 121 | public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { 122 | // Toast.makeText(getContext(), "groupPosition:"+groupPosition, Toast.LENGTH_SHORT).show(); 123 | return true;// 124 | } 125 | }); 126 | id_elv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { 127 | @Override 128 | public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { 129 | mMultiSelectViewContentBaseExpandableListAdapter.seletOne(v,groupPosition,childPosition); 130 | refreshTextData(); 131 | return false; 132 | } 133 | }); 134 | } 135 | public void setupMultiSelectHasChildBeanList(List multiSelectHasChildBeanList) { 136 | mMultiSelectViewContentBaseExpandableListAdapter.updateMultiSelectHasChildBeanList(multiSelectHasChildBeanList); 137 | //默认展开所有 138 | for(int i = 0; i < mMultiSelectViewContentBaseExpandableListAdapter.getGroupCount(); i++){ 139 | id_elv.expandGroup(i); 140 | } 141 | refreshTextData(); 142 | } 143 | 144 | private void refreshTextData() { 145 | int count = mMultiSelectViewContentBaseExpandableListAdapter.getCheckNum(); 146 | id_tv_title.setText("选项("+count+")"); 147 | } 148 | 149 | /* public void setupSeletedItemMapList( List> seletedItemMapList){ 150 | mMapList.clear(); 151 | mMapList.addAll(seletedItemMapList); 152 | mMultiSelectViewAdapter.notifyDataSetChanged(); 153 | }*/ 154 | /** 155 | * 取到所有的(包括未选中的) 156 | * @return 157 | */ 158 | public List getMultiSelectMapListInnerGroupAndChildBeanList(){ 159 | return mMultiSelectViewContentBaseExpandableListAdapter.getMultiSelectMapListInnerGroupAndChildBeanList(); 160 | } 161 | /** 162 | * 取到所有的选中的 163 | * @return 164 | */ 165 | public List getSelectedMapGroupAndChildBeanListOnly(){ 166 | List multiSelectMapListInnerGroupAndChildBeanList=getMultiSelectMapListInnerGroupAndChildBeanList();; 167 | 168 | List multiSelectMapListInnerGroupAndChildBeanListTemp=new ArrayList<>(); 169 | for (int j = 0; j < multiSelectMapListInnerGroupAndChildBeanList.size(); j++) { 170 | List> multiSelectMapList=multiSelectMapListInnerGroupAndChildBeanList.get(j).getMultiSelectMapList(); 171 | MultiSelectHasChildBean multiSelectMapListInnerGroupAndChildBean=new MultiSelectHasChildBean(); 172 | multiSelectMapListInnerGroupAndChildBean.setName(multiSelectMapListInnerGroupAndChildBeanList.get(j).getName()); 173 | multiSelectMapListInnerGroupAndChildBean.setID(multiSelectMapListInnerGroupAndChildBeanList.get(j).getID()); 174 | 175 | List> multiSelectMapListTemp=new ArrayList<>(); 176 | for (int i = 0; i < multiSelectMapList.size(); i++) { 177 | if(multiSelectMapList.get(i).get("checked")!=null){ 178 | if (Boolean.parseBoolean(multiSelectMapList.get(i).get("checked").toString())){ 179 | multiSelectMapListTemp.add(multiSelectMapList.get(i)); 180 | } 181 | } 182 | } 183 | multiSelectMapListInnerGroupAndChildBean.setMultiSelectMapList(multiSelectMapListTemp); 184 | multiSelectMapListInnerGroupAndChildBeanListTemp.add(multiSelectMapListInnerGroupAndChildBean); 185 | } 186 | 187 | return multiSelectMapListInnerGroupAndChildBeanListTemp; 188 | } 189 | /** 190 | * 取到所有的选中的 191 | * @return 192 | */ 193 | public List> getSelectMapListInAll(){ 194 | List multiSelectMapListInnerGroupAndChildBeanList=getSelectedMapGroupAndChildBeanListOnly();; 195 | 196 | List> selectMapListInAllTemp=new ArrayList<>(); 197 | for (int j = 0; j < multiSelectMapListInnerGroupAndChildBeanList.size(); j++) { 198 | List> multiSelectMapList=multiSelectMapListInnerGroupAndChildBeanList.get(j).getMultiSelectMapList(); 199 | 200 | for (int i = 0; i < multiSelectMapList.size(); i++) { 201 | if(multiSelectMapList.get(i).get("checked")!=null){ 202 | if (Boolean.parseBoolean(multiSelectMapList.get(i).get("checked").toString())){ 203 | selectMapListInAllTemp.add(multiSelectMapList.get(i)); 204 | } 205 | } 206 | } 207 | } 208 | 209 | return selectMapListInAllTemp; 210 | } 211 | public interface OnBtnClickListener{ 212 | /** 213 | * 214 | * @param v 215 | * @param multiSelectMapList 总的list 216 | * @param selectMapList 选中的list 217 | */ 218 | void onOkBtnClick(View v, List multiSelectMapList, List selectMapList); 219 | void onCancelBtnClick(View v); 220 | } 221 | 222 | public void setOnBtnClickListener(OnBtnClickListener onBtnClickListener) { 223 | this.onBtnClickListener = onBtnClickListener; 224 | } 225 | 226 | OnBtnClickListener onBtnClickListener; 227 | } 228 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/ProCateSelectView.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.widget.LinearLayout; 8 | 9 | import com.alibaba.fastjson.JSON; 10 | import com.louisgeek.dropdownviewlib.javabean.ProCate; 11 | import com.louisgeek.dropdownviewlib.tools.MySSQTool; 12 | 13 | import java.util.ArrayList; 14 | import java.util.HashMap; 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | /** 19 | * Created by louisgeek on 2016/6/28. 20 | */ 21 | public class ProCateSelectView extends LinearLayout{ 22 | private Context mContext; 23 | DropDownView id_parent_pro; 24 | DropDownView id_child_pro; 25 | String pro_cate_json; 26 | List proCate_CatesBeanList; 27 | public ProCateSelectView(Context context) { 28 | this(context,null); 29 | } 30 | 31 | public ProCateSelectView(Context context, AttributeSet attrs) { 32 | this(context, attrs,0); 33 | } 34 | 35 | public ProCateSelectView(Context context, AttributeSet attrs, int defStyleAttr) { 36 | super(context, attrs, defStyleAttr); 37 | 38 | init(context); 39 | } 40 | 41 | private void init(Context context) { 42 | mContext=context; 43 | View view = LayoutInflater.from(mContext).inflate(R.layout.layout_procate_selectview, this); 44 | id_parent_pro = (DropDownView) view.findViewById(R.id.id_parent_pro); 45 | id_child_pro = (DropDownView) view.findViewById(R.id.id_child_pro); 46 | 47 | initData(); 48 | initDropDownView(); 49 | } 50 | 51 | private void initData() { 52 | pro_cate_json = MySSQTool.getStringFromRaw(getContext(), R.raw.pro_cate); 53 | ProCate proCate= JSON.parseObject(pro_cate_json,ProCate.class); 54 | 55 | proCate_CatesBeanList=proCate.getCates(); 56 | } 57 | 58 | private void initDropDownView() { 59 | 60 | List> dataList = new ArrayList<>(); 61 | for (int i = 0; i < proCate_CatesBeanList.size(); i++) { 62 | Map map = new HashMap<>(); 63 | map.put("name", proCate_CatesBeanList.get(i).getCatename()); 64 | map.put("key", proCate_CatesBeanList.get(i).getCateid()); 65 | dataList.add(map); 66 | } 67 | id_parent_pro.setupDataList(dataList); 68 | id_parent_pro.setOnItemClickListener(new DropDownView.OnItemClickListener() { 69 | @Override 70 | public void onItemClick(Map map, int pos,int realPos) { 71 | 72 | initInnerChild(realPos); 73 | } 74 | }); 75 | 76 | ///###initInnerChild(0); 77 | 78 | } 79 | 80 | private void initInnerChild(int parent_pos) { 81 | id_child_pro.setText(id_child_pro.getDefaultText()); 82 | List> dataList_area = new ArrayList<>(); 83 | if (parent_pos>=0){ 84 | for (int i = 0; i < proCate_CatesBeanList.get(parent_pos).getChildren().size(); i++) { 85 | Map map = new HashMap<>(); 86 | map.put("name", proCate_CatesBeanList.get(parent_pos).getChildren().get(i).getCatename()); 87 | map.put("key", proCate_CatesBeanList.get(parent_pos).getChildren().get(i).getCateid()); 88 | dataList_area.add(map); 89 | } 90 | } 91 | id_child_pro.setupDataList(dataList_area); 92 | } 93 | 94 | @Deprecated 95 | public void setupProCateByKey(String key){ 96 | String parentkey=""; 97 | String childkey=""; 98 | if(key!=null&&!key.equals("")) { 99 | if (key.startsWith("0_")) {//只有父类 100 | parentkey=key; 101 | } else { 102 | childkey=key; 103 | String[] Keys=key.split("_"); 104 | if (Keys!=null&&Keys.length>0){ 105 | parentkey="0_"+Keys[0]; 106 | } 107 | } 108 | id_parent_pro.setSelectNameByKey(parentkey); 109 | int parent_pos= id_parent_pro.getPositionByKey(parentkey); 110 | if (parent_pos>0) { 111 | initInnerChild(parent_pos); 112 | if (!childkey.equals("")) { 113 | id_child_pro.setSelectNameByKey(childkey); 114 | } 115 | } 116 | } 117 | } 118 | public void setupProCateByKey(String OneKey,String TwoKey){ 119 | String parentkey=""; 120 | String childkey=""; 121 | if(OneKey!=null&&!OneKey.equals("")) { 122 | parentkey="0_"+OneKey; 123 | } 124 | if(TwoKey!=null&&!TwoKey.equals("")) { 125 | childkey=OneKey+"_"+TwoKey; 126 | } 127 | id_parent_pro.setSelectNameByKey(parentkey); 128 | int parent_pos= id_parent_pro.getPositionByKey(parentkey); 129 | if (parent_pos>-1) { 130 | initInnerChild(parent_pos); 131 | if (!childkey.equals("")) { 132 | id_child_pro.setSelectNameByKey(childkey); 133 | } 134 | } 135 | // 136 | } 137 | 138 | public String getProCateKey(){ 139 | String parent_key = id_parent_pro.getSelectKey(); 140 | String child_key = id_child_pro.getSelectKey(); 141 | if (child_key != null && !child_key.equals("")&&!child_key.equals("-1")) { 142 | return child_key; 143 | } else if (parent_key != null && !parent_key.equals("")&&!parent_key.equals("-1")) { 144 | return parent_key; 145 | } else { 146 | return "0_0"; 147 | } 148 | } 149 | public String getProCateNameOnlyChild(){ 150 | // String parent_key = id_parent_pro.getSelectKey(); 151 | String child_name = id_child_pro.getSelectName(); 152 | if (child_name != null && !child_name.equals("")) { 153 | return child_name; 154 | } else { 155 | return ""; 156 | } 157 | } 158 | public int getProCateKeyOnlyChildId(){ 159 | int childId=0; 160 | String proCateKey=getProCateKey(); 161 | if (proCateKey!=null){ 162 | if (proCateKey.contains("_")){ 163 | String[] proCateKeys=proCateKey.split("_"); 164 | if (proCateKeys!=null&&proCateKeys.length>0){ 165 | if (proCateKeys.length>1&&proCateKeys[1]!=null){ 166 | childId=Integer.valueOf(proCateKeys[1]); 167 | } 168 | } 169 | } 170 | } 171 | return childId; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/adapter/DropDownViewRecycleViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.adapter; 2 | 3 | import android.content.Context; 4 | import android.os.Handler; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.util.Log; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.ImageView; 11 | import android.widget.LinearLayout; 12 | import android.widget.TextView; 13 | 14 | import com.louisgeek.dropdownviewlib.DropDownView; 15 | import com.louisgeek.dropdownviewlib.R; 16 | 17 | import java.util.ArrayList; 18 | import java.util.HashMap; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | /** 23 | * Created by louisgeek on 2016/6/3. 24 | */ 25 | public class DropDownViewRecycleViewAdapter extends RecyclerView.Adapter { 26 | 27 | private int itemWidth; 28 | private boolean mShowAtAbove=false; 29 | private static final String TAG = "DropDownViewAdapter"; 30 | private Map mIntegerBooleanMap_StoreSelectedState=new HashMap<>(); 31 | 32 | public void updateBackground(boolean showAbove,RecyclerView recyclerView) { 33 | mShowAtAbove=showAbove; 34 | List> mNameStateListTemp=new ArrayList<>(); 35 | for (int i = 0; i < mDataList.size(); i++) { 36 | Map mapTemp= mDataList.get(i); 37 | if (showAbove){ 38 | mapTemp.put("isShowAbove","true"); 39 | }else{ 40 | mapTemp.put("isShowAbove","false"); 41 | } 42 | mNameStateListTemp.add(mapTemp); 43 | } 44 | mDataList.clear(); 45 | mDataList.addAll(mNameStateListTemp); 46 | Log.d(TAG, "updateBackground:isShowAbove"+showAbove); 47 | Handler handler=new Handler(); 48 | //线程报错 49 | // this.notifyDataSetChanged(); 50 | handlerPostAndNotifyAdapterNotifyDataSetChanged(handler,recyclerView,this); 51 | } 52 | 53 | 54 | /* public DropDownViewRecycleViewAdapter(Context context, List> dataList, int itemWidth,boolean isMutiSelect) { 55 | mContext = context; 56 | this.mDataList = dataList; 57 | this.itemWidth=itemWidth; 58 | this.isMutiSelect=isMutiSelect; 59 | }*/ 60 | public DropDownViewRecycleViewAdapter(Context context, List> dataList, int itemWidth) { 61 | mContext = context; 62 | this.mDataList = dataList; 63 | this.itemWidth=itemWidth; 64 | } 65 | 66 | private List> mDataList; 67 | private Context mContext; 68 | 69 | 70 | /** 71 | * 72 | * 73 | * @param parent 74 | * @param viewType 75 | * @return 76 | */ 77 | @Override 78 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 79 | View view = LayoutInflater.from(mContext).inflate(R.layout.dropdown_item, parent,false);//不false 在popupwindow里报错 80 | 81 | //设置Item的宽 82 | view.setLayoutParams(new ViewGroup.LayoutParams(itemWidth, ViewGroup.LayoutParams.WRAP_CONTENT)); 83 | 84 | MyRecyclerViewHolder myRecyclerViewHolder = new MyRecyclerViewHolder(view); 85 | return myRecyclerViewHolder; 86 | } 87 | 88 | @Override 89 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { 90 | MyRecyclerViewHolder myRecyclerViewHolder = (MyRecyclerViewHolder) holder; 91 | 92 | 93 | if (position==0){ 94 | /// 95 | myRecyclerViewHolder.mTextView.setText(DropDownView.NUSELETED_SHOW_NAME); 96 | if (mShowAtAbove){ 97 | myRecyclerViewHolder.id_ll_item.setBackgroundResource(R.drawable.selector_shape_list_item_nobottom); 98 | }else{ 99 | myRecyclerViewHolder.id_ll_item.setBackgroundResource(R.drawable.selector_shape_list_item_notop); 100 | } 101 | }else{ 102 | int realPos=position-1; 103 | /// 104 | if (mDataList.get(realPos).get("isShowAbove")!=null){ 105 | String isShowAbove=mDataList.get(realPos).get("isShowAbove").toString(); 106 | Log.d(TAG, "onBindViewHolder updateBackground:isShowAbove"+isShowAbove); 107 | if("true".equals(isShowAbove)) { 108 | myRecyclerViewHolder.id_ll_item.setBackgroundResource(R.drawable.selector_shape_list_item_nobottom); 109 | }else{ 110 | myRecyclerViewHolder.id_ll_item.setBackgroundResource(R.drawable.selector_shape_list_item_notop); 111 | } 112 | } 113 | /// 114 | if (mDataList.get(realPos).get("name")!=null){ 115 | myRecyclerViewHolder.mTextView.setText(mDataList.get(realPos).get("name").toString()); 116 | } 117 | } 118 | 119 | 120 | } 121 | 122 | @Override 123 | public int getItemCount() { 124 | return mDataList.size()+1; 125 | } 126 | 127 | class MyRecyclerViewHolder extends RecyclerView.ViewHolder { 128 | TextView mTextView; 129 | ImageView mImageView; 130 | LinearLayout id_ll_item; 131 | public MyRecyclerViewHolder(View itemView) { 132 | super(itemView); 133 | mTextView = (TextView) itemView.findViewById(R.id.id_tv); 134 | id_ll_item= (LinearLayout) itemView.findViewById(R.id.id_ll_item); 135 | itemView.setOnClickListener(new View.OnClickListener() { 136 | @Override 137 | public void onClick(View v) { 138 | mOnItemViewClickListener.onItemViewClick(v,getAdapterPosition(),getAdapterPosition()-1); 139 | } 140 | }); 141 | mImageView= (ImageView) itemView.findViewById(R.id.id_iv); 142 | } 143 | } 144 | 145 | /** 146 | * 重复post message 直到recyclerView 完成显示 147 | * @param handler 148 | * @param recyclerView 149 | * @param adapter 150 | */ 151 | protected void handlerPostAndNotifyAdapterNotifyDataSetChanged(final Handler handler, final RecyclerView recyclerView, final RecyclerView.Adapter adapter) { 152 | handler.post(new Runnable() { 153 | @Override 154 | public void run() { 155 | if (!recyclerView.isComputingLayout()) { 156 | adapter.notifyDataSetChanged(); 157 | } else { 158 | handlerPostAndNotifyAdapterNotifyDataSetChanged(handler, recyclerView, adapter); 159 | } 160 | } 161 | }); 162 | } 163 | 164 | public interface OnItemViewClickListener{ 165 | void onItemViewClick(View v, int position,int realPosition); 166 | } 167 | 168 | public void setOnItemViewClickListener(OnItemViewClickListener onItemViewClickListener) { 169 | mOnItemViewClickListener = onItemViewClickListener; 170 | } 171 | 172 | private OnItemViewClickListener mOnItemViewClickListener; 173 | 174 | 175 | 176 | } 177 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/adapter/MultiSelectViewContentBaseAdapter.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.CheckBox; 9 | import android.widget.TextView; 10 | 11 | import com.louisgeek.dropdownviewlib.R; 12 | 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | /** 18 | * Created by louisgeek on 2016/6/17. 19 | */ 20 | public class MultiSelectViewContentBaseAdapter extends BaseAdapter { 21 | public void updateMultiSelectMapListInner(List> multiSelectMapListInner) { 22 | mMultiSelectMapListInner.clear(); 23 | mMultiSelectMapListInner.addAll(multiSelectMapListInner); 24 | initSelectedData();//重新初始化 25 | this.notifyDataSetChanged(); 26 | } 27 | 28 | private List> mMultiSelectMapListInner; 29 | // 用来控制CheckBox的选中状况 30 | private Map isSelectedMap; 31 | private Context context; 32 | // 用来导入布局 33 | private LayoutInflater inflater = null; 34 | int checkNum = 0; 35 | 36 | public int getCheckNum() { 37 | return checkNum<0?0:checkNum; 38 | } 39 | 40 | // 构造器 41 | public MultiSelectViewContentBaseAdapter(Context context, List> multiSelectMapListInner) { 42 | this.context = context; 43 | this.mMultiSelectMapListInner = multiSelectMapListInner; 44 | inflater = LayoutInflater.from(context); 45 | // 初始化数据 46 | initSelectedData(); 47 | } 48 | 49 | // 初始化isSelected的数据 50 | private void initSelectedData() { 51 | isSelectedMap=new HashMap<>(); 52 | if(mMultiSelectMapListInner!=null&&mMultiSelectMapListInner.size()>0){ 53 | for (int i = 0; i < mMultiSelectMapListInner.size(); i++) { 54 | if (Boolean.parseBoolean(String.valueOf(mMultiSelectMapListInner.get(i).get("checked")))) { 55 | isSelectedMap.put(i, true);//索引 56 | checkNum++; 57 | }else{ 58 | isSelectedMap.put(i, false);//索引 59 | } 60 | }} 61 | } 62 | 63 | @Override 64 | public int getCount() { 65 | return mMultiSelectMapListInner.size(); 66 | } 67 | 68 | @Override 69 | public Object getItem(int position) { 70 | return mMultiSelectMapListInner.get(position); 71 | } 72 | 73 | @Override 74 | public long getItemId(int position) { 75 | return position; 76 | } 77 | 78 | @Override 79 | public View getView(int position, View convertView, ViewGroup parent) { 80 | ViewHolder holder; 81 | if (convertView == null) { 82 | // 获得ViewHolder对象 83 | holder = new ViewHolder(); 84 | // 导入布局并赋值给convertview 85 | convertView = inflater.inflate(R.layout.mutiselect_dialog_frag_list_item, parent, false); 86 | holder.tv = (TextView) convertView.findViewById(R.id.item_tv); 87 | holder.cb = (CheckBox) convertView.findViewById(R.id.item_cb); 88 | // 为view设置标签 89 | convertView.setTag(holder); 90 | } else { 91 | // 取出holder 92 | holder = (ViewHolder) convertView.getTag(); 93 | } 94 | holder.tv.setText(mMultiSelectMapListInner.get(position).get("name").toString()); 95 | // 根据isSelected来设置checkbox的选中状况 96 | holder.cb.setChecked(isSelectedMap.get(position)); 97 | return convertView; 98 | } 99 | 100 | 101 | public static class ViewHolder { 102 | TextView tv; 103 | CheckBox cb; 104 | } 105 | 106 | public void seletOne(View view,int pos) { 107 | ViewHolder viewHolder= (ViewHolder) view.getTag(); 108 | viewHolder.cb.toggle();//转变 109 | isSelectedMap.put(pos,viewHolder.cb.isChecked()); 110 | if (viewHolder.cb.isChecked()){ 111 | checkNum++; 112 | }else{ 113 | checkNum--; 114 | } 115 | this.notifyDataSetChanged(); 116 | checkNum=checkNum<0?0:checkNum; 117 | } 118 | public void seletAll() { 119 | // 遍历list,全部设为true 120 | for (int i = 0; i < mMultiSelectMapListInner.size(); i++) { 121 | if (!isSelectedMap.get(i)) { 122 | isSelectedMap.put(i, true); 123 | checkNum++; 124 | } 125 | } 126 | this.notifyDataSetChanged(); 127 | checkNum=checkNum<0?0:checkNum; 128 | } 129 | 130 | public void unSeletAll() { 131 | // 遍历list,全部设为false 132 | for (int i = 0; i < mMultiSelectMapListInner.size(); i++) { 133 | if (isSelectedMap.get(i)) { 134 | isSelectedMap.put(i, false); 135 | checkNum--; 136 | } 137 | } 138 | this.notifyDataSetChanged(); 139 | checkNum=checkNum<0?0:checkNum; 140 | } 141 | 142 | 143 | 144 | public void backSelet() { 145 | for (int i = 0; i < mMultiSelectMapListInner.size(); i++) { 146 | if (isSelectedMap.get(i)) { 147 | isSelectedMap.put(i, false); 148 | checkNum--; 149 | } else { 150 | isSelectedMap.put(i, true); 151 | checkNum++; 152 | } 153 | } 154 | this.notifyDataSetChanged(); 155 | checkNum=checkNum<0?0:checkNum; 156 | } 157 | 158 | /* 159 | public List> getSeletedItemDataList(){ 160 | List> seletedItemDataList=new ArrayList<>(); 161 | for (int i = 0; i < mMultiSelectMapList.size();i++) { 162 | if (isSelectedMap.get(i)) { 163 | seletedItemDataList.add(mMultiSelectMapList.get(i)); 164 | } 165 | } 166 | return seletedItemDataList; 167 | } 168 | */ 169 | public List> getMultiSelectMapListInner() { 170 | for (int i = 0; i < mMultiSelectMapListInner.size(); i++) { 171 | if (isSelectedMap.get(i)){ 172 | mMultiSelectMapListInner.get(i).put("checked",true); 173 | }else{ 174 | mMultiSelectMapListInner.get(i).put("checked",false); 175 | } 176 | } 177 | return mMultiSelectMapListInner; 178 | } 179 | 180 | public Boolean isAllSeleted(){ 181 | boolean isAllSeleted=true; 182 | for (int i = 0; i < isSelectedMap.size(); i++) { 183 | if (!isSelectedMap.get(i)){//有一个未选择 就算没全选 184 | isAllSeleted=false;// 185 | break; 186 | } 187 | } 188 | return isAllSeleted; 189 | } 190 | 191 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/adapter/MultiSelectViewRecycleViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.CheckBox; 9 | import android.widget.CompoundButton; 10 | 11 | import com.louisgeek.dropdownviewlib.R; 12 | 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | /** 17 | * 可见的view适配器 18 | * Created by louisgeek on 2016/6/20. 19 | */ 20 | public class MultiSelectViewRecycleViewAdapter extends RecyclerView.Adapter{ 21 | private int mShowCount; 22 | // private final int NORMAL_ITEM=0; 23 | // private final int MORE_ITEM=1; 24 | public MultiSelectViewRecycleViewAdapter(List> dataList, Context context,int showCount) { 25 | mDataList = dataList; 26 | mContext = context; 27 | mShowCount=showCount; 28 | } 29 | 30 | private List> mDataList; 31 | private Context mContext; 32 | @Override 33 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 34 | View view = LayoutInflater.from(mContext).inflate(R.layout.mutiselect_enter_list_item, parent,false); 35 | 36 | MyRecyclerViewHolder myRecyclerViewHolder = new MyRecyclerViewHolder(view); 37 | return myRecyclerViewHolder; 38 | } 39 | 40 | @Override 41 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 42 | MyRecyclerViewHolder myRecyclerViewHolder = (MyRecyclerViewHolder) holder; 43 | // myRecyclerViewHolder.item_tv.setText(mDataList.get(position).get("name").toString()); 44 | myRecyclerViewHolder.item_cb.setTag(R.id.hold_check_pos,position); 45 | myRecyclerViewHolder.item_cb.setText(mDataList.get(position).get("name").toString()); 46 | myRecyclerViewHolder.item_cb.setChecked(Boolean.parseBoolean(String.valueOf(mDataList.get(position).get("checked")))); 47 | } 48 | 49 | @Override 50 | public int getItemCount() { 51 | return mDataList.size(); 52 | // return mDataList.size()> multiSelectMapList){ 75 | mDataList.clear(); 76 | mDataList.addAll(multiSelectMapList); 77 | 78 | this.notifyDataSetChanged(); 79 | } 80 | 81 | public interface OnCheckboxSelectListener{ 82 | void onCheckboxSelect(int pos,boolean isChecked); 83 | } 84 | 85 | public void setOnCheckboxSelectListener(OnCheckboxSelectListener onCheckboxSelectListener) { 86 | this.onCheckboxSelectListener = onCheckboxSelectListener; 87 | } 88 | 89 | OnCheckboxSelectListener onCheckboxSelectListener; 90 | 91 | 92 | 93 | } 94 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/adapter/MyRecylerViewLeftAdapter.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import com.louisgeek.dropdownviewlib.R; 10 | import com.louisgeek.dropdownviewlib.javabean.ClassfiyBean; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by louisgeek on 2016/8/9. 16 | */ 17 | public class MyRecylerViewLeftAdapter extends RecyclerView.Adapter { 18 | 19 | // private Map selectedStateMap=new HashMap<>(); 20 | private List mClassfiyBeanList; 21 | // int mParentSelectedPos; 22 | public MyRecylerViewLeftAdapter(List classfiyBeanList) { 23 | mClassfiyBeanList = classfiyBeanList; 24 | // mParentSelectedPos=parentSelectedPos; 25 | } 26 | @Override 27 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 28 | View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.left_item,parent,false); 29 | return new MyRecyclerViewViewHolder(view); 30 | } 31 | 32 | @Override 33 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { 34 | MyRecyclerViewViewHolder myRecyclerViewViewHolder= (MyRecyclerViewViewHolder) holder; 35 | myRecyclerViewViewHolder.mTextViewName.setText(mClassfiyBeanList.get(position).getName()); 36 | myRecyclerViewViewHolder.mTextViewCount.setText(""+mClassfiyBeanList.get(position).getChildClassfiyBeanList().size()); 37 | myRecyclerViewViewHolder.itemView.setOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | setSelectedState(position); 41 | onItemClickListener.onItemClick(v,position); 42 | } 43 | }); 44 | myRecyclerViewViewHolder.itemView.setSelected(getSeletedState(position)); 45 | 46 | 47 | } 48 | 49 | @Override 50 | public int getItemCount() { 51 | return mClassfiyBeanList.size(); 52 | } 53 | 54 | public void clearAllSelectedState(){ 55 | for (int i = 0; i < mClassfiyBeanList.size(); i++) { 56 | mClassfiyBeanList.get(i).setSelected(false); 57 | } 58 | //this.notifyDataSetChanged(); 59 | this.notifyItemRangeChanged(0,getItemCount()); 60 | } 61 | public void setSelectedState(int position){ 62 | clearAllSelectedState(); 63 | mClassfiyBeanList.get(position).setSelected(true); 64 | //selectedStateMap.put(position,true); 65 | //this.notifyDataSetChanged(); 66 | this.notifyItemChanged(position); 67 | } 68 | private boolean getSeletedState(int position){ 69 | boolean isSelected=mClassfiyBeanList.get(position).isSelected(); 70 | return isSelected; 71 | } 72 | 73 | private class MyRecyclerViewViewHolder extends RecyclerView.ViewHolder{ 74 | 75 | TextView mTextViewName; 76 | TextView mTextViewCount; 77 | 78 | public MyRecyclerViewViewHolder(View itemView) { 79 | super(itemView); 80 | mTextViewName= (TextView) itemView.findViewById(R.id.id_tv_name); 81 | 82 | mTextViewCount= (TextView) itemView.findViewById(R.id.id_tv_count); 83 | } 84 | } 85 | 86 | public interface OnItemClickListener{ 87 | void onItemClick(View v, int pos); 88 | } 89 | 90 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) { 91 | this.onItemClickListener = onItemClickListener; 92 | } 93 | 94 | public OnItemClickListener onItemClickListener; 95 | } 96 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/adapter/MyRecylerViewOnlyOneAdapter.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.louisgeek.dropdownviewlib.R; 11 | import com.louisgeek.dropdownviewlib.javabean.ClassfiyBean; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Created by louisgeek on 2016/8/9. 17 | */ 18 | public class MyRecylerViewOnlyOneAdapter extends RecyclerView.Adapter { 19 | 20 | // private Map selectedStateMap=new HashMap<>(); 21 | private List mClassfiyBeanList; 22 | // int mParentSelectedPos; 23 | public MyRecylerViewOnlyOneAdapter(List classfiyBeanList) { 24 | mClassfiyBeanList = classfiyBeanList; 25 | // mParentSelectedPos=parentSelectedPos; 26 | } 27 | @Override 28 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 29 | View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.item,parent,false); 30 | return new MyRecyclerViewViewHolder(view); 31 | } 32 | 33 | @Override 34 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { 35 | MyRecyclerViewViewHolder myRecyclerViewViewHolder= (MyRecyclerViewViewHolder) holder; 36 | myRecyclerViewViewHolder.mTextViewName.setText(mClassfiyBeanList.get(position).getName()); 37 | myRecyclerViewViewHolder.itemView.setOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | setSelectedState(position); 41 | onItemClickListener.onItemClick(v,position); 42 | } 43 | }); 44 | myRecyclerViewViewHolder.itemView.setSelected(getSeletedState(position)); 45 | if (myRecyclerViewViewHolder.itemView.isSelected()){ 46 | myRecyclerViewViewHolder.id_iv_icon.setVisibility(View.VISIBLE); 47 | }else{ 48 | myRecyclerViewViewHolder.id_iv_icon.setVisibility(View.INVISIBLE); 49 | } 50 | 51 | } 52 | 53 | @Override 54 | public int getItemCount() { 55 | return mClassfiyBeanList.size(); 56 | } 57 | 58 | public void clearAllSelectedState(){ 59 | for (int i = 0; i < mClassfiyBeanList.size(); i++) { 60 | mClassfiyBeanList.get(i).setSelected(false); 61 | } 62 | //this.notifyDataSetChanged(); 63 | this.notifyItemRangeChanged(0,getItemCount()); 64 | } 65 | public void setSelectedState(int position){ 66 | clearAllSelectedState(); 67 | mClassfiyBeanList.get(position).setSelected(true); 68 | //selectedStateMap.put(position,true); 69 | //this.notifyDataSetChanged(); 70 | this.notifyItemChanged(position); 71 | } 72 | private boolean getSeletedState(int position){ 73 | boolean isSelected=mClassfiyBeanList.get(position).isSelected(); 74 | return isSelected; 75 | } 76 | 77 | private class MyRecyclerViewViewHolder extends RecyclerView.ViewHolder{ 78 | 79 | TextView mTextViewName; 80 | TextView mTextViewCount; 81 | ImageView id_iv_icon; 82 | public MyRecyclerViewViewHolder(View itemView) { 83 | super(itemView); 84 | mTextViewName= (TextView) itemView.findViewById(R.id.id_tv_name); 85 | mTextViewCount= (TextView) itemView.findViewById(R.id.id_tv_count); 86 | id_iv_icon= (ImageView) itemView.findViewById(R.id.id_iv_icon); 87 | } 88 | } 89 | 90 | public interface OnItemClickListener{ 91 | void onItemClick(View v, int pos); 92 | } 93 | 94 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) { 95 | this.onItemClickListener = onItemClickListener; 96 | } 97 | 98 | public OnItemClickListener onItemClickListener; 99 | } 100 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/adapter/MyRecylerViewRightAdapter.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.louisgeek.dropdownviewlib.R; 11 | import com.louisgeek.dropdownviewlib.javabean.ClassfiyBean; 12 | 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | /** 18 | * Created by louisgeek on 2016/8/9. 19 | */ 20 | public class MyRecylerViewRightAdapter extends RecyclerView.Adapter { 21 | 22 | private final int TYPE_VIEW_ALL=1; 23 | private final int TYPE_VIEW_NORMAL=2; 24 | 25 | private Map theAllSelectedStateMap=new HashMap<>(); 26 | public MyRecylerViewRightAdapter(List classfiyBeanList, int parentPos) { 27 | mClassfiyBeanList = classfiyBeanList; 28 | this.parentPos = parentPos; 29 | // dealThenSetTheAllSelectedState(); 30 | } 31 | 32 | private void dealThenSetTheAllSelectedState() { 33 | for (int i = 0; i < mClassfiyBeanList.size(); i++) { 34 | boolean childNoOneHasSelected=true; 35 | for (int j = 0; j < mClassfiyBeanList.get(i).getChildClassfiyBeanList().size(); j++) { 36 | if (mClassfiyBeanList.get(i).getChildClassfiyBeanList().get(j).isSelected()){ 37 | childNoOneHasSelected=false; 38 | break; 39 | } 40 | } 41 | if (childNoOneHasSelected){ 42 | theAllSelectedStateMap.put(i,true); 43 | } 44 | } 45 | 46 | } 47 | 48 | private List mClassfiyBeanList; 49 | private int parentPos; 50 | // int mChildSelectedPos; 51 | @Override 52 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 53 | View view; 54 | RecyclerView.ViewHolder myRecyclerViewViewHolder = null; 55 | switch (viewType){ 56 | case TYPE_VIEW_NORMAL: 57 | view= LayoutInflater.from(parent.getContext()).inflate(R.layout.right_item_normal,parent,false); 58 | myRecyclerViewViewHolder=new MyRecyclerViewViewNormalHolder(view); 59 | break; 60 | case TYPE_VIEW_ALL: 61 | view= LayoutInflater.from(parent.getContext()).inflate(R.layout.right_item_all,parent,false); 62 | myRecyclerViewViewHolder=new MyRecyclerViewViewAllHolder(view); 63 | break; 64 | } 65 | return myRecyclerViewViewHolder; 66 | } 67 | 68 | @Override 69 | public int getItemViewType(int position) { 70 | if (position==0){ 71 | return TYPE_VIEW_ALL; 72 | }else { 73 | return TYPE_VIEW_NORMAL; 74 | } 75 | //return super.getItemViewType(position); 76 | } 77 | 78 | @Override 79 | public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { 80 | 81 | MyRecyclerViewViewNormalHolder myRecyclerViewViewNormalHolder; 82 | MyRecyclerViewViewAllHolder myRecyclerViewViewAllHolder; 83 | if (holder instanceof MyRecyclerViewViewNormalHolder){ 84 | myRecyclerViewViewNormalHolder= (MyRecyclerViewViewNormalHolder) holder; 85 | final int realPos=position-1; 86 | myRecyclerViewViewNormalHolder.mTextViewName.setText(mClassfiyBeanList.get(parentPos).getChildClassfiyBeanList().get(realPos).getName()); 87 | myRecyclerViewViewNormalHolder.mTextViewCount.setText(mClassfiyBeanList.get(parentPos).getChildClassfiyBeanList().get(realPos).getCount()); 88 | 89 | // 90 | myRecyclerViewViewNormalHolder.itemView.setOnClickListener(new View.OnClickListener() { 91 | @Override 92 | public void onClick(View v) { 93 | setNormalSelectedState(realPos); 94 | if (onItemClickListener!=null){ 95 | onItemClickListener.onItemClickNormal(v,mClassfiyBeanList,parentPos,realPos); 96 | } 97 | } 98 | }); 99 | myRecyclerViewViewNormalHolder.itemView.setSelected(getNormalSeletedState(realPos)); 100 | if (myRecyclerViewViewNormalHolder.itemView.isSelected()){ 101 | myRecyclerViewViewNormalHolder.id_iv_icon.setVisibility(View.VISIBLE); 102 | }else{ 103 | myRecyclerViewViewNormalHolder.id_iv_icon.setVisibility(View.INVISIBLE); 104 | } 105 | 106 | }else if (holder instanceof MyRecyclerViewViewAllHolder){ 107 | myRecyclerViewViewAllHolder= (MyRecyclerViewViewAllHolder) holder; 108 | myRecyclerViewViewAllHolder.mTextViewName.setText("全部"); 109 | myRecyclerViewViewAllHolder.itemView.setTag(myRecyclerViewViewAllHolder.mTextViewName.getText()); 110 | myRecyclerViewViewAllHolder.itemView.setOnClickListener(new View.OnClickListener() { 111 | @Override 112 | public void onClick(View v) { 113 | // setSelectedState(position); 114 | setTheAllSelectedState(parentPos); 115 | onItemClickListener.onItemClickAll(v,mClassfiyBeanList,parentPos); 116 | } 117 | }); 118 | myRecyclerViewViewAllHolder.itemView.setSelected(getTheAllSeletedState(parentPos)); 119 | if (myRecyclerViewViewAllHolder.itemView.isSelected()){ 120 | myRecyclerViewViewAllHolder.id_iv_icon.setVisibility(View.VISIBLE); 121 | }else{ 122 | myRecyclerViewViewAllHolder.id_iv_icon.setVisibility(View.INVISIBLE); 123 | } 124 | } 125 | 126 | } 127 | 128 | public void updateParentPos(int parentPos){ 129 | this.parentPos=parentPos; 130 | this.notifyDataSetChanged(); 131 | } 132 | 133 | @Override 134 | public int getItemCount() { 135 | return mClassfiyBeanList.get(parentPos).getChildClassfiyBeanList().size()+1; 136 | } 137 | public void clearNormalSelectedState(){ 138 | for (int i = 0; i < mClassfiyBeanList.get(parentPos).getChildClassfiyBeanList().size(); i++) { 139 | mClassfiyBeanList.get(parentPos).getChildClassfiyBeanList().get(i).setSelected(false); 140 | } 141 | this.notifyDataSetChanged(); 142 | // this.notifyItemRangeChanged(0,getItemCount());//不包括pos==0 143 | } 144 | public void setNormalSelectedState(int position){ 145 | clearTheAllAndNormalSelectedState(); 146 | mClassfiyBeanList.get(parentPos).getChildClassfiyBeanList().get(position).setSelected(true); 147 | this.notifyDataSetChanged(); 148 | // this.notifyItemRangeChanged(0,getItemCount()); 149 | } 150 | private boolean getNormalSeletedState(int position){ 151 | boolean isSelected=mClassfiyBeanList.get(parentPos).getChildClassfiyBeanList().get(position).isSelected(); 152 | return isSelected; 153 | } 154 | public void clearTheAllSelectedState(){ 155 | for (int key : theAllSelectedStateMap.keySet()) { 156 | // System.out.println("key= "+ key + " and value= " + map.get(key)); 157 | theAllSelectedStateMap.put(key,false); 158 | } 159 | this.notifyDataSetChanged(); 160 | // this.notifyItemRangeChanged(0,getItemCount()); 161 | } 162 | public void clearTheAllAndNormalSelectedState(){ 163 | clearNormalSelectedState(); 164 | clearTheAllSelectedState(); 165 | } 166 | public void setTheAllSelectedState(int parentPos){ 167 | clearTheAllAndNormalSelectedState(); 168 | 169 | theAllSelectedStateMap.put(parentPos,true); 170 | this.notifyDataSetChanged(); 171 | //this.notifyItemRangeChanged(0,getItemCount()); 172 | } 173 | private boolean getTheAllSeletedState(int parentPos){ 174 | boolean isSelect=false; 175 | if (theAllSelectedStateMap.get(parentPos)!=null){ 176 | isSelect=theAllSelectedStateMap.get(parentPos); 177 | } 178 | return isSelect; 179 | } 180 | class MyRecyclerViewViewNormalHolder extends RecyclerView.ViewHolder{ 181 | 182 | TextView mTextViewName; 183 | TextView mTextViewCount; 184 | ImageView id_iv_icon; 185 | public MyRecyclerViewViewNormalHolder(View itemView) { 186 | super(itemView); 187 | id_iv_icon= (ImageView) itemView.findViewById(R.id.id_iv_icon); 188 | mTextViewName= (TextView) itemView.findViewById(R.id.id_tv_name); 189 | mTextViewCount= (TextView) itemView.findViewById(R.id.id_tv_count); 190 | } 191 | } 192 | 193 | class MyRecyclerViewViewAllHolder extends RecyclerView.ViewHolder{ 194 | 195 | TextView mTextViewName; 196 | ImageView id_iv_icon; 197 | public MyRecyclerViewViewAllHolder(View itemView) { 198 | super(itemView); 199 | id_iv_icon= (ImageView) itemView.findViewById(R.id.id_iv_icon); 200 | mTextViewName= (TextView) itemView.findViewById(R.id.id_tv_name); 201 | } 202 | } 203 | 204 | public interface OnItemClickListener{ 205 | void onItemClickNormal(View v, List classfiyBeanList, int parentPos, int childPos); 206 | void onItemClickAll(View v, List classfiyBeanList, int parentPos); 207 | } 208 | 209 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) { 210 | this.onItemClickListener = onItemClickListener; 211 | } 212 | 213 | public OnItemClickListener onItemClickListener; 214 | } 215 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/decoration/GridSpacingItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.decoration; 2 | 3 | /** 4 | * Created by louisgeek on 2016/6/21. 5 | */ 6 | 7 | import android.graphics.Rect; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.View; 10 | 11 | /** 12 | * int spanCount = 3; // 3 columns 13 | int spacing = 50; // 50px 14 | boolean includeEdge = false; // includeEdge贴边 15 | */ 16 | public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration { 17 | 18 | private int spanCount; 19 | private int spacing; 20 | private boolean includeEdge; 21 | 22 | public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) { 23 | this.spanCount = spanCount; 24 | this.spacing = spacing; 25 | this.includeEdge = includeEdge; 26 | } 27 | 28 | @Override 29 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 30 | int position = parent.getChildAdapterPosition(view); // item position 31 | int column = position % spanCount; // item column 32 | 33 | if (includeEdge) { 34 | outRect.left = spacing - column * spacing / spanCount; // spacing - column * ((1f / spanCount) * spacing) 35 | outRect.right = (column + 1) * spacing / spanCount; // (column + 1) * ((1f / spanCount) * spacing) 36 | 37 | if (position < spanCount) { // top edge 38 | outRect.top = spacing; 39 | } 40 | outRect.bottom = spacing; // item bottom 41 | } else { 42 | outRect.left = column * spacing / spanCount; // column * ((1f / spanCount) * spacing) 43 | outRect.right = spacing - (column + 1) * spacing / spanCount; // spacing - (column + 1) * ((1f / spanCount) * spacing) 44 | if (position >= spanCount) { 45 | outRect.top = spacing; // item top 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/decoration/ItemOffsetDecoration.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.decoration; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.support.annotation.DimenRes; 6 | import android.support.annotation.NonNull; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.View; 9 | 10 | /** 11 | * mRecyclerView.setLayoutManager(new GridLayoutManager(context, NUM_COLUMNS); 12 | ItemOffsetDecoration itemDecoration = new ItemOffsetDecoration(context, R.dimen.item_offset); 13 | mRecyclerView.addItemDecoration(itemDecoration); 14 | * Created by louisgeek on 2016/6/21. 15 | */ 16 | public class ItemOffsetDecoration extends RecyclerView.ItemDecoration { 17 | 18 | private int mItemOffset; 19 | 20 | public ItemOffsetDecoration(int itemOffset) { 21 | mItemOffset = itemOffset; 22 | } 23 | 24 | public ItemOffsetDecoration(@NonNull Context context, @DimenRes int itemOffsetId) { 25 | this(context.getResources().getDimensionPixelSize(itemOffsetId)); 26 | } 27 | 28 | @Override 29 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, 30 | RecyclerView.State state) { 31 | super.getItemOffsets(outRect, view, parent, state); 32 | outRect.set(mItemOffset, mItemOffset, mItemOffset, mItemOffset); 33 | } 34 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/decoration/ListSpacingDecoration.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.decoration; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.support.annotation.DimenRes; 6 | import android.support.v7.widget.GridLayoutManager; 7 | import android.support.v7.widget.LinearLayoutManager; 8 | import android.support.v7.widget.OrientationHelper; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.support.v7.widget.StaggeredGridLayoutManager; 11 | import android.view.View; 12 | 13 | /** 14 | * Created by louisgeek on 2016/6/21. 15 | */ 16 | public class ListSpacingDecoration extends RecyclerView.ItemDecoration { 17 | 18 | private static final int VERTICAL = OrientationHelper.VERTICAL; 19 | 20 | private int orientation = -1; 21 | private int spanCount = -1; 22 | private int spacing; 23 | private int halfSpacing; 24 | 25 | 26 | public ListSpacingDecoration(Context context, @DimenRes int spacingDimen) { 27 | 28 | spacing = context.getResources().getDimensionPixelSize(spacingDimen); 29 | halfSpacing = spacing / 2; 30 | } 31 | 32 | public ListSpacingDecoration(int spacingPx) { 33 | 34 | spacing = spacingPx; 35 | halfSpacing = spacing / 2; 36 | } 37 | 38 | @Override 39 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 40 | 41 | super.getItemOffsets(outRect, view, parent, state); 42 | 43 | if (orientation == -1) { 44 | orientation = getOrientation(parent); 45 | } 46 | 47 | if (spanCount == -1) { 48 | spanCount = getTotalSpan(parent); 49 | } 50 | 51 | int childCount = parent.getLayoutManager().getItemCount(); 52 | int childIndex = parent.getChildAdapterPosition(view); 53 | 54 | int itemSpanSize = getItemSpanSize(parent, childIndex); 55 | int spanIndex = getItemSpanIndex(parent, childIndex); 56 | 57 | /* INVALID SPAN */ 58 | if (spanCount < 1) return; 59 | 60 | setSpacings(outRect, parent, childCount, childIndex, itemSpanSize, spanIndex); 61 | } 62 | 63 | protected void setSpacings(Rect outRect, RecyclerView parent, int childCount, int childIndex, int itemSpanSize, int spanIndex) { 64 | 65 | outRect.top = halfSpacing; 66 | outRect.bottom = halfSpacing; 67 | outRect.left = halfSpacing; 68 | outRect.right = halfSpacing; 69 | 70 | if (isTopEdge(parent, childCount, childIndex, itemSpanSize, spanIndex)) { 71 | outRect.top = spacing; 72 | } 73 | 74 | if (isLeftEdge(parent, childCount, childIndex, itemSpanSize, spanIndex)) { 75 | outRect.left = spacing; 76 | } 77 | 78 | if (isRightEdge(parent, childCount, childIndex, itemSpanSize, spanIndex)) { 79 | outRect.right = spacing; 80 | } 81 | 82 | if (isBottomEdge(parent, childCount, childIndex, itemSpanSize, spanIndex)) { 83 | outRect.bottom = spacing; 84 | } 85 | } 86 | 87 | @SuppressWarnings("all") 88 | protected int getTotalSpan(RecyclerView parent) { 89 | 90 | RecyclerView.LayoutManager mgr = parent.getLayoutManager(); 91 | if (mgr instanceof GridLayoutManager) { 92 | return ((GridLayoutManager) mgr).getSpanCount(); 93 | } else if (mgr instanceof StaggeredGridLayoutManager) { 94 | return ((StaggeredGridLayoutManager) mgr).getSpanCount(); 95 | } else if (mgr instanceof LinearLayoutManager) { 96 | return 1; 97 | } 98 | 99 | return -1; 100 | } 101 | 102 | @SuppressWarnings("all") 103 | protected int getItemSpanSize(RecyclerView parent, int childIndex) { 104 | 105 | RecyclerView.LayoutManager mgr = parent.getLayoutManager(); 106 | if (mgr instanceof GridLayoutManager) { 107 | return ((GridLayoutManager) mgr).getSpanSizeLookup().getSpanSize(childIndex); 108 | } else if (mgr instanceof StaggeredGridLayoutManager) { 109 | return 1; 110 | } else if (mgr instanceof LinearLayoutManager) { 111 | return 1; 112 | } 113 | 114 | return -1; 115 | } 116 | 117 | @SuppressWarnings("all") 118 | protected int getItemSpanIndex(RecyclerView parent, int childIndex) { 119 | 120 | RecyclerView.LayoutManager mgr = parent.getLayoutManager(); 121 | if (mgr instanceof GridLayoutManager) { 122 | return ((GridLayoutManager) mgr).getSpanSizeLookup().getSpanIndex(childIndex, spanCount); 123 | } else if (mgr instanceof StaggeredGridLayoutManager) { 124 | return childIndex % spanCount; 125 | } else if (mgr instanceof LinearLayoutManager) { 126 | return 0; 127 | } 128 | 129 | return -1; 130 | } 131 | 132 | @SuppressWarnings("all") 133 | protected int getOrientation(RecyclerView parent) { 134 | 135 | RecyclerView.LayoutManager mgr = parent.getLayoutManager(); 136 | if (mgr instanceof LinearLayoutManager) { 137 | return ((LinearLayoutManager) mgr).getOrientation(); 138 | } else if (mgr instanceof GridLayoutManager) { 139 | return ((GridLayoutManager) mgr).getOrientation(); 140 | } else if (mgr instanceof StaggeredGridLayoutManager) { 141 | return ((StaggeredGridLayoutManager) mgr).getOrientation(); 142 | } 143 | 144 | return VERTICAL; 145 | } 146 | 147 | protected boolean isLeftEdge(RecyclerView parent, int childCount, int childIndex, int itemSpanSize, int spanIndex) { 148 | 149 | if (orientation == VERTICAL) { 150 | 151 | return spanIndex == 0; 152 | 153 | } else { 154 | 155 | return (childIndex == 0) || isFirstItemEdgeValid((childIndex < spanCount), parent, childIndex); 156 | } 157 | } 158 | 159 | protected boolean isRightEdge(RecyclerView parent, int childCount, int childIndex, int itemSpanSize, int spanIndex) { 160 | 161 | if (orientation == VERTICAL) { 162 | 163 | return (spanIndex + itemSpanSize) == spanCount; 164 | 165 | } else { 166 | 167 | return isLastItemEdgeValid((childIndex >= childCount - spanCount), parent, childCount, childIndex, spanIndex); 168 | } 169 | } 170 | 171 | protected boolean isTopEdge(RecyclerView parent, int childCount, int childIndex, int itemSpanSize, int spanIndex) { 172 | 173 | if (orientation == VERTICAL) { 174 | 175 | return (childIndex == 0) || isFirstItemEdgeValid((childIndex < spanCount), parent, childIndex); 176 | 177 | } else { 178 | 179 | return spanIndex == 0; 180 | } 181 | } 182 | 183 | protected boolean isBottomEdge(RecyclerView parent, int childCount, int childIndex, int itemSpanSize, int spanIndex) { 184 | 185 | if (orientation == VERTICAL) { 186 | 187 | return isLastItemEdgeValid((childIndex >= childCount - spanCount), parent, childCount, childIndex, spanIndex); 188 | 189 | } else { 190 | 191 | return (spanIndex + itemSpanSize) == spanCount; 192 | } 193 | } 194 | 195 | protected boolean isFirstItemEdgeValid(boolean isOneOfFirstItems, RecyclerView parent, int childIndex) { 196 | 197 | int totalSpanArea = 0; 198 | if (isOneOfFirstItems) { 199 | for (int i = childIndex; i >= 0; i--) { 200 | totalSpanArea = totalSpanArea + getItemSpanSize(parent, i); 201 | } 202 | } 203 | 204 | return isOneOfFirstItems && totalSpanArea <= spanCount; 205 | } 206 | 207 | protected boolean isLastItemEdgeValid(boolean isOneOfLastItems, RecyclerView parent, int childCount, int childIndex, int spanIndex) { 208 | 209 | int totalSpanRemaining = 0; 210 | if (isOneOfLastItems) { 211 | for (int i = childIndex; i < childCount; i++) { 212 | totalSpanRemaining = totalSpanRemaining + getItemSpanSize(parent, i); 213 | } 214 | } 215 | 216 | return isOneOfLastItems && (totalSpanRemaining <= spanCount - spanIndex); 217 | } 218 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/decoration/SpacesItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.decoration; 2 | 3 | import android.graphics.Rect; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | 7 | /** 8 | * mRecyclerView = (RecyclerView) rootView.findViewById(R.id.my_recycler_view); 9 | int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.spacing); 10 | mRecyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels)); 11 | 12 | * Created by louisgeek on 2016/6/21. 13 | */ 14 | public class SpacesItemDecoration extends RecyclerView.ItemDecoration { 15 | private int space; 16 | 17 | public SpacesItemDecoration(int space) { 18 | this.space = space; 19 | } 20 | 21 | @Override 22 | public void getItemOffsets(Rect outRect, View view, 23 | RecyclerView parent, RecyclerView.State state) { 24 | outRect.left = space; 25 | outRect.right = space; 26 | outRect.bottom = space; 27 | 28 | // Add top margin only for the first item to avoid double space between items 29 | if (parent.getChildLayoutPosition(view) == 0) { 30 | outRect.top = space; 31 | } else { 32 | outRect.top = 0; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/decoration/SpacesItemDecorationTwo.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.decoration; 2 | 3 | import android.graphics.Rect; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | 7 | /** 8 | * mRecyclerView.addItemDecoration(new SpacesItemDecoration(mMargin)); 9 | * Created by louisgeek on 2016/6/21. 10 | */ 11 | public class SpacesItemDecorationTwo extends RecyclerView.ItemDecoration { 12 | 13 | private int halfSpace; 14 | 15 | public SpacesItemDecorationTwo(int space) { 16 | this.halfSpace = space / 2; 17 | } 18 | 19 | @Override 20 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 21 | 22 | if (parent.getPaddingLeft() != halfSpace) { 23 | parent.setPadding(halfSpace, halfSpace, halfSpace, halfSpace); 24 | parent.setClipToPadding(false); 25 | } 26 | 27 | outRect.top = halfSpace; 28 | outRect.bottom = halfSpace; 29 | outRect.left = halfSpace; 30 | outRect.right = halfSpace; 31 | } 32 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/javabean/Area.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.javabean; 2 | 3 | /** 4 | * Created by louisgeek on 2016/5/30. 5 | */ 6 | public class Area { 7 | private String areaID; 8 | private String areaName; 9 | 10 | public Area(String areaID, String areaName, String areaSimpleName, String areaEnName) { 11 | this.areaID = areaID; 12 | this.areaName = areaName; 13 | this.areaSimpleName = areaSimpleName; 14 | this.areaEnName = areaEnName; 15 | } 16 | 17 | private String areaSimpleName; 18 | private String areaEnName; 19 | 20 | public String getAreaID() { 21 | return areaID; 22 | } 23 | 24 | public void setAreaID(String areaID) { 25 | this.areaID = areaID; 26 | } 27 | 28 | public String getAreaName() { 29 | return areaName; 30 | } 31 | 32 | public void setAreaName(String areaName) { 33 | this.areaName = areaName; 34 | } 35 | 36 | public String getAreaSimpleName() { 37 | return areaSimpleName; 38 | } 39 | 40 | public void setAreaSimpleName(String areaSimpleName) { 41 | this.areaSimpleName = areaSimpleName; 42 | } 43 | 44 | public String getAreaEnName() { 45 | return areaEnName; 46 | } 47 | 48 | public void setAreaEnName(String areaEnName) { 49 | this.areaEnName = areaEnName; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/javabean/City.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.javabean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by louisgeek on 2016/5/30. 7 | */ 8 | public class City { 9 | private String cityID; 10 | private String cityName; 11 | 12 | public City(String cityID, String cityName, String citySimpleName, String cityEnName, List areas) { 13 | this.cityID = cityID; 14 | this.cityName = cityName; 15 | this.citySimpleName = citySimpleName; 16 | this.cityEnName = cityEnName; 17 | this.areas = areas; 18 | } 19 | 20 | private String citySimpleName; 21 | private String cityEnName; 22 | private List areas; 23 | 24 | public String getCityID() { 25 | return cityID; 26 | } 27 | 28 | public void setCityID(String cityID) { 29 | this.cityID = cityID; 30 | } 31 | 32 | public String getCityName() { 33 | return cityName; 34 | } 35 | 36 | public void setCityName(String cityName) { 37 | this.cityName = cityName; 38 | } 39 | 40 | public String getCitySimpleName() { 41 | return citySimpleName; 42 | } 43 | 44 | public void setCitySimpleName(String citySimpleName) { 45 | this.citySimpleName = citySimpleName; 46 | } 47 | 48 | public String getCityEnName() { 49 | return cityEnName; 50 | } 51 | 52 | public void setCityEnName(String cityEnName) { 53 | this.cityEnName = cityEnName; 54 | } 55 | 56 | public List getAreas() { 57 | return areas; 58 | } 59 | 60 | public void setAreas(List areas) { 61 | this.areas = areas; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/javabean/ClassfiyBean.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.javabean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by louisgeek on 2016/8/9. 7 | */ 8 | public class ClassfiyBean { 9 | private int ID; 10 | private String beanID; 11 | private String name; 12 | 13 | public boolean isSelected() { 14 | return selected; 15 | } 16 | 17 | public void setSelected(boolean selected) { 18 | this.selected = selected; 19 | } 20 | 21 | private boolean selected; 22 | public List getChildClassfiyBeanList() { 23 | return childClassfiyBeanList; 24 | } 25 | 26 | public void setChildClassfiyBeanList(List childClassfiyBeanList) { 27 | this.childClassfiyBeanList = childClassfiyBeanList; 28 | } 29 | 30 | private List childClassfiyBeanList; 31 | public int getID() { 32 | return ID; 33 | } 34 | 35 | public void setID(int ID) { 36 | this.ID = ID; 37 | } 38 | 39 | public String getBeanID() { 40 | return beanID; 41 | } 42 | 43 | public void setBeanID(String beanID) { 44 | this.beanID = beanID; 45 | } 46 | 47 | public String getName() { 48 | return name; 49 | } 50 | 51 | public void setName(String name) { 52 | this.name = name; 53 | } 54 | 55 | public static class ChildClassfiyBean{ 56 | private int ID; 57 | private String beanID; 58 | private String name; 59 | private String count; 60 | 61 | public boolean isSelected() { 62 | return selected; 63 | } 64 | 65 | public void setSelected(boolean selected) { 66 | this.selected = selected; 67 | } 68 | 69 | private boolean selected; 70 | public int getID() { 71 | return ID; 72 | } 73 | 74 | public void setID(int ID) { 75 | this.ID = ID; 76 | } 77 | 78 | public String getBeanID() { 79 | return beanID; 80 | } 81 | 82 | public void setBeanID(String beanID) { 83 | this.beanID = beanID; 84 | } 85 | 86 | public String getName() { 87 | return name; 88 | } 89 | 90 | public void setName(String name) { 91 | this.name = name; 92 | } 93 | 94 | public String getCount() { 95 | return count; 96 | } 97 | 98 | public void setCount(String count) { 99 | this.count = count; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/javabean/MultiSelectHasChildBean.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.javabean; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by louisgeek on 2016/7/25. 8 | */ 9 | public class MultiSelectHasChildBean { 10 | private int ID ; 11 | private String key; 12 | private String name; 13 | 14 | public int getID() { 15 | return ID; 16 | } 17 | 18 | public void setID(int ID) { 19 | this.ID = ID; 20 | } 21 | 22 | public String getKey() { 23 | return key; 24 | } 25 | 26 | public void setKey(String key) { 27 | this.key = key; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public List> getMultiSelectMapList() { 39 | return mMultiSelectMapList; 40 | } 41 | 42 | public void setMultiSelectMapList(List> multiSelectMapList) { 43 | mMultiSelectMapList = multiSelectMapList; 44 | } 45 | 46 | private List> mMultiSelectMapList; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/javabean/ProCate.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.javabean; 2 | 3 | import java.util.List; 4 | 5 | public class ProCate { 6 | 7 | /** 8 | * cateid : 0_1 9 | * catename : 瓜菜类 10 | * children : [{"cateid":"1_2","catename":"甜瓜"},{"cateid":"1_3","catename":"黄瓜"}] 11 | */ 12 | 13 | private List cates; 14 | 15 | public List getCates() { 16 | return cates; 17 | } 18 | 19 | public void setCates(List cates) { 20 | this.cates = cates; 21 | } 22 | 23 | public static class CatesBean { 24 | private String cateid; 25 | private String catename; 26 | /** 27 | * cateid : 1_2 28 | * catename : 甜瓜 29 | */ 30 | 31 | private List children; 32 | 33 | public String getCateid() { 34 | return cateid; 35 | } 36 | 37 | public void setCateid(String cateid) { 38 | this.cateid = cateid; 39 | } 40 | 41 | public String getCatename() { 42 | return catename; 43 | } 44 | 45 | public void setCatename(String catename) { 46 | this.catename = catename; 47 | } 48 | 49 | public List getChildren() { 50 | return children; 51 | } 52 | 53 | public void setChildren(List children) { 54 | this.children = children; 55 | } 56 | 57 | public static class ChildrenBean { 58 | private String cateid; 59 | private String catename; 60 | 61 | public String getCateid() { 62 | return cateid; 63 | } 64 | 65 | public void setCateid(String cateid) { 66 | this.cateid = cateid; 67 | } 68 | 69 | public String getCatename() { 70 | return catename; 71 | } 72 | 73 | public void setCatename(String catename) { 74 | this.catename = catename; 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/javabean/Province.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.javabean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by louisgeek on 2016/5/30. 7 | */ 8 | public class Province { 9 | private String provinceID; 10 | private String provinceName; 11 | private String provinceSimpleName; 12 | private String provinceEnName; 13 | 14 | public Province(String provinceID, String provinceName, String provinceSimpleName, String provinceEnName, List cites) { 15 | this.provinceID = provinceID; 16 | this.provinceName = provinceName; 17 | this.provinceSimpleName = provinceSimpleName; 18 | this.provinceEnName = provinceEnName; 19 | this.cites = cites; 20 | } 21 | 22 | private List cites; 23 | 24 | public String getProvinceID() { 25 | return provinceID; 26 | } 27 | 28 | public void setProvinceID(String provinceID) { 29 | this.provinceID = provinceID; 30 | } 31 | 32 | public String getProvinceName() { 33 | return provinceName; 34 | } 35 | 36 | public void setProvinceName(String provinceName) { 37 | this.provinceName = provinceName; 38 | } 39 | 40 | public String getProvinceSimpleName() { 41 | return provinceSimpleName; 42 | } 43 | 44 | public void setProvinceSimpleName(String provinceSimpleName) { 45 | this.provinceSimpleName = provinceSimpleName; 46 | } 47 | 48 | public String getProvinceEnName() { 49 | return provinceEnName; 50 | } 51 | 52 | public void setProvinceEnName(String provinceEnName) { 53 | this.provinceEnName = provinceEnName; 54 | } 55 | 56 | public List getCites() { 57 | return cites; 58 | } 59 | 60 | public void setCites(List cites) { 61 | this.cites = cites; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/tools/DateTool.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.tools; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | import java.util.GregorianCalendar; 8 | import java.util.Locale; 9 | import java.util.TimeZone; 10 | 11 | /** 12 | * Created by louisgeek on 2016/6/19. 13 | */ 14 | public class DateTool { 15 | 16 | public static final String FORMAT_DATE="yyyy-MM-dd"; 17 | public static final String FORMAT_DATE_TIME="yyyy-MM-dd HH:mm:ss"; 18 | 19 | public static final String DEFAULT_DATA="1970-01-01"; 20 | /** 21 | * 取当前China日期 22 | * @return 23 | */ 24 | public static String getChinaDate() { 25 | return parseDate2Str(new Date(),FORMAT_DATE);//取当前时间 26 | } 27 | /** 28 | * 取当前China时间 29 | * @return 30 | */ 31 | public static String getChinaDateTime() { 32 | return parseDate2Str(new Date(),FORMAT_DATE_TIME);//取当前时间 33 | } 34 | 35 | /** 36 | * 多参数 Calendar 获取日期 37 | * @param year 38 | * @param monthOfYear 39 | * @param dayOfMonth 40 | * @return 41 | */ 42 | public static String getChinaDateFromCalendar(int year,int monthOfYear,int dayOfMonth) { 43 | SimpleDateFormat sdf=new SimpleDateFormat(FORMAT_DATE, Locale.CHINA);//Locale.SIMPLIFIED_CHINESE和Locale.CHINA一样 44 | //new Data(int,int,int)过时了 45 | GregorianCalendar calendar = new GregorianCalendar(year,monthOfYear,dayOfMonth);//初始具有指定年月日的公历类对象。 46 | Long timeInMillis = calendar.getTimeInMillis(); 47 | return sdf.format(timeInMillis);//new Data()//取当前时间 48 | } 49 | /** 50 | * 多参数 Calendar 获取时间 51 | * @param year 52 | * @param monthOfYear 53 | * @param dayOfMonth 54 | * @return 55 | */ 56 | public static String getChinaDateTimeFromCalendar(int year,int monthOfYear,int dayOfMonth) { 57 | SimpleDateFormat sdf=new SimpleDateFormat(FORMAT_DATE_TIME, Locale.CHINA);//Locale.SIMPLIFIED_CHINESE和Locale.CHINA一样 58 | //new Data(int,int,int)过时了 59 | GregorianCalendar calendar = new GregorianCalendar(year,monthOfYear,dayOfMonth);//初始具有指定年月日的公历类对象。 60 | Long timeInMillis = calendar.getTimeInMillis(); 61 | return sdf.format(timeInMillis);//new Data()//取当前时间 62 | } 63 | 64 | 65 | //不推荐 好用的 66 | @Deprecated 67 | public static String getZhongGuoTime(){ 68 | System.setProperty("user.timezone", "Asia/Shanghai"); 69 | TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); 70 | TimeZone.setDefault(tz); 71 | SimpleDateFormat format = new SimpleDateFormat(FORMAT_DATE_TIME); 72 | String times = format.format(new Date()); 73 | System.out.print("日期格式---->" + times); 74 | return times; 75 | } 76 | 77 | 78 | public static Date parseStr2Date(String dateStr,String formatStr){ 79 | Date date=new Date(); 80 | SimpleDateFormat sdf = new SimpleDateFormat(formatStr, Locale.CHINA);//Locale.SIMPLIFIED_CHINESE和Locale.CHINA一样 81 | try { 82 | date=sdf.parse(dateStr); 83 | } catch (ParseException e) { 84 | e.printStackTrace(); 85 | } 86 | return date; 87 | } 88 | 89 | public static String parseDate2Str(Date date,String formatStr) { 90 | SimpleDateFormat sdf=new SimpleDateFormat(formatStr, Locale.CHINA);//Locale.SIMPLIFIED_CHINESE和Locale.CHINA一样 91 | return sdf.format(date); 92 | } 93 | 94 | 95 | 96 | public static String parseCalendar2Str(Calendar calendar,String formatStr){ 97 | Date date=parseCalendar2Date(calendar); 98 | return parseDate2Str(date,formatStr); 99 | } 100 | 101 | 102 | public static Calendar parseStr2Calendar(String dateStr,String formatStr){ 103 | Date date=parseStr2Date(dateStr,formatStr); 104 | return parseDate2Calendar(date); 105 | } 106 | 107 | public static Date parseCalendar2Date(Calendar calendar){ 108 | if (calendar==null){ 109 | calendar= Calendar.getInstance(); 110 | } 111 | Date date=calendar.getTime(); 112 | return date; 113 | } 114 | 115 | public static Calendar parseDate2Calendar(Date date){ 116 | Calendar calendar = Calendar.getInstance(); 117 | calendar.setTime(date); 118 | return calendar; 119 | } 120 | 121 | public static boolean canParseToDate(String stringMayBeDate){ 122 | if (stringMayBeDate==null){ 123 | return false; 124 | } 125 | Date date; 126 | SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE, Locale.CHINA);//Locale.SIMPLIFIED_CHINESE和Locale.CHINA一样 127 | try { 128 | date=sdf.parse(stringMayBeDate); 129 | } catch (Exception e) { 130 | return false; 131 | } 132 | return date!=null; 133 | } 134 | public static boolean canParseToDateTime(String stringMayBeDateTime){ 135 | if (stringMayBeDateTime==null){ 136 | return false; 137 | } 138 | Date date; 139 | SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_TIME, Locale.CHINA);//Locale.SIMPLIFIED_CHINESE和Locale.CHINA一样 140 | try { 141 | date=sdf.parse(stringMayBeDateTime); 142 | } catch (Exception e) { 143 | return false; 144 | } 145 | return date!=null; 146 | } 147 | 148 | public static String dealMaybeCanParseDateOrDefaultDateOrJustBackSource(String stringDateMayBe){ 149 | String temp; 150 | if (DateTool.canParseToDateTime(stringDateMayBe)||DateTool.canParseToDate(stringDateMayBe)){ 151 | //格式化时间 152 | temp=DateTool.parseDate2Str(DateTool.parseStr2Date(stringDateMayBe,DateTool.FORMAT_DATE),DateTool.FORMAT_DATE); 153 | //默认时间 154 | if(temp.equals(DEFAULT_DATA)){ 155 | temp="暂无"; 156 | } 157 | }else { 158 | temp=stringDateMayBe; 159 | } 160 | return temp; 161 | 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/tools/KeyBoardTool.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @version 1.0 2015年1月27日 3 | */ 4 | package com.louisgeek.dropdownviewlib.tools; 5 | 6 | import android.content.Context; 7 | import android.view.View; 8 | import android.view.inputmethod.InputMethodManager; 9 | 10 | /** 11 | * 键盘操作工具类 12 | * @author louisgeek 13 | * 2016年9月22日13:21:20 14 | */ 15 | public class KeyBoardTool { 16 | 17 | //隐藏虚拟键盘 18 | public static void hideKeyboard(View v) 19 | { 20 | InputMethodManager imm = ( InputMethodManager ) v.getContext( ).getSystemService( Context.INPUT_METHOD_SERVICE ); 21 | if ( imm.isActive( ) ) { 22 | imm.hideSoftInputFromWindow( v.getApplicationWindowToken( ) , 0 ); 23 | 24 | } 25 | } 26 | 27 | //显示虚拟键盘 28 | public static void showKeyboard(View v) 29 | { 30 | InputMethodManager imm = ( InputMethodManager ) v.getContext( ).getSystemService( Context.INPUT_METHOD_SERVICE ); 31 | 32 | imm.showSoftInput(v,InputMethodManager.SHOW_FORCED); 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/java/com/louisgeek/dropdownviewlib/tools/MySSQTool.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib.tools; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | 6 | import com.alibaba.fastjson.JSON; 7 | import com.louisgeek.dropdownviewlib.R; 8 | import com.louisgeek.dropdownviewlib.javabean.Area; 9 | import com.louisgeek.dropdownviewlib.javabean.City; 10 | import com.louisgeek.dropdownviewlib.javabean.ProCate; 11 | import com.louisgeek.dropdownviewlib.javabean.Province; 12 | 13 | import org.json.JSONArray; 14 | import org.json.JSONException; 15 | import org.json.JSONObject; 16 | 17 | import java.io.BufferedReader; 18 | import java.io.InputStream; 19 | import java.io.InputStreamReader; 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | /** 24 | * Created by louisgeek on 2016/6/16. 25 | */ 26 | public class MySSQTool { 27 | public static List parseJson(String ssq_json) { 28 | List provinceList = new ArrayList<>(); 29 | try { 30 | // 31 | JSONObject jsonObject = new JSONObject(ssq_json); 32 | JSONObject o_provinces = jsonObject.getJSONObject("provinces"); 33 | JSONArray a_province = o_provinces.getJSONArray("province"); 34 | //=== 35 | 36 | for (int i = 0; i < a_province.length(); i++) { 37 | JSONObject o_province = (JSONObject) a_province.get(i); 38 | String ssqid = o_province.getString("ssqid"); 39 | String ssqname = o_province.getString("ssqname"); 40 | String ssqename = o_province.getString("ssqename"); 41 | JSONObject o_cities = o_province.getJSONObject("cities"); 42 | JSONArray a_city = o_cities.getJSONArray("city"); 43 | //=== 44 | List cityList = new ArrayList<>(); 45 | for (int j = 0; j < a_city.length(); j++) { 46 | //=== 47 | JSONObject o_city = (JSONObject) a_city.get(j); 48 | String ssqid_C = o_city.getString("ssqid"); 49 | String ssqname_C = o_city.getString("ssqname"); 50 | String ssqename_C = o_city.getString("ssqename"); 51 | JSONObject o_areas_C = o_city.getJSONObject("areas"); 52 | JSONArray a_area = o_areas_C.getJSONArray("area"); 53 | //=== 54 | List areaList = new ArrayList<>(); 55 | for (int k = 0; k < a_area.length(); k++) { 56 | JSONObject O_area = (JSONObject) a_area.get(k); 57 | String ssqid_A = O_area.getString("ssqid"); 58 | String ssqname_A = O_area.getString("ssqname"); 59 | String ssqename_A = O_area.getString("ssqename"); 60 | //=== 61 | Area area = new Area(ssqid_A, ssqname_A, "简称", ssqename_A); 62 | areaList.add(area); 63 | } 64 | //=== 65 | City city = new City(ssqid_C, ssqname_C, "简称", ssqename_C, areaList); 66 | cityList.add(city); 67 | } 68 | //=== 69 | Province province = new Province(ssqid, ssqname, "简称", ssqename, cityList); 70 | provinceList.add(province); 71 | } 72 | 73 | Log.d("XXX", "LOUIS" + provinceList.toString()); 74 | } catch (JSONException e) { 75 | e.printStackTrace(); 76 | Log.d("XXX", "LOUIS" + e.getMessage()); 77 | } 78 | return provinceList; 79 | } 80 | 81 | /** 82 | * getStringFromRaw 83 | * @param rawID 84 | * @return 85 | */ 86 | public static String getStringFromRaw(Context context,int rawID) { 87 | StringBuilder sb_result = new StringBuilder(""); 88 | try { 89 | InputStream ssq_is = context.getResources().openRawResource(rawID); 90 | 91 | InputStreamReader inputReader = new InputStreamReader(ssq_is); 92 | //InputStreamReader inputReader = new InputStreamReader(ssq_is,"UTF-8"); 93 | BufferedReader bufReader = new BufferedReader(inputReader); 94 | String line = ""; 95 | while ((line = bufReader.readLine()) != null) 96 | { sb_result.append(line);} 97 | } catch (Exception e) { 98 | e.printStackTrace(); 99 | } 100 | return sb_result.toString(); 101 | } 102 | 103 | /** 104 | * 很多行 会卡死 105 | * @param context 106 | * @param rawID 107 | * @return 108 | */ 109 | @Deprecated 110 | public static String getStringFromRawOld(Context context,int rawID) { 111 | String result = ""; 112 | try { 113 | InputStream ssq_is = context.getResources().openRawResource(rawID); 114 | 115 | InputStreamReader inputReader = new InputStreamReader(ssq_is); 116 | //InputStreamReader inputReader = new InputStreamReader(ssq_is,"UTF-8"); 117 | BufferedReader bufReader = new BufferedReader(inputReader); 118 | String line = ""; 119 | while ((line = bufReader.readLine()) != null) 120 | {result += line;} 121 | } catch (Exception e) { 122 | e.printStackTrace(); 123 | } 124 | return result; 125 | } 126 | 127 | public static String getCateNameByCateID(Context context,String proCateID){ 128 | String proCateName=""; 129 | String pro_cate_json = getStringFromRaw(context, R.raw.pro_cate); 130 | ProCate proCate= JSON.parseObject(pro_cate_json,ProCate.class); 131 | List proCateCatesBeanList=proCate.getCates(); 132 | for (int i = 0; i 1) 140 | { 141 | String nowParentID=nowProcateIDArray[1]; 142 | List childrenBeans=pccb.getChildren(); 143 | for (int j = 0; j < childrenBeans.size(); j++) { 144 | if ((nowParentID+"_"+proCateID).equals( childrenBeans.get(j).getCateid())){ 145 | proCateName=pccb.getCatename(); 146 | break; 147 | } 148 | }} 149 | } 150 | return proCateName; 151 | 152 | } 153 | 154 | public static String getProvinceCityAreaNameStrByOnlyAreaID(Context context,String areaKey){ 155 | if (areaKey==null||areaKey.trim().equals("")||areaKey.trim().toLowerCase().equals("null")){ 156 | return ""; 157 | } 158 | String ssqJson = getStringFromRaw(context, R.raw.ssq); 159 | // String ssqJson = getStringFromRawOld(context, R.raw.ssq); 160 | List provinceList = parseJson(ssqJson); 161 | // 162 | String province = ""; 163 | String city = ""; 164 | String area = ""; 165 | // 166 | String provinceID = areaKey.substring(0, 2) + "0000";//从0开始数,其中不包括endIndex位置的字符 167 | String cityID = areaKey.substring(0, 4) + "00"; 168 | String areaID = areaKey; 169 | 170 | int nowProvinceIndex=0; 171 | for (int i = 0; i > multiSelectMapList) { 37 | mMultiSelectMapList = multiSelectMapList; 38 | 39 | }*/ 40 | 41 | private List> mMultiSelectMapListOut; 42 | private List mMultiSelectHasChildBeanList; 43 | public static MutiSelectDialogFragment newInstance(String title,boolean isHasChild) { 44 | MutiSelectDialogFragment myDialogFragment = new MutiSelectDialogFragment(); 45 | Bundle args = new Bundle(); 46 | // 自定义的标题 47 | args.putString(TITLE_KEY, title); 48 | args.putBoolean(IS_HAS_CHILD_KEY,isHasChild); 49 | myDialogFragment.setArguments(args); 50 | return myDialogFragment; 51 | } 52 | 53 | /** 54 | * 在onCreateView中使用 getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);即可去掉 55 | * @param inflater 56 | * @param container 57 | * @param savedInstanceState 58 | * @return 59 | */ 60 | @Nullable 61 | @Override 62 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 63 | String title = getArguments().getString(TITLE_KEY); 64 | mIsHasChild= getArguments().getBoolean(IS_HAS_CHILD_KEY); 65 | dialog=this.getDialog(); 66 | if (title.equals("")) { 67 | getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);// 68 | }else{ 69 | dialog.setTitle(title); 70 | } 71 | View view; 72 | 73 | if (mIsHasChild){ 74 | view=inflater.inflate(R.layout.layout_mutiselect_dialog_frag_has_child,container,false); 75 | id_msl_gac= (MultiSelectLayout_HasChild) view.findViewById(R.id.id_msl_gac); 76 | 77 | id_msl_gac.setOnBtnClickListener(new MultiSelectLayout_HasChild.OnBtnClickListener() { 78 | @Override 79 | public void onOkBtnClick(View v, List multiSelectMapList, List selectMapList) { 80 | dialog.dismiss(); 81 | onBackHasChildDataListener.onBackHasChildData(multiSelectMapList,selectMapList); 82 | 83 | } 84 | 85 | @Override 86 | public void onCancelBtnClick(View v) { 87 | dialog.dismiss(); 88 | 89 | } 90 | }); 91 | }else{ 92 | view=inflater.inflate(R.layout.layout_mutiselect_dialog_frag,container,false); 93 | id_msl= (MultiSelectLayout) view.findViewById(R.id.id_msl); 94 | 95 | id_msl.setOnBtnClickListener(new MultiSelectLayout.OnBtnClickListener() { 96 | @Override 97 | public void onOkBtnClick(View v, List> multiSelectMapList, List> selectMapList) { 98 | dialog.dismiss(); 99 | onBackDataListener.onBackData(multiSelectMapList,selectMapList); 100 | 101 | /* StringBuilder sb=new StringBuilder("选中"+selectMapList.size()+"项,分别是:"); 102 | for (int i = 0; i < selectMapList.size(); i++) { 103 | String name= selectMapList.get(i).get("name").toString(); 104 | sb.append(name); 105 | } 106 | Toast.makeText(getActivity(), ""+sb.toString(), Toast.LENGTH_LONG).show();*/ 107 | } 108 | 109 | @Override 110 | public void onCancelBtnClick(View v) { 111 | dialog.dismiss(); 112 | } 113 | }); 114 | // id_msv.setupMultiSelectMapListInner(mMultiSelectMapList); 115 | //return super.onCreateView(inflater, container, savedInstanceState); 116 | 117 | } 118 | return view; 119 | } 120 | 121 | @Override 122 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 123 | super.onViewCreated(view, savedInstanceState); 124 | /** 125 | * 设置数据 126 | */ 127 | if (mMultiSelectMapListOut!=null){ 128 | id_msl.setupMultiSelectMapList(mMultiSelectMapListOut);//初始化view后 初始化数据 129 | } 130 | // 131 | Log.d("tag", "louis:3 onViewCreated: mMultiSelectHasChildBeanList:"+mMultiSelectHasChildBeanList); 132 | if (mMultiSelectHasChildBeanList!=null){ 133 | id_msl_gac.setupMultiSelectHasChildBeanList(mMultiSelectHasChildBeanList); 134 | } 135 | } 136 | 137 | 138 | /** 139 | * set date for onViewCreated 140 | * 141 | * @param multiSelectMapListOut 142 | */ 143 | public void setupMultiSelectMapListOut(List> multiSelectMapListOut,List multiSelectMapList){ 144 | mMultiSelectMapListOut=multiSelectMapListOut; 145 | Logger.d("setupMultiSelectMapListOut:mMultiSelectMapListOut:"+mMultiSelectMapListOut); 146 | mMultiSelectHasChildBeanList=multiSelectMapList; 147 | Logger.d("setupMultiSelectMapListOut:multiSelectMapList: "+multiSelectMapList); 148 | } 149 | 150 | public interface OnBackDataListener{ 151 | void onBackData(List> multiSelectMapList,List> selectMapList); 152 | } 153 | 154 | public void setOnBackDataListener(OnBackDataListener onBackDataListener) { 155 | this.onBackDataListener = onBackDataListener; 156 | } 157 | 158 | OnBackDataListener onBackDataListener; 159 | 160 | public interface OnBackHasChildDataListener{ 161 | void onBackHasChildData(List multiSelectMapList, List selectMapList); 162 | } 163 | 164 | public void setOnBackHasChildDataListener(OnBackHasChildDataListener onBackHasChildDataListener) { 165 | this.onBackHasChildDataListener = onBackHasChildDataListener; 166 | } 167 | 168 | OnBackHasChildDataListener onBackHasChildDataListener; 169 | } 170 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/anim/popupwindow_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 15 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/anim/popupwindow_bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 15 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_check_grey_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_check_grey_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_check_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_check_grey_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_check_light_green_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_check_light_green_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_check_light_green_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_check_light_green_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-hdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_check_grey_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_check_grey_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_check_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_check_grey_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_check_light_green_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_check_light_green_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_check_light_green_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_check_light_green_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-mdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_grey_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_grey_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_grey_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_light_green_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_light_green_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_light_green_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_check_light_green_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xhdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_grey_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_grey_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_grey_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_light_green_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_light_green_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_light_green_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_check_light_green_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_grey_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_grey_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_grey_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_grey_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_light_green_600_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_light_green_600_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_light_green_700_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_check_light_green_700_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_18dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_24dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_36dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louisgeek/LouisDropDownView/12f80a127794f2ef0ff0c60b3e19b50b44473603/DropDownViewLib/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_down_blue_grey_400_48dp.png -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable/selector_item_checked.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable/selector_item_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable/selector_left_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable/selector_shape_list_item_nobottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable/selector_shape_list_item_notop.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable/shape_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/drawable/shape_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/dropdown_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 20 | 21 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/dropdown_item_muti.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 19 | 24 | 25 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 19 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_mutiselect_dialog_frag.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_mutiselect_dialog_frag_content_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 21 | 22 | 23 | 30 | 31 | 37 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 57 | 64 | 72 | 73 | 74 | 81 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_mutiselect_dialog_frag_has_child.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_mutiselect_dialog_frag_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 21 | 22 | 23 | 30 | 31 | 37 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 57 | 64 | 72 | 73 | 74 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_mutiselect_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 17 | 22 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_popupwindow_datepick.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 | 21 | 27 | 28 | 35 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_popupwindow_dropdown.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 15 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_popupwindow_selectview.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 | 15 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_procate_selectview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 23 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/layout_provincecityarea_selectview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 23 | 32 | 37 | 38 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/left_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 19 | 26 | 27 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/mutiselect_dialog_frag_list_group_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/mutiselect_dialog_frag_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/mutiselect_enter_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/right_item_all.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 21 | 26 | 33 | 34 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/layout/right_item_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 21 | 26 | 32 | 33 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/raw/pro_cate.json: -------------------------------------------------------------------------------- 1 | { 2 | "cates": 3 | [ 4 | { 5 | "cateid": "0_1", 6 | "catename": "瓜菜类", 7 | "children": [ 8 | { 9 | "cateid": "1_2", 10 | "catename": "甜瓜" 11 | }, 12 | { 13 | "cateid": "1_3", 14 | "catename": "黄瓜" 15 | } 16 | ] 17 | }, 18 | { 19 | "cateid": "0_5", 20 | "catename": "薯类", 21 | "children": [ 22 | { 23 | "cateid": "5_6", 24 | "catename": "红薯" 25 | } 26 | ] 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/raw/pro_cate_bak.json: -------------------------------------------------------------------------------- 1 | { 2 | "cates": [ 3 | { 4 | "cateid": "0_1", 5 | "catename": "瓜菜类", 6 | "children": [ 7 | { 8 | "cateid": "1_2", 9 | "catename": "甜瓜" 10 | }, 11 | { 12 | "cateid": "1_3", 13 | "catename": "黄瓜" 14 | }, 15 | { 16 | "cateid": "1_4", 17 | "catename": "西瓜" 18 | } 19 | ] 20 | }, 21 | { 22 | "cateid": "0_5", 23 | "catename": "玉米类[先别选我]", 24 | "children": [ 25 | { 26 | "cateid": "5_6", 27 | "catename": "菜用玉米" 28 | } 29 | ] 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 选项1 5 | 选项2 6 | 选项3 7 | 8 | 9 | op1_选项1 10 | op2_选项2 11 | op3_选项3 12 | 13 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #EEEEEE 4 | #FFFFFF 5 | #EEEEEE 6 | #FFFFFF 7 | #47b82d 8 | #1a1818 9 | 10 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DropDownViewLib 3 | 4 | -------------------------------------------------------------------------------- /DropDownViewLib/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /DropDownViewLib/src/test/java/com/louisgeek/dropdownviewlib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.dropdownviewlib; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LouisDropDownView 2 | :grin: 自定义下拉选择 、时间选择控件、省市区、多选对话框、二级分类多选、列表二级分类选择 3 | ![image](https://github.com/louisgeek/LouisDropDownView/blob/master/screenshots/pic2.png) 4 | ![image](https://github.com/louisgeek/LouisDropDownView/blob/master/screenshots/pic1.png) 5 | ![image](https://github.com/louisgeek/LouisDropDownView/blob/master/screenshots/pic3.png) 6 | ![image](https://github.com/louisgeek/LouisDropDownView/blob/master/screenshots/pic4.png) 7 | ![image](https://github.com/louisgeek/LouisDropDownView/blob/master/screenshots/pic5.png) 8 | ![image](https://github.com/louisgeek/LouisDropDownView/blob/master/screenshots/pic6.png) 9 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.louisgeek.louisdropdownview" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.3.0' 26 | compile project(':DropDownViewLib') 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\LouisIDE\Android\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/louisgeek/louisdropdownview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.louisdropdownview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/louisgeek/louisdropdownview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.louisgeek.louisdropdownview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.util.Log; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.louisgeek.dropdownviewlib.ClassfiySeletView; 10 | import com.louisgeek.dropdownviewlib.DateSelectView; 11 | import com.louisgeek.dropdownviewlib.DropDownView; 12 | import com.louisgeek.dropdownviewlib.MultiSelectView; 13 | import com.louisgeek.dropdownviewlib.MultiSelectView_HasChild; 14 | import com.louisgeek.dropdownviewlib.ProCateSelectView; 15 | import com.louisgeek.dropdownviewlib.ProvinceCityAreaSelectView; 16 | import com.louisgeek.dropdownviewlib.javabean.MultiSelectHasChildBean; 17 | 18 | import java.util.ArrayList; 19 | import java.util.HashMap; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | public class MainActivity extends AppCompatActivity { 24 | 25 | List> mMultiSelectMapListOut; 26 | List mMultiSelectHasChildBeanList; 27 | private static final String TAG = "MainActivity"; 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | setContentView(R.layout.activity_main); 32 | 33 | final MultiSelectView_HasChild idmsvgac = (MultiSelectView_HasChild) findViewById(R.id.id_msv_gac); 34 | 35 | final ProCateSelectView idpcsv = (ProCateSelectView) findViewById(R.id.id_pcsv); 36 | final ProvinceCityAreaSelectView idpcasv = (ProvinceCityAreaSelectView) findViewById(R.id.id_pcasv); 37 | final DateSelectView iddsv = (DateSelectView) findViewById(R.id.id_dsv); 38 | final DropDownView idddv = (DropDownView) findViewById(R.id.id_ddv); 39 | initData(); 40 | // initHasChildData(); 41 | 42 | final MultiSelectView multiSelectView= (MultiSelectView) findViewById(R.id.id_msv); 43 | multiSelectView.setupMultiSelectMapListOutter(mMultiSelectMapListOut); 44 | 45 | /* final MultiSelectView_HasChild id_msv_gac= (MultiSelectView_HasChild) findViewById(R.id.id_msv_gac); 46 | Log.d("tag", "louis:1 onCreate: mMultiSelectHasChildBeanList:"+mMultiSelectHasChildBeanList);*/ 47 | //### id_msv_gac.setupMultiSelectHasChildBeanListOutter(mMultiSelectHasChildBeanList); 48 | 49 | /* final Button id_btn= (Button) findViewById(R.id.id_btn); 50 | id_btn.setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View v) { 53 | id_btn.setText(id_msv_gac.getSelectedKey()); 54 | } 55 | });*/ 56 | final ClassfiySeletView id_csv = (ClassfiySeletView) findViewById(R.id.id_csv); 57 | 58 | 59 | 60 | 61 | 62 | Button id_btn= (Button) findViewById(R.id.id_btn); 63 | id_btn.setOnClickListener(new View.OnClickListener() { 64 | @Override 65 | public void onClick(View v) { 66 | Log.i(TAG,"=================DropDownView======================"); 67 | Log.i(TAG, "onClick:getSelectKey "+idddv.getSelectKey()); 68 | Log.i(TAG, "onClick: getSelectName"+idddv.getSelectName()); 69 | Log.i(TAG,"=================DateSelectView======================"); 70 | Log.i(TAG, "onClick: getNowSelectData"+iddsv.getNowSelectData()); 71 | Log.i(TAG, "onClick: getNowSelectDataFixedNowData"+iddsv.getNowSelectDataFixedNowData()); 72 | Log.i(TAG,"=================ProvinceCityAreaSelectView======================"); 73 | Log.i(TAG, "onClick: getProvinceCityAreaKey"+idpcasv.getProvinceCityAreaKey()); 74 | Log.i(TAG, "onClick: getProvinceCityAreaNameStr"+idpcasv.getProvinceCityAreaNameStr()); 75 | Log.i(TAG, "onClick: getProvinceCityAreaNameStrWithOutFix"+idpcasv.getProvinceCityAreaNameStrWithOutFix()); 76 | Log.i(TAG,"=================ProCateSelectView======================"); 77 | Log.i(TAG, "onClick: getProCateKey"+idpcsv.getProCateKey()); 78 | Log.i(TAG, "onClick: getProCateNameOnlyChild"+idpcsv.getProCateNameOnlyChild()); 79 | Log.i(TAG, "onClick: getProCateKeyOnlyChildId"+idpcsv.getProCateKeyOnlyChildId()); 80 | Log.i(TAG,"=================MultiSelectView======================"); 81 | Log.i(TAG, "onClick: getSelectedKey"+multiSelectView.getSelectedKey()); 82 | Log.i(TAG,"==================MultiSelectView_HasChild====================="); 83 | Log.i(TAG, "onClick: getSelectedKey"+idmsvgac.getSelectedKey()); 84 | Log.i(TAG,"==================ClassfiySeletView====================="); 85 | Log.i(TAG, "onClick: getSelectedClassfiyKey"+id_csv.getSelectedClassfiyKey()); 86 | Log.i(TAG, "onClick: getSelectedClassfiyKeyWithoutFix"+id_csv.getSelectedClassfiyKeyWithoutFix()); 87 | } 88 | }); 89 | 90 | 91 | } 92 | 93 | private void initData() { 94 | mMultiSelectMapListOut=new ArrayList<>(); 95 | for (int i = 0; i < 18; i++) { 96 | Map map=new HashMap<>(); 97 | map.put("name", "name" + i); 98 | map.put("key", "key" + i); 99 | map.put("checked", false); 100 | mMultiSelectMapListOut.add(map); 101 | } 102 | } 103 | 104 | 105 | } 106 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 23 | 24 | 30 | 31 | 36 | 37 | 42 | 43 | 49 | 50 | 56 | 62 | 63 | 68 | 69 |