Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
Widget
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Android Widget
Widget
Commits
b799da99
Commit
b799da99
authored
May 07, 2020
by
王韦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[new] 修复 touchoutside
parent
02d8aefd
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
176 additions
and
14 deletions
+176
-14
GridDividerActivity.kt
...main/java/com/qimai/android/widget/GridDividerActivity.kt
+2
-2
MainActivity.kt
app/src/main/java/com/qimai/android/widget/MainActivity.kt
+2
-2
StoreLocalLayout.kt
...rc/main/java/com/qimai/android/widget/StoreLocalLayout.kt
+107
-0
TestWindow.kt
app/src/main/java/com/qimai/android/widget/TestWindow.kt
+2
-1
activity_grid_divider.xml
app/src/main/res/layout/activity_grid_divider.xml
+2
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+17
-0
tip.xml
app/src/main/res/layout/tip.xml
+12
-0
build.gradle
build.gradle
+0
-2
build.gradle
widgetlib/build.gradle
+1
-1
AbsQMBasePopup.kt
.../java/com/qimai/android/widgetlib/popup/AbsQMBasePopup.kt
+3
-3
GridItemDivider.java
...com/qimai/android/widgetlib/rvrelate/GridItemDivider.java
+1
-1
ShapeView.java
...java/com/qimai/android/widgetlib/shapeview/ShapeView.java
+25
-0
griddivide.xml
widgetlib/src/main/res/drawable/griddivide.xml
+2
-2
No files found.
app/src/main/java/com/qimai/android/widget/GridDividerActivity.kt
View file @
b799da99
...
...
@@ -17,8 +17,8 @@ class GridDividerActivity : AppCompatActivity() {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_grid_divider
)
val
gridLayoutManager
=
GridLayoutManager
(
this
,
5
)
val
datas
=
mutableListOf
<
String
>(
"1"
,
"2"
,
"1"
,
"2"
,
"1"
,
"2"
)
val
gridLayoutManager
=
GridLayoutManager
(
this
,
3
)
val
datas
=
mutableListOf
<
String
>(
"1"
,
"2"
)
val
adapter
=
GridAdatper
(
datas
)
grid
.
layoutManager
=
gridLayoutManager
...
...
app/src/main/java/com/qimai/android/widget/MainActivity.kt
View file @
b799da99
...
...
@@ -26,8 +26,8 @@ class MainActivity : AppCompatActivity() {
// loding.isCancelable =false
// loding.show(supportFragmentManager, "loading")
//
TestWindow(this, findViewById<Button>(R.id.commonPop)).build().show()
CustomToastUtils
.
getInstance
().
success
()
TestWindow
(
this
,
findViewById
<
Button
>(
R
.
id
.
commonPop
)).
build
().
show
()
//
CustomToastUtils.getInstance().success()
}
...
...
app/src/main/java/com/qimai/android/widget/StoreLocalLayout.kt
0 → 100644
View file @
b799da99
package
com.qimai.android.widget
import
android.content.Context
import
android.util.AttributeSet
import
android.view.View
import
android.view.ViewGroup
/**
* created by wangwei ON 4/17/20 email:wangwei_5521@163.com
* @version 1.1.1
* @Description
**/
class
StoreLocalLayout
:
ViewGroup
{
constructor
(
context
:
Context
?)
:
this
(
context
,
null
)
constructor
(
context
:
Context
?,
attrs
:
AttributeSet
?)
:
this
(
context
,
attrs
,
0
)
constructor
(
context
:
Context
?,
attrs
:
AttributeSet
?,
defStyleAttr
:
Int
)
:
super
(
context
,
attrs
,
defStyleAttr
)
{
}
private
val
mAllView
=
mutableListOf
<
List
<
View
>>()
private
val
mLineHeight
=
mutableListOf
<
Int
>()
override
fun
onLayout
(
changed
:
Boolean
,
l
:
Int
,
t
:
Int
,
r
:
Int
,
b
:
Int
)
{
if
(
childCount
==
0
)
return
var
left
=
0
var
top
=
0
mAllView
.
clear
()
mLineHeight
.
clear
()
var
lineHeight
=
0
var
lineViews
=
arrayListOf
<
View
>()
if
(
childCount
==
1
){
val
child
=
getChildAt
(
0
)
val
lc
=
left
val
tc
=
top
val
rc
=
measuredWidth
val
bc
=
tc
+
child
.
measuredHeight
child
.
layout
(
lc
,
tc
,
rc
,
bc
)
return
}
for
(
index
in
0
until
childCount
)
{
val
child
=
getChildAt
(
index
)
lineHeight
=
Math
.
max
(
child
.
measuredHeight
,
lineHeight
)
lineViews
.
add
(
child
)
if
((
index
+
1
)
%
2
==
0
)
{
mLineHeight
.
add
(
lineHeight
)
mAllView
.
add
(
lineViews
)
lineViews
=
arrayListOf
<
View
>()
}
}
mLineHeight
.
add
(
lineHeight
)
mAllView
.
add
(
lineViews
)
mAllView
.
forEachIndexed
{
index
,
list
->
val
mLineHeight
=
mLineHeight
[
index
]
list
.
forEachIndexed
{
index
,
view
->
val
child
=
view
val
lc
=
left
val
tc
=
top
val
rc
=
lc
+
measuredWidth
/
2
val
bc
=
tc
+
child
.
measuredHeight
child
.
layout
(
lc
,
tc
,
rc
,
bc
)
left
+=
measuredWidth
/
2
}
left
=
0
top
+=
mLineHeight
}
}
override
fun
measureChild
(
child
:
View
?,
parentWidthMeasureSpec
:
Int
,
parentHeightMeasureSpec
:
Int
)
{
super
.
measureChild
(
child
,
parentWidthMeasureSpec
,
parentHeightMeasureSpec
)
}
override
fun
onMeasure
(
widthMeasureSpec
:
Int
,
heightMeasureSpec
:
Int
)
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
)
if
(
childCount
==
0
)
return
val
heightSize
=
MeasureSpec
.
getSize
(
heightMeasureSpec
)
val
widthSize
=
MeasureSpec
.
getSize
(
widthMeasureSpec
)
for
(
i
in
0
until
childCount
)
{
if
(
i
==
0
&&
childCount
==
1
)
{
val
widthSpec
=
MeasureSpec
.
makeMeasureSpec
(
0
,
MeasureSpec
.
AT_MOST
)
val
heightSpec
=
MeasureSpec
.
makeMeasureSpec
(
0
,
MeasureSpec
.
UNSPECIFIED
)
measureChild
(
getChildAt
(
i
),
widthSpec
,
heightSpec
)
}
if
(
childCount
>
1
)
{
val
widthSpec
=
MeasureSpec
.
makeMeasureSpec
(
widthSize
/
2
,
MeasureSpec
.
EXACTLY
)
val
heightSpec
=
MeasureSpec
.
makeMeasureSpec
(
300
,
MeasureSpec
.
EXACTLY
)
measureChild
(
getChildAt
(
i
),
widthSpec
,
heightSpec
)
}
}
setMeasuredDimension
(
widthSize
,
heightSize
)
}
}
\ No newline at end of file
app/src/main/java/com/qimai/android/widget/TestWindow.kt
View file @
b799da99
...
...
@@ -22,13 +22,14 @@ class TestWindow constructor(var ctx: Context, var anchor: View) : AbsQMBasePopu
override
fun
config
():
WindowConfig
{
val
content
=
LayoutInflater
.
from
(
ctx
).
inflate
(
R
.
layout
.
qm_alert_content
,
null
)
val
content
=
LayoutInflater
.
from
(
ctx
).
inflate
(
R
.
layout
.
qm_alert_content
,
null
)
return
AbsQMBasePopup
.
WindowConfig
().
apply
{
mContentView
=
content
mAnchorView
=
anchor
mWindowWidth
=
getScreenWidth
(
ctx
)
-
ctx
.
dpTopx
(
30.0f
)
mGravity
=
Gravity
.
CENTER
isOutsideTouchable
=
false
}
}
...
...
app/src/main/res/layout/activity_grid_divider.xml
View file @
b799da99
...
...
@@ -8,6 +8,8 @@
tools:context=
".GridDividerActivity"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/grid"
android:layout_marginLeft=
"15dp"
android:layout_marginRight=
"15dp"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
...
...
app/src/main/res/layout/activity_main.xml
View file @
b799da99
...
...
@@ -34,6 +34,23 @@
android:text=
"griddivider"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
<TextView
android:layout_width=
"match_parent"
android:text=
"测试111111 "
android:gravity=
"center"
android:textColor=
"@color/colorAccent"
android:layout_height=
"20dp"
/>
<com.qimai.android.widget.StoreLocalLayout
android:layout_width=
"match_parent"
android:layout_height=
"100dp"
>
<TextView
android:layout_width=
"wrap_content"
android:text=
"测试111111 "
android:textColor=
"@color/colorAccent"
android:layout_height=
"20dp"
/>
</com.qimai.android.widget.StoreLocalLayout>
</LinearLayout>
...
...
app/src/main/res/layout/tip.xml
View file @
b799da99
...
...
@@ -4,6 +4,12 @@
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"测试测试测试"
android:textColor=
"#C02F14"
android:textSize=
"10sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -11,4 +17,10 @@
android:textColor=
"#C02F14"
android:textSize=
"10sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"测试测试测试"
android:textColor=
"#C02F14"
android:textSize=
"10sp"
/>
</LinearLayout>
\ No newline at end of file
build.gradle
View file @
b799da99
...
...
@@ -3,8 +3,6 @@
buildscript
{
ext
.
kotlin_version
=
'1.3.60'
ext
.
kotlin_version
=
'1.3.50'
ext
.
kotlin_version
=
'1.3.41'
repositories
{
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public/'
}
// 阿里云镜像
maven
{
url
'http://maven.aliyun.com/nexus/content/repositories/jcenter'
}
...
...
widgetlib/build.gradle
View file @
b799da99
...
...
@@ -47,7 +47,7 @@ repositories {
group
'com.qmai.android.sdk'
version
'1.1.
29
-SNAPSHOT'
version
'1.1.
30
-SNAPSHOT'
gradlePublish
{
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/AbsQMBasePopup.kt
View file @
b799da99
...
...
@@ -28,7 +28,7 @@ abstract class AbsQMBasePopup(open var context: Context) {
abstract
fun
config
():
WindowConfig
var
touchOutside
=
tru
e
var
touchOutside
=
fals
e
set
(
value
)
{
field
=
value
mWindow
.
isOutsideTouchable
=
value
...
...
@@ -57,7 +57,7 @@ abstract class AbsQMBasePopup(open var context: Context) {
}
mWindow
.
isTouchable
=
true
mWindow
.
isFocusable
=
tru
e
mWindow
.
isFocusable
=
config
().
isOutsideTouchabl
e
mWindow
.
isOutsideTouchable
=
config
().
isOutsideTouchable
// 在相关的View被移除时,window也自动移除。避免当Fragment退出后,Fragment中弹出的PopupWindow还存在于界面上。
...
...
@@ -119,7 +119,7 @@ abstract class AbsQMBasePopup(open var context: Context) {
mRootViewWrapper
.
addView
(
contentView
)
mWindow
.
contentView
=
mRootViewWrapper
mWindow
.
setTouchInterceptor
(
View
.
OnTouchListener
{
v
,
event
->
if
(
event
.
action
==
MotionEvent
.
ACTION_OUTSIDE
)
{
if
(
event
.
action
==
MotionEvent
.
ACTION_OUTSIDE
&&
config
().
isOutsideTouchable
)
{
mWindow
.
dismiss
()
return
@OnTouchListener
false
}
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/rvrelate/GridItemDivider.java
View file @
b799da99
...
...
@@ -21,7 +21,7 @@ public class GridItemDivider extends RecyclerView.ItemDecoration {
private
Drawable
mDivider
;
private
final
Rect
mBounds
=
new
Rect
();
private
int
mode
=
OPEN
;
private
int
mode
=
CLOSE
;
public
final
static
int
CLOSE
=
1
;
public
final
static
int
OPEN
=
2
;
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/shapeview/ShapeView.java
0 → 100644
View file @
b799da99
package
com
.
qimai
.
android
.
widgetlib
.
shapeview
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.widget.FrameLayout
;
/**
* created by wangwei ON 4/13/20 email:wangwei_5521@163.com
*
* @version 1.1.1
* @Description
**/
public
class
ShapeView
extends
FrameLayout
{
public
ShapeView
(
Context
context
)
{
this
(
context
,
null
);
}
public
ShapeView
(
Context
context
,
AttributeSet
attrs
)
{
this
(
context
,
attrs
,
0
);
}
public
ShapeView
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
}
}
widgetlib/src/main/res/drawable/griddivide.xml
View file @
b799da99
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"
@color/color_22222
2"
/>
<size
android:width=
"
0.5dp"
android:height=
"0.5
dp"
/>
<solid
android:color=
"
#f2f2f
2"
/>
<size
android:width=
"
1dp"
android:height=
"1
dp"
/>
</shape>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment