|
|
@@ -25,12 +25,17 @@ import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.List;
|
|
|
|
|
|
+/**
|
|
|
+ * Created by RaoMeng on 2017/8/14.
|
|
|
+ * 数据查询列表页面高级查询配置选项适配器
|
|
|
+ */
|
|
|
public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
private List<SchemeConditionBean> objects = new ArrayList<SchemeConditionBean>();
|
|
|
|
|
|
private Context context;
|
|
|
private LayoutInflater layoutInflater;
|
|
|
private boolean strChanged = true, numChanged1 = true, numChanged2 = true;
|
|
|
+ private int mTouchPosition = -1, mTouchIndex = -1;
|
|
|
|
|
|
public DataInquirySchemeConditionAdapter(Context context, List<SchemeConditionBean> objects) {
|
|
|
this.context = context;
|
|
|
@@ -38,6 +43,11 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
this.objects = objects;
|
|
|
}
|
|
|
|
|
|
+ public void resetTouchPosition() {
|
|
|
+ mTouchPosition = -1;
|
|
|
+ mTouchIndex = -1;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
return objects.size();
|
|
|
@@ -59,12 +69,18 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
convertView = layoutInflater.inflate(R.layout.item_list_data_inquiry_exact_query, null);
|
|
|
convertView.setTag(new ViewHolder(convertView));
|
|
|
// }
|
|
|
- initializeViews((SchemeConditionBean) getItem(position), (ViewHolder) convertView.getTag());
|
|
|
+ initializeViews((SchemeConditionBean) getItem(position), (ViewHolder) convertView.getTag(), position);
|
|
|
return convertView;
|
|
|
}
|
|
|
|
|
|
- private void initializeViews(final SchemeConditionBean object, final ViewHolder holder) {
|
|
|
+ private void initializeViews(final SchemeConditionBean object, final ViewHolder holder, int position) {
|
|
|
holder.captionTv.setText(object.getCaption());
|
|
|
+ holder.captionTv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
switch (object.getType()) {
|
|
|
|
|
|
@@ -75,6 +91,9 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
holder.gridview.setVisibility(View.GONE);
|
|
|
List<SchemeConditionBean.Property> mProperties = object.getProperties();
|
|
|
|
|
|
+ holder.numEdittext1.setTag(position);
|
|
|
+ holder.numEdittext2.setTag(position);
|
|
|
+
|
|
|
holder.numEdittext1.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
@@ -115,6 +134,44 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ /*holder.numEdittext1.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ mTouchPosition = (int) holder.numEdittext1.getTag();
|
|
|
+ mTouchIndex = 1;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ holder.numEdittext2.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ mTouchPosition = (int) holder.numEdittext2.getTag();
|
|
|
+ mTouchIndex = 2;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });*/
|
|
|
+
|
|
|
+ holder.numEdittext1.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onFocusChange(View v, boolean hasFocus) {
|
|
|
+ if (hasFocus) {
|
|
|
+ mTouchPosition = (int) holder.numEdittext1.getTag();
|
|
|
+ mTouchIndex = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ holder.numEdittext2.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onFocusChange(View v, boolean hasFocus) {
|
|
|
+ if (hasFocus) {
|
|
|
+ mTouchPosition = (int) holder.numEdittext2.getTag();
|
|
|
+ mTouchIndex = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
numChanged1 = true;
|
|
|
numChanged2 = true;
|
|
|
if (mProperties != null && mProperties.size() == 2) {
|
|
|
@@ -124,6 +181,22 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
holder.numEdittext2.setText(mProperties.get(1).getDisplay());
|
|
|
numChanged2 = false;
|
|
|
}
|
|
|
+
|
|
|
+ if (mTouchPosition == position) {
|
|
|
+ if (mTouchIndex == 1) {
|
|
|
+ holder.numEdittext1.requestFocus();
|
|
|
+ holder.numEdittext1.setSelection(holder.numEdittext1.getText().length());
|
|
|
+ } else if (mTouchIndex == 2) {
|
|
|
+ holder.numEdittext2.requestFocus();
|
|
|
+ holder.numEdittext2.setSelection(holder.numEdittext2.getText().length());
|
|
|
+ } else {
|
|
|
+ holder.numEdittext1.clearFocus();
|
|
|
+ holder.numEdittext2.clearFocus();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ holder.numEdittext1.clearFocus();
|
|
|
+ holder.numEdittext2.clearFocus();
|
|
|
+ }
|
|
|
break;
|
|
|
case "D":
|
|
|
case "CD":
|
|
|
@@ -142,20 +215,6 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
|
|
|
mProperties = object.getProperties();
|
|
|
|
|
|
- holder.textview1.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- holder.textview2.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
holder.calendar1.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
@@ -249,6 +308,8 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
holder.gridview.setVisibility(View.GONE);
|
|
|
mProperties = object.getProperties();
|
|
|
|
|
|
+ holder.stringEdittext.setTag(position);
|
|
|
+
|
|
|
holder.stringEdittext.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
@@ -269,11 +330,34 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ /*holder.stringEdittext.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ mTouchPosition = (int) v.getTag();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });*/
|
|
|
+
|
|
|
+ holder.stringEdittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onFocusChange(View v, boolean hasFocus) {
|
|
|
+ if (hasFocus)
|
|
|
+ mTouchPosition = (int) v.getTag();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
strChanged = true;
|
|
|
if (mProperties != null && object.getProperties().size() == 1) {
|
|
|
holder.stringEdittext.setText(mProperties.get(0).getDisplay());
|
|
|
strChanged = false;
|
|
|
}
|
|
|
+
|
|
|
+ if (mTouchPosition == position) {
|
|
|
+ holder.stringEdittext.requestFocus();
|
|
|
+ holder.stringEdittext.setSelection(holder.stringEdittext.getText().length());
|
|
|
+ } else {
|
|
|
+ holder.stringEdittext.clearFocus();
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|