初始化1v1语聊项目

This commit is contained in:
2023-09-27 14:37:28 +08:00
parent d74d8d7e2f
commit 93acf4c8c6
68 changed files with 7183 additions and 9 deletions

1
ViewPager2Delegate/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,34 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//https://github.com/angcyo/DslTabLayout
implementation project(':TabLayout')
//https://mvnrepository.com/artifact/androidx.viewpager2/viewpager2
implementation 'androidx.viewpager2:viewpager2:1.0.0'
}
//apply from: "$gradleHost/master/publish.gradle"

View File

21
ViewPager2Delegate/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.angcyo.tablayout.delegate2" />

View File

@@ -0,0 +1,66 @@
package com.angcyo.tablayout.delegate2
import androidx.viewpager2.widget.ViewPager2
import com.angcyo.tablayout.DslTabLayout
import com.angcyo.tablayout.ViewPagerDelegate
import kotlin.math.absoluteValue
/**
* 兼容[ViewPager2]
* Email:angcyo@126.com
* @author angcyo
* @date 2019/12/14
*/
open class ViewPager2Delegate(
val viewPager: ViewPager2,
val dslTabLayout: DslTabLayout?,
val forceSmoothScroll: Boolean? = null
) : ViewPager2.OnPageChangeCallback(), ViewPagerDelegate {
companion object {
/**
* [forceSmoothScroll] 为 null, 只有切换左右page时, 才有VP的动画, 否则没有.
* */
fun install(
viewPager: ViewPager2,
dslTabLayout: DslTabLayout?,
forceSmoothScroll: Boolean? = null
): ViewPager2Delegate {
return ViewPager2Delegate(viewPager, dslTabLayout, forceSmoothScroll)
}
}
init {
viewPager.registerOnPageChangeCallback(this)
dslTabLayout?.setupViewPager(this)
}
override fun onGetCurrentItem(): Int {
return viewPager.currentItem
}
override fun onSetCurrentItem(
fromIndex: Int,
toIndex: Int,
reselect: Boolean,
fromUser: Boolean
) {
if (fromUser) {
val smoothScroll = forceSmoothScroll ?: ((toIndex - fromIndex).absoluteValue <= 1)
viewPager.setCurrentItem(toIndex, smoothScroll)
}
}
override fun onPageScrollStateChanged(state: Int) {
dslTabLayout?.onPageScrollStateChanged(state)
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
dslTabLayout?.onPageScrolled(position, positionOffset, positionOffsetPixels)
}
override fun onPageSelected(position: Int) {
dslTabLayout?.onPageSelected(position)
}
}