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
d5f6b340
Commit
d5f6b340
authored
Sep 19, 2019
by
王韦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[new] bugfix
parent
1bbf1180
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
58 additions
and
19 deletions
+58
-19
TipActivity.kt
app/src/main/java/com/qimai/android/widget/TipActivity.kt
+5
-2
TopBarActivity.kt
app/src/main/java/com/qimai/android/widget/TopBarActivity.kt
+4
-0
readme.md
readme.md
+1
-0
build.gradle
tools/build.gradle
+1
-1
SharedPreferencesTools.kt
...in/java/com/qimai/android/tools/SharedPreferencesTools.kt
+12
-0
StringLogExt.kt
tools/src/main/java/com/qimai/android/tools/StringLogExt.kt
+8
-8
TopBarReadMe.MD
widgetlib/TopBarReadMe.MD
+2
-2
build.gradle
widgetlib/build.gradle
+1
-1
QmToolTip.kt
.../main/java/com/qimai/android/widgetlib/popup/QmToolTip.kt
+10
-1
QmTopBar.kt
.../main/java/com/qimai/android/widgetlib/topbar/QmTopBar.kt
+10
-2
TextProperty.kt
...n/java/com/qimai/android/widgetlib/topbar/TextProperty.kt
+3
-1
dimens.xml
widgetlib/src/main/res/values/dimens.xml
+1
-1
No files found.
app/src/main/java/com/qimai/android/widget/TipActivity.kt
View file @
d5f6b340
...
@@ -13,12 +13,14 @@ import androidx.recyclerview.widget.LinearLayoutManager
...
@@ -13,12 +13,14 @@ import androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
com.qimai.android.widgetlib.popup.QmToolTip
import
com.qimai.android.widgetlib.popup.QmToolTip
import
com.qimai.android.widgetlib.topbar.QmTopBar
import
com.qimai.android.widgetlib.topbar.QmTopBar
import
kotlinx.android.synthetic.main.goodmanager_rightview_titlebar.*
class
TipActivity
:
AppCompatActivity
()
{
class
TipActivity
:
AppCompatActivity
()
{
lateinit
var
mPop
:
QmToolTip
lateinit
var
mPop
:
QmToolTip
lateinit
var
topbar
:
QmTopBar
lateinit
var
topbar
:
QmTopBar
var
items
=
mutableListOf
(
"堂食"
,
"外卖"
)
var
items
=
mutableListOf
(
"堂食"
,
"外卖"
)
private
lateinit
var
rightText
:
TextView
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_tip
)
setContentView
(
R
.
layout
.
activity_tip
)
...
@@ -51,7 +53,7 @@ class TipActivity : AppCompatActivity() {
...
@@ -51,7 +53,7 @@ class TipActivity : AppCompatActivity() {
}
}
findViewById
<
Button
>(
R
.
id
.
topnorrow
).
setOnClickListener
{
findViewById
<
Button
>(
R
.
id
.
topnorrow
).
setOnClickListener
{
rightText
.
text
=
"测试"
val
view
=
LayoutInflater
.
from
(
TipActivity
@
this
).
inflate
(
R
.
layout
.
tip
,
null
)
val
view
=
LayoutInflater
.
from
(
TipActivity
@
this
).
inflate
(
R
.
layout
.
tip
,
null
)
QmToolTip
.
Builder
()
QmToolTip
.
Builder
()
.
withAttachedView
(
findViewById
(
R
.
id
.
topnorrow
))
.
withAttachedView
(
findViewById
(
R
.
id
.
topnorrow
))
...
@@ -114,7 +116,7 @@ class TipActivity : AppCompatActivity() {
...
@@ -114,7 +116,7 @@ class TipActivity : AppCompatActivity() {
private
fun
customTopBar
()
{
private
fun
customTopBar
()
{
val
topRight
=
val
topRight
=
layoutInflater
.
inflate
(
R
.
layout
.
goodmanager_rightview_titlebar
,
topbar
,
false
)
layoutInflater
.
inflate
(
R
.
layout
.
goodmanager_rightview_titlebar
,
topbar
,
false
)
val
rightText
=
topRight
.
findViewById
<
TextView
>(
R
.
id
.
rightText
)
rightText
=
topRight
.
findViewById
<
TextView
>(
R
.
id
.
rightText
)
rightText
.
text
=
"堂食"
rightText
.
text
=
"堂食"
topbar
.
customRightView
(
topRight
,
null
)
topbar
.
customRightView
(
topRight
,
null
)
val
recyclerView
=
RecyclerView
(
this
)
val
recyclerView
=
RecyclerView
(
this
)
...
@@ -137,6 +139,7 @@ class TipActivity : AppCompatActivity() {
...
@@ -137,6 +139,7 @@ class TipActivity : AppCompatActivity() {
.
withContentView
(
recyclerView
)
.
withContentView
(
recyclerView
)
.
withArrowShow
(
true
)
.
withArrowShow
(
true
)
.
withArrowWeight
(
0.5f
)
.
withArrowWeight
(
0.5f
)
.
withOffset
(-
100
)
.
build
()
.
build
()
}
}
mPop
.
show
()
mPop
.
show
()
...
...
app/src/main/java/com/qimai/android/widget/TopBarActivity.kt
View file @
d5f6b340
...
@@ -7,6 +7,7 @@ import android.widget.TextView
...
@@ -7,6 +7,7 @@ import android.widget.TextView
import
android.widget.Toast
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
com.qimai.android.tools.dpTopx
import
com.qimai.android.widgetlib.topbar.QmTopBar
import
com.qimai.android.widgetlib.topbar.QmTopBar
class
TopBarActivity
:
AppCompatActivity
()
{
class
TopBarActivity
:
AppCompatActivity
()
{
...
@@ -49,6 +50,7 @@ class TopBarActivity : AppCompatActivity() {
...
@@ -49,6 +50,7 @@ class TopBarActivity : AppCompatActivity() {
)
)
textBackground
=
textBackground
=
ContextCompat
.
getDrawable
(
this
@TopBarActivity
,
R
.
drawable
.
btn_shape
)
ContextCompat
.
getDrawable
(
this
@TopBarActivity
,
R
.
drawable
.
btn_shape
)
}
}
}
}
...
@@ -59,6 +61,8 @@ class TopBarActivity : AppCompatActivity() {
...
@@ -59,6 +61,8 @@ class TopBarActivity : AppCompatActivity() {
this
@TopBarActivity
,
this
@TopBarActivity
,
R
.
color
.
abc_btn_colored_borderless_text_material
R
.
color
.
abc_btn_colored_borderless_text_material
)
)
textSize
=
20
bold
=
true
}
}
}
}
...
...
readme.md
View file @
d5f6b340
...
@@ -66,4 +66,5 @@ last, execute `./gradlew publish` or `./gradlew :library:publish` task to publis
...
@@ -66,4 +66,5 @@ last, execute `./gradlew publish` or `./gradlew :library:publish` task to publis
[
Tip(筹划中)
](
)
[
Tip(筹划中)
](
)
[
Pop(筹划中)
](
)
[
Pop(筹划中)
](
)
\ No newline at end of file
tools/build.gradle
View file @
d5f6b340
...
@@ -42,7 +42,7 @@ repositories {
...
@@ -42,7 +42,7 @@ repositories {
group
'com.qmai.android.tools'
group
'com.qmai.android.tools'
version
'1.1.
4
-SNAPSHOT'
version
'1.1.
6
-SNAPSHOT'
gradlePublish
{
gradlePublish
{
...
...
tools/src/main/java/com/qimai/android/tools/SharedPreferencesTools.kt
View file @
d5f6b340
...
@@ -61,6 +61,18 @@ class SharedPreferencesTools {
...
@@ -61,6 +61,18 @@ class SharedPreferencesTools {
}
}
}
}
fun
getString
(
key
:
String
,
default
:
String
):
String
?
{
return
sp
?.
getString
(
key
,
default
)
}
fun
getBoolean
(
key
:
String
,
default
:
Boolean
):
Boolean
?
{
return
sp
?.
getBoolean
(
key
,
default
)
}
fun
getInt
(
key
:
String
,
default
:
Int
):
Int
?
{
return
sp
?.
getInt
(
key
,
default
)
}
fun
remove
(
key
:
String
)
{
fun
remove
(
key
:
String
)
{
check
()
check
()
sp
?.
edit
{
sp
?.
edit
{
...
...
tools/src/main/java/com/qimai/android/tools/StringLogExt.kt
View file @
d5f6b340
...
@@ -10,22 +10,22 @@ import android.util.Log
...
@@ -10,22 +10,22 @@ import android.util.Log
const
val
TAG
=
"QM_NETWORK"
const
val
TAG
=
"QM_NETWORK"
fun
String
.
V
()
{
fun
String
.
V
(
tag
:
String
=
TAG
)
{
Log
.
v
(
TAG
,
this
)
Log
.
v
(
tag
,
this
)
}
}
fun
String
.
E
()
{
fun
String
.
E
(
tag
:
String
=
TAG
)
{
Log
.
e
(
TAG
,
this
)
Log
.
e
(
tag
,
this
)
}
}
fun
String
.
W
()
{
fun
String
.
W
(
tag
:
String
=
TAG
)
{
Log
.
w
(
TAG
,
this
)
Log
.
w
(
tag
,
this
)
}
}
fun
String
.
I
()
{
fun
String
.
I
(
tag
:
String
=
TAG
)
{
Log
.
i
(
TAG
,
this
)
Log
.
i
(
tag
,
this
)
}
}
widgetlib/TopBarReadMe.MD
View file @
d5f6b340
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
````
````
debugImplementation 'com.qmai.android.sdk:widget:1.1.1-SNAPSHOT'
debugImplementation 'com.qmai.android.sdk:widget
lib
:1.1.1-SNAPSHOT'
releaseImplementation 'com.qmai.android.sdk:widget:1.1.1'
releaseImplementation 'com.qmai.android.sdk:widget
lib
:1.1.1'
````
````
...
...
widgetlib/build.gradle
View file @
d5f6b340
...
@@ -45,7 +45,7 @@ repositories {
...
@@ -45,7 +45,7 @@ repositories {
group
'com.qmai.android.sdk'
group
'com.qmai.android.sdk'
version
'1.1.
7
-SNAPSHOT'
version
'1.1.
12
-SNAPSHOT'
gradlePublish
{
gradlePublish
{
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/popup/QmToolTip.kt
View file @
d5f6b340
...
@@ -47,12 +47,15 @@ class QmToolTip private constructor(
...
@@ -47,12 +47,15 @@ class QmToolTip private constructor(
private
var
containerMeasureHeight
=
0
private
var
containerMeasureHeight
=
0
private
var
arrowWeight
=
0f
private
var
arrowWeight
=
0f
private
var
offset
=
0
private
constructor
(
builder
:
Builder
)
:
this
(
private
constructor
(
builder
:
Builder
)
:
this
(
builder
.
attachedView
,
builder
.
attachedView
,
builder
.
defaultOverlayStyle
,
builder
.
defaultOverlayStyle
,
builder
.
gravity
builder
.
gravity
)
{
)
{
checkMustParams
(
builder
)
checkMustParams
(
builder
)
offset
=
builder
.
offset
arrowWeight
=
builder
.
arrowWeight
arrowWeight
=
builder
.
arrowWeight
mWindow
.
width
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
mWindow
.
width
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
mWindow
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
mWindow
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
...
@@ -217,7 +220,7 @@ class QmToolTip private constructor(
...
@@ -217,7 +220,7 @@ class QmToolTip private constructor(
point
=
calculateBottomOffset
(
anchorView
)
point
=
calculateBottomOffset
(
anchorView
)
}
}
}
}
return
point
return
Point
(
point
.
x
,
point
.
y
+
offset
)
}
}
private
fun
calculateTopOffset
(
anchorView
:
View
):
Point
{
private
fun
calculateTopOffset
(
anchorView
:
View
):
Point
{
...
@@ -265,6 +268,8 @@ class QmToolTip private constructor(
...
@@ -265,6 +268,8 @@ class QmToolTip private constructor(
internal
var
arrowWeight
=
0.5f
internal
var
arrowWeight
=
0.5f
internal
var
offset
=
0
fun
withAttachedView
(
attachedView
:
View
?)
=
apply
{
fun
withAttachedView
(
attachedView
:
View
?)
=
apply
{
...
@@ -302,6 +307,10 @@ class QmToolTip private constructor(
...
@@ -302,6 +307,10 @@ class QmToolTip private constructor(
this
.
contentView
=
contentView
this
.
contentView
=
contentView
}
}
fun
withOffset
(
offset
:
Int
)
=
apply
{
this
.
offset
=
offset
}
fun
build
():
QmToolTip
{
fun
build
():
QmToolTip
{
return
QmToolTip
(
this
)
return
QmToolTip
(
this
)
}
}
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/topbar/QmTopBar.kt
View file @
d5f6b340
...
@@ -2,6 +2,7 @@ package com.qimai.android.widgetlib.topbar
...
@@ -2,6 +2,7 @@ package com.qimai.android.widgetlib.topbar
import
android.content.Context
import
android.content.Context
import
android.content.res.TypedArray
import
android.content.res.TypedArray
import
android.graphics.Typeface
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.util.AttributeSet
import
android.util.AttributeSet
import
android.view.View
import
android.view.View
...
@@ -70,6 +71,7 @@ class QmTopBar : Toolbar {
...
@@ -70,6 +71,7 @@ class QmTopBar : Toolbar {
}
}
private
var
qmTopBarTextSize
:
Int
private
var
qmTopBarTextSize
:
Int
private
var
qmTopBarTextColor
:
Int
private
var
qmTopBarTextColor
:
Int
private
var
qmTopBarCenterBold
=
false
var
qmTopBarLeftDrawable
:
Int
var
qmTopBarLeftDrawable
:
Int
...
@@ -109,6 +111,7 @@ class QmTopBar : Toolbar {
...
@@ -109,6 +111,7 @@ class QmTopBar : Toolbar {
qmTopBarText
=
field
.
text
qmTopBarText
=
field
.
text
qmTopBarTextColor
=
field
.
textColor
qmTopBarTextColor
=
field
.
textColor
qmTopBarTextSize
=
field
.
textSize
qmTopBarTextSize
=
field
.
textSize
qmTopBarCenterBold
=
field
.
bold
buildOrModifyCenter
(
relativeLayout
)
buildOrModifyCenter
(
relativeLayout
)
}
}
...
@@ -367,10 +370,9 @@ class QmTopBar : Toolbar {
...
@@ -367,10 +370,9 @@ class QmTopBar : Toolbar {
leftImageView
!!
.
id
=
View
.
generateViewId
()
leftImageView
!!
.
id
=
View
.
generateViewId
()
val
leftImageViewParams
=
RelativeLayout
.
LayoutParams
(
val
leftImageViewParams
=
RelativeLayout
.
LayoutParams
(
context
.
dpTopx
(
16f
),
context
.
dpTopx
(
16f
),
context
.
dpTopx
(
1
6
f
)
context
.
dpTopx
(
1
9
f
)
)
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
ALIGN_LEFT
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
ALIGN_LEFT
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
leftImageViewParams
.
addRule
(
RelativeLayout
.
CENTER_VERTICAL
)
leftImageViewParams
.
leftMargin
=
context
.
dpTopx
(
16f
)
leftImageViewParams
.
leftMargin
=
context
.
dpTopx
(
16f
)
relativeLayout
.
addView
(
leftImageView
,
leftImageViewParams
)
relativeLayout
.
addView
(
leftImageView
,
leftImageViewParams
)
...
@@ -395,6 +397,12 @@ class QmTopBar : Toolbar {
...
@@ -395,6 +397,12 @@ class QmTopBar : Toolbar {
centerTextView
.
text
=
qmTopBarText
centerTextView
.
text
=
qmTopBarText
centerTextView
.
setTextColor
(
qmTopBarTextColor
)
centerTextView
.
setTextColor
(
qmTopBarTextColor
)
}
}
centerTextView
.
textSize
=
context
.
pxTosp
(
qmTopBarTextSize
.
toFloat
()).
toFloat
()
if
(
qmTopBarCenterBold
)
{
centerTextView
.
typeface
=
Typeface
.
defaultFromStyle
(
Typeface
.
BOLD
)
}
else
{
centerTextView
.
typeface
=
Typeface
.
defaultFromStyle
(
Typeface
.
NORMAL
)
}
}
}
inner
class
ListenerViewClick
{
inner
class
ListenerViewClick
{
...
...
widgetlib/src/main/java/com/qimai/android/widgetlib/topbar/TextProperty.kt
View file @
d5f6b340
...
@@ -14,5 +14,7 @@ data class TextProperty(
...
@@ -14,5 +14,7 @@ data class TextProperty(
var
text
:
CharSequence
?,
var
text
:
CharSequence
?,
var
textColor
:
Int
,
var
textColor
:
Int
,
var
textSize
:
Int
,
var
textSize
:
Int
,
var
textBackground
:
Drawable
?
var
textBackground
:
Drawable
?,
var
bold
:
Boolean
=
false
)
)
\ No newline at end of file
widgetlib/src/main/res/values/dimens.xml
View file @
d5f6b340
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
<resources>
<resources>
<dimen
name=
"QmTopBar_dp_18"
>
18dp
</dimen>
<dimen
name=
"QmTopBar_dp_18"
>
18dp
</dimen>
<dimen
name=
"QmTopBar_dp_16"
>
16dp
</dimen>
<dimen
name=
"QmTopBar_dp_16"
>
16dp
</dimen>
<dimen
name=
"QmTopBar_sp_12"
>
1
2
dp
</dimen>
<dimen
name=
"QmTopBar_sp_12"
>
1
7
dp
</dimen>
</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