Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
luiing committed May 23, 2019
0 parents commit 0ab393d
Show file tree
Hide file tree
Showing 65 changed files with 2,082 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
.idea
.DS_Store
/build
/captures
.externalNativeBuild
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 luiing

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

### 吸顶解决方案(demo模块)
1. Single RecyclerView:简单模式【利用RecyclerView.OnScrollListener监听滑动位置,吸顶View被 ViewHolder和Activity复用】

2. Double RecyclerView:RecyclerView嵌套RecyclerView【事件分发,吸顶View是个单独ViewHolder,无须做其他处理】

3. Viewpager RecyclerView:RecyclerView嵌套ViewPager(其中包含的页面内容是RecyclerView)【事件分发,吸顶View是个单独ViewHolder,无须做其他处理】


### PREVIEW
![](/preview/001.png)

### USE by Kotlin
implementation 'com.uis:groupadapter:0.4.0
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:recyclerview-v7:$supportVer"

``` 项目中使用的是compileOnly,使用者需自行加入外部依赖库 ```

```
```




### VERSION

Version|Descipt|Fixed|Time
----|----|----|----
0.1.0|初始版本| |2019/05/23


### LICENSE
MIT License

Copyright (c) 2019 uis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
1 change: 1 addition & 0 deletions adsorbent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
34 changes: 34 additions & 0 deletions adsorbent/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion compileVer
buildToolsVersion buildToolsVer
defaultConfig {
applicationId "com.uis.groupadater.demo"
minSdkVersion minSdkVer
targetSdkVersion targetVer
versionCode 1
versionName "1.0"
//ndk{
//abiFilters 'x86'//'armeabi-v7a'
//}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:'+supportVer
implementation 'com.android.support:appcompat-v7:'+supportVer
implementation 'com.android.support:recyclerview-v7:'+supportVer
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
21 changes: 21 additions & 0 deletions adsorbent/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions adsorbent/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uis.groupadater.demo">
<application
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".DemoUi">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity android:name=".SingleRecyclerUi"/>
<activity android:name=".DoubleRecyclerUi"/>
<activity android:name=".ViewpagerRecyclerUi"/>
</application>
</manifest>
30 changes: 30 additions & 0 deletions adsorbent/src/main/java/com/uis/groupadater/demo/DemoUi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.uis.groupadater.demo

import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import kotlinx.android.synthetic.main.ui_demo_main.*


class DemoUi: AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_demo_main)

bt_single.setOnClickListener{
val intent = Intent(this,SingleRecyclerUi::class.java)
startActivity(intent)
}

bt_double.setOnClickListener{
val intent = Intent(this,DoubleRecyclerUi::class.java)
startActivity(intent)
}

bt_viewpager.setOnClickListener{
val intent = Intent(this,ViewpagerRecyclerUi::class.java)
startActivity(intent)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.uis.groupadater.demo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import com.uis.groupadapter.GroupEntity
import com.uis.groupadater.demo.holder.*
import kotlinx.android.synthetic.main.ui_demo.*
import kotlinx.android.synthetic.main.ui_view_pin.view.*


class DoubleRecyclerUi: AppCompatActivity() {

val adapter = DemoGroupAdapter()
lateinit var pin: View
lateinit var manager: LinearLayoutManager

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_demo)
pin = layoutInflater.inflate(R.layout.ui_view_pin,null)
pin.bt_add.setOnClickListener{

}
pin.bt_clear.setOnClickListener{

}
adapter.initGroup(10)
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT, "txt $i"))
}
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT_BLUE, "txt blue $i"))
}
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT, "txt position $i"))
}
adapter.addEntity(GroupEntity(VT_PIN,pin))
adapter.addEntity(GroupEntity(VT_RECYCLER,""))

manager = LinearLayoutManager(this)
recyclerView.layoutManager = manager
recyclerView.adapter = adapter

}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.uis.groupadater.demo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import android.view.ViewGroup
import com.uis.groupadapter.GroupEntity
import com.uis.groupadater.demo.holder.*
import com.uis.groupadater.demo.adsorbent.SingleAdsorbentListener
import kotlinx.android.synthetic.main.ui_demo.*
import kotlinx.android.synthetic.main.ui_view_pin.view.*


class SingleRecyclerUi: AppCompatActivity() {

val adapter = DemoGroupAdapter()
lateinit var pin: View
lateinit var manager: LinearLayoutManager

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_demo)
pin = layoutInflater.inflate(R.layout.ui_view_pin,null)
pin.bt_add.setOnClickListener{

}
pin.bt_clear.setOnClickListener{

}
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT, "txt $i"))
}
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT_BLUE, "txt blue $i"))
}
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT, "txt position $i"))
}
adapter.addEntity(GroupEntity(VT_PIN_SINGLE,pin))
for(i in 0 until 50) {
adapter.addEntity(GroupEntity(VT_TXT, "txt bottom $i"))
}


manager = LinearLayoutManager(this)
recyclerView.layoutManager = manager
recyclerView.adapter = adapter

recyclerView.addOnScrollListener(object : SingleAdsorbentListener(){
/** 获取被吸顶ViewGroup*/
override fun getUiViewGroup(): ViewGroup = relative
/** 获取吸顶View*/
override fun getPinView(): View = pin
/** 获取吸顶View在RecyclerView中的位置*/
override fun getPinViewPosition(): Int = 15
})
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.uis.groupadater.demo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import com.uis.groupadapter.GroupEntity
import com.uis.groupadater.demo.holder.*
import kotlinx.android.synthetic.main.ui_demo.*
import kotlinx.android.synthetic.main.ui_view_pin.view.*


class ViewpagerRecyclerUi: AppCompatActivity() {

val adapter = DemoGroupAdapter()
lateinit var pin: View
lateinit var manager: LinearLayoutManager

override fun onCreate(savedInstanceState: Bundle?) {
//Fresco.initialize(applicationContext)
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_demo)
pin = layoutInflater.inflate(R.layout.ui_view_pin,null)
pin.bt_add.setOnClickListener{

}
pin.bt_clear.setOnClickListener{

}
adapter.initGroup(10)
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT, "txt $i"))
}
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT_BLUE, "txt blue $i"))
}
for(i in 0 until 5) {
adapter.addEntity(GroupEntity(VT_TXT, "txt position $i"))
}
adapter.addEntity(GroupEntity(VT_PIN,pin))
adapter.addEntity(GroupEntity(VT_VIEWPAGER,""))

manager = LinearLayoutManager(this)
recyclerView.layoutManager = manager
recyclerView.adapter = adapter
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.uis.groupadater.demo.adsorbent

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
import android.view.MotionEvent

class ChildRecyclerView :RecyclerView{
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle)

override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
/** true child在顶部*/
val isChildTop = !canScrollVertically(-1)
var pv = parent
while (pv != null) {
if (pv is OnInterceptListener) {
pv.onTopChild(isChildTop)
break
}
pv = pv.parent
}
return super.dispatchTouchEvent(ev)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.uis.groupadater.demo.adsorbent

interface OnInterceptListener {
fun onTopChild(isTop :Boolean)
}
Loading

0 comments on commit 0ab393d

Please sign in to comment.