Skip to content

Commit

Permalink
细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewis committed Mar 10, 2021
1 parent 75f7f78 commit 37d0fcb
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
|:---:|:---:|:---:|
|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%9D%83%E9%99%90%E7%94%B3%E8%AF%B7.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E7%B3%BB%E7%BB%9F%E6%B5%AE%E7%AA%97.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%B5%AE%E7%AA%97%E7%BC%A9%E6%94%BE.gif)|

|状态回调|View修改|拓展使用|
|状态回调|拖拽边界|拓展使用|
|:---:|:---:|:---:|
|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%B5%AE%E7%AA%97Callbacks.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/%E6%96%B9%E4%BE%BF%E7%9A%84view%E4%BF%AE%E6%94%B9.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/DragUtils.gif)|
|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/Callbacks.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/BoarderAndSlide.gif)|![](https://github.com/princekin-f/EasyFloat/blob/master/readme/DragUtils.gif)|

## 下载体验:
- [直接下载测试APK](http://fir.zsc7454.cn/qgp2?release_id=603e0d26b2eb4639c8315f4d),或者扫码下载:
- [直接下载测试APK](http://fir.zsc7454.cn/qgp2),或者扫码下载:

![](https://github.com/princekin-f/EasyFloat/blob/master/readme/downloadImage.png)

Expand All @@ -44,7 +44,7 @@ allprojects {
- **在应用模块的`build.gradle`添加:**
```
dependencies {
// 抢先版,希望大家多反馈
// 最新版本,希望大家多反馈
implementation 'com.github.princekin-f:EasyFloat:2.0.0'
}
```
Expand Down
4 changes: 2 additions & 2 deletions UpdateDoc.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 版本更新日志
#### v 2.0.0-beta:
- 新增拖拽关闭、侧滑创建、状态栏沉浸等功能
#### v 2.0.0:
- 新增拖拽关闭、侧滑创建、状态栏沉浸、拖拽边界等功能
- 重构单页面浮窗(创建和PopupWindow同类型的子窗口),减少了API数目,提高利用率;
- 优化使用体验,无需手动init,无需手动调起软键盘。

Expand Down
3 changes: 3 additions & 0 deletions easyfloat/src/main/java/com/lzf/easyfloat/EasyFloat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class EasyFloat {
* @param x 更新后的X轴坐标
* @param y 更新后的Y轴坐标
*/
@JvmStatic
@JvmOverloads
fun updateFloat(tag: String? = null, x: Int = -1, y: Int = -1) =
FloatingWindowManager.getHelper(tag)?.updateFloat(x, y)

Expand Down Expand Up @@ -217,6 +219,7 @@ class EasyFloat {
* @param right 浮窗右侧边距
* @param bottom 浮窗底部边距
*/
@JvmOverloads
fun setBorder(
left: Int = 0,
top: Int = -DisplayUtils.getStatusBarHeight(activity),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal class TouchUtils(val context: Context, val config: FloatConfig) {
MotionEvent.ACTION_MOVE -> {
// 过滤边界值之外的拖拽
if (event.rawX < leftBorder || event.rawX > rightBorder + view.width
|| event.rawY < topBorder || event.rawY > bottomBorder + view.width
|| event.rawY < topBorder || event.rawY > bottomBorder + view.height
) return

// 移动值 = 本次触摸值 - 上次触摸值
Expand Down
Binary file modified example/release/EasyFloat.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.widget.ImageView
import com.lzf.easyfloat.EasyFloat
import com.lzf.easyfloat.enums.SidePattern
import com.lzf.easyfloat.example.R
import com.lzf.easyfloat.utils.DisplayUtils
import kotlinx.android.synthetic.main.activity_border_test.*

/**
Expand Down Expand Up @@ -45,16 +44,10 @@ class BorderTestActivity : BaseActivity() {
EasyFloat.updateFloat(tag)
}
}
.setBorder(
30f.dp2px(), 50f.dp2px(),
DisplayUtils.getScreenWidth(this) - 30f.dp2px(),
DisplayUtils.getScreenHeight(this) - 180f.dp2px()
)
.setBorder(view_bg.left, view_bg.top, view_bg.right, view_bg.bottom)
.setGravity(Gravity.CENTER)
.setSidePattern(SidePattern.RESULT_SIDE)
.show()
}

private fun Float.dp2px() = DisplayUtils.dp2px(this@BorderTestActivity, this)

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ private void test() {
.setLocation(100, 200)
// 设置浮窗的对齐方式和坐标偏移量
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
// 设置拖拽边界值
.setBorder(100, 100, 800, 800)
// 设置宽高是否充满父布局,直接在xml设置match_parent属性无效
.setMatchParent(false, false)
// 设置浮窗的出入动画,可自定义,实现相应接口即可(策略模式),无需动画直接设置为null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ class MainActivity : BaseActivity(), View.OnClickListener {
.setTag(tag)
.registerCallback {
// 在此处设置view也可以,建议在setLayout进行view操作
createResult { isCreated, msg, _ -> logger.e("DSL: $isCreated $msg") }
createResult { isCreated, msg, _ ->
toast("isCreated: $isCreated")
logger.e("DSL: $isCreated $msg")
}

show { toast("show") }

Expand Down Expand Up @@ -148,7 +151,8 @@ class MainActivity : BaseActivity(), View.OnClickListener {

private fun showActivity2(tag: String = "seekBar") {
// 改变浮窗1的文字
EasyFloat.getFloatView("showActivityFloat")?.findViewById<TextView>(R.id.textView)?.text = "欢迎浮窗2"
EasyFloat.getFloatView("showActivityFloat")?.findViewById<TextView>(R.id.textView)?.text =
"欢迎浮窗2"

EasyFloat.with(this)
.setTag(tag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class SecondActivity : BaseActivity() {
.setLocation(100, 200)
// 设置浮窗的对齐方式和坐标偏移量
.setGravity(Gravity.END or Gravity.CENTER_VERTICAL, 0, 200)
// 设置拖拽边界值
.setBorder(100, 100, 800, 800)
// 设置宽高是否充满父布局,直接在xml设置match_parent属性无效
.setMatchParent(widthMatch = false, heightMatch = false)
// 设置浮窗的出入动画,可自定义,实现相应接口即可(策略模式),无需动画直接设置为null
Expand Down
Binary file added readme/BoarderAndSlide.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/Callbacks.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified readme/downloadImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed readme/方便的view修改.gif
Binary file not shown.
Binary file removed readme/浮窗Callbacks.gif
Binary file not shown.

0 comments on commit 37d0fcb

Please sign in to comment.