1629
This commit is contained in:
parent
859238a173
commit
9ff8b1ed80
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue Mar 04 10:00:11 GMT 2025
|
#Wed Mar 05 08:27:53 GMT 2025
|
||||||
stageCount=9
|
stageCount=9
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=1.0
|
baseVersion=1.0
|
||||||
publishVersion=1.0.8
|
publishVersion=1.0.8
|
||||||
buildCount=60
|
buildCount=112
|
||||||
baseBetaVersion=1.0.9
|
baseBetaVersion=1.0.9
|
||||||
|
@ -47,10 +47,10 @@ public class PhoneConnectRuleAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
if (viewType == VIEW_TYPE_SIMPLE) {
|
if (viewType == VIEW_TYPE_SIMPLE) {
|
||||||
View view = inflater.inflate(R.layout.view_phone_connect_rule_simple, parent, false);
|
View view = inflater.inflate(R.layout.view_phone_connect_rule_simple, parent, false);
|
||||||
return new SimpleViewHolder(view);
|
return new SimpleViewHolder(parent, view);
|
||||||
} else {
|
} else {
|
||||||
View view = inflater.inflate(R.layout.view_phone_connect_rule, parent, false);
|
View view = inflater.inflate(R.layout.view_phone_connect_rule, parent, false);
|
||||||
return new EditViewHolder(view);
|
return new EditViewHolder(parent, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,13 +165,16 @@ public class PhoneConnectRuleAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||||||
private final TextView tvRuleText;
|
private final TextView tvRuleText;
|
||||||
|
|
||||||
|
|
||||||
public SimpleViewHolder(@NonNull View itemView) {
|
public SimpleViewHolder(@NonNull ViewGroup parent, @NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
scrollView = itemView.findViewById(R.id.scrollView);
|
scrollView = itemView.findViewById(R.id.scrollView);
|
||||||
//tvRuleText = itemView.findViewById(R.id.ruletext_tv);
|
//tvRuleText = itemView.findViewById(R.id.ruletext_tv);
|
||||||
tvRuleText = new TextView(itemView.getContext());
|
tvRuleText = new TextView(itemView.getContext());
|
||||||
|
scrollView.setContentWidth(parent.getWidth());
|
||||||
|
//scrollView.setContentWidth(600);
|
||||||
scrollView.addContentLayout(tvRuleText);
|
scrollView.addContentLayout(tvRuleText);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class EditViewHolder extends RecyclerView.ViewHolder {
|
static class EditViewHolder extends RecyclerView.ViewHolder {
|
||||||
@ -180,7 +183,7 @@ public class PhoneConnectRuleAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||||||
CheckBox checkBoxEnable;
|
CheckBox checkBoxEnable;
|
||||||
Button buttonConfirm;
|
Button buttonConfirm;
|
||||||
|
|
||||||
public EditViewHolder(@NonNull View itemView) {
|
public EditViewHolder(@NonNull ViewGroup parent, @NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
editText = itemView.findViewById(R.id.edit_text);
|
editText = itemView.findViewById(R.id.edit_text);
|
||||||
checkBoxAllow = itemView.findViewById(R.id.checkbox_allow);
|
checkBoxAllow = itemView.findViewById(R.id.checkbox_allow);
|
||||||
|
@ -14,6 +14,8 @@ import android.widget.HorizontalScrollView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import cc.winboll.studio.contacts.R;
|
import cc.winboll.studio.contacts.R;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
|
||||||
public class LeftScrollView extends HorizontalScrollView {
|
public class LeftScrollView extends HorizontalScrollView {
|
||||||
|
|
||||||
@ -24,8 +26,8 @@ public class LeftScrollView extends HorizontalScrollView {
|
|||||||
private TextView textView;
|
private TextView textView;
|
||||||
private Button editButton;
|
private Button editButton;
|
||||||
private Button deleteButton;
|
private Button deleteButton;
|
||||||
private float startX;
|
private float mLastX;
|
||||||
private boolean isDragging = false;
|
private boolean isScrolling = false;
|
||||||
|
|
||||||
public LeftScrollView(Context context) {
|
public LeftScrollView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -46,66 +48,28 @@ public class LeftScrollView extends HorizontalScrollView {
|
|||||||
contentLayout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
contentLayout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContentWidth(int contentWidth) {
|
||||||
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) contentLayout.getLayoutParams();
|
||||||
|
layoutParams.width = contentWidth;
|
||||||
|
contentLayout.setLayoutParams(layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
View viewMain = inflate(getContext(), R.layout.view_left_scroll, null);
|
View viewMain = inflate(getContext(), R.layout.view_left_scroll, null);
|
||||||
|
|
||||||
// 创建内容布局
|
// 创建内容布局
|
||||||
contentLayout = viewMain.findViewById(R.id.content_layout);
|
contentLayout = viewMain.findViewById(R.id.content_layout);
|
||||||
toolLayout = viewMain.findViewById(R.id.action_layout);
|
toolLayout = viewMain.findViewById(R.id.action_layout);
|
||||||
addView(viewMain);
|
|
||||||
|
|
||||||
// 动态设置content_layout的宽度为scrollView的宽度
|
//LogUtils.d(TAG, String.format("getWidth() %d", getWidth()));
|
||||||
// post(new Runnable() {
|
|
||||||
// @Override
|
addView(viewMain);
|
||||||
// public void run() {
|
|
||||||
// int scrollViewWidth = getWidth();
|
|
||||||
// LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) contentLayout.getLayoutParams();
|
|
||||||
// layoutParams.width = scrollViewWidth;
|
|
||||||
// contentLayout.setLayoutParams(layoutParams);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// 创建编辑按钮
|
// 创建编辑按钮
|
||||||
editButton = viewMain.findViewById(R.id.edit_btn);
|
editButton = viewMain.findViewById(R.id.edit_btn);
|
||||||
// 创建删除按钮
|
// 创建删除按钮
|
||||||
deleteButton = viewMain.findViewById(R.id.delete_btn);
|
deleteButton = viewMain.findViewById(R.id.delete_btn);
|
||||||
|
|
||||||
// 设置触摸事件监听器
|
|
||||||
// setOnTouchListener(new OnTouchListener() {
|
|
||||||
// @Override
|
|
||||||
// public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
// switch (event.getAction()) {
|
|
||||||
// case MotionEvent.ACTION_DOWN:
|
|
||||||
// startX = event.getX();
|
|
||||||
// isDragging = true;
|
|
||||||
// break;
|
|
||||||
// case MotionEvent.ACTION_MOVE:
|
|
||||||
// if (isDragging) {
|
|
||||||
// float deltaX = startX - event.getX();
|
|
||||||
// if (deltaX > 0) { // 左滑
|
|
||||||
// float translationX = Math.max(-(editButton.getWidth() + deleteButton.getWidth()), -deltaX);
|
|
||||||
// toolLayout.setTranslationX(translationX);
|
|
||||||
// scrollTo((int) translationX, 0);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// case MotionEvent.ACTION_UP:
|
|
||||||
// case MotionEvent.ACTION_CANCEL:
|
|
||||||
// isDragging = false;
|
|
||||||
// if (getScrollX() <= -(editButton.getWidth())) {
|
|
||||||
// // 编辑按钮完全显示,保持按钮显示
|
|
||||||
// smoothScrollTo(-(editButton.getWidth() + deleteButton.getWidth()), 0);
|
|
||||||
// } else {
|
|
||||||
// // 恢复原状
|
|
||||||
// smoothScrollTo(0, 0);
|
|
||||||
// toolLayout.setTranslationX(0);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// 编辑按钮点击事件
|
// 编辑按钮点击事件
|
||||||
editButton.setOnClickListener(new OnClickListener() {
|
editButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -127,6 +91,41 @@ public class LeftScrollView extends HorizontalScrollView {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
switch (event.getAction()) {
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
LogUtils.d(TAG, "ACTION_DOWN");
|
||||||
|
mLastX = event.getX();
|
||||||
|
isScrolling = false;
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
//LogUtils.d(TAG, "ACTION_MOVE");
|
||||||
|
float currentX = event.getX();
|
||||||
|
float deltaX = mLastX - currentX;
|
||||||
|
mLastX = currentX;
|
||||||
|
if (Math.abs(deltaX) > 0) {
|
||||||
|
isScrolling = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_UP:
|
||||||
|
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, ">>>>>");
|
||||||
|
} else {
|
||||||
|
smoothScrollTo(0, 0);
|
||||||
|
LogUtils.d(TAG, "<<<<<");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return super.onTouchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
// 设置文本内容
|
// 设置文本内容
|
||||||
public void setText(CharSequence text) {
|
public void setText(CharSequence text) {
|
||||||
textView.setText(text);
|
textView.setText(text);
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -241,8 +245,7 @@
|
|||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="400dp"
|
||||||
android:layout_weight="1.0"
|
|
||||||
android:background="@drawable/recycler_view_border"
|
android:background="@drawable/recycler_view_border"
|
||||||
android:layout_margin="5dp"/>
|
android:layout_margin="5dp"/>
|
||||||
|
|
||||||
@ -267,5 +270,7 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user