Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser White
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Browser White
Commits
2464c0f3
Commit
2464c0f3
authored
Sep 04, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
ee2ba7b2
63a99165
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
21 deletions
+74
-21
SearchActivity.kt
...om/base/browserwhite/ui/activity/search/SearchActivity.kt
+73
-20
WebBrowserActivity.kt
...browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
+1
-1
No files found.
app/src/main/java/com/base/browserwhite/ui/activity/search/SearchActivity.kt
View file @
2464c0f3
package
com.base.browserwhite.ui.activity.search
import
android.animation.Animator
import
android.animation.AnimatorSet
import
android.animation.ObjectAnimator
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.content.Intent
import
android.content.res.Resources
import
android.graphics.Color
import
android.os.Handler
import
android.util.DisplayMetrics
import
android.util.Log
import
android.util.TypedValue
import
android.view.KeyEvent
import
android.view.View
...
...
@@ -252,26 +257,74 @@ class SearchActivity : BaseActivity<ActivitySearchBinding>() {
}
fun
startActivityWithButtonExpandAnimation
(
currentActivity
:
Activity
,
button
:
View
,
verticalOffset
:
Int
)
{
// val finalPosition =
// TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, currentActivity.resources.displayMetrics).toInt()
// val buttonTop = button.top - finalPosition
// val distanceToTop = -buttonTop - verticalOffset
// val animator = ObjectAnimator.ofFloat(button, "scaleX", 1f, 1.05f)
// animator.setDuration(500)
// animator.addListener(object : Animator.AnimatorListener {
// override fun onAnimationStart(animation: Animator) {}
// override fun onAnimationEnd(animation: Animator) {
// button.visibility = View.VISIBLE
fun
startActivityWithButtonExpandAnimation
(
currentActivity
:
Activity
,
button
:
View
,
verticalOffset
:
Int
)
{
val
context
:
Context
=
button
.
getContext
()
val
res
:
Resources
=
context
.
resources
// 将dp单位转换为像素
val
startHeight
=
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
40f
,
res
.
getDisplayMetrics
())
.
toInt
()
val
endHeight
=
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
50f
,
res
.
getDisplayMetrics
())
.
toInt
()
val
marginEnd
=
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
30f
,
res
.
getDisplayMetrics
())
.
toInt
()
// 获取屏幕宽度和视图当前宽度
val
metrics
=
DisplayMetrics
()
(
context
as
Activity
).
windowManager
.
defaultDisplay
.
getMetrics
(
metrics
)
val
startWidth
:
Int
=
button
.
getWidth
()
// 假设view已经布局,可以获取宽度
val
screenWidth
=
context
.
getResources
().
displayMetrics
.
widthPixels
-
marginEnd
val
x
=
screenWidth
.
toFloat
()
/
button
.
width
.
toFloat
()
Log
.
d
(
"glc"
,
"screenWidth:"
+
screenWidth
)
Log
.
d
(
"glc"
,
"button.width.toFloat():"
+
button
.
width
.
toFloat
())
val
scaleXAnimator
=
ObjectAnimator
.
ofFloat
(
button
,
"scaleX"
,
1f
,
x
)
val
scaleYAnimator
=
ObjectAnimator
.
ofFloat
(
button
,
"scaleY"
,
1f
,
1.13f
)
button
.
pivotX
=
0f
button
.
pivotY
=
0f
scaleXAnimator
.
setDuration
(
500
)
scaleYAnimator
.
setDuration
(
500
)
val
animatorSet
=
AnimatorSet
()
animatorSet
.
playTogether
(
scaleXAnimator
,
scaleYAnimator
)
animatorSet
.
start
()
animatorSet
.
addListener
(
object
:
Animator
.
AnimatorListener
{
override
fun
onAnimationStart
(
animation
:
Animator
)
{
}
override
fun
onAnimationEnd
(
animation
:
Animator
)
{
val
intent
=
Intent
(
currentActivity
,
SearchActivity
::
class
.
java
)
currentActivity
.
startActivityForResult
(
intent
,
10086
)
currentActivity
.
startActivityForResult
(
intent
,
10087
)
currentActivity
.
overridePendingTransition
(
R
.
anim
.
fade_in
,
R
.
anim
.
fade_out
)
// }
//
// override fun onAnimationCancel(animation: Animator) {}
// override fun onAnimationRepeat(animation: Animator) {}
// })
// animator.start()
}
override
fun
onAnimationCancel
(
animation
:
Animator
)
{
}
override
fun
onAnimationRepeat
(
animation
:
Animator
)
{
}
})
}
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
View file @
2464c0f3
...
...
@@ -256,7 +256,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
binding
.
editWeb
.
setOnFocusChangeListener
{
v
,
hasFocus
->
if
(
hasFocus
)
{
binding
.
editWeb
.
selectAll
()
binding
.
ivShare
.
visibility
=
View
.
GON
E
binding
.
ivShare
.
visibility
=
View
.
INVISIBL
E
SearchActivity
.
searchContent
=
binding
.
editWeb
.
text
.
toString
()
SearchActivity
.
startActivityWithButtonExpandAnimation
(
this
,
binding
.
clSearch
,
0
)
v
.
clearFocus
()
...
...
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