Commit f1cfac16 authored by xwenliang's avatar xwenliang

update data structure

parent 3c8fc35e
...@@ -95,7 +95,6 @@ public class PickerViewModule extends ReactContextBaseJavaModule { ...@@ -95,7 +95,6 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
Activity activity = getCurrentActivity(); Activity activity = getCurrentActivity();
if (activity != null && options.hasKey(PICKER_DATA)) { if (activity != null && options.hasKey(PICKER_DATA)) {
view = activity.getLayoutInflater().inflate(R.layout.popup_picker_view, null); view = activity.getLayoutInflater().inflate(R.layout.popup_picker_view, null);
pickerParent = (RelativeLayout) view.findViewById(R.id.pickerParent); pickerParent = (RelativeLayout) view.findViewById(R.id.pickerParent);
barLayout = (RelativeLayout) view.findViewById(R.id.barLayout); barLayout = (RelativeLayout) view.findViewById(R.id.barLayout);
cancelTV = (TextView) view.findViewById(R.id.cancel); cancelTV = (TextView) view.findViewById(R.id.cancel);
...@@ -218,15 +217,6 @@ public class PickerViewModule extends ReactContextBaseJavaModule { ...@@ -218,15 +217,6 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
} }
} }
switch (options.getType(PICKER_DATA).name()) {
case "Map":
pickerViewLinkage.setVisibility(View.VISIBLE);
pickerViewAlone.setVisibility(View.GONE);
ReadableMap linkageData = options.getMap(PICKER_DATA);
if (linkageData != null) {
pickerViewLinkage.setLinkageData(linkageData, curSelectedList);
}
pickerViewLinkage.setIsLoop(isLoop);
if (options.hasKey(PICKER_BG_COLOR)) { if (options.hasKey(PICKER_BG_COLOR)) {
ReadableArray array = options.getArray(PICKER_BG_COLOR); ReadableArray array = options.getArray(PICKER_BG_COLOR);
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
...@@ -236,8 +226,18 @@ public class PickerViewModule extends ReactContextBaseJavaModule { ...@@ -236,8 +226,18 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
pickerColor[i] = array.getInt(i); pickerColor[i] = array.getInt(i);
} }
} }
pickerViewLinkage.setBackgroundColor(Color.argb(pickerColor[3], pickerColor[0], pickerColor[1], pickerColor[2]));
} }
ReadableArray pickerData = options.getArray(PICKER_DATA);
String name = pickerData.getType(0).name();
switch (name) {
case "Map":
pickerViewLinkage.setVisibility(View.VISIBLE);
pickerViewAlone.setVisibility(View.GONE);
pickerViewLinkage.setPickerData(pickerData, curSelectedList);
pickerViewLinkage.setIsLoop(isLoop);
pickerViewLinkage.setBackgroundColor(Color.argb(pickerColor[3], pickerColor[0], pickerColor[1], pickerColor[2]));
pickerViewLinkage.setOnSelectListener(new OnSelectedListener() { pickerViewLinkage.setOnSelectListener(new OnSelectedListener() {
@Override @Override
public void onSelected(ArrayList<String> selectedList) { public void onSelected(ArrayList<String> selectedList) {
...@@ -247,33 +247,13 @@ public class PickerViewModule extends ReactContextBaseJavaModule { ...@@ -247,33 +247,13 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
}); });
pickerViewLinkage.setSelectValue(selectValue, curSelectedList); pickerViewLinkage.setSelectValue(selectValue, curSelectedList);
break; break;
case "Array": default:
pickerViewAlone.setVisibility(View.VISIBLE); pickerViewAlone.setVisibility(View.VISIBLE);
pickerViewLinkage.setVisibility(View.GONE); pickerViewLinkage.setVisibility(View.GONE);
ReadableArray aloneData = options.getArray(PICKER_DATA);
if (aloneData != null) { pickerViewAlone.setPickerData(pickerData, curSelectedList);
switch (aloneData.getType(0).name()) {
case "Array":
pickerViewAlone.setPickerViewDta(aloneData, curSelectedList);
break;
default:
pickerViewAlone.setAloneData(aloneData, curSelectedList);
break;
}
}
pickerViewAlone.setIsLoop(isLoop); pickerViewAlone.setIsLoop(isLoop);
if (options.hasKey(PICKER_BG_COLOR)) {
ReadableArray array = options.getArray(PICKER_BG_COLOR);
for (int i = 0; i < array.size(); i++) {
if (i == 3) {
pickerColor[i] = (int) (array.getDouble(i) * 255);
} else {
pickerColor[i] = array.getInt(i);
}
}
pickerViewAlone.setBackgroundColor(Color.argb(pickerColor[3], pickerColor[0], pickerColor[1], pickerColor[2])); pickerViewAlone.setBackgroundColor(Color.argb(pickerColor[3], pickerColor[0], pickerColor[1], pickerColor[2]));
}
pickerViewAlone.setOnSelectedListener(new OnSelectedListener() { pickerViewAlone.setOnSelectedListener(new OnSelectedListener() {
@Override @Override
...@@ -284,10 +264,10 @@ public class PickerViewModule extends ReactContextBaseJavaModule { ...@@ -284,10 +264,10 @@ public class PickerViewModule extends ReactContextBaseJavaModule {
}); });
pickerViewAlone.setSelectValue(selectValue, curSelectedList); pickerViewAlone.setSelectValue(selectValue, curSelectedList);
break; break;
} }
if (popupWindow == null) { if (popupWindow == null) {
popupWindow = new PopupWindow(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); popupWindow = new PopupWindow(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
popupWindow.setBackgroundDrawable(new ColorDrawable()); popupWindow.setBackgroundDrawable(new ColorDrawable());
......
...@@ -43,7 +43,18 @@ public class PickerViewAlone extends LinearLayout { ...@@ -43,7 +43,18 @@ public class PickerViewAlone extends LinearLayout {
this.onSelectedListener = listener; this.onSelectedListener = listener;
} }
public void setAloneData(ReadableArray array, final ArrayList<String> curSelectedList) { public void setPickerData(ReadableArray array, final ArrayList<String> curSelectedList){
switch (array.getType(0).name()){
case "Array":
setMultipleData(array,curSelectedList);
break;
default:
setAloneData(array,curSelectedList);
break;
}
}
private void setAloneData(ReadableArray array, final ArrayList<String> curSelectedList) {
ArrayList<String> values = arrayToList(array); ArrayList<String> values = arrayToList(array);
final LoopView loopView = new LoopView(getContext()); final LoopView loopView = new LoopView(getContext());
LayoutParams params = new LayoutParams( LayoutParams params = new LayoutParams(
...@@ -69,8 +80,7 @@ public class PickerViewAlone extends LinearLayout { ...@@ -69,8 +80,7 @@ public class PickerViewAlone extends LinearLayout {
pickerViewAloneLayout.addView(loopView); pickerViewAloneLayout.addView(loopView);
} }
private void setMultipleData(ReadableArray array, final ArrayList<String> curSelectedList) {
public void setPickerViewDta(ReadableArray array, final ArrayList<String> curSelectedList) {
final String[] selectedItems = new String[array.size()]; final String[] selectedItems = new String[array.size()];
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
switch (array.getType(i).name()) { switch (array.getType(i).name()) {
......
...@@ -22,12 +22,15 @@ typedef void(^backBolock)(NSDictionary * ); ...@@ -22,12 +22,15 @@ typedef void(^backBolock)(NSDictionary * );
@property (strong, nonatomic) NSDictionary *pickerDic;//一开始进来的字典 @property (strong, nonatomic) NSDictionary *pickerDic;//一开始进来的字典
@property (strong, nonatomic) NSArray *provinceArray;//省、市 @property(strong,nonatomic)NSArray *dataDry;//一进来的就没有数组和字典的区别肯定是一个字典
@property (strong, nonatomic) NSArray *cityArray;//市,县
@property (strong, nonatomic) NSMutableArray *provinceArray;//省、市
@property (strong, nonatomic) NSMutableArray *cityArray;//市,县
@property (strong, nonatomic) NSArray *townArray;//县,区 @property (strong, nonatomic) NSArray *townArray;//县,区
@property (strong, nonatomic) NSDictionary *selectedDic;//3级联动时候用到的 @property(strong,nonatomic)NSArray *selectthreeAry;
@property (strong,nonatomic)NSArray *selectArry;//2级联动时候用的 @property (strong,nonatomic)NSArray *selectArry;//2级联动时候用的
@property (strong,nonatomic)UIButton *leftBtn;//取消 @property (strong,nonatomic)UIButton *leftBtn;//取消
...@@ -38,8 +41,6 @@ typedef void(^backBolock)(NSDictionary * ); ...@@ -38,8 +41,6 @@ typedef void(^backBolock)(NSDictionary * );
@property(strong,nonatomic)NSString *rightStr; @property(strong,nonatomic)NSString *rightStr;
//用来判断进来的类型
@property(strong,nonatomic)id value;
@property(assign,nonatomic)BOOL Correlation;//判断有没有没有关联 @property(assign,nonatomic)BOOL Correlation;//判断有没有没有关联
...@@ -52,10 +53,20 @@ typedef void(^backBolock)(NSDictionary * ); ...@@ -52,10 +53,20 @@ typedef void(^backBolock)(NSDictionary * );
@property(assign,nonatomic)BOOL noArryElementBool; @property(assign,nonatomic)BOOL noArryElementBool;
@property(strong,nonatomic)NSMutableArray *infoArry;
//创建一个数组 接收进来的选择Value //创建一个数组 接收进来的选择Value
@property(strong,nonatomic)NSArray *selectValueArry; @property(strong,nonatomic)NSArray *selectValueArry;
//创建一个下角标记录是第几行 来一进来判断第一行被选中 当进来的是关联两行的逻辑的时候 或者三行关联的时候取第二行做记录
@property(assign,nonatomic)NSInteger num;
//创建一个下角标 第三行做记录
@property(assign,nonatomic)NSInteger threenum;
-(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSString *)leftStr centerStr:(NSString *)centerStr rightStr:(NSString *)rightStr topbgColor:(NSArray *)topbgColor bottombgColor:(NSArray *)bottombgColor leftbtnbgColor:(NSArray *)leftbtnbgColor rightbtnbgColor:(NSArray *)rightbtnbgColor centerbtnColor:(NSArray *)centerbtnColor selectValueArry:(NSArray *)selectValueArry; -(instancetype)initWithFrame:(CGRect)frame dic:(NSDictionary *)dic leftStr:(NSString *)leftStr centerStr:(NSString *)centerStr rightStr:(NSString *)rightStr topbgColor:(NSArray *)topbgColor bottombgColor:(NSArray *)bottombgColor leftbtnbgColor:(NSArray *)leftbtnbgColor rightbtnbgColor:(NSArray *)rightbtnbgColor centerbtnColor:(NSArray *)centerbtnColor selectValueArry:(NSArray *)selectValueArry;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment