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
02d8aefd
Commit
02d8aefd
authored
Dec 13, 2019
by
王韦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[new] 增加 RecyclerView GridDecoration
parent
93329b07
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
612 additions
and
25 deletions
+612
-25
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
CommomPopActivity.kt
...c/main/java/com/qimai/android/widget/CommomPopActivity.kt
+2
-1
DemoDialogFragmemt.kt
.../main/java/com/qimai/android/widget/DemoDialogFragmemt.kt
+43
-0
GridDividerActivity.kt
...main/java/com/qimai/android/widget/GridDividerActivity.kt
+56
-0
MainActivity.kt
app/src/main/java/com/qimai/android/widget/MainActivity.kt
+6
-1
TestWindow.kt
app/src/main/java/com/qimai/android/widget/TestWindow.kt
+4
-1
activity_grid_divider.xml
app/src/main/res/layout/activity_grid_divider.xml
+14
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+5
-0
grid_item.xml
app/src/main/res/layout/grid_item.xml
+17
-0
build.gradle
tools/build.gradle
+1
-1
BigDecimalExtention.kt
.../main/java/com/qimai/android/tools/BigDecimalExtention.kt
+35
-0
TimeFormat.kt
tools/src/main/java/com/qimai/android/tools/TimeFormat.kt
+1
-0
build.gradle
widgetlib/build.gradle
+1
-1
AbsQMBaseDialogFragment.kt
.../qimai/android/widgetlib/popup/AbsQMBaseDialogFragment.kt
+54
-0
AbsQMBasePopup.kt
.../java/com/qimai/android/widgetlib/popup/AbsQMBasePopup.kt
+17
-11
GridItemDivider.java
...com/qimai/android/widgetlib/rvrelate/GridItemDivider.java
+102
-0
CommonToastFactory.kt
...a/com/qimai/android/widgetlib/toast/CommonToastFactory.kt
+14
-0
CustomToastFactory.kt
...a/com/qimai/android/widgetlib/toast/CustomToastFactory.kt
+14
-0
CustomToastUtils.java
...a/com/qimai/android/widgetlib/toast/CustomToastUtils.java
+141
-0
ToastFactory.kt
...in/java/com/qimai/android/widgetlib/toast/ToastFactory.kt
+12
-0
ToastUtils.java
...in/java/com/qimai/android/widgetlib/toast/ToastUtils.java
+6
-8
toast_fail.png
widgetlib/src/main/res/drawable-xhdpi/toast_fail.png
+0
-0
toast_success.png
widgetlib/src/main/res/drawable-xhdpi/toast_success.png
+0
-0
griddivide.xml
widgetlib/src/main/res/drawable/griddivide.xml
+5
-0
shape_toast.xml
widgetlib/src/main/res/drawable/shape_toast.xml
+6
-0
custometoast.xml
widgetlib/src/main/res/layout/custometoast.xml
+39
-0
qm_alert_content.xml
widgetlib/src/main/res/layout/qm_alert_content.xml
+1
-0
colors.xml
widgetlib/src/main/res/values/colors.xml
+2
-0
styles.xml
widgetlib/src/main/res/values/styles.xml
+12
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
02d8aefd
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".TipActivity"
></activity>
<activity
android:name=
".GridDividerActivity"
></activity>
<activity
android:name=
".TipActivity"
/>
<activity
android:name=
".CommomPopActivity"
/>
<activity
android:name=
".CommomPopActivity"
/>
<activity
android:name=
".TopBarActivity"
/>
<activity
android:name=
".TopBarActivity"
/>
<activity
android:name=
".MainActivity"
>
<activity
android:name=
".MainActivity"
>
...
...
app/src/main/java/com/qimai/android/widget/CommomPopActivity.kt
View file @
02d8aefd
...
@@ -30,7 +30,8 @@ class CommomPopActivity : AppCompatActivity() {
...
@@ -30,7 +30,8 @@ class CommomPopActivity : AppCompatActivity() {
// commonPopWindow.show(findViewById(R.id.root))
// commonPopWindow.show(findViewById(R.id.root))
// commonPopWindow.dimBehind(0.5f)
// commonPopWindow.dimBehind(0.5f)
TestWindow
(
this
,
findViewById
<
Button
>(
R
.
id
.
root
)).
build
().
show
()
// TestWindow(this, findViewById<Button>(R.id.root)).build().show()
DemoDialogFragmemt
().
show
(
supportFragmentManager
,
"fefe"
)
// i = System.currentTimeMillis()
// i = System.currentTimeMillis()
// "$i".V()
// "$i".V()
...
...
app/src/main/java/com/qimai/android/widget/DemoDialogFragmemt.kt
0 → 100644
View file @
02d8aefd
package
com.qimai.android.widget
import
android.app.Activity
import
android.content.Context
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
com.qimai.android.tools.dpTopx
import
com.qimai.android.tools.getScreenWidth
import
com.qimai.android.widgetlib.popup.AbsQMBaseDialogFragment
/**
* created by wangwei ON 2019-11-06 email:wangwei_5521@163.com
* @version 1.1.1
* @Description
**/
class
DemoDialogFragmemt
:
AbsQMBaseDialogFragment
()
{
override
fun
prepareView
(
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?
):
View
{
val
view
=
inflater
?.
inflate
(
R
.
layout
.
qm_alert_content
,
container
,
false
)
return
view
!!
}
override
fun
onAttach
(
context
:
Context
?)
{
super
.
onAttach
(
context
)
}
override
fun
config
():
DialogFramgentConfig
{
return
DialogFramgentConfig
().
apply
{
mWindowWidth
=
getScreenWidth
(
context
!!
)
-
context
!!
.
dpTopx
(
30.0f
)
}
}
}
\ No newline at end of file
app/src/main/java/com/qimai/android/widget/GridDividerActivity.kt
0 → 100644
View file @
02d8aefd
package
com.qimai.android.widget
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
androidx.recyclerview.widget.GridLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.qimai.android.widgetlib.rvrelate.GridItemDivider
import
kotlinx.android.synthetic.main.activity_grid_divider.*
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
adapter
=
GridAdatper
(
datas
)
grid
.
layoutManager
=
gridLayoutManager
grid
.
addItemDecoration
(
GridItemDivider
(
ContextCompat
.
getDrawable
(
this
,
R
.
drawable
.
griddivide
)))
grid
.
adapter
=
adapter
}
}
class
GridAdatper
(
var
datas
:
MutableList
<
String
>)
:
RecyclerView
.
Adapter
<
GridViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
GridViewHolder
{
val
itemview
=
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
grid_item
,
parent
,
false
);
return
GridViewHolder
(
itemView
=
itemview
)
}
override
fun
getItemCount
():
Int
{
return
datas
.
size
}
override
fun
onBindViewHolder
(
holder
:
GridViewHolder
,
position
:
Int
)
{
holder
.
conent
.
text
=
datas
[
position
]
}
}
class
GridViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
val
conent
=
itemView
.
findViewById
<
TextView
>(
R
.
id
.
conent
)
}
app/src/main/java/com/qimai/android/widget/MainActivity.kt
View file @
02d8aefd
...
@@ -4,6 +4,7 @@ import android.content.Intent
...
@@ -4,6 +4,7 @@ import android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
android.widget.Button
import
android.widget.Button
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
com.qimai.android.widgetlib.toast.CustomToastUtils
import
com.qimai.android.widgetlib.toast.HolderContext
import
com.qimai.android.widgetlib.toast.HolderContext
class
MainActivity
:
AppCompatActivity
()
{
class
MainActivity
:
AppCompatActivity
()
{
...
@@ -20,12 +21,13 @@ class MainActivity : AppCompatActivity() {
...
@@ -20,12 +21,13 @@ class MainActivity : AppCompatActivity() {
// ToastUtils.getInstance().setMsgColor(Color.RED).showTaost("测试出的的")
// ToastUtils.getInstance().setMsgColor(Color.RED).showTaost("测试出的的")
startActivity
(
Intent
(
MainActivity
@
this
,
CommomPopActivity
::
class
.
java
))
//
startActivity(Intent(MainActivity@ this, CommomPopActivity::class.java))
// val loding = Loading()
// val loding = Loading()
// loding.isCancelable =false
// loding.isCancelable =false
// loding.show(supportFragmentManager, "loading")
// loding.show(supportFragmentManager, "loading")
// TestWindow(this, findViewById<Button>(R.id.commonPop)).build().show()
// TestWindow(this, findViewById<Button>(R.id.commonPop)).build().show()
CustomToastUtils
.
getInstance
().
success
()
}
}
...
@@ -38,6 +40,9 @@ class MainActivity : AppCompatActivity() {
...
@@ -38,6 +40,9 @@ class MainActivity : AppCompatActivity() {
startActivity
(
Intent
(
MainActivity
@
this
,
TopBarActivity
::
class
.
java
))
startActivity
(
Intent
(
MainActivity
@
this
,
TopBarActivity
::
class
.
java
))
}
}
findViewById
<
Button
>(
R
.
id
.
divide
).
setOnClickListener
{
startActivity
(
Intent
(
MainActivity
@
this
,
GridDividerActivity
::
class
.
java
))
}
}
}
}
}
app/src/main/java/com/qimai/android/widget/TestWindow.kt
View file @
02d8aefd
...
@@ -20,9 +20,12 @@ class TestWindow constructor(var ctx: Context, var anchor: View) : AbsQMBasePopu
...
@@ -20,9 +20,12 @@ class TestWindow constructor(var ctx: Context, var anchor: View) : AbsQMBasePopu
dimBehind
(
0.5f
)
dimBehind
(
0.5f
)
}
}
override
fun
config
():
WindowConfig
{
override
fun
config
():
WindowConfig
{
val
content
=
LayoutInflater
.
from
(
ctx
).
inflate
(
R
.
layout
.
qm_alert_content
,
null
)
return
AbsQMBasePopup
.
WindowConfig
().
apply
{
return
AbsQMBasePopup
.
WindowConfig
().
apply
{
mContentView
=
LayoutInflater
.
from
(
ctx
).
inflate
(
R
.
layout
.
qm_alert_content
,
null
)
mContentView
=
content
mAnchorView
=
anchor
mAnchorView
=
anchor
mWindowWidth
=
getScreenWidth
(
ctx
)
-
ctx
.
dpTopx
(
30.0f
)
mWindowWidth
=
getScreenWidth
(
ctx
)
-
ctx
.
dpTopx
(
30.0f
)
mGravity
=
Gravity
.
CENTER
mGravity
=
Gravity
.
CENTER
...
...
app/src/main/res/layout/activity_grid_divider.xml
0 → 100644
View file @
02d8aefd
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#ffffff"
tools:context=
".GridDividerActivity"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/grid"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</FrameLayout>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
02d8aefd
...
@@ -29,6 +29,11 @@
...
@@ -29,6 +29,11 @@
android:text=
"Tip"
android:text=
"Tip"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
android:layout_height=
"50dp"
/>
<Button
android:id=
"@+id/divide"
android:text=
"griddivider"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
/>
</LinearLayout>
</LinearLayout>
...
...
app/src/main/res/layout/grid_item.xml
0 → 100644
View file @
02d8aefd
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:gravity=
"center"
android:background=
"@color/QmTopBar_color_FFFFFFF"
android:layout_height=
"wrap_content"
>
<TextView
android:id=
"@+id/conent"
android:layout_height=
"90dp"
android:gravity=
"center"
android:layout_width=
"80dp"
android:text=
"1"
android:textSize=
"19sp"
android:textColor=
"#416EBD"
/>
</LinearLayout>
\ No newline at end of file
tools/build.gradle
View file @
02d8aefd
...
@@ -42,7 +42,7 @@ repositories {
...
@@ -42,7 +42,7 @@ repositories {
group
'com.qmai.android.tools'
group
'com.qmai.android.tools'
version
'1.1.
7
-SNAPSHOT'
version
'1.1.
8
-SNAPSHOT'
gradlePublish
{
gradlePublish
{
...
...
tools/src/main/java/com/qimai/android/tools/BigDecimalExtention.kt
0 → 100644
View file @
02d8aefd
package
com.qimai.android.tools
import
java.math.BigDecimal
/**
* created by wangwei ON 2019-11-28 email:wangwei_5521@163.com
* @version 1.1.1
* @Description
**/
// 加法运算
fun
BigDecimal
.
add
(
d2
:
Double
,
retain
:
Int
):
Double
{
return
add
(
BigDecimal
(
d2
)).
setScale
(
retain
,
BigDecimal
.
ROUND_HALF_UP
).
toDouble
()
}
//减法
fun
BigDecimal
.
sub
(
d2
:
Double
,
retain
:
Int
):
Double
{
return
subtract
(
BigDecimal
(
d2
)).
setScale
(
retain
,
BigDecimal
.
ROUND_HALF_UP
).
toDouble
()
}
// 乘法运算
fun
mul
(
d1
:
Double
,
d2
:
Double
,
decimalPoint
:
Int
):
Double
=
BigDecimal
(
d1
).
multiply
(
BigDecimal
(
d2
)).
setScale
(
decimalPoint
,
BigDecimal
.
ROUND_DOWN
).
toDouble
()
// 除法运算
fun
div
(
d1
:
Double
,
d2
:
Double
,
decimalPoint
:
Int
):
Double
=
BigDecimal
(
d1
).
divide
(
BigDecimal
(
d2
)).
setScale
(
decimalPoint
,
BigDecimal
.
ROUND_DOWN
).
toDouble
()
\ No newline at end of file
tools/src/main/java/com/qimai/android/tools/TimeFormat.kt
View file @
02d8aefd
...
@@ -10,6 +10,7 @@ import java.util.*
...
@@ -10,6 +10,7 @@ import java.util.*
**/
**/
fun
formatCurrentDate
(
pattern
:
String
)
=
getTimeFormatStr
(
pattern
)
fun
formatCurrentDate
(
pattern
:
String
)
=
getTimeFormatStr
(
pattern
)
private
fun
getTimeFormatStr
(
pattern
:
String
,
original
:
Any
=
Date
())
=
private
fun
getTimeFormatStr
(
pattern
:
String
,
original
:
Any
=
Date
())
=
...
...
widgetlib/build.gradle
View file @
02d8aefd
...
@@ -47,7 +47,7 @@ repositories {
...
@@ -47,7 +47,7 @@ repositories {
group
'com.qmai.android.sdk'
group
'com.qmai.android.sdk'
version
'1.1.2
0
-SNAPSHOT'
version
'1.1.2
9
-SNAPSHOT'
gradlePublish
{
gradlePublish
{
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/AbsQMBaseDialogFragment.kt
0 → 100644
View file @
02d8aefd
package
com.qimai.android.widgetlib.popup
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.fragment.app.DialogFragment
import
com.qimai.android.widgetlib.R
/**
* created by wangwei ON 2019-11-26 email:wangwei_5521@163.com
* @version 1.1.1
* @Description
**/
abstract
class
AbsQMBaseDialogFragment
:
DialogFragment
()
{
abstract
fun
config
():
AbsQMBaseDialogFragment
.
DialogFramgentConfig
class
DialogFramgentConfig
{
var
mWindowWidth
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
var
mWindowHeight
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
var
mAnimationStyle
:
Int
=
-
1
var
isOutsideTouchable
=
true
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
):
View
?
{
return
prepareView
(
inflater
,
container
)
}
abstract
fun
prepareView
(
inflater
:
LayoutInflater
?,
container
:
ViewGroup
?
):
View
override
fun
onStart
()
{
super
.
onStart
()
setStyle
(
STYLE_NO_TITLE
,
R
.
style
.
Widget_DialogFragment
)
isCancelable
=
false
dialog
.
setCanceledOnTouchOutside
(
config
().
isOutsideTouchable
)
dialog
?.
window
?.
apply
{
setBackgroundDrawableResource
(
R
.
color
.
transparent
)
val
lp
=
attributes
lp
.
dimAmount
=
0.6f
lp
.
width
=
config
().
mWindowWidth
lp
.
height
=
config
().
mWindowHeight
attributes
=
lp
}
}
}
\ No newline at end of file
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/AbsQMBasePopup.kt
View file @
02d8aefd
...
@@ -41,26 +41,27 @@ abstract class AbsQMBasePopup(open var context: Context) {
...
@@ -41,26 +41,27 @@ abstract class AbsQMBasePopup(open var context: Context) {
fun
build
():
AbsQMBasePopup
{
fun
build
():
AbsQMBasePopup
{
val
config
=
config
()
setContentView
(
contentView
=
config
().
mContentView
)
setContentView
(
contentView
=
config
.
mContentView
)
mWindow
.
width
=
config
.
mWindowWidth
mWindow
.
width
=
mWindow
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
if
(
config
().
mWindowWidth
==
-
1
)
ViewGroup
.
LayoutParams
.
MATCH_PARENT
else
config
().
mWindowWidth
mWindow
.
height
=
if
(
config
().
mWindowHeight
==
-
1
)
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
else
config
().
mWindowHeight
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP_MR1
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP_MR1
)
{
mWindow
.
isAttachedInDecor
=
false
mWindow
.
isAttachedInDecor
=
false
}
}
if
(
config
.
mBackground
==
null
)
{
if
(
config
()
.
mBackground
==
null
)
{
mWindow
.
setBackgroundDrawable
(
ColorDrawable
(
Color
.
TRANSPARENT
))
mWindow
.
setBackgroundDrawable
(
ColorDrawable
(
Color
.
TRANSPARENT
))
}
else
{
}
else
{
mWindow
.
setBackgroundDrawable
(
config
.
mBackground
)
mWindow
.
setBackgroundDrawable
(
config
()
.
mBackground
)
}
}
mWindow
.
isTouchable
=
true
mWindow
.
isTouchable
=
true
mWindow
.
isFocusable
=
true
mWindow
.
isFocusable
=
true
mWindow
.
isOutsideTouchable
=
config
.
isOutsideTouchable
mWindow
.
isOutsideTouchable
=
config
()
.
isOutsideTouchable
// 在相关的View被移除时,window也自动移除。避免当Fragment退出后,Fragment中弹出的PopupWindow还存在于界面上。
// 在相关的View被移除时,window也自动移除。避免当Fragment退出后,Fragment中弹出的PopupWindow还存在于界面上。
config
.
mAnchorView
.
addOnAttachStateChangeListener
(
object
:
config
()
.
mAnchorView
.
addOnAttachStateChangeListener
(
object
:
View
.
OnAttachStateChangeListener
{
View
.
OnAttachStateChangeListener
{
override
fun
onViewAttachedToWindow
(
v
:
View
)
{
override
fun
onViewAttachedToWindow
(
v
:
View
)
{
...
@@ -102,7 +103,7 @@ abstract class AbsQMBasePopup(open var context: Context) {
...
@@ -102,7 +103,7 @@ abstract class AbsQMBasePopup(open var context: Context) {
fun
show
()
{
fun
show
()
{
if
(!
isShowing
())
{
if
(!
isShowing
())
{
val
point
=
onShowBegin
(
config
().
mC
ontentView
)
val
point
=
onShowBegin
(
mWindow
.
c
ontentView
)
mWindow
.
showAtLocation
(
config
().
mAnchorView
,
config
().
mGravity
,
point
.
x
,
point
.
y
)
mWindow
.
showAtLocation
(
config
().
mAnchorView
,
config
().
mGravity
,
point
.
x
,
point
.
y
)
onShowEnd
()
onShowEnd
()
}
}
...
@@ -130,8 +131,13 @@ abstract class AbsQMBasePopup(open var context: Context) {
...
@@ -130,8 +131,13 @@ abstract class AbsQMBasePopup(open var context: Context) {
mDismissListener
!!
.
onDismiss
()
mDismissListener
!!
.
onDismiss
()
}
}
}
}
configViewEnd
(
mWindow
.
contentView
)
}
}
open
protected
fun
configViewEnd
(
contentView
:
View
)
{}
protected
fun
onDismiss
()
{}
protected
fun
onDismiss
()
{}
private
fun
getDecorView
():
View
?
{
private
fun
getDecorView
():
View
?
{
...
@@ -158,8 +164,8 @@ abstract class AbsQMBasePopup(open var context: Context) {
...
@@ -158,8 +164,8 @@ abstract class AbsQMBasePopup(open var context: Context) {
}
}
class
WindowConfig
{
class
WindowConfig
{
var
mWindowWidth
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
var
mWindowWidth
=
-
1
var
mWindowHeight
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
var
mWindowHeight
=
-
1
var
mAnimationStyle
:
Int
=
-
1
var
mAnimationStyle
:
Int
=
-
1
var
mGravity
:
Int
=
Gravity
.
CENTER
var
mGravity
:
Int
=
Gravity
.
CENTER
var
mBackground
:
Drawable
?
=
null
var
mBackground
:
Drawable
?
=
null
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/rvrelate/GridItemDivider.java
0 → 100644
View file @
02d8aefd
package
com
.
qimai
.
android
.
widgetlib
.
rvrelate
;
import
android.graphics.Canvas
;
import
android.graphics.Rect
;
import
android.graphics.drawable.Drawable
;
import
android.view.View
;
import
androidx.annotation.NonNull
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
/**
* created by wangwei ON 2019-12-03 email:wangwei_5521@163.com
*
* @version 1.1.1
* @Description
**/
public
class
GridItemDivider
extends
RecyclerView
.
ItemDecoration
{
// 多少列
private
Drawable
mDivider
;
private
final
Rect
mBounds
=
new
Rect
();
private
int
mode
=
OPEN
;
public
final
static
int
CLOSE
=
1
;
public
final
static
int
OPEN
=
2
;
public
GridItemDivider
(
Drawable
drawable
)
{
this
.
mDivider
=
drawable
;
}
public
GridItemDivider
(
int
dividerColor
,
int
divideWidth
)
{
}
public
void
setMode
(
int
mode
)
{
this
.
mode
=
mode
;
}
@Override
public
void
onDraw
(
@NonNull
Canvas
c
,
@NonNull
RecyclerView
parent
,
@NonNull
RecyclerView
.
State
state
)
{
super
.
onDraw
(
c
,
parent
,
state
);
if
(!(
parent
.
getLayoutManager
()
instanceof
GridLayoutManager
))
{
throw
new
IllegalStateException
(
"请使用GridLayoutManager"
);
}
int
mNumcolums
=
((
GridLayoutManager
)
parent
.
getLayoutManager
()).
getSpanCount
();
c
.
save
();
int
childCount
=
parent
.
getChildCount
();
int
closeChildCount
=
childCount
;
if
(
mode
==
CLOSE
&&
childCount
%
mNumcolums
!=
0
)
{
closeChildCount
=
childCount
+
(
mNumcolums
-
childCount
%
mNumcolums
);
}
View
child
=
null
;
for
(
int
i
=
0
;
i
<
closeChildCount
;
i
++)
{
if
(
i
<
childCount
)
{
child
=
parent
.
getChildAt
(
i
);
if
((
i
+
1
)
%
mNumcolums
!=
0
)
{
// 竖线
mDivider
.
setBounds
(
child
.
getRight
(),
child
.
getTop
(),
child
.
getRight
()
+
mDivider
.
getIntrinsicWidth
(),
child
.
getBottom
());
mDivider
.
draw
(
c
);
}
// 横线
mDivider
.
setBounds
(
child
.
getLeft
(),
child
.
getBottom
(),
child
.
getRight
()
+
mDivider
.
getIntrinsicWidth
(),
child
.
getBottom
()
+
mDivider
.
getIntrinsicWidth
());
mDivider
.
draw
(
c
);
}
if
(
childCount
!=
closeChildCount
&&
i
>=
childCount
&&
i
<
closeChildCount
-
1
)
{
int
top
=
child
.
getTop
();
int
left
=
child
.
getRight
()
*
(
i
-
childCount
+
2
)
+
mDivider
.
getIntrinsicWidth
()
*
(
i
-
childCount
+
1
);
int
right
=
(
child
.
getRight
()
+
mDivider
.
getIntrinsicWidth
())
*
(
i
-
childCount
+
2
);
int
bottom
=
child
.
getBottom
();
mDivider
.
setBounds
(
left
,
top
,
right
,
bottom
);
mDivider
.
draw
(
c
);
}
if
(
childCount
!=
closeChildCount
&&
i
>=
childCount
&&
i
<
closeChildCount
)
{
int
top
=
child
.
getBottom
();
int
left
=
child
.
getRight
()
*
(
i
-
childCount
+
1
)
+
mDivider
.
getIntrinsicWidth
()
*
(
i
-
childCount
+
1
);
int
right
=
child
.
getRight
()
*
(
i
-
childCount
+
2
)
+
mDivider
.
getIntrinsicWidth
()
*
(
i
-
childCount
+
2
);
int
bottom
=
child
.
getBottom
()
+
mDivider
.
getIntrinsicWidth
();
mDivider
.
setBounds
(
left
,
top
,
right
,
bottom
);
mDivider
.
draw
(
c
);
}
}
c
.
restore
();
}
@Override
public
void
getItemOffsets
(
Rect
outRect
,
View
view
,
RecyclerView
parent
,
RecyclerView
.
State
state
)
{
super
.
getItemOffsets
(
outRect
,
view
,
parent
,
state
);
GridLayoutManager
.
LayoutParams
lp
=
(
GridLayoutManager
.
LayoutParams
)
view
.
getLayoutParams
();
int
childPos
=
parent
.
getChildAdapterPosition
(
view
);
if
((
childPos
+
1
)
%
((
GridLayoutManager
)
parent
.
getLayoutManager
()).
getSpanCount
()
==
0
)
{
outRect
.
set
(
0
,
0
,
0
,
mDivider
.
getIntrinsicHeight
());
}
else
{
outRect
.
set
(
0
,
0
,
mDivider
.
getIntrinsicHeight
(),
mDivider
.
getIntrinsicHeight
());
}
}
}
widgetlib/src/main/java/com/qimai/android/widgetlib/toast/CommonToastFactory.kt
0 → 100644
View file @
02d8aefd
package
com.qimai.android.widgetlib.toast
import
android.widget.Toast
/**
* created by wangwei ON 2019-12-02 email:wangwei_5521@163.com
* @version 1.1.1
* @Description
**/
class
CommonToastFactory
:
ToastFactory
{
override
fun
create
():
Toast
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
}
\ No newline at end of file
widgetlib/src/main/java/com/qimai/android/widgetlib/toast/CustomToastFactory.kt
0 → 100644
View file @
02d8aefd
package
com.qimai.android.widgetlib.toast
import
android.widget.Toast
/**
* created by wangwei ON 2019-12-02 email:wangwei_5521@163.com
* @version 1.1.1
* @Description
**/
class
CustomToastFactory
:
ToastFactory
{
override
fun
create
():
Toast
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
}
\ No newline at end of file
widgetlib/src/main/java/com/qimai/android/widgetlib/toast/CustomToastUtils.java
0 → 100644
View file @
02d8aefd
package
com
.
qimai
.
android
.
widgetlib
.
toast
;
import
android.graphics.PorterDuff
;
import
android.graphics.PorterDuffColorFilter
;
import
android.graphics.drawable.ColorDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.MainThread
;
import
com.qimai.android.widgetlib.R
;
/**
* created by wangwei ON 2019-11-04 email:wangwei_5521@163.com
*
* @version 1.1.1
* @Description
**/
public
class
CustomToastUtils
{
private
static
volatile
CustomToastUtils
instance
;
private
static
final
int
COLOR_DEFAULT
=
0xFEFFFFFF
;
private
static
volatile
Toast
mToast
;
private
static
volatile
Toast
mCustomToast
;
private
int
sMsgTextSize
=
-
1
;
private
int
sMsgColor
=
COLOR_DEFAULT
;
private
int
sGravity
=
-
1
;
private
int
sBgColor
=
COLOR_DEFAULT
;
private
int
sBgResource
=
-
1
;
public
static
CustomToastUtils
getInstance
()
{
if
(
instance
==
null
)
{
synchronized
(
CustomToastUtils
.
class
)
{
if
(
instance
==
null
)
{
instance
=
new
CustomToastUtils
();
}
}
}
return
instance
;
}
public
void
success
()
{
View
view
=
getToast
().
getView
();
ImageView
icon
=
view
.
findViewById
(
R
.
id
.
toastIcon
);
TextView
title
=
view
.
findViewById
(
R
.
id
.
toastMsg
);
title
.
setText
(
"支付成功"
);
icon
.
setImageResource
(
R
.
drawable
.
toast_success
);
mToast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
mToast
.
show
();
}
public
void
fail
()
{
View
view
=
getToast
().
getView
();
ImageView
icon
=
view
.
findViewById
(
R
.
id
.
toastIcon
);
TextView
title
=
view
.
findViewById
(
R
.
id
.
toastMsg
);
title
.
setText
(
"支付失败"
);
icon
.
setImageResource
(
R
.
drawable
.
toast_fail
);
mToast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
mToast
.
show
();
}
@MainThread
public
void
showToast
(
CharSequence
msg
)
{
getToast
();
View
toastView
=
mToast
.
getView
();
TextView
message
=
toastView
.
findViewById
(
android
.
R
.
id
.
message
);
message
.
setText
(
msg
);
if
(
sMsgTextSize
!=
-
1
)
{
message
.
setTextSize
(
sMsgTextSize
);
}
if
(
sMsgColor
!=
COLOR_DEFAULT
)
{
message
.
setTextColor
(
sMsgColor
);
}
if
(
sGravity
!=
-
1
)
{
mToast
.
setGravity
(
sGravity
,
0
,
0
);
}
if
(
sBgResource
!=
-
1
)
{
toastView
.
setBackgroundResource
(
sBgResource
);
}
else
if
(
sBgColor
!=
COLOR_DEFAULT
)
{
Drawable
background
=
toastView
.
getBackground
();
if
(
background
!=
null
)
{
background
.
setColorFilter
(
new
PorterDuffColorFilter
(
sBgColor
,
PorterDuff
.
Mode
.
SRC_IN
)
);
}
else
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN
)
{
toastView
.
setBackground
(
new
ColorDrawable
(
sBgColor
));
}
else
{
toastView
.
setBackgroundDrawable
(
new
ColorDrawable
(
sBgColor
));
}
}
}
mToast
.
show
();
}
public
CustomToastUtils
setsMsgTextSize
(
int
msgTextSize
)
{
sMsgTextSize
=
msgTextSize
;
return
this
;
}
public
CustomToastUtils
setMsgColor
(
int
color
)
{
this
.
sMsgColor
=
color
;
return
this
;
}
public
CustomToastUtils
setGravity
(
int
gravity
)
{
this
.
sGravity
=
gravity
;
return
this
;
}
public
CustomToastUtils
setBgColor
(
int
color
)
{
this
.
sBgColor
=
color
;
return
this
;
}
public
CustomToastUtils
setBgResouce
(
int
bgResouce
)
{
this
.
sBgColor
=
bgResouce
;
return
this
;
}
private
static
Toast
getToast
()
{
if
(
mToast
==
null
)
{
synchronized
(
CustomToastUtils
.
class
)
{
if
(
mToast
==
null
)
{
mToast
=
Toast
.
makeText
(
HolderContext
.
getContext
(),
""
,
Toast
.
LENGTH_LONG
);
mToast
.
setView
(
LayoutInflater
.
from
(
HolderContext
.
getContext
()).
inflate
(
R
.
layout
.
custometoast
,
null
));
}
}
}
return
mToast
;
}
}
widgetlib/src/main/java/com/qimai/android/widgetlib/toast/ToastFactory.kt
0 → 100644
View file @
02d8aefd
package
com.qimai.android.widgetlib.toast
import
android.widget.Toast
/**
* created by wangwei ON 2019-11-29 email:wangwei_5521@163.com
* @version 1.1.1
* @Description
**/
interface
ToastFactory
{
fun
create
():
Toast
}
\ No newline at end of file
widgetlib/src/main/java/com/qimai/android/widgetlib/toast/ToastUtils.java
View file @
02d8aefd
...
@@ -10,6 +10,8 @@ import android.view.View;
...
@@ -10,6 +10,8 @@ import android.view.View;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
androidx.annotation.MainThread
;
/**
/**
* created by wangwei ON 2019-11-04 email:wangwei_5521@163.com
* created by wangwei ON 2019-11-04 email:wangwei_5521@163.com
*
*
...
@@ -22,6 +24,7 @@ public class ToastUtils {
...
@@ -22,6 +24,7 @@ public class ToastUtils {
private
static
final
int
COLOR_DEFAULT
=
0xFEFFFFFF
;
private
static
final
int
COLOR_DEFAULT
=
0xFEFFFFFF
;
private
static
volatile
Toast
mToast
;
private
static
volatile
Toast
mToast
;
private
static
volatile
Toast
mCustomToast
;
private
int
sMsgTextSize
=
-
1
;
private
int
sMsgTextSize
=
-
1
;
private
int
sMsgColor
=
COLOR_DEFAULT
;
private
int
sMsgColor
=
COLOR_DEFAULT
;
...
@@ -40,15 +43,15 @@ public class ToastUtils {
...
@@ -40,15 +43,15 @@ public class ToastUtils {
return
instance
;
return
instance
;
}
}
@MainThread
public
void
showCenter
(
String
msg
)
{
public
void
showCenter
(
String
msg
)
{
getToast
().
setText
(
msg
);
getToast
().
setText
(
msg
);
mToast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
mToast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
mToast
.
show
();
mToast
.
show
();
}
}
@MainThread
public
void
showT
ao
st
(
CharSequence
msg
)
{
public
void
showT
oa
st
(
CharSequence
msg
)
{
getToast
();
getToast
();
View
toastView
=
mToast
.
getView
();
View
toastView
=
mToast
.
getView
();
TextView
message
=
toastView
.
findViewById
(
android
.
R
.
id
.
message
);
TextView
message
=
toastView
.
findViewById
(
android
.
R
.
id
.
message
);
...
@@ -59,7 +62,6 @@ public class ToastUtils {
...
@@ -59,7 +62,6 @@ public class ToastUtils {
if
(
sMsgColor
!=
COLOR_DEFAULT
)
{
if
(
sMsgColor
!=
COLOR_DEFAULT
)
{
message
.
setTextColor
(
sMsgColor
);
message
.
setTextColor
(
sMsgColor
);
}
}
if
(
sGravity
!=
-
1
)
{
if
(
sGravity
!=
-
1
)
{
mToast
.
setGravity
(
sGravity
,
0
,
0
);
mToast
.
setGravity
(
sGravity
,
0
,
0
);
}
}
...
@@ -79,10 +81,8 @@ public class ToastUtils {
...
@@ -79,10 +81,8 @@ public class ToastUtils {
toastView
.
setBackgroundDrawable
(
new
ColorDrawable
(
sBgColor
));
toastView
.
setBackgroundDrawable
(
new
ColorDrawable
(
sBgColor
));
}
}
}
}
}
}
mToast
.
show
();
mToast
.
show
();
}
}
public
ToastUtils
setsMsgTextSize
(
int
msgTextSize
)
{
public
ToastUtils
setsMsgTextSize
(
int
msgTextSize
)
{
...
@@ -110,7 +110,6 @@ public class ToastUtils {
...
@@ -110,7 +110,6 @@ public class ToastUtils {
return
this
;
return
this
;
}
}
private
static
Toast
getToast
()
{
private
static
Toast
getToast
()
{
if
(
mToast
==
null
)
{
if
(
mToast
==
null
)
{
synchronized
(
ToastUtils
.
class
)
{
synchronized
(
ToastUtils
.
class
)
{
...
@@ -121,5 +120,4 @@ public class ToastUtils {
...
@@ -121,5 +120,4 @@ public class ToastUtils {
}
}
return
mToast
;
return
mToast
;
}
}
}
}
widgetlib/src/main/res/drawable-xhdpi/toast_fail.png
0 → 100644
View file @
02d8aefd
1.2 KB
widgetlib/src/main/res/drawable-xhdpi/toast_success.png
0 → 100644
View file @
02d8aefd
1.83 KB
widgetlib/src/main/res/drawable/griddivide.xml
0 → 100644
View file @
02d8aefd
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"@color/color_222222"
/>
<size
android:width=
"0.5dp"
android:height=
"0.5dp"
/>
</shape>
\ No newline at end of file
widgetlib/src/main/res/drawable/shape_toast.xml
0 → 100644
View file @
02d8aefd
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#80000000"
/>
<corners
android:radius=
"5dp"
/>
</shape>
\ No newline at end of file
widgetlib/src/main/res/layout/custometoast.xml
0 → 100644
View file @
02d8aefd
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"wrap_content"
android:background=
"@drawable/shape_toast"
android:layout_gravity=
"center_horizontal"
android:layout_height=
"wrap_content"
>
<LinearLayout
android:layout_centerInParent=
"true"
android:id=
"@+id/llToast"
android:layout_marginLeft=
"20dp"
android:layout_marginRight=
"20dp"
android:layout_width=
"wrap_content"
android:orientation=
"vertical"
android:layout_height=
"wrap_content"
>
<ImageView
android:id=
"@+id/toastIcon"
android:layout_width=
"40dp"
android:layout_marginTop=
"10dp"
android:layout_gravity=
"center_horizontal"
android:src=
"@drawable/toast_success"
android:layout_height=
"40dp"
/>
<TextView
android:id=
"@+id/toastMsg"
android:layout_width=
"wrap_content"
android:textSize=
"16sp"
tools:text=
"支付成功"
android:layout_marginBottom=
"10dp"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"10dp"
android:textColor=
"@color/QmTopBar_color_FFFFFFF"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
widgetlib/src/main/res/layout/qm_alert_content.xml
View file @
02d8aefd
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1.0"
android:layout_weight=
"1.0"
android:background=
"@drawable/shape_alert_cancel"
android:background=
"@drawable/shape_alert_cancel"
android:gravity=
"center"
android:gravity=
"center"
android:text=
"取消"
android:text=
"取消"
...
...
widgetlib/src/main/res/values/colors.xml
View file @
02d8aefd
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
<color
name=
"color_777777"
>
#777777
</color>
<color
name=
"color_777777"
>
#777777
</color>
<color
name=
"color_222222"
>
#222222
</color>
<color
name=
"color_222222"
>
#222222
</color>
<color
name=
"segment_divider_dark"
>
#d9d9d9
</color>
<color
name=
"segment_divider_dark"
>
#d9d9d9
</color>
<color
name=
"transparent"
>
#00000000
</color>
<color
name=
"color_80"
>
#80000000
</color>
</resources>
</resources>
\ No newline at end of file
widgetlib/src/main/res/values/styles.xml
View file @
02d8aefd
...
@@ -8,4 +8,16 @@
...
@@ -8,4 +8,16 @@
<item
name=
"overlay_borderWidth"
>
1dp
</item>
<item
name=
"overlay_borderWidth"
>
1dp
</item>
</style>
</style>
<style
name=
"Widget_DialogFragment"
>
<item
name=
"android:windowBackground"
>
@color/color_80
</item>
<item
name=
"android:windowFrame"
>
@null
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowIsFloating"
>
false
</item>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
<item
name=
"android:windowCloseOnTouchOutside"
>
false
</item>
<item
name=
"android:windowContentOverlay"
>
@null
</item>
<item
name=
"android:windowAnimationStyle"
>
@android:style/Animation.Dialog
</item>
<item
name=
"android:backgroundDimEnabled"
>
true
</item>
<item
name=
"colorAccent"
>
#FFD100
</item>
</style>
</resources>
</resources>
\ 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