-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
845 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 0 additions & 198 deletions
198
app/src/main/java/com/lxj/androidktxdemo/ShadowLayout.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/lxj/androidktxdemo/blibli/BlibliFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.lxj.androidktxdemo.blibli | ||
|
||
import android.widget.TextView | ||
import androidx.core.graphics.ColorUtils | ||
import com.lxj.androidktx.core.bindData | ||
import com.lxj.androidktx.core.vertical | ||
import com.lxj.androidktxdemo.R | ||
import com.lxj.androidktxdemo.fragment.BaseFragment | ||
import kotlinx.android.synthetic.main.fragment_blibli.* | ||
|
||
class BlibliFragment: BaseFragment() { | ||
override fun getLayoutId() = R.layout.fragment_blibli | ||
|
||
override fun initView() { | ||
super.initView() | ||
rvBliBli.vertical() | ||
.bindData(listOf(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1), R.layout.adapter_blibli, bindFn = {holder, t, position -> | ||
(holder.itemView as TextView).setText("评论内容-${position}") | ||
(holder.itemView as TextView).setBackgroundColor(com.blankj.utilcode.util.ColorUtils.getRandomColor()) | ||
}) | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
app/src/main/java/com/lxj/androidktxdemo/blibli/BlibliVideoActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.lxj.androidktxdemo.blibli | ||
|
||
import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
import androidx.viewpager.widget.ViewPager | ||
import com.blankj.utilcode.util.ScreenUtils | ||
import com.lxj.androidktx.base.BaseActivity | ||
import com.lxj.androidktx.core.* | ||
import com.lxj.androidktx.widget.behavior.AppBarScaleHeaderBehavior | ||
import com.lxj.androidktxdemo.R | ||
import kotlinx.android.synthetic.main.activity_blibli_video.* | ||
|
||
class BlibliVideoActivity: BaseActivity() { | ||
|
||
override fun getLayoutId() = R.layout.activity_blibli_video | ||
val behavior = AppBarScaleHeaderBehavior() | ||
override fun initView() { | ||
viewPager.bindFragment( | ||
fm = supportFragmentManager, fragments = listOf(BlibliFragment(), BlibliFragment()), | ||
pageTitles = listOf("评论", "相关产品"), | ||
) | ||
tabLayout.setupWithViewPager(viewPager) | ||
viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener{ | ||
override fun onPageScrolled( | ||
position: Int, | ||
positionOffset: Float, | ||
positionOffsetPixels: Int | ||
) {} | ||
override fun onPageSelected(position: Int) { | ||
appBar.setExpanded(false, true) | ||
} | ||
override fun onPageScrollStateChanged(state: Int) {} | ||
}) | ||
|
||
tvScale.click { | ||
if (behavior.isFullscreenHeader){ | ||
ScreenUtils.setPortrait(this) | ||
behavior.fullscreenHeader(false) | ||
toast("恢复正常播放") | ||
}else{ | ||
ScreenUtils.setLandscape(this) | ||
behavior.fullscreenHeader(true) //禁用padding更新 | ||
toast("模拟视频全屏播放") | ||
} | ||
} | ||
tvEnableDrag.click { | ||
behavior.enableAppBarDrag(!behavior.enableAppBarDrag) | ||
toast("AppBar区域${if(behavior.enableAppBarDrag) "可以" else "禁用"}拖拽") | ||
} | ||
(appBar.layoutParams as CoordinatorLayout.LayoutParams).behavior = behavior | ||
tvHideTab.click { | ||
tabLayout.visible(!tabLayout.isVisible) | ||
} | ||
} | ||
|
||
override fun initData() {} | ||
|
||
override fun onBackPressed() { | ||
if(behavior.isFullscreenHeader){ | ||
tvScale.performClick() | ||
return | ||
} | ||
super.onBackPressed() | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/lxj/androidktxdemo/blibli/CustomCoordinatorLayout.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.lxj.androidktxdemo.blibli | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.MotionEvent | ||
import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
|
||
class CustomCoordinatorLayout @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, defStyleAttr: Int = 0) | ||
: CoordinatorLayout(context, attributeSet, defStyleAttr){ | ||
|
||
|
||
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { | ||
return isEnabled && super.onInterceptTouchEvent(ev) | ||
} | ||
|
||
override fun onTouchEvent(ev: MotionEvent?): Boolean { | ||
return isEnabled && super.onTouchEvent(ev) | ||
} | ||
|
||
fun resetTouchBehaviors() { | ||
// val childCount = childCount | ||
// for (i in 0 until childCount) { | ||
// val child = getChildAt(i) | ||
// val lp = child.layoutParams as LayoutParams | ||
// val b = lp.behavior | ||
// if (b != null) { | ||
// val now = SystemClock.uptimeMillis() | ||
// val cancelEvent = MotionEvent.obtain( | ||
// now, now, | ||
// MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0 | ||
// ) | ||
// b.onInterceptTouchEvent(this, child, cancelEvent) | ||
//// if (notifyOnInterceptTouchEvent) { | ||
//// } else { | ||
// b.onTouchEvent(this, child, cancelEvent) | ||
//// } | ||
// cancelEvent.recycle() | ||
// } | ||
// } | ||
// for (i in 0 until childCount) { | ||
// val child = getChildAt(i) | ||
// val lp = child.layoutParams as LayoutParams | ||
// lp.resetTouchBehaviorTracking() | ||
// } | ||
// mBehaviorTouchView = null | ||
// mDisallowInterceptReset = false | ||
} | ||
|
||
} |
Oops, something went wrong.