当前位置:网站首页>左滑从小窗到大窗口DispatchFrameLayout
左滑从小窗到大窗口DispatchFrameLayout
2022-06-24 03:34:00 【赵健zj】
DispatchFrameLayout
/* * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. */
package com.qisi.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import lombok.Setter;
/** * 【打字弹图】内容容器,设置dispatchTouchEvent监听 * * @author zhaojian * @since 2022-06-15 */
public class DispatchFrameLayout extends FrameLayout {
@Setter
private OnTouchListener dispatchOnTouchListener;
/** * 构造函数 * * @param context 上下文 */
public DispatchFrameLayout(@NonNull Context context) {
super(context);
}
/** * 构造函数 * * @param context 上下文 * @param attrs AttributeSet */
public DispatchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
/** * 构造函数 * * @param context 上下文 * @param attrs attrs * @param defStyleAttr defStyleAttr */
public DispatchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (dispatchOnTouchListener != null) {
return dispatchOnTouchListener.onTouch(this, ev) || super.dispatchTouchEvent(ev);
}
return super.dispatchTouchEvent(ev);
}
}
@SuppressLint("ClickableViewAccessibility")
private void showBigWhenRecyclerViewMove() {
DispatchFrameLayout typingContent = findViewById(R.id.typing_content);
OnTouchListener dispatchOnTouchListener = new OnTouchListener() {
private boolean isFirstIntercept = false;
private int dx; // 记录上次dx的距离
@Override
public boolean onTouch(View v, MotionEvent event) {
// 只有表情小窗,才拦截事件
if (event == null || isFirstIntercept || !isExpress() || rotateTransitionListener.isExpand()) {
return false; // 不处理
}
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
dx = (int) event.getX();
} else if (action == MotionEvent.ACTION_MOVE) {
final int distance = 10;
isFirstIntercept = Math.abs(event.getX() - dx) > distance;
} else {
LogUtil.logV(TAG, MSG_DO_NOTHING);
}
if (isFirstIntercept) {
clickLeftButton();
}
return isFirstIntercept;
}
};
typingContent.setDispatchOnTouchListener(dispatchOnTouchListener);
}

边栏推荐
- Thank you for your recognition! One thank-you note after another
- Velocitytracker use
- Industry experts talk about "extortion virus": how does e-government build a moat?
- NLP task summary introduction and understanding
- Tencent cloud launched its new 100g+ cloud server product!! Expect more than 400g+ in the future!
- Applicationclientprotocol of yarn source code
- Differences between EDI and VMI
- Why use code signing? What certificates are required for code signing?
- Independent innovation and localization technology: SMT production line monitoring and management visualization of intelligent manufacturing
- Grpc: how do I start multiple ports?
猜你喜欢

元气森林推“有矿”,农夫山泉们跟着“卷”?

QT creator tips
Thank you for your recognition! One thank-you note after another

On Sunday, I rolled up the uni app "uview excellent UI framework"
![[summary of interview questions] zj6 redis](/img/4b/eadf66ca8d834f049f3546d348fa32.jpg)
[summary of interview questions] zj6 redis

Community pycharm installation visual database
![[summary of interview questions] zj5](/img/d8/ece82f8b2479adb948ba706f6f5039.jpg)
[summary of interview questions] zj5

Ar 3D map technology

Get to know MySQL database

Sorting out of key vulnerabilities identified by CMS in the peripheral management of red team (I)
随机推荐
Why do I need a code signing certificate? Where can I get a code signing certificate?
Why does the fortress machine use an application publisher? What are the main functions of the fortress machine
A figure showing the price and expense structure of Tencent cloud real-time audio and video TRTC
How do I check the trademark registration number? Where do I need to check?
What aspects does the intelligent identification system include? Is the technology of intelligent identification system mature now?
Dry goods how to build a data visualization project from scratch?
The request was aborted: Could not create SSL/TLS secure channel.
Chapter 5: key led demo case of PS bare metal and FreeRTOS case development
Ar 3D map technology
Three Scheduling Strategies in yarn
Understanding Devops from the perspective of decision makers
Go program lifecycle
How does cloud computing achieve elastic scaling? What are the characteristics of elasticity?
Record the creation process of a joke widget (I)
What is the principle of intelligent image recognition? What are the applications of intelligent image recognition?
[summary of interview questions] zj5
Troubleshooting and resolution of errors in easycvr calling batch deletion interface
Does the user need a code signing certificate? What is the use of a code signing certificate
Grpc: how to make grpc provide restful API services?
RI Geng series: tricks of using function pointers