Skip to content

Commit

Permalink
add landscape offset support
Browse files Browse the repository at this point in the history
  • Loading branch information
iielse committed Mar 31, 2023
1 parent 0642a1d commit 38ac936
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
App.context = this.applicationContext // 随便找位置借个全局context用用.
Config.TRANSITION_OFFSET_Y = statusBarHeight()
// Config.TRANSITION_OFFSET_X = statusBarHeight() // android:screenOrientation="landscape"
setContentView(binding.root)
initialViews()
viewModel.dataList.observe(this, androidx.lifecycle.Observer(adapter::submitList))
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ ext {
buildToolsVersion= "30.0.3"
minSdkVersion = 21
targetSdkVersion = 30
versionCode = 227
versionName = "2.1.21"
versionCode = 228
versionName = "2.1.22"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ object Config {
var SWIPE_TOUCH_SLOP = 4f
var DISMISS_FRACTION: Float = 0.12f
var TRANSITION_OFFSET_Y = 0
var TRANSITION_OFFSET_X = 0
var VIEWER_FIRST_PAGE_SELECTED_DELAY = 300L
var VIDEO_SCALE_TYPE = ExoVideoView.SCALE_TYPE_FIT_CENTER
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object TransitionEndHelper {
val location = IntArray(2)
getLocationOnScreen(startView, location)
if (this is ViewGroup.MarginLayoutParams) {
marginStart = location[0]
marginStart = location[0] - Config.TRANSITION_OFFSET_X
topMargin = location[1] - Config.TRANSITION_OFFSET_Y
}
}
Expand All @@ -99,7 +99,7 @@ object TransitionEndHelper {
val location = IntArray(2)
getLocationOnScreen(startView, location)
if (this is ViewGroup.MarginLayoutParams) {
marginStart = location[0]
marginStart = location[0] - Config.TRANSITION_OFFSET_X
topMargin = location[1] - Config.TRANSITION_OFFSET_Y
}
}
Expand All @@ -118,7 +118,7 @@ object TransitionEndHelper {
val location = IntArray(2)
getLocationOnScreen(startView, location)
if (this is ViewGroup.MarginLayoutParams) {
marginStart = location[0]
marginStart = location[0] - Config.TRANSITION_OFFSET_X
topMargin = location[1] - Config.TRANSITION_OFFSET_Y
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object TransitionStartHelper {
val location = IntArray(2)
getLocationOnScreen(startView, location)
if (this is ViewGroup.MarginLayoutParams) {
marginStart = location[0]
marginStart = location[0] - Config.TRANSITION_OFFSET_X
topMargin = location[1] - Config.TRANSITION_OFFSET_Y
}
}
Expand All @@ -75,7 +75,7 @@ object TransitionStartHelper {
val location = IntArray(2)
getLocationOnScreen(startView, location)
if (this is ViewGroup.MarginLayoutParams) {
marginStart = location[0]
marginStart = location[0] - Config.TRANSITION_OFFSET_X
topMargin = location[1] - Config.TRANSITION_OFFSET_Y
}
}
Expand All @@ -87,7 +87,7 @@ object TransitionStartHelper {
val location = IntArray(2)
getLocationOnScreen(startView, location)
if (this is ViewGroup.MarginLayoutParams) {
marginStart = location[0]
marginStart = location[0] - Config.TRANSITION_OFFSET_X
topMargin = location[1] - Config.TRANSITION_OFFSET_Y
}
}
Expand Down

0 comments on commit 38ac936

Please sign in to comment.