当前位置:网站首页>左滑从小窗到大窗口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);
}

边栏推荐
- General scheme for improving reading and writing ability of online es cluster
- take the crown! Tencent security won the 2021 national network security week outstanding innovation achievement award
- [new double 11] the latest interpretation of Tencent cloud double 11! Get 11000 yuan voucher now!!
- Create a telepresence USB drive using the DD command
- What if the computer audio and video engine is abnormal? What are the causes of abnormal computer audio and video engine?
- What does cloud computing elasticity mean? What are its functions?
- QT creator tips
- EIP maximum EIP EIP remote desktop access
- Summary of common problems of real-time audio and video TRTC - quality
- RI Geng series: write a simple shell script, but it seems to have technical content
猜你喜欢

Community pycharm installation visual database

Sorting out of key vulnerabilities identified by CMS in the peripheral management of red team (I)
![[summary of interview questions] zj5](/img/d8/ece82f8b2479adb948ba706f6f5039.jpg)
[summary of interview questions] zj5
Thank you for your recognition! One thank-you note after another

Get to know MySQL database

618大促:手机品牌“神仙打架”,高端市场“谁主沉浮”?
![[summary of interview questions] zj6 redis](/img/4b/eadf66ca8d834f049f3546d348fa32.jpg)
[summary of interview questions] zj6 redis

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

Ar 3D map technology

QT creator tips
随机推荐
Tencent location service appeared at the 11th China Surveying and mapping Geographic Information Technology Equipment Expo
Use lightweight application server to automatically download and upload to onedrive
What is the difference between server leasing and hosting?
Interpreting Tencent cloud product experience through user experience elements
Lua language development, esp8266 access to Bafa cloud, mqtt and TCP protocols
Why do I need a code signing certificate? Where can I get a code signing certificate?
QT creator tips
How to select a cloud game server? Which cloud game server recommends?
Why can't the fortress machine open the port? There is a problem with the use of the fortress machine port
web渗透测试----5、暴力破解漏洞--(4)Telnet密码破解
EIP maximum EIP EIP remote desktop access
Industry experts talk about "extortion virus": how does e-government build a moat?
RI Geng series: write a simple shell script, but it seems to have technical content
Self built DNS to realize the automatic intranet resolution of tke cluster apiserver domain name
What is load balancing? What are the functions of load balancing?
How does cloud computing achieve elastic scaling? What are the characteristics of elasticity?
2021-10-02: word search. Given an M x n two-dimensional character grid boa
Under what circumstances do you need a fortress machine? What are the functions of a fortress machine
The request was aborted: Could not create SSL/TLS secure channel.
Which domestic cloud desktop server is good? What are the security guarantees for cloud desktop servers?