Sfoglia il codice sorgente

Adjust the common editor framework to solve the problem of incompatibility with the application framework -- 调整common editor 框架,解决与 application 框架不兼容问题(resolve: #14548)
The common editor action button adds support for online enum type -- common editor action 按钮增加支持 online enum 类型(issue50: #14549)
Common editor action button adds support for secondary editor -- common editor action 按钮增加支持 次级editor (issue30: #14550)
Common editor several kinds of enumeration selection interface single selection can be inverted -- common editor 几种枚举选择界面单选都可以反选(resolve: #(resolve: #14548))

Ray Zhang 4 anni fa
parent
commit
f303d2ad2b

+ 130 - 61
ApexDrivers/CommonEditorLib/src/main/java/com/usai/commoneditorlib/CommonEditorActivity.java

@@ -88,6 +88,7 @@ import static android.view.Gravity.TOP;
 public class CommonEditorActivity extends AppCompatActivity implements View.OnLayoutChangeListener{
 
 
+    protected  String ONLINE_ENUM_URL;
     public ExpandAdapter adapter;
     public String service_url;
 
@@ -2210,13 +2211,13 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                     if(online)
                     {
 
-                        String url = item_json.optString("url");
+//                        String url = item_json.optString("url");
 
                         JSONObject paramsjson = item_json.optJSONObject("params");
 
                         Bundle params=RAUtil.Json2Bundle(paramsjson);
 
-                        intent = new EnumSlectOnlineActivity.Builder().build(mCtx,title,max_select,groupPosition,childPosition,singleSelect,true,url,params);
+                        intent = new EnumSlectOnlineActivity.Builder().build(mCtx,title,max_select,groupPosition,childPosition,singleSelect,true,ONLINE_ENUM_URL,params);
                     }
                     else
                     {
@@ -2241,65 +2242,66 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
                 else if (control.equals("action")) {
 
                     String value = item_json.optString("value");
-                    if (value.equals("new_addr")) {
-                        AddressEditorActivity.Builder builder = new AddressEditorActivity.Builder();
-                        intent = builder.build(mCtx,URL_REMOTE,requesturl,null,null,groupPosition,childPosition);
-                        request_code = 2;
-
-                    } // new addr
-                    else if (value.equals("credit_card")) {
-
-                        JSONObject data = item_json.optJSONObject("data");
-                        int url_type;
-                        JSONObject download_data;
-                        if (data != null) {
-                            download_data = data;
-                            url_type = URL_NONE;
-                            requesturl = null;
-                        } else {
-                            download_data = null;
-                            url_type = URL_REMOTE;
-                            requesturl = "";
-                        }
-                        intent = new CreditCardEditorActivity.Builder().build(mCtx,url_type,requesturl,Application.order_code,null,null,download_data,groupPosition,childPosition);
-                        request_code = 3;
-                    }
-                    else if (value.equals("Sales_Order_Freight_Bill_To")) {
-
-                        request_code = 4;
-                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
-
-                    }
-                    else if (value.equals("Sales_Order_Ship_From")) {
-
-                        request_code = 5;
-                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
-
-                    }
-                    else if (value.equals("Sales_Order_Customer")) {
-
-                        request_code = 6;
-                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
-
-                    }
-                    else if (value.equals("Sales_Order_Merchandise_Bill_To")) {
-
-                        request_code = 7;
-                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
-
-                    }
-                    else if (value.equals("Contact_Return_To")) {
-
-                        request_code = 8;
-                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
-
-                    }
-                    else if (value.equals("Sales_Order_Ship_To")) {
-
-                        request_code = 9;
-                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
-                    }
-
+//                    if (value.equals("new_addr")) {
+//                        AddressEditorActivity.Builder builder = new AddressEditorActivity.Builder();
+//                        intent = builder.build(mCtx,URL_REMOTE,requesturl,null,null,groupPosition,childPosition);
+//                        request_code = 2;
+//
+//                    } // new addr
+//                    else if (value.equals("credit_card")) {
+//
+//                        JSONObject data = item_json.optJSONObject("data");
+//                        int url_type;
+//                        JSONObject download_data;
+//                        if (data != null) {
+//                            download_data = data;
+//                            url_type = URL_NONE;
+//                            requesturl = null;
+//                        } else {
+//                            download_data = null;
+//                            url_type = URL_REMOTE;
+//                            requesturl = "";
+//                        }
+//                        intent = new CreditCardEditorActivity.Builder().build(mCtx,url_type,requesturl,Application.order_code,null,null,download_data,groupPosition,childPosition);
+//                        request_code = 3;
+//                    }
+//                    else if (value.equals("Sales_Order_Freight_Bill_To")) {
+//
+//                        request_code = 4;
+//                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                    }
+//                    else if (value.equals("Sales_Order_Ship_From")) {
+//
+//                        request_code = 5;
+//                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                    }
+//                    else if (value.equals("Sales_Order_Customer")) {
+//
+//                        request_code = 6;
+//                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                    }
+//                    else if (value.equals("Sales_Order_Merchandise_Bill_To")) {
+//
+//                        request_code = 7;
+//                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                    }
+//                    else if (value.equals("Contact_Return_To")) {
+//
+//                        request_code = 8;
+//                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                    }
+//                    else if (value.equals("Sales_Order_Ship_To")) {
+//
+//                        request_code = 9;
+//                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//                    }
+                    commonAction(value,groupPosition,childPosition,item_json);
+                        return true;
                 } // action
                 else if (control.equals("datepicker")) {
 
@@ -2396,7 +2398,74 @@ public class CommonEditorActivity extends AppCompatActivity implements View.OnLa
             return false;
         }
     }
+protected void commonAction(String value, int groupIndex,int itemIndex,JSONObject item_json)
+{
 
+        throw new AssertionError("CommonEditor.commonAction not impl");
+//    {
+//
+//
+//        if (value.equals("new_addr")) {
+//            AddressEditorActivity.Builder builder = new AddressEditorActivity.Builder();
+//            intent = builder.build(mCtx,URL_REMOTE,requesturl,null,null,groupPosition,childPosition);
+//            request_code = 2;
+//
+//        } // new addr
+//        else if (value.equals("credit_card")) {
+//
+//            JSONObject data = item_json.optJSONObject("data");
+//            int url_type;
+//            JSONObject download_data;
+//            if (data != null) {
+//                download_data = data;
+//                url_type = URL_NONE;
+//                requesturl = null;
+//            } else {
+//                download_data = null;
+//                url_type = URL_REMOTE;
+//                requesturl = "";
+//            }
+//            intent = new CreditCardEditorActivity.Builder().build(mCtx,url_type,requesturl,Application.order_code,null,null,download_data,groupPosition,childPosition);
+//            request_code = 3;
+//        }
+//        else if (value.equals("Sales_Order_Freight_Bill_To")) {
+//
+//                request_code = 4;
+//                intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//            }
+//            else if (value.equals("Sales_Order_Ship_From")) {
+//
+//                    request_code = 5;
+//                    intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                }
+//                else if (value.equals("Sales_Order_Customer")) {
+//
+//                        request_code = 6;
+//                        intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                    }
+//                    else if (value.equals("Sales_Order_Merchandise_Bill_To")) {
+//
+//                            request_code = 7;
+//                            intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                        }
+//                        else if (value.equals("Contact_Return_To")) {
+//
+//                                request_code = 8;
+//                                intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//
+//                            }
+//                            else if (value.equals("Sales_Order_Ship_To")) {
+//
+//                                    request_code = 9;
+//                                    intent = new ContactListActivity.Builder().build(mCtx,null,null,value,true,groupPosition,childPosition);
+//                                }
+//
+//    }
+}
   void DateTimeValueChanged(String value ,int groupindex, int itemindex)
     {
 

+ 274 - 156
ApexDrivers/CommonEditorLib/src/main/java/com/usai/commoneditorlib/EnumSelectAndSort/EnumSelectAndSortActivity.java

@@ -5,6 +5,7 @@ import android.content.Context;
 import android.content.Intent;
 
 import androidx.appcompat.app.AppCompatActivity;
+
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextWatcher;
@@ -27,7 +28,8 @@ import org.json.JSONObject;
 
 import java.io.Serializable;
 
-public class EnumSelectAndSortActivity extends AppCompatActivity {
+public class EnumSelectAndSortActivity extends AppCompatActivity
+{
 
 
     static String MAX_SELECT = "max_select";
@@ -38,36 +40,43 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
     static String TITLE = "title";
     static String AUTO_CLOSE = "auto_close";
 
-    public static class Builder {
-        public Intent build(Context context, String title, int max_select, int group, int child, String cadedate, boolean single_select, boolean auto_close) {
-            if (context == null) {
+    public static class Builder
+    {
+        public Intent build(Context context, String title, int max_select, int group, int child, String cadedate, boolean single_select, boolean auto_close)
+        {
+            if (context == null)
+            {
                 return null;
             }
 
-            Intent intent = new Intent(context,EnumSelectAndSortActivity.class);
+            Intent intent = new Intent(context, EnumSelectAndSortActivity.class);
 
-            intent.putExtra(MAX_SELECT,max_select);
-            intent.putExtra(GROUP_POSITION,group);
-            intent.putExtra(CHILD_POSITION,child);
-            if (cadedate != null) {
-                intent.putExtra(CADEDATE,(Serializable) cadedate);
+            intent.putExtra(MAX_SELECT, max_select);
+            intent.putExtra(GROUP_POSITION, group);
+            intent.putExtra(CHILD_POSITION, child);
+            if (cadedate != null)
+            {
+                intent.putExtra(CADEDATE, (Serializable) cadedate);
             }
-            intent.putExtra(SINGLE_SELECT,single_select);
-            if (title != null) {
-                intent.putExtra(TITLE,title);
+            intent.putExtra(SINGLE_SELECT, single_select);
+            if (title != null)
+            {
+                intent.putExtra(TITLE, title);
             }
-            intent.putExtra(AUTO_CLOSE,auto_close);
+            intent.putExtra(AUTO_CLOSE, auto_close);
 
             return intent;
         }
     }
 
-    public class SearchBarWatcher implements TextWatcher {
+    public class SearchBarWatcher implements TextWatcher
+    {
 
         Context mCtx;
         EditText textView;
 
-        public SearchBarWatcher(Context ctx,EditText textView) {
+        public SearchBarWatcher(Context ctx, EditText textView)
+        {
             this.mCtx = ctx;
             this.textView = textView;
 
@@ -86,9 +95,10 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
          * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
          * count    选中s中的内容长度(发生改变的原内容长度),未选中为0
          * after    新添加的内容长度,删除为0
-         * */
+         */
         @Override
-        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+        public void beforeTextChanged(CharSequence s, int start, int count, int after)
+        {
 //            Log.d("TextChange", "before Text Changed: " + s + " Start: " + start + " Count: " + count + " After: " + after);
 
             origin_text = s.toString();
@@ -102,27 +112,35 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
          * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
          * before   选中s中的内容长度(发生改变的原内容长度),未选中为0
          * count    增加内容长度,删除内容为0
-         * */
+         */
         @Override
-        public void onTextChanged(CharSequence s, int start, int before, int count) {
+        public void onTextChanged(CharSequence s, int start, int before, int count)
+        {
 //            Log.d("TextChange", "on Text Changed: " + s + " Start: " + start + " Before: " + before + " Count: " + count);
         }
 
         @Override
-        public void afterTextChanged(Editable s) {
+        public void afterTextChanged(Editable s)
+        {
 
             /**
              * 文本处理
              * */
-            if (new_string_length == 0) {
+            if (new_string_length == 0)
+            {
                 string = "";
-            } else {
-                string = s.toString().substring(start_position,start_position + new_string_length);
+            }
+            else
+            {
+                string = s.toString().substring(start_position, start_position + new_string_length);
             }
 
-            if (change_length == 0) { // 新加内容
+            if (change_length == 0)
+            { // 新加内容
 
-            } else { // 替换原文或删除原文
+            }
+            else
+            { // 替换原文或删除原文
 
             }
 
@@ -130,7 +148,8 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
              * 业务逻辑
              * */
 
-            if (string.equals("\n") || string.equals("\r") || string.equals("\r\n")) {
+            if (string.equals("\n") || string.equals("\r") || string.equals("\r\n"))
+            {
                 textView.setText(origin_text);
                 return;
             }
@@ -138,9 +157,12 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
             mKeywords = s.toString();
             adapter.notifyDataSetChanged();
 
-            if (mKeywords.isEmpty()) {
-                enum_list_view.canDrag =  true;
-            } else {
+            if (mKeywords.isEmpty())
+            {
+                enum_list_view.canDrag = true;
+            }
+            else
+            {
                 enum_list_view.canDrag = false;
             }
 
@@ -148,8 +170,6 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
     }
 
 
-
-
     private int maxSelect;
     private int mGroup;
     private int mChild;
@@ -171,7 +191,8 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
 
 
     @Override
-    protected void onCreate(Bundle savedInstanceState) {
+    protected void onCreate(Bundle savedInstanceState)
+    {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_enum_select_and_sort);
 
@@ -179,8 +200,8 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
 
         setTitle(mTitle);
 
-        searchBar = (EditText)findViewById(R.id.common_editor_enum_select_sort_search_bar);
-        searchBar.addTextChangedListener(new SearchBarWatcher(mCtx,searchBar));
+        searchBar = (EditText) findViewById(R.id.common_editor_enum_select_sort_search_bar);
+        searchBar.addTextChangedListener(new SearchBarWatcher(mCtx, searchBar));
 
         enum_list_view = (DragListView) findViewById(R.id.enum__select_sort_list_view);
 
@@ -215,49 +236,58 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
 //    }
 
     @Override
-    public void finish() {
+    public void finish()
+    {
 
-        if (mDirty != false) {
+        if (mDirty != false)
+        {
             Intent intent = new Intent();
-            intent.putExtra(CADEDATE,mCadedate.toString());
-            intent.putExtra(GROUP_POSITION,mGroup);
-            intent.putExtra(CHILD_POSITION,mChild);
+            intent.putExtra(CADEDATE, mCadedate.toString());
+            intent.putExtra(GROUP_POSITION, mGroup);
+            intent.putExtra(CHILD_POSITION, mChild);
 
-            setResult(RESULT_OK,intent);
+            setResult(RESULT_OK, intent);
         }
 
 
         super.finish();
     }
 
-    private void init() {
+    private void init()
+    {
         mCtx = this;
         Intent intent = getIntent();
         String cadedate_str = intent.getStringExtra(CADEDATE);
-        try {
+        try
+        {
             mCadedate = new JSONObject(cadedate_str);
-        } catch (Exception e) {
+        } catch (Exception e)
+        {
             e.printStackTrace();
         }
-        mSingleSelect = intent.getBooleanExtra(SINGLE_SELECT,true);
-        mGroup = intent.getIntExtra(GROUP_POSITION,0);
-        mChild = intent.getIntExtra(CHILD_POSITION,0);
+        mSingleSelect = intent.getBooleanExtra(SINGLE_SELECT, true);
+        mGroup = intent.getIntExtra(GROUP_POSITION, 0);
+        mChild = intent.getIntExtra(CHILD_POSITION, 0);
         mTitle = intent.getStringExtra(TITLE);
-        maxSelect = intent.getIntExtra(MAX_SELECT,0);
-        mAuto_close = intent.getBooleanExtra(AUTO_CLOSE,true);
+        maxSelect = intent.getIntExtra(MAX_SELECT, 0);
+        mAuto_close = intent.getBooleanExtra(AUTO_CLOSE, true);
 
 
     }
 
-    private class CellClickListener implements AdapterView.OnItemClickListener {
+    private class CellClickListener implements AdapterView.OnItemClickListener
+    {
 
         private Context ctx;
-        public CellClickListener(Context ctx) {
+
+        public CellClickListener(Context ctx)
+        {
             this.ctx = ctx;
         }
 
         @Override
-        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
+        {
 
 //            if (isEditing) {
 //                return;
@@ -265,67 +295,85 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
 
             mDirty = true;
 
-            try {
-                if (mSingleSelect) {
+            try
+            {
+                if (mSingleSelect)
+                {
 
-                    boolean is_worked = false;
+                    boolean is_worked = true;
 
-                    if (mKeywords == null || mKeywords.isEmpty()) {
+                    if (mKeywords == null || mKeywords.isEmpty())
+                    {
 
-                        for (int i = 0; i < mCadedate.optInt("count"); i++) {
+                        for (int i = 0; i < mCadedate.optInt("count"); i++)
+                        {
                             JSONObject val_json = mCadedate.optJSONObject("val_" + i);
 
-                            if (i == position) {
+                            if (i == position)
+                            {
                                 int select = val_json.optInt("check");
-                                if (select == 0) {
-                                    val_json.put("check","1");
-                                } else {
-                                    val_json.put("check","0");
+                                if (select == 0)
+                                {
+                                    val_json.put("check", "1");
                                 }
-                                is_worked = select == 0;
-                            } else {
-                                val_json.put("check","0");
+//                                else
+//                                {
+//                                    val_json.put("check", "0");
+//                                }
+//                                is_worked = select == 0;
                             }
-                            mCadedate.put("val_" + i,val_json);
-
+                            else
+                            {
+                                val_json.put("check", "0");
+                            }
+                            mCadedate.put("val_" + i, val_json);
 
 
                         } // for
 
                     } // keywords null
-                    else {
+                    else
+                    {
 
 
                         JSONObject val_json = null;
                         int count = 0;
                         boolean getIt = false;
-                        for (int cc = 0; cc < mCadedate.optInt("count"); cc++) {
+                        for (int cc = 0; cc < mCadedate.optInt("count"); cc++)
+                        {
 
                             JSONObject search_json = mCadedate.optJSONObject("val_" + cc);
                             String value = search_json.optString("value");
                             boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                            if (contain && count < filter_count) {
+                            if (contain && count < filter_count)
+                            {
                                 count++;
                             }
 
                             val_json = search_json;
-                            if (!getIt && count - 1 == position) {
+                            if (!getIt && count - 1 == position)
+                            {
                                 getIt = true;
 
                                 //==========
                                 int select = val_json.optInt("check");
-                                if (select != 0) {
-                                    val_json.put("check","0");
-                                } else {
-                                    val_json.put("check","1");
+//                                if (select != 0)
+//                                {
+//                                    val_json.put("check", "0");
+//                                }
+//                                else
+                                {
+                                    val_json.put("check", "1");
                                 }
                                 is_worked = select == 0;
 
-                            } else  {
-                                val_json.put("check","0");
+                            }
+                            else
+                            {
+                                val_json.put("check", "0");
                             }
 
-                            mCadedate.put("val_" + cc,val_json);
+                            mCadedate.put("val_" + cc, val_json);
                         } // for cc
 
 //                        for (int sc = 0; sc < mCadedate.optInt("count"); sc++) {
@@ -344,38 +392,52 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
 
                     }
 
-                    if (is_worked) {
-                        if (mAuto_close) {
+                    if (is_worked)
+                    {
+                        if (mAuto_close)
+                        {
                             finish();
-                        } else {
+                        }
+                        else
+                        {
                             adapter.notifyDataSetChanged();
                         }
-                    } else {
+                    }
+                    else
+                    {
                         adapter.notifyDataSetChanged();
                     }
 
 
                 } // single select
-                else {
+                else
+                {
 
                     int index = position;
                     JSONObject val_json = null;
-                    if (mKeywords == null || mKeywords.isEmpty()) {
+                    if (mKeywords == null || mKeywords.isEmpty())
+                    {
                         val_json = mCadedate.optJSONObject("val_" + position);
-                    } else {
+                    }
+                    else
+                    {
                         int count = 0;
-                        for (int i = 0; i < mCadedate.optInt("count"); i++) {
-                            if (count >= filter_count) {
+                        for (int i = 0; i < mCadedate.optInt("count"); i++)
+                        {
+                            if (count >= filter_count)
+                            {
                                 break;
                             }
                             JSONObject search_json = mCadedate.optJSONObject("val_" + i);
                             String value = search_json.optString("value");
                             boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                            if (contain) {
+                            if (contain)
+                            {
                                 count++;
                             }
 
-                            if (count - 1 == position) {
+                            if (count - 1 == position)
+                            {
                                 val_json = search_json;
                                 index = i;
                                 break;
@@ -384,39 +446,47 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
                     }
 
                     int check = val_json.optInt("check");
-                    if (check == 1) {
-                        val_json.put("check","0");
-                    } else {
-                        if (check_count() >= maxSelect && maxSelect > 0) {
+                    if (check == 1)
+                    {
+                        val_json.put("check", "0");
+                    }
+                    else
+                    {
+                        if (check_count() >= maxSelect && maxSelect > 0)
+                        {
                             new AlertDialog.Builder(this.ctx)
                                     .setTitle("Max count reached")
                                     .setMessage(maxSelect + " items at most for this field.")
-                                    .setPositiveButton("OK",null)
+                                    .setPositiveButton("OK", null)
                                     .show();
                             return;
 
                         }
-                        val_json.put("check","1");
+                        val_json.put("check", "1");
                     }
-                    mCadedate.put("val_" + index,val_json);
+                    mCadedate.put("val_" + index, val_json);
 
                 }
                 adapter.notifyDataSetChanged();
 
-            } catch (Exception e) {
+            } catch (Exception e)
+            {
                 e.printStackTrace();
             }
 
         }
     }
 
-    public int check_count() {
+    public int check_count()
+    {
 
         int check_count = 0;
-        for (int i = 0; i < mCadedate.optInt("count"); i++) {
+        for (int i = 0; i < mCadedate.optInt("count"); i++)
+        {
             JSONObject val_json = mCadedate.optJSONObject("val_" + i);
             int check = val_json.optInt("check");
-            if (check == 1) {
+            if (check == 1)
+            {
                 check_count++;
             }
         }
@@ -424,22 +494,26 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
     }
 
 
-    private class EnumAdapter extends DragListView.DragListAdapter {
+    private class EnumAdapter extends DragListView.DragListAdapter
+    {
 
-        public class Holder {
+        public class Holder
+        {
             public TextView value_tv;
             public ImageView check_iv;
             public ImageView drag_iv;
 
-            public Holder(View cell) {
-                if (cell == null) {
+            public Holder(View cell)
+            {
+                if (cell == null)
+                {
                     return;
                 }
-                value_tv = (TextView)cell.findViewById(R.id.enum_value_tv);
-                check_iv = (ImageView)cell.findViewById(R.id.enum_check_iv);
+                value_tv = (TextView) cell.findViewById(R.id.enum_value_tv);
+                check_iv = (ImageView) cell.findViewById(R.id.enum_check_iv);
                 check_iv.setClickable(false);
                 check_iv.setFocusable(false);
-                drag_iv = (ImageView)cell.findViewById(R.id.drag_list_item_image);
+                drag_iv = (ImageView) cell.findViewById(R.id.drag_list_item_image);
 
                 cell.setTag(this);
 
@@ -448,28 +522,35 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
 
 
         private Context ctx;
-        public EnumAdapter(Context context) {
+
+        public EnumAdapter(Context context)
+        {
             this.ctx = context;
         }
 
         @Override
-        public int getCount() {
+        public int getCount()
+        {
 
-            if (mCadedate == null) {
+            if (mCadedate == null)
+            {
                 return 0;
             }
 
-            if (mKeywords == null || mKeywords.isEmpty()) {
+            if (mKeywords == null || mKeywords.isEmpty())
+            {
                 filter_count = 0;
                 return mCadedate.optInt("count");
             }
 
             int count = 0;
-            for (int i = 0; i < mCadedate.optInt("count"); i++) {
+            for (int i = 0; i < mCadedate.optInt("count"); i++)
+            {
                 JSONObject val_json = mCadedate.optJSONObject("val_" + i);
                 String value = val_json.optString("value");
                 boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                if (contain) {
+                if (contain)
+                {
                     count++;
                 }
             }
@@ -478,26 +559,36 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
         }
 
         @Override
-        public Object getItem(int position) {
+        public Object getItem(int position)
+        {
             JSONObject val_json = null;
-            if (mKeywords == null || mKeywords.isEmpty()) {
+            if (mKeywords == null || mKeywords.isEmpty())
+            {
                 val_json = mCadedate.optJSONObject("val_" + position);
-            } else {
+            }
+            else
+            {
                 int count = 0;
-                for (int i = 0; i < mCadedate.optInt("count"); i++) {
-                    if (count >= filter_count) {
+                for (int i = 0; i < mCadedate.optInt("count"); i++)
+                {
+                    if (count >= filter_count)
+                    {
                         break;
                     }
                     JSONObject search_json = mCadedate.optJSONObject("val_" + i);
                     String value = search_json.optString("value");
                     boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                    if (contain) {
+                    if (contain)
+                    {
                         count++;
-                    } else {
+                    }
+                    else
+                    {
                         continue;
                     }
 
-                    if (count - 1 == position) {
+                    if (count - 1 == position)
+                    {
                         val_json = search_json;
                         break;
                     }
@@ -508,12 +599,14 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
         }
 
         @Override
-        public long getItemId(int position) {
+        public long getItemId(int position)
+        {
             return position;
         }
 
         @Override
-        public View getView(int position, View convertView, ViewGroup parent) {
+        public View getView(int position, View convertView, ViewGroup parent)
+        {
             JSONObject val_json = (JSONObject) getItem(position);
 //            if (mKeywords == null || mKeywords.isEmpty()) {
 //                val_json = mCadedate.optJSONObject("val_" + position);
@@ -522,12 +615,15 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
 //            }
 
             Holder holder;
-            if (convertView == null) {
+            if (convertView == null)
+            {
 
-                convertView = LayoutInflater.from(this.ctx).inflate(R.layout.enum_select_sort_cell,null);
+                convertView = LayoutInflater.from(this.ctx).inflate(R.layout.enum_select_sort_cell, null);
                 holder = new Holder(convertView);
 
-            } else {
+            }
+            else
+            {
                 holder = (Holder) convertView.getTag();
             }
 
@@ -535,9 +631,12 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
             holder.value_tv.setText(value);
 
             int check = val_json.optInt("check");
-            if (check == 1) {
+            if (check == 1)
+            {
                 holder.check_iv.setVisibility(View.VISIBLE);
-            } else {
+            }
+            else
+            {
                 holder.check_iv.setVisibility(View.INVISIBLE);
             }
 
@@ -562,41 +661,52 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
         }
 
         @Override
-        public void insert(Object object,int position) {
+        public void insert(Object object, int position)
+        {
 
             int count = getCount();
 
             mDirty = true;
-            if (position >= count) {
-                if (position > count) {
+            if (position >= count)
+            {
+                if (position > count)
+                {
                     position = count;
                 }
 
-                JSONObject val_json = (JSONObject)object;
-                try {
+                JSONObject val_json = (JSONObject) object;
+                try
+                {
                     mCadedate.put("val_" + position, val_json);
-                    mCadedate.put("count", count+1);
-                } catch (JSONException e) {
+                    mCadedate.put("count", count + 1);
+                } catch (JSONException e)
+                {
                     e.printStackTrace();
                 }
 
 
-            } else {
-                if (position < 0) {
+            }
+            else
+            {
+                if (position < 0)
+                {
                     position = 0;
                 }
 
-                try {
-                    for (int i = count - 1; i >= position; i--) {
+                try
+                {
+                    for (int i = count - 1; i >= position; i--)
+                    {
                         JSONObject val_json = mCadedate.getJSONObject("val_" + i);
-                        mCadedate.put("val_" + (i + 1),val_json);
+                        mCadedate.put("val_" + (i + 1), val_json);
                     }
 
-                    JSONObject val_json = (JSONObject)object;
+                    JSONObject val_json = (JSONObject) object;
                     mCadedate.put("val_" + position, val_json);
-                    mCadedate.put("count", count+1);
+                    mCadedate.put("count", count + 1);
 
-                } catch (JSONException e) {
+                } catch (JSONException e)
+                {
                     e.printStackTrace();
                 }
 
@@ -604,33 +714,42 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
         }
 
         @Override
-        public void remove(Object object) {
+        public void remove(Object object)
+        {
 
             int count = getCount();
-            if (count <= 0) {
+            if (count <= 0)
+            {
                 return;
             }
 
             mDirty = true;
-            try {
+            try
+            {
                 int remove_index = count;
-                for (int i = 0; i < count; i++) {
+                for (int i = 0; i < count; i++)
+                {
                     JSONObject val_json = mCadedate.getJSONObject("val_" + i);
-                    if (val_json.equals(object)) {
+                    if (val_json.equals(object))
+                    {
                         remove_index = i;
                     }
-                    if (remove_index < count) { // 有删除
-                        if (i > remove_index) {
-                            mCadedate.put("val_" + (i - 1),val_json);
+                    if (remove_index < count)
+                    { // 有删除
+                        if (i > remove_index)
+                        {
+                            mCadedate.put("val_" + (i - 1), val_json);
                         }
 
-                        if (i == count - 1) { // 清除末尾
-                            mCadedate.put("val_" + i,null);
+                        if (i == count - 1)
+                        { // 清除末尾
+                            mCadedate.put("val_" + i, null);
                         }
-                        mCadedate.put("count",count - 1);
+                        mCadedate.put("count", count - 1);
                     }
                 }
-            } catch (JSONException e) {
+            } catch (JSONException e)
+            {
                 e.printStackTrace();
             }
 
@@ -638,5 +757,4 @@ public class EnumSelectAndSortActivity extends AppCompatActivity {
     }
 
 
-
 }

+ 221 - 123
ApexDrivers/CommonEditorLib/src/main/java/com/usai/commoneditorlib/EnumSlectActivity.java

@@ -5,6 +5,7 @@ import android.content.Intent;
 
 import androidx.appcompat.app.AlertDialog;
 import androidx.appcompat.app.AppCompatActivity;
+
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextWatcher;
@@ -25,7 +26,8 @@ import org.json.JSONObject;
 import java.io.Serializable;
 import java.util.zip.Inflater;
 
-public class EnumSlectActivity extends AppCompatActivity {
+public class EnumSlectActivity extends AppCompatActivity
+{
 
     static String MAX_SELECT = "max_select";
     static String GROUP_POSITION = "group";
@@ -35,36 +37,43 @@ public class EnumSlectActivity extends AppCompatActivity {
     static String TITLE = "title";
     static String AUTO_CLOSE = "auto_close";
 
-    public static class Builder {
-        public Intent build(Context context,String title, int max_select, int group, int child, String cadedate,boolean single_select,boolean auto_close) {
-            if (context == null) {
+    public static class Builder
+    {
+        public Intent build(Context context, String title, int max_select, int group, int child, String cadedate, boolean single_select, boolean auto_close)
+        {
+            if (context == null)
+            {
                 return null;
             }
 
-            Intent intent = new Intent(context,EnumSlectActivity.class);
+            Intent intent = new Intent(context, EnumSlectActivity.class);
 
-            intent.putExtra(MAX_SELECT,max_select);
-            intent.putExtra(GROUP_POSITION,group);
-            intent.putExtra(CHILD_POSITION,child);
-            if (cadedate != null) {
-                intent.putExtra(CADEDATE,(Serializable) cadedate);
+            intent.putExtra(MAX_SELECT, max_select);
+            intent.putExtra(GROUP_POSITION, group);
+            intent.putExtra(CHILD_POSITION, child);
+            if (cadedate != null)
+            {
+                intent.putExtra(CADEDATE, (Serializable) cadedate);
             }
-            intent.putExtra(SINGLE_SELECT,single_select);
-            if (title != null) {
-                intent.putExtra(TITLE,title);
+            intent.putExtra(SINGLE_SELECT, single_select);
+            if (title != null)
+            {
+                intent.putExtra(TITLE, title);
             }
-            intent.putExtra(AUTO_CLOSE,auto_close);
+            intent.putExtra(AUTO_CLOSE, auto_close);
 
             return intent;
         }
     }
 
-    public class SearchBarWatcher implements TextWatcher {
+    public class SearchBarWatcher implements TextWatcher
+    {
 
         Context mCtx;
         EditText textView;
 
-        public SearchBarWatcher(Context ctx,EditText textView) {
+        public SearchBarWatcher(Context ctx, EditText textView)
+        {
             this.mCtx = ctx;
             this.textView = textView;
 
@@ -83,9 +92,10 @@ public class EnumSlectActivity extends AppCompatActivity {
          * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
          * count    选中s中的内容长度(发生改变的原内容长度),未选中为0
          * after    新添加的内容长度,删除为0
-         * */
+         */
         @Override
-        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+        public void beforeTextChanged(CharSequence s, int start, int count, int after)
+        {
 //            Log.d("TextChange", "before Text Changed: " + s + " Start: " + start + " Count: " + count + " After: " + after);
 
             origin_text = s.toString();
@@ -99,27 +109,35 @@ public class EnumSlectActivity extends AppCompatActivity {
          * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
          * before   选中s中的内容长度(发生改变的原内容长度),未选中为0
          * count    增加内容长度,删除内容为0
-         * */
+         */
         @Override
-        public void onTextChanged(CharSequence s, int start, int before, int count) {
+        public void onTextChanged(CharSequence s, int start, int before, int count)
+        {
 //            Log.d("TextChange", "on Text Changed: " + s + " Start: " + start + " Before: " + before + " Count: " + count);
         }
 
         @Override
-        public void afterTextChanged(Editable s) {
+        public void afterTextChanged(Editable s)
+        {
 
             /**
              * 文本处理
              * */
-            if (new_string_length == 0) {
+            if (new_string_length == 0)
+            {
                 string = "";
-            } else {
-                string = s.toString().substring(start_position,start_position + new_string_length);
+            }
+            else
+            {
+                string = s.toString().substring(start_position, start_position + new_string_length);
             }
 
-            if (change_length == 0) { // 新加内容
+            if (change_length == 0)
+            { // 新加内容
 
-            } else { // 替换原文或删除原文
+            }
+            else
+            { // 替换原文或删除原文
 
             }
 
@@ -127,7 +145,8 @@ public class EnumSlectActivity extends AppCompatActivity {
              * 业务逻辑
              * */
 
-            if (string.equals("\n") || string.equals("\r") || string.equals("\r\n")) {
+            if (string.equals("\n") || string.equals("\r") || string.equals("\r\n"))
+            {
                 textView.setText(origin_text);
                 return;
             }
@@ -159,7 +178,8 @@ public class EnumSlectActivity extends AppCompatActivity {
 
 
     @Override
-    protected void onCreate(Bundle savedInstanceState) {
+    protected void onCreate(Bundle savedInstanceState)
+    {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_enum_slect);
 
@@ -167,10 +187,10 @@ public class EnumSlectActivity extends AppCompatActivity {
 
         setTitle(mTitle);
 
-        searchBar = (EditText)findViewById(R.id.common_editor_enum_search_bar);
-        searchBar.addTextChangedListener(new SearchBarWatcher(mCtx,searchBar));
+        searchBar = (EditText) findViewById(R.id.common_editor_enum_search_bar);
+        searchBar.addTextChangedListener(new SearchBarWatcher(mCtx, searchBar));
 
-        enum_list_view = (ListView)findViewById(R.id.enum_list_view);
+        enum_list_view = (ListView) findViewById(R.id.enum_list_view);
 
         adapter = new EnumAdapter(mCtx);
         enum_list_view.setAdapter(adapter);
@@ -181,112 +201,139 @@ public class EnumSlectActivity extends AppCompatActivity {
     }
 
     @Override
-    public void finish() {
+    public void finish()
+    {
 
-        if (mDirty != false) {
+        if (mDirty != false)
+        {
             Intent intent = new Intent();
-            intent.putExtra(CADEDATE,mCadedate.toString());
-            intent.putExtra(GROUP_POSITION,mGroup);
-            intent.putExtra(CHILD_POSITION,mChild);
+            intent.putExtra(CADEDATE, mCadedate.toString());
+            intent.putExtra(GROUP_POSITION, mGroup);
+            intent.putExtra(CHILD_POSITION, mChild);
 
-            setResult(RESULT_OK,intent);
+            setResult(RESULT_OK, intent);
         }
 
 
         super.finish();
     }
 
-    private void init() {
+    private void init()
+    {
         mCtx = this;
         Intent intent = getIntent();
         String cadedate_str = intent.getStringExtra(CADEDATE);
-        try {
+        try
+        {
             mCadedate = new JSONObject(cadedate_str);
-        } catch (Exception e) {
+        } catch (Exception e)
+        {
             e.printStackTrace();
         }
-        mSingleSelect = intent.getBooleanExtra(SINGLE_SELECT,true);
-        mGroup = intent.getIntExtra(GROUP_POSITION,0);
-        mChild = intent.getIntExtra(CHILD_POSITION,0);
+        mSingleSelect = intent.getBooleanExtra(SINGLE_SELECT, true);
+        mGroup = intent.getIntExtra(GROUP_POSITION, 0);
+        mChild = intent.getIntExtra(CHILD_POSITION, 0);
         mTitle = intent.getStringExtra(TITLE);
-        maxSelect = intent.getIntExtra(MAX_SELECT,0);
-        mAuto_close = intent.getBooleanExtra(AUTO_CLOSE,true);
+        maxSelect = intent.getIntExtra(MAX_SELECT, 0);
+        mAuto_close = intent.getBooleanExtra(AUTO_CLOSE, true);
 
 
     }
 
-    private class CellClickListener implements AdapterView.OnItemClickListener {
+    private class CellClickListener implements AdapterView.OnItemClickListener
+    {
 
         private Context ctx;
-        public CellClickListener(Context ctx) {
+
+        public CellClickListener(Context ctx)
+        {
             this.ctx = ctx;
         }
 
         @Override
-        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
+        {
 
             mDirty = true;
 
-            try {
-                if (mSingleSelect) {
+            try
+            {
+                if (mSingleSelect)
+                {
 
-                    boolean is_worked = false;
+                    boolean is_worked = true;
 
-                    if (mKeywords == null || mKeywords.isEmpty()) {
+                    if (mKeywords == null || mKeywords.isEmpty())
+                    {
 
-                        for (int i = 0; i < mCadedate.optInt("count"); i++) {
+                        for (int i = 0; i < mCadedate.optInt("count"); i++)
+                        {
                             JSONObject val_json = mCadedate.optJSONObject("val_" + i);
 
-                            if (i == position) {
+                            if (i == position)
+                            {
                                 int select = val_json.optInt("check");
-                                if (select == 0) {
-                                    val_json.put("check","1");
-                                } else {
-                                    val_json.put("check","0");
+                                if (select == 0)
+                                {
+                                    val_json.put("check", "1");
                                 }
-                                is_worked = select == 0;
-                            } else {
-                                val_json.put("check","0");
+//                                else
+//                                {
+//                                    val_json.put("check", "0");
+//                                }
+//                                is_worked = select == 0;
                             }
-                            mCadedate.put("val_" + i,val_json);
-
+                            else
+                            {
+                                val_json.put("check", "0");
+                            }
+                            mCadedate.put("val_" + i, val_json);
 
 
                         } // for
 
                     } // keywords null
-                    else {
+                    else
+                    {
 
 
                         JSONObject val_json = null;
                         int count = 0;
                         boolean getIt = false;
-                        for (int cc = 0; cc < mCadedate.optInt("count"); cc++) {
+                        for (int cc = 0; cc < mCadedate.optInt("count"); cc++)
+                        {
 
                             JSONObject search_json = mCadedate.optJSONObject("val_" + cc);
                             String value = search_json.optString("value");
                             boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                            if (contain && count < filter_count) {
+                            if (contain && count < filter_count)
+                            {
                                 count++;
                             }
 
                             val_json = search_json;
-                            if (!getIt && count - 1 == position) {
+                            if (!getIt && count - 1 == position)
+                            {
                                 getIt = true;
                                 //==========
                                 int select = val_json.optInt("check");
-                                if (select != 0) {
-                                    val_json.put("check","0");
-                                } else {
-                                    val_json.put("check","1");
+//                                if (select != 0)
+//                                {
+//                                    val_json.put("check", "0");
+//                                }
+//                                else
+                                {
+                                    val_json.put("check", "1");
                                 }
                                 is_worked = select == 0;
 
-                            } else  {
-                                val_json.put("check","0");
+                            }
+                            else
+                            {
+                                val_json.put("check", "0");
                             }
 
-                            mCadedate.put("val_" + cc,val_json);
+                            mCadedate.put("val_" + cc, val_json);
 
 
                         } // for cc
@@ -307,38 +354,52 @@ public class EnumSlectActivity extends AppCompatActivity {
 
                     }
 
-                    if (is_worked) {
-                        if (mAuto_close) {
+                    if (is_worked)
+                    {
+                        if (mAuto_close)
+                        {
                             finish();
-                        } else {
+                        }
+                        else
+                        {
                             adapter.notifyDataSetChanged();
                         }
-                    } else {
+                    }
+                    else
+                    {
                         adapter.notifyDataSetChanged();
                     }
 
 
                 } // single select
-                else {
+                else
+                {
 
                     int index = position;
                     JSONObject val_json = null;
-                    if (mKeywords == null || mKeywords.isEmpty()) {
+                    if (mKeywords == null || mKeywords.isEmpty())
+                    {
                         val_json = mCadedate.optJSONObject("val_" + position);
-                    } else {
+                    }
+                    else
+                    {
                         int count = 0;
-                        for (int i = 0; i < mCadedate.optInt("count"); i++) {
-                            if (count >= filter_count) {
+                        for (int i = 0; i < mCadedate.optInt("count"); i++)
+                        {
+                            if (count >= filter_count)
+                            {
                                 break;
                             }
                             JSONObject search_json = mCadedate.optJSONObject("val_" + i);
                             String value = search_json.optString("value");
                             boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                            if (contain) {
+                            if (contain)
+                            {
                                 count++;
                             }
 
-                            if (count - 1 == position) {
+                            if (count - 1 == position)
+                            {
                                 val_json = search_json;
                                 index = i;
                                 break;
@@ -347,39 +408,47 @@ public class EnumSlectActivity extends AppCompatActivity {
                     }
 
                     int check = val_json.optInt("check");
-                    if (check == 1) {
-                        val_json.put("check","0");
-                    } else {
-                        if (check_count() >= maxSelect && maxSelect > 0) {
+                    if (check == 1)
+                    {
+                        val_json.put("check", "0");
+                    }
+                    else
+                    {
+                        if (check_count() >= maxSelect && maxSelect > 0)
+                        {
                             new AlertDialog.Builder(this.ctx)
                                     .setTitle("Max count reached")
                                     .setMessage(maxSelect + " items at most for this field.")
-                                    .setPositiveButton("OK",null)
+                                    .setPositiveButton("OK", null)
                                     .show();
                             return;
 
                         }
-                        val_json.put("check","1");
+                        val_json.put("check", "1");
                     }
-                    mCadedate.put("val_" + index,val_json);
+                    mCadedate.put("val_" + index, val_json);
 
                 }
                 adapter.notifyDataSetChanged();
 
-            } catch (Exception e) {
+            } catch (Exception e)
+            {
                 e.printStackTrace();
             }
 
         }
     }
 
-    public int check_count() {
+    public int check_count()
+    {
 
         int check_count = 0;
-        for (int i = 0; i < mCadedate.optInt("count"); i++) {
+        for (int i = 0; i < mCadedate.optInt("count"); i++)
+        {
             JSONObject val_json = mCadedate.optJSONObject("val_" + i);
             int check = val_json.optInt("check");
-            if (check == 1) {
+            if (check == 1)
+            {
                 check_count++;
             }
         }
@@ -387,18 +456,22 @@ public class EnumSlectActivity extends AppCompatActivity {
     }
 
 
-    private class EnumAdapter extends BaseAdapter {
+    private class EnumAdapter extends BaseAdapter
+    {
 
-        public class Holder {
+        public class Holder
+        {
             public TextView value_tv;
             public ImageView check_iv;
 
-            public Holder(View cell) {
-                if (cell == null) {
+            public Holder(View cell)
+            {
+                if (cell == null)
+                {
                     return;
                 }
-                value_tv = (TextView)cell.findViewById(R.id.enum_value_tv);
-                check_iv = (ImageView)cell.findViewById(R.id.enum_check_iv);
+                value_tv = (TextView) cell.findViewById(R.id.enum_value_tv);
+                check_iv = (ImageView) cell.findViewById(R.id.enum_check_iv);
                 check_iv.setClickable(false);
                 check_iv.setFocusable(false);
                 cell.setTag(this);
@@ -408,28 +481,35 @@ public class EnumSlectActivity extends AppCompatActivity {
 
 
         private Context ctx;
-        public EnumAdapter(Context context) {
+
+        public EnumAdapter(Context context)
+        {
             this.ctx = context;
         }
 
         @Override
-        public int getCount() {
+        public int getCount()
+        {
 
-            if (mCadedate == null) {
+            if (mCadedate == null)
+            {
                 return 0;
             }
 
-            if (mKeywords == null || mKeywords.isEmpty()) {
+            if (mKeywords == null || mKeywords.isEmpty())
+            {
                 filter_count = 0;
                 return mCadedate.optInt("count");
             }
 
             int count = 0;
-            for (int i = 0; i < mCadedate.optInt("count"); i++) {
+            for (int i = 0; i < mCadedate.optInt("count"); i++)
+            {
                 JSONObject val_json = mCadedate.optJSONObject("val_" + i);
                 String value = val_json.optString("value");
                 boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                if (contain) {
+                if (contain)
+                {
                     count++;
                 }
             }
@@ -438,26 +518,36 @@ public class EnumSlectActivity extends AppCompatActivity {
         }
 
         @Override
-        public Object getItem(int position) {
+        public Object getItem(int position)
+        {
             JSONObject val_json = null;
-            if (mKeywords == null || mKeywords.isEmpty()) {
+            if (mKeywords == null || mKeywords.isEmpty())
+            {
                 val_json = mCadedate.optJSONObject("val_" + position);
-            } else {
+            }
+            else
+            {
                 int count = 0;
-                for (int i = 0; i < mCadedate.optInt("count"); i++) {
-                    if (count >= filter_count) {
+                for (int i = 0; i < mCadedate.optInt("count"); i++)
+                {
+                    if (count >= filter_count)
+                    {
                         break;
                     }
                     JSONObject search_json = mCadedate.optJSONObject("val_" + i);
                     String value = search_json.optString("value");
                     boolean contain = value.toUpperCase().contains(mKeywords.toUpperCase());
-                    if (contain) {
+                    if (contain)
+                    {
                         count++;
-                    } else {
+                    }
+                    else
+                    {
                         continue;
                     }
 
-                    if (count - 1 == position) {
+                    if (count - 1 == position)
+                    {
                         val_json = search_json;
                         break;
                     }
@@ -468,12 +558,14 @@ public class EnumSlectActivity extends AppCompatActivity {
         }
 
         @Override
-        public long getItemId(int position) {
+        public long getItemId(int position)
+        {
             return position;
         }
 
         @Override
-        public View getView(int position, View convertView, ViewGroup parent) {
+        public View getView(int position, View convertView, ViewGroup parent)
+        {
             JSONObject val_json = (JSONObject) getItem(position);
 //            if (mKeywords == null || mKeywords.isEmpty()) {
 //                val_json = mCadedate.optJSONObject("val_" + position);
@@ -482,12 +574,15 @@ public class EnumSlectActivity extends AppCompatActivity {
 //            }
 
             Holder holder;
-            if (convertView == null) {
+            if (convertView == null)
+            {
 
-                convertView = LayoutInflater.from(this.ctx).inflate(R.layout.enum_select_cell,null);
+                convertView = LayoutInflater.from(this.ctx).inflate(R.layout.enum_select_cell, null);
                 holder = new Holder(convertView);
 
-            } else {
+            }
+            else
+            {
                 holder = (Holder) convertView.getTag();
             }
 
@@ -495,9 +590,12 @@ public class EnumSlectActivity extends AppCompatActivity {
             holder.value_tv.setText(value);
 
             int check = val_json.optInt("check");
-            if (check == 1) {
+            if (check == 1)
+            {
                 holder.check_iv.setVisibility(View.VISIBLE);
-            } else {
+            }
+            else
+            {
                 holder.check_iv.setVisibility(View.INVISIBLE);
             }
 

+ 263 - 168
ApexDrivers/CommonEditorLib/src/main/java/com/usai/commoneditorlib/EnumSlectOnlineActivity.java

@@ -38,13 +38,15 @@ import org.w3c.dom.Text;
 import java.io.Serializable;
 
 import static com.usai.redant.rautils.utils.RAUtil.getJsonFromAsset;
+import static java.lang.Thread.sleep;
 
-public class EnumSlectOnlineActivity extends AppCompatActivity {
+public class EnumSlectOnlineActivity extends AppCompatActivity
+{
 
     static String MAX_SELECT = "max_select";
     static String GROUP_POSITION = "group";
     static String CHILD_POSITION = "child";
-//    static String CADEDATE = "cadedate";
+    //    static String CADEDATE = "cadedate";
     static String SINGLE_SELECT = "single_select";
     static String TITLE = "title";
     static String AUTO_CLOSE = "auto_close";
@@ -56,47 +58,53 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
     private final int LoadDataOptionLoadMore = 2;
 
 
-//    Bundle params;
+    //    Bundle params;
 //    String url;
-    int offset=0;
-    int limit=2;
+    int offset = 0;
+    int limit = 20;
 
     private ScrollListener mScrollListener;
-    boolean isLoading=false;
-    boolean hasmore=false;
+    boolean isLoading = false;
+    boolean hasmore = false;
     private SwipeRefreshLayout mRefreshLayout;
     private ProgressBar mProgressBar;
     private TextView mListFooterView;
 
-    private void setupListFooterView() {
+    private void setupListFooterView()
+    {
         mListFooterView = new TextView(mCtx);
         mListFooterView.setBackgroundColor(Color.WHITE);
         mListFooterView.setGravity(Gravity.CENTER);
         mListFooterView.setText("loading more...");
-        mListFooterView.setTextSize(RAUtil.sp2px(mCtx,8));
+        mListFooterView.setTextSize(RAUtil.sp2px(mCtx, 8));
         mListFooterView.setVisibility(View.INVISIBLE);
     }
 
-    private void setupRefreshLayout() {
+    private void setupRefreshLayout()
+    {
 
         mRefreshLayout = findViewById(R.id.enum_refresh_layout);
-        mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+        mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener()
+        {
             @Override
-            public void onRefresh() {
-                hasmore=false;
-                offset=0;
+            public void onRefresh()
+            {
+                hasmore = false;
+                offset = 0;
                 LoadData(LoadDataOptionReload);
             }
         });
     }
 
 
-    private class ScrollListener implements AbsListView.OnScrollListener {
+    private class ScrollListener implements AbsListView.OnScrollListener
+    {
 
         private int last_index, total_index;
 
         @Override
-        public void onScrollStateChanged(AbsListView view, int scrollState) {
+        public void onScrollStateChanged(AbsListView view, int scrollState)
+        {
 //            if(isNoMore&& (scrollState == SCROLL_STATE_IDLE))
 //            {
 //                showMessage("No more data.");
@@ -105,8 +113,10 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 ////                return;
 //            }
 
-            if (last_index == total_index && (scrollState == SCROLL_STATE_IDLE)) {
-                if (!isLoading) {
+            if (last_index == total_index && (scrollState == SCROLL_STATE_IDLE))
+            {
+                if (!isLoading)
+                {
 
                     mListFooterView.setVisibility(View.VISIBLE);
                     EnumSlectOnlineActivity.this.LoadData(LoadDataOptionLoadMore);
@@ -115,16 +125,18 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
         }
 
         @Override
-        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
+        {
             last_index = firstVisibleItem + visibleItemCount;
             total_index = totalItemCount;
         }
     }
+
     void LoadData(int option)
     {
 
 
-        RedantApplication application= (RedantApplication) getApplication();
+        RedantApplication application = (RedantApplication) getApplication();
 
         boolean fakedata = application.useFakeData();
 
@@ -132,19 +144,21 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
         Bundle params = intent.getBundleExtra(PARAMETERS);
 
         String url = intent.getStringExtra(URL);
-        if(option == LoadDataOptionReload)
+        if (option == LoadDataOptionReload)
         {
-            offset=0;
+            offset = 0;
 //            limit = 0;
         }
 
-        if(params ==null)
+        if (params == null)
+        {
             params = new Bundle();
-        params.putInt("offset",offset);
-        params.putInt("limit",limit);
-        if(!TextUtils.isEmpty(mKeywords))
+        }
+        params.putInt("offset", offset);
+        params.putInt("limit", limit);
+        if (!TextUtils.isEmpty(mKeywords))
         {
-            params.putString("keywords",mKeywords);
+            params.putString("keywords", mKeywords);
 
         }
 
@@ -152,35 +166,47 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 
         showProgressBar();
         Bundle finalParams = params;
-        new Thread(new Runnable() {
+        new Thread(new Runnable()
+        {
             @Override
-            public void run() {
-
+            public void run()
+            {
 
 
                 JSONObject result_json = null;
 
-                if(fakedata)
+                if (fakedata)
                 {
-
-                    result_json = getJsonFromAsset(getApplicationContext(),"enum_cadedate.json");
+//                    try
+//                    {
+//                        sleep(2000);
+//                    } catch (InterruptedException e)
+//                    {
+//                        e.printStackTrace();
+//                    }
+                    result_json = getJsonFromAsset(getApplicationContext(), "enum_cadedate.json");
 
 
                 }
                 else
-                    result_json=Network.GetCadedate(url, finalParams);
+                {
+                    result_json = Network.GetCadedate(url, finalParams);
+                }
 
                 JSONObject finalResult_json = result_json;
-                runOnUiThread(new Runnable() {
+                runOnUiThread(new Runnable()
+                {
                     @Override
-                    public void run() {
+                    public void run()
+                    {
 
                         dismissProgressBar();
-
-                        if(option == LoadDataOptionReload)
+                        mListFooterView.setVisibility(View.INVISIBLE);
+                        if (option == LoadDataOptionReload)
                         {
 
-                            if (mRefreshLayout.isRefreshing()) {
+                            if (mRefreshLayout.isRefreshing())
+                            {
                                 mRefreshLayout.setRefreshing(false);
                             }
                             mListFooterView.setVisibility(View.INVISIBLE);
@@ -192,43 +218,49 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
                         try
                         {
 
-                        int result = finalResult_json.optInt("result");
-                        if (result == 2) {
-
-                            if (option !=     LoadDataOptionLoadMore) {
-                                mCadedate = new JSONObject();
-                            }
-
-                            int count = finalResult_json.optInt("count");
-                            if(count>=limit)
-                                hasmore=true;
-                            else
+                            int result = finalResult_json.optInt("result");
+                            if (result == 2)
                             {
 
-                                mListFooterView.setText("No more data");
-                                mListFooterView.setVisibility(View.VISIBLE);
-                                hasmore = false;
+                                if (option != LoadDataOptionLoadMore)
+                                {
+                                    mCadedate = new JSONObject();
+                                }
 
-                            }
-                            int ccount = mCadedate.optInt("count");
-                            for (int ipr = 0; ipr < count; ipr++) {
+                                int count = finalResult_json.optInt("count");
+                                if (count >= limit)
+                                {
+                                    hasmore = true;
+                                }
+                                else
+                                {
 
-                                JSONObject item = finalResult_json.optJSONObject("val_" + ipr);
+                                    mListFooterView.setText("No more data");
+                                    mListFooterView.setVisibility(View.VISIBLE);
+                                    hasmore = false;
 
+                                }
+                                int ccount = mCadedate.optInt("count");
+                                for (int ipr = 0; ipr < count; ipr++)
+                                {
 
-                                    mCadedate.put("val_"+(ccount+ipr),item);
+                                    JSONObject item = finalResult_json.optJSONObject("val_" + ipr);
 
 
+                                    mCadedate.put("val_" + (ccount + ipr), item);
 
-                            }
-                            mCadedate.put("count",ccount+count);
-                            offset = ccount+count;
 
-                            adapter.notifyDataSetChanged();
+                                }
+                                mCadedate.put("count", ccount + count);
+                                offset = ccount + count;
 
-                        } else {
-                            RAUtil.alertMessage(mCtx,"", finalResult_json.optString("err_msg"));
-                        }
+                                adapter.notifyDataSetChanged();
+
+                            }
+                            else
+                            {
+                                RAUtil.alertMessage(mCtx, "", finalResult_json.optString("err_msg"));
+                            }
                         } catch (JSONException e)
                         {
                             e.printStackTrace();
@@ -241,39 +273,45 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 
     }
 
-    public static class Builder {
-        public Intent build(Context context,String title, int max_select, int group, int child, boolean single_select,boolean auto_close,String url, Bundle params) {
-            if (context == null) {
+    public static class Builder
+    {
+        public Intent build(Context context, String title, int max_select, int group, int child, boolean single_select, boolean auto_close, String url, Bundle params)
+        {
+            if (context == null)
+            {
                 return null;
             }
 
             Intent intent = new Intent(context, EnumSlectOnlineActivity.class);
 
-            intent.putExtra(MAX_SELECT,max_select);
-            intent.putExtra(GROUP_POSITION,group);
-            intent.putExtra(CHILD_POSITION,child);
-            intent.putExtra(PARAMETERS,params);
-            intent.putExtra(URL,url);
+            intent.putExtra(MAX_SELECT, max_select);
+            intent.putExtra(GROUP_POSITION, group);
+            intent.putExtra(CHILD_POSITION, child);
+            intent.putExtra(PARAMETERS, params);
+            intent.putExtra(URL, url);
 
 //            if (cadedate != null) {
 //                intent.putExtra(CADEDATE,(Serializable) cadedate);
 //            }
-            intent.putExtra(SINGLE_SELECT,single_select);
-            if (title != null) {
-                intent.putExtra(TITLE,title);
+            intent.putExtra(SINGLE_SELECT, single_select);
+            if (title != null)
+            {
+                intent.putExtra(TITLE, title);
             }
-            intent.putExtra(AUTO_CLOSE,auto_close);
+            intent.putExtra(AUTO_CLOSE, auto_close);
 
             return intent;
         }
     }
 
-    public class SearchBarWatcher implements TextWatcher {
+    public class SearchBarWatcher implements TextWatcher
+    {
 
         Context mCtx;
         EditText textView;
 
-        public SearchBarWatcher(Context ctx,EditText textView) {
+        public SearchBarWatcher(Context ctx, EditText textView)
+        {
             this.mCtx = ctx;
             this.textView = textView;
 
@@ -292,9 +330,10 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
          * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
          * count    选中s中的内容长度(发生改变的原内容长度),未选中为0
          * after    新添加的内容长度,删除为0
-         * */
+         */
         @Override
-        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+        public void beforeTextChanged(CharSequence s, int start, int count, int after)
+        {
 //            Log.d("TextChange", "before Text Changed: " + s + " Start: " + start + " Count: " + count + " After: " + after);
 
             origin_text = s.toString();
@@ -308,27 +347,35 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
          * start    增加内容前光标位置,删除内容后光标位置 (起始位置)
          * before   选中s中的内容长度(发生改变的原内容长度),未选中为0
          * count    增加内容长度,删除内容为0
-         * */
+         */
         @Override
-        public void onTextChanged(CharSequence s, int start, int before, int count) {
+        public void onTextChanged(CharSequence s, int start, int before, int count)
+        {
 //            Log.d("TextChange", "on Text Changed: " + s + " Start: " + start + " Before: " + before + " Count: " + count);
         }
 
         @Override
-        public void afterTextChanged(Editable s) {
+        public void afterTextChanged(Editable s)
+        {
 
             /**
              * 文本处理
              * */
-            if (new_string_length == 0) {
+            if (new_string_length == 0)
+            {
                 string = "";
-            } else {
-                string = s.toString().substring(start_position,start_position + new_string_length);
+            }
+            else
+            {
+                string = s.toString().substring(start_position, start_position + new_string_length);
             }
 
-            if (change_length == 0) { // 新加内容
+            if (change_length == 0)
+            { // 新加内容
 
-            } else { // 替换原文或删除原文
+            }
+            else
+            { // 替换原文或删除原文
 
             }
 
@@ -336,7 +383,8 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
              * 业务逻辑
              * */
 
-            if (string.equals("\n") || string.equals("\r") || string.equals("\r\n")) {
+            if (string.equals("\n") || string.equals("\r") || string.equals("\r\n"))
+            {
                 textView.setText(origin_text);
                 return;
             }
@@ -369,17 +417,20 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 
     // region ProgressBar
 
-    public void showProgressBar() {
+    public void showProgressBar()
+    {
         mProgressBar.setVisibility(View.VISIBLE);
     }
 
-    public void dismissProgressBar() {
+    public void dismissProgressBar()
+    {
         mProgressBar.setVisibility(View.GONE);
     }
 
     // endregion
     @Override
-    protected void onCreate(Bundle savedInstanceState) {
+    protected void onCreate(Bundle savedInstanceState)
+    {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_enum_online_slect);
         setupRefreshLayout();
@@ -389,12 +440,10 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 
         setTitle(mTitle);
 
-        searchBar = (EditText)findViewById(R.id.common_editor_enum_search_bar);
-        searchBar.addTextChangedListener(new SearchBarWatcher(mCtx,searchBar));
-
-        enum_list_view = (ListView)findViewById(R.id.enum_list_view);
-
+        searchBar = (EditText) findViewById(R.id.common_editor_enum_search_bar);
+        searchBar.addTextChangedListener(new SearchBarWatcher(mCtx, searchBar));
 
+        enum_list_view = (ListView) findViewById(R.id.enum_list_view);
 
 
         adapter = new EnumAdapter(mCtx);
@@ -407,30 +456,32 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
         enum_list_view.setOnScrollListener(mScrollListener);
 
 
-
         setupListFooterView();
-        AbsListView.LayoutParams footerLayoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
+        AbsListView.LayoutParams footerLayoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
         mListFooterView.setLayoutParams(footerLayoutParams);
         enum_list_view.addFooterView(mListFooterView);
     }
 
     @Override
-    public void finish() {
+    public void finish()
+    {
 
-        if (mDirty != false) {
+        if (mDirty != false)
+        {
             Intent intent = new Intent();
 //            intent.putExtra(CADEDATE,mCadedate.toString());
-            intent.putExtra(GROUP_POSITION,mGroup);
-            intent.putExtra(CHILD_POSITION,mChild);
+            intent.putExtra(GROUP_POSITION, mGroup);
+            intent.putExtra(CHILD_POSITION, mChild);
 
-            setResult(RESULT_OK,intent);
+            setResult(RESULT_OK, intent);
         }
 
 
         super.finish();
     }
 
-    private void init() {
+    private void init()
+    {
         mCtx = this;
         Intent intent = getIntent();
 
@@ -441,54 +492,66 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 //        } catch (Exception e) {
 //            e.printStackTrace();
 //        }
-        mSingleSelect = intent.getBooleanExtra(SINGLE_SELECT,true);
-        mGroup = intent.getIntExtra(GROUP_POSITION,0);
-        mChild = intent.getIntExtra(CHILD_POSITION,0);
+        mSingleSelect = intent.getBooleanExtra(SINGLE_SELECT, true);
+        mGroup = intent.getIntExtra(GROUP_POSITION, 0);
+        mChild = intent.getIntExtra(CHILD_POSITION, 0);
         mTitle = intent.getStringExtra(TITLE);
-        maxSelect = intent.getIntExtra(MAX_SELECT,0);
-        mAuto_close = intent.getBooleanExtra(AUTO_CLOSE,true);
+        maxSelect = intent.getIntExtra(MAX_SELECT, 0);
+        mAuto_close = intent.getBooleanExtra(AUTO_CLOSE, true);
 
 
     }
 
-    private class CellClickListener implements AdapterView.OnItemClickListener {
+    private class CellClickListener implements AdapterView.OnItemClickListener
+    {
 
         private Context ctx;
-        public CellClickListener(Context ctx) {
+
+        public CellClickListener(Context ctx)
+        {
             this.ctx = ctx;
         }
 
         @Override
-        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
+        {
 
             mDirty = true;
 
-            try {
-                if (mSingleSelect) {
+            try
+            {
+                if (mSingleSelect)
+                {
 
-                    boolean is_worked = false;
+                    boolean is_worked = true;
 
 //                    if (mKeywords == null || mKeywords.isEmpty()) {
 
-                        for (int i = 0; i < mCadedate.optInt("count"); i++) {
-                            JSONObject val_json = mCadedate.optJSONObject("val_" + i);
+                    for (int i = 0; i < mCadedate.optInt("count"); i++)
+                    {
+                        JSONObject val_json = mCadedate.optJSONObject("val_" + i);
 
-                            if (i == position) {
-                                int select = val_json.optInt("check");
-                                if (select == 0) {
-                                    val_json.put("check","1");
-                                } else {
-                                    val_json.put("check","0");
-                                }
-                                is_worked = select == 0;
-                            } else {
-                                val_json.put("check","0");
+                        if (i == position)
+                        {
+                            int select = val_json.optInt("check");
+                            if (select == 0)
+                            {
+                                val_json.put("check", "1");
                             }
-                            mCadedate.put("val_" + i,val_json);
-
+//                            else
+//                            {
+//                                val_json.put("check", "0");
+//                            }
+//                            is_worked =true;
+                        }
+                        else
+                        {
+                            val_json.put("check", "0");
+                        }
+                        mCadedate.put("val_" + i, val_json);
 
 
-                        } // for
+                    } // for
 
 //                    } // keywords null
 //                    else {
@@ -543,24 +606,31 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 //
 //                    }
 
-                    if (is_worked) {
-                        if (mAuto_close) {
+                    if (is_worked)
+                    {
+                        if (mAuto_close)
+                        {
                             finish();
-                        } else {
+                        }
+                        else
+                        {
                             adapter.notifyDataSetChanged();
                         }
-                    } else {
+                    }
+                    else
+                    {
                         adapter.notifyDataSetChanged();
                     }
 
 
                 } // single select
-                else {
+                else
+                {
 
                     int index = position;
                     JSONObject val_json = null;
 //                    if (mKeywords == null || mKeywords.isEmpty()) {
-                        val_json = mCadedate.optJSONObject("val_" + position);
+                    val_json = mCadedate.optJSONObject("val_" + position);
 //                    }
 //                    else {
 //                        int count = 0;
@@ -584,39 +654,47 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 //                    }
 
                     int check = val_json.optInt("check");
-                    if (check == 1) {
-                        val_json.put("check","0");
-                    } else {
-                        if (check_count() >= maxSelect && maxSelect > 0) {
+                    if (check == 1)
+                    {
+                        val_json.put("check", "0");
+                    }
+                    else
+                    {
+                        if (check_count() >= maxSelect && maxSelect > 0)
+                        {
                             new AlertDialog.Builder(this.ctx)
                                     .setTitle("Max count reached")
                                     .setMessage(maxSelect + " items at most for this field.")
-                                    .setPositiveButton("OK",null)
+                                    .setPositiveButton("OK", null)
                                     .show();
                             return;
 
                         }
-                        val_json.put("check","1");
+                        val_json.put("check", "1");
                     }
-                    mCadedate.put("val_" + index,val_json);
+                    mCadedate.put("val_" + index, val_json);
 
                 }
                 adapter.notifyDataSetChanged();
 
-            } catch (Exception e) {
+            } catch (Exception e)
+            {
                 e.printStackTrace();
             }
 
         }
     }
 
-    public int check_count() {
+    public int check_count()
+    {
 
         int check_count = 0;
-        for (int i = 0; i < mCadedate.optInt("count"); i++) {
+        for (int i = 0; i < mCadedate.optInt("count"); i++)
+        {
             JSONObject val_json = mCadedate.optJSONObject("val_" + i);
             int check = val_json.optInt("check");
-            if (check == 1) {
+            if (check == 1)
+            {
                 check_count++;
             }
         }
@@ -624,18 +702,22 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
     }
 
 
-    private class EnumAdapter extends BaseAdapter {
+    private class EnumAdapter extends BaseAdapter
+    {
 
-        public class Holder {
+        public class Holder
+        {
             public TextView value_tv;
             public ImageView check_iv;
 
-            public Holder(View cell) {
-                if (cell == null) {
+            public Holder(View cell)
+            {
+                if (cell == null)
+                {
                     return;
                 }
-                value_tv = (TextView)cell.findViewById(R.id.enum_value_tv);
-                check_iv = (ImageView)cell.findViewById(R.id.enum_check_iv);
+                value_tv = (TextView) cell.findViewById(R.id.enum_value_tv);
+                check_iv = (ImageView) cell.findViewById(R.id.enum_check_iv);
                 check_iv.setClickable(false);
                 check_iv.setFocusable(false);
                 cell.setTag(this);
@@ -645,20 +727,24 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 
 
         private Context ctx;
-        public EnumAdapter(Context context) {
+
+        public EnumAdapter(Context context)
+        {
             this.ctx = context;
         }
 
         @Override
-        public int getCount() {
+        public int getCount()
+        {
 
-            if (mCadedate == null) {
+            if (mCadedate == null)
+            {
                 return 0;
             }
 
 //            if (mKeywords == null || mKeywords.isEmpty()) {
 //                filter_count = 0;
-                return mCadedate.optInt("count");
+            return mCadedate.optInt("count");
 //            }
 
 //            int count = 0;
@@ -675,10 +761,11 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
         }
 
         @Override
-        public Object getItem(int position) {
+        public Object getItem(int position)
+        {
             JSONObject val_json = null;
 //            if (mKeywords == null || mKeywords.isEmpty()) {
-                val_json = mCadedate.optJSONObject("val_" + position);
+            val_json = mCadedate.optJSONObject("val_" + position);
 //            }
 //            else {
 //                int count = 0;
@@ -706,12 +793,14 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
         }
 
         @Override
-        public long getItemId(int position) {
+        public long getItemId(int position)
+        {
             return position;
         }
 
         @Override
-        public View getView(int position, View convertView, ViewGroup parent) {
+        public View getView(int position, View convertView, ViewGroup parent)
+        {
             JSONObject val_json = (JSONObject) getItem(position);
 //            if (mKeywords == null || mKeywords.isEmpty()) {
 //                val_json = mCadedate.optJSONObject("val_" + position);
@@ -720,12 +809,15 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
 //            }
 
             Holder holder;
-            if (convertView == null) {
+            if (convertView == null)
+            {
 
-                convertView = LayoutInflater.from(this.ctx).inflate(R.layout.enum_select_cell,null);
+                convertView = LayoutInflater.from(this.ctx).inflate(R.layout.enum_select_cell, null);
                 holder = new Holder(convertView);
 
-            } else {
+            }
+            else
+            {
                 holder = (Holder) convertView.getTag();
             }
 
@@ -733,9 +825,12 @@ public class EnumSlectOnlineActivity extends AppCompatActivity {
             holder.value_tv.setText(value);
 
             int check = val_json.optInt("check");
-            if (check == 1) {
+            if (check == 1)
+            {
                 holder.check_iv.setVisibility(View.VISIBLE);
-            } else {
+            }
+            else
+            {
                 holder.check_iv.setVisibility(View.INVISIBLE);
             }
 

+ 1 - 1
ApexDrivers/CommonEditorLib/src/main/res/layout/activity_enum_online_slect.xml

@@ -55,6 +55,6 @@
         android:layout_width="100dp"
         android:layout_height="100dp"
         android:layout_centerInParent="true"
-        android:visibility="gone" />
+        android:visibility="visible" />
 
 </RelativeLayout>

+ 98 - 0
ApexDrivers/ratradefiling/src/main/java/com/usai/ratradefiling/tfeditor/TFEditorActivity.java

@@ -2,6 +2,7 @@ package com.usai.ratradefiling.tfeditor;
 
 import android.content.Context;
 //import android.support.v7.app.AppCompatActivity;
+import android.content.Intent;
 import android.os.Bundle;
 
 //import com.usai.redant.CommonEditor.CommonEditorActivity;
@@ -9,13 +10,18 @@ import android.os.Bundle;
 //import com.usai.redant.util.Network;
 
 import com.usai.commoneditorlib.CommonEditorActivity;
+import com.usai.commoneditorlib.EnumSlectOnlineActivity;
 import com.usai.ratradefiling.R;
 import com.usai.ratradefiling.dataprovider.RADataProvider;
+import com.usai.redant.rautils.utils.RAUtil;
 
 import org.json.JSONObject;
 
 import java.lang.reflect.ParameterizedType;
 
+import static com.usai.ratradefiling.dataprovider.OnlineDataProvider.URL_CADEDATE;
+import static com.usai.ratradefiling.dataprovider.OnlineDataProvider.URL_EDIT;
+
 public class TFEditorActivity extends CommonEditorActivity
 {
 
@@ -27,6 +33,8 @@ public class TFEditorActivity extends CommonEditorActivity
         mContext = this;
 
         hasChildView = false;
+
+        ONLINE_ENUM_URL=URL_CADEDATE;
 //        setContentView(R.layout.activity_tfeditor);
 
         super.onCreate(savedInstanceState);
@@ -43,4 +51,94 @@ public class TFEditorActivity extends CommonEditorActivity
 
         return RADataProvider.request_editor(request_url, params);
     }
+
+
+    @Override
+    protected void commonAction(String value, int groupIndex, int itemIndex, JSONObject item_json)
+    {
+        if(value.equals("editor"))
+        {
+//        NSDictionary* item_json =((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row];
+            boolean readonly = content_data_download.optBoolean("readonly"); 
+            
+            int disable = item_json.optInt("disable");
+            
+
+            if(disable==1||readonly)
+                return ;
+
+            Bundle b= RAUtil.Json2Bundle(item_json.optJSONObject("params"));
+            Intent intent = TFEditorActivity.build(mContext,TFEditorActivity.class,null,URL_REMOTE,URL_EDIT,b);
+
+            startActivity(intent);
+
+//            TFEditorViewController *vc = [[UIStoryboard storyboardWithName:@"TFEditor" bundle:nil] instantiateViewControllerWithIdentifier:@"TFEditorViewController"];
+//
+//            vc.url_type = URL_REMOTE;
+//            vc.request_url=URL_EDIT;
+//            vc.from = indexPath;
+//            vc.delegate = self;
+//            vc.params = [[item_json valueForKey:@"params"] mutableCopy];
+//
+//            [self.navigationController pushViewController:vc animated:NO];
+
+
+        }
+        if(value.equals("online_enum"))
+        {
+            
+            String title = item_json.optString("aname");
+
+            int max_select = item_json.optInt("max");
+
+
+            JSONObject paramsjson = item_json.optJSONObject("params");
+
+            Bundle params=RAUtil.Json2Bundle(paramsjson);
+
+            String single_select = item_json.optString("single_select");
+
+            boolean singleSelect = single_select.toLowerCase().equals("true");
+
+
+            Intent intent = new EnumSlectOnlineActivity.Builder().build(mCtx,title,max_select,groupIndex,itemIndex,singleSelect,true,ONLINE_ENUM_URL,params);
+
+            int request_code = 10;
+
+            startActivityForResult(intent,request_code);
+//            EnumSelectOnlineViewController* enumvc =[[UIStoryboard storyboardWithName:@"CommonEditor" bundle:nil] instantiateViewControllerWithIdentifier:@"EnumSelectOnlineViewController"];
+//            enumvc.delegate = self;
+//            enumvc.max_select = max_select;
+//            enumvc.updatePosition = indexPath;
+//            enumvc.online_params = item_json[@"params"];
+//            enumvc.single_select = true;
+//            //        if([[required lowercaseString] isEqualToString:@"true"])
+//            //        enumvc.canbeEmpty = false;
+//            //        else
+//            //        enumvc.canbeEmpty =true;
+//            //            enumvc.cadedate = [cadedate_json mutableCopy];
+//            enumvc.title = title;
+//            //       enumvc.value = [value_json mutableCopy];
+//            //    enumvc.single_select =[[single_select lowercaseString] isEqualToString:@"true"];
+//
+//            enumvc.from = indexPath;
+//            enumvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//
+//
+//                    [self handle_action_return:value[@"val_0"] indexPath:indexPath action:ACTION_FILL_SECTION];
+//
+//        };
+//
+//
+//        [self.navigationController pushViewController:enumvc animated:true];
+        }
+
+        return ;
+    }
+
+//    @Override
+//    public void handle_action_return(JSONObject value,int group,int child,int action_code)
+//    {
+//
+//    }
 }