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

边栏推荐
- What is edge computing? What are the characteristics of the Internet platform edge calculator?
- What aspects does the intelligent identification system include? Is the technology of intelligent identification system mature now?
- How to access the server through the fortress machine? What's the use of the fortress machine?
- Grp: how to add Prometheus monitoring in GRP service?
- [summary of interview questions] zj6 redis
- Supply chain system platform: two management areas
- What is the role of the distributed configuration center? What are the advantages of a distributed configuration center?
- Sinclair radio stopped broadcasting many TV stations, suspected of being attacked by blackmail software
- Why do I need a code signing certificate? Where can I get a code signing certificate?
- 2021-10-02: word search. Given an M x n two-dimensional character grid boa
猜你喜欢

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

元气森林推“有矿”,农夫山泉们跟着“卷”?
![[summary of interview questions] zj5](/img/d8/ece82f8b2479adb948ba706f6f5039.jpg)
[summary of interview questions] zj5

618大促:手机品牌“神仙打架”,高端市场“谁主沉浮”?

Ar 3D map technology
![[summary of interview questions] zj6 redis](/img/4b/eadf66ca8d834f049f3546d348fa32.jpg)
[summary of interview questions] zj6 redis

Sorting out of key vulnerabilities identified by CMS in the peripheral management of red team (I)

Get to know MySQL database

On Sunday, I rolled up the uni app "uview excellent UI framework"
随机推荐
元气森林推“有矿”,农夫山泉们跟着“卷”?
TRTC audio quality problem
Process kill problem
Mocktio usage (Part 2)
Understanding Devops from the perspective of decision makers
take the crown! Tencent security won the 2021 national network security week outstanding innovation achievement award
LeetCode 1047. Delete all adjacent duplicates in the string
NLP task summary introduction and understanding
Use lightweight application server to automatically download and upload to onedrive
Why should I change my PC to a cloud desktop server? What are the characteristics of this server?
Double 11 will arrive soon. Is your website ready?
[hot] with a budget of only 100 yuan, how to build a 1-year web site on Tencent cloud??
What technology does cloud computing elasticity scale? What are the advantages of elastic scaling in cloud computing?
What is distributed configuration center Nacos? What are the functions of distributed configuration center Nacos?
Create a telepresence USB drive using the DD command
How to register a trademark? What needs to be prepared?
What is fortress resource authorization? What is barrier machine?
How to install CentOS 6.5 PHP extension
How to select a cloud game server? Which cloud game server recommends?
Disk partition extension using graphical interface and PowerShell code