连接规则记录操作接口完成
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Wed Mar 05 08:27:53 GMT 2025 | ||||
| #Wed Mar 05 09:18:14 GMT 2025 | ||||
| stageCount=9 | ||||
| libraryProject= | ||||
| baseVersion=1.0 | ||||
| publishVersion=1.0.8 | ||||
| buildCount=112 | ||||
| buildCount=124 | ||||
| baseBetaVersion=1.0.9 | ||||
|   | ||||
| @@ -232,6 +232,12 @@ public class SettingsActivity extends AppCompatActivity implements IWinBollActiv | ||||
|         Intent intent = new Intent(this, UnitTestActivity.class); | ||||
|         startActivity(intent); | ||||
|     } | ||||
|      | ||||
|     public void onAddNewConnectionRule(View view) { | ||||
|         Rules.getInstance(this).getPhoneBlacRuleBeanList().add(new PhoneConnectRuleModel()); | ||||
|         Rules.getInstance(this).saveRules(); | ||||
|         adapter.notifyDataSetChanged(); | ||||
|     } | ||||
|  | ||||
|     public void onDefaultPhone(View view) { | ||||
|         Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS); | ||||
|   | ||||
| @@ -59,23 +59,28 @@ public class PhoneConnectRuleAdapter extends RecyclerView.Adapter<RecyclerView.V | ||||
|         final PhoneConnectRuleModel model = ruleList.get(position); | ||||
|         if (holder instanceof SimpleViewHolder) { | ||||
|             final SimpleViewHolder simpleViewHolder = (SimpleViewHolder) holder; | ||||
|             simpleViewHolder.tvRuleText.setText(model.getRuleText()); | ||||
| //            simpleViewHolder.setOnActionListener(new SimpleViewHolder.OnActionListener(){ | ||||
| // | ||||
| //                    @Override | ||||
| //                    public void onEdit(int position) { | ||||
| //                        model.setIsSimpleView(false); | ||||
| //                        notifyItemChanged(position); | ||||
| //                    } | ||||
| //                    @Override | ||||
| //                    public void onDelete(int position) { | ||||
| //                        model.setIsSimpleView(false); | ||||
| //                        ArrayList<PhoneConnectRuleModel> list = Rules.getInstance(context).getPhoneBlacRuleBeanList(); | ||||
| //                        list.remove(position); | ||||
| //                        Rules.getInstance(context).saveRules(); | ||||
| //                        notifyItemChanged(position); | ||||
| //                    } | ||||
| //                }); | ||||
|             String szView = model.getRuleText().trim().equals("")?"[NULL]":model.getRuleText(); | ||||
|             simpleViewHolder.tvRuleText.setText(szView); | ||||
|             simpleViewHolder.scrollView.setOnActionListener(new LeftScrollView.OnActionListener(){ | ||||
|                     @Override | ||||
|                     public void onEdit() { | ||||
|                         simpleViewHolder.scrollView.smoothScrollTo(0, 0); | ||||
|                         model.setIsSimpleView(false); | ||||
|                         notifyDataSetChanged(); | ||||
|                         //notifyItemChanged(position); | ||||
|                     } | ||||
|  | ||||
|                     @Override | ||||
|                     public void onDelete() { | ||||
|                         simpleViewHolder.scrollView.smoothScrollTo(0, 0); | ||||
|                         model.setIsSimpleView(true); | ||||
|                         ArrayList<PhoneConnectRuleModel> list = Rules.getInstance(context).getPhoneBlacRuleBeanList(); | ||||
|                         list.remove(position); | ||||
|                         Rules.getInstance(context).saveRules(); | ||||
|                         notifyDataSetChanged(); | ||||
|                         //notifyItemChanged(position); | ||||
|                     } | ||||
|                 }); | ||||
| //            simpleViewHolder.editButton.setOnClickListener(new View.OnClickListener() { | ||||
| //                    @Override | ||||
| //                    public void onClick(View v) { | ||||
| @@ -174,7 +179,7 @@ public class PhoneConnectRuleAdapter extends RecyclerView.Adapter<RecyclerView.V | ||||
|             //scrollView.setContentWidth(600); | ||||
|             scrollView.addContentLayout(tvRuleText); | ||||
|         } | ||||
|          | ||||
|  | ||||
|     } | ||||
|  | ||||
|     static class EditViewHolder extends RecyclerView.ViewHolder { | ||||
|   | ||||
| @@ -109,16 +109,40 @@ public class LeftScrollView extends HorizontalScrollView { | ||||
|                 } | ||||
|                 break; | ||||
|             case MotionEvent.ACTION_UP: | ||||
|             case MotionEvent.ACTION_CANCEL: | ||||
|                 LogUtils.d(TAG, "ACTION_UP"); | ||||
|                 if (isScrolling) { | ||||
|                     LogUtils.d(TAG, String.format("isScrolling \ngetScrollX() %d\neditButton.getWidth() %d", getScrollX(), editButton.getWidth())); | ||||
|                     int scrollX = getScrollX(); | ||||
|                     if (scrollX > editButton.getWidth()) { | ||||
|                         smoothScrollTo(getChildAt(0).getWidth(), 0); | ||||
|                         LogUtils.d(TAG, ">>>>>"); | ||||
|                         // 获取HorizontalScrollView的子视图 | ||||
|                         View childView = getChildAt(0); | ||||
|                         if (childView != null) { | ||||
|                             // 计算需要滑动到最右边的距离 | ||||
|                             int scrollToX = childView.getWidth() - getWidth(); | ||||
|                             // 确保滑动距离不小于0 | ||||
|                             final int scrollToX2 = Math.max(0, scrollToX); | ||||
|                             // 平滑滑动到最右边 | ||||
|                             post(new Runnable() { | ||||
|                                     @Override | ||||
|                                     public void run() { | ||||
|                                         smoothScrollTo(scrollToX2, 0); | ||||
|                                         LogUtils.d(TAG, "smoothScrollTo(0, 0);"); | ||||
|                                     } | ||||
|                                 }); | ||||
|                             LogUtils.d(TAG, "smoothScrollTo(scrollToX, 0);"); | ||||
|                         } | ||||
|                     } else { | ||||
|                         smoothScrollTo(0, 0); | ||||
|                         LogUtils.d(TAG, "<<<<<"); | ||||
|                         // 恢复原状 | ||||
|                         // 在手指抬起时,使用 post 方法调用 smoothScrollTo(0, 0) | ||||
|                         post(new Runnable() { | ||||
|                                 @Override | ||||
|                                 public void run() { | ||||
|                                     smoothScrollTo(0, 0); | ||||
|                                     LogUtils.d(TAG, "smoothScrollTo(0, 0);"); | ||||
|                                 } | ||||
|                             }); | ||||
|                         //toolLayout.setTranslationX(0); | ||||
|                     } | ||||
|                 } | ||||
|                 break; | ||||
|   | ||||
| @@ -2,8 +2,8 @@ | ||||
| <ScrollView | ||||
| 	xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| 	xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
| 	xmlns:tools="http://schemas.android.com/tools" | ||||
| 	android:layout_width="match_parent" | ||||
| 	android:layout_height="match_parent"> | ||||
|  | ||||
| 	<LinearLayout | ||||
| @@ -237,15 +237,29 @@ | ||||
|  | ||||
| 			</LinearLayout> | ||||
|  | ||||
| 			<TextView | ||||
| 				android:layout_width="wrap_content" | ||||
| 				android:layout_height="wrap_content" | ||||
| 				android:text="Phone Connect Rule :"/> | ||||
| 			<LinearLayout | ||||
| 				android:orientation="horizontal" | ||||
| 				android:layout_width="match_parent" | ||||
| 				android:layout_height="wrap_content"> | ||||
|  | ||||
| 				<TextView | ||||
| 					android:layout_width="0dp" | ||||
| 					android:layout_height="wrap_content" | ||||
| 					android:text="Phone Connect Rule :" | ||||
| 					android:layout_weight="1.0"/> | ||||
|  | ||||
| 				<Button | ||||
| 					android:layout_width="wrap_content" | ||||
| 					android:layout_height="wrap_content" | ||||
| 					android:text="添加新规则" | ||||
| 					android:onClick="onAddNewConnectionRule"/> | ||||
|  | ||||
| 			</LinearLayout> | ||||
|  | ||||
| 			<androidx.recyclerview.widget.RecyclerView | ||||
| 				android:id="@+id/recycler_view" | ||||
| 				android:layout_width="match_parent" | ||||
| 				android:layout_height="400dp" | ||||
| 				android:layout_height="300dp" | ||||
| 				android:background="@drawable/recycler_view_border" | ||||
| 				android:layout_margin="5dp"/> | ||||
|  | ||||
|   | ||||
| @@ -4,7 +4,8 @@ | ||||
| 	xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
| 	android:layout_width="match_parent" | ||||
| 	android:layout_height="wrap_content" | ||||
| 	android:orientation="horizontal"> | ||||
| 	android:orientation="horizontal" | ||||
| 	android:padding="2dp"> | ||||
|  | ||||
| 	<cc.winboll.studio.contacts.views.LeftScrollView | ||||
| 		android:layout_width="match_parent" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen