Skip to content

Commit 690a44c

Browse files
committed
提取module,通过Jitpack发布aar
1 parent f7365e2 commit 690a44c

19 files changed

+289
-372
lines changed

README.md

+36-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
11
# GangedRecyclerview
22

3-
4-
#### 实现要求
3+
#### 演示效果
54

65
1. 左侧联动右侧:
7-
点击左侧列表的某一项,背景变色,同时右侧列表中对应的分类滚动到顶部
6+
点击左侧列表的某一项,背景变色,同时右侧列表中对应的分类滚动到顶部
87
2. 右侧列表悬停:
9-
右侧列表滑动的时候相应的标题栏需要在顶部悬停
8+
右侧列表滑动的时候相应的标题栏需要在顶部悬停
109
3. 标题栏可点击
1110
4. 右侧联动左侧:
12-
滚动右侧列表,监听滚动的位置,左侧列表需要同步选中相应的列表
11+
滚动右侧列表,监听滚动的位置,左侧列表需要同步选中相应的列表
12+
13+
<video width="540" height="1170" controls> <source src="docs/device-2022-02-04-190625.mp4" type="video/mp4"> </video>
14+
15+
#### 接入文档
16+
17+
**Step 1.** Add the JitPack repository to your build file
18+
19+
```groovy
20+
allprojects {
21+
repositories {
22+
...
23+
maven { url 'https://jitpack.io' }
24+
}
25+
}
26+
```
27+
28+
**Step 2.** Add the dependency
29+
30+
```groovy
31+
implementation 'com.github.wustor:GangedRecyclerview:latest-version'
32+
```
33+
34+
**Step 3.** 启动GangedRvActivity
1335

14-
![列表联动效果图](https://i.loli.net/2018/12/16/5c1601ff0a10c.gif)
36+
```kotlin
37+
val intent = Intent(this, GangedRvActivity::class.java)
38+
//获取SortBean数据,具体可参见Demo
39+
val data = DataUtil.getData(this, path)
40+
val bundle = Bundle()
41+
bundle.putSerializable(IIntent.DATA_TAG, data)
42+
intent.putExtras(bundle)
43+
startActivity(intent)
44+
```

app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
implementation 'com.google.code.gson:gson:2.8.2'
2727
implementation 'com.google.android.material:material:1.1.0'
2828
implementation project(path: ':library')
29-
// implementation 'com.github.wustor:GangedRecyclerview:-0.0.1-g791b048-1'
29+
// implementation 'com.github.wustor:GangedRecyclerview:0.0.2.1'
3030
implementation 'androidx.appcompat:appcompat:1.1.0'
3131
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3232
testImplementation 'junit:junit:4.12'

library/src/main/assets/sort.json app/src/main/assets/sort.json

-3
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@
131131
"imgsrc": "https://121.10.217.171:9002/_ui/desktop/common/cmyy/image/app_18_18144.png",
132132
"cacode": "18144"
133133
}
134-
135-
136134
],
137135
"name": "中成药",
138136
"imgsrc": "https://121.10.217.171:9002/_ui/desktop/common/cmyy/image/app_2.png",
@@ -235,7 +233,6 @@
235233
"imgsrc": "https://121.10.217.171:9002/_ui/desktop/common/cmyy/image/app_19_19150.png",
236234
"cacode": "19150"
237235
}
238-
239236
],
240237
"name": "西药",
241238
"imgsrc": "https://121.10.217.171:9002/_ui/desktop/common/cmyy/image/app_3.png",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.feiyu.ganged
2+
3+
import android.content.Context
4+
import android.util.Log
5+
import com.feiyu.rv.SortBean
6+
import com.google.gson.Gson
7+
import java.io.IOException
8+
9+
/**
10+
* Created by wustor
11+
* 日期 2/4/22.
12+
*/
13+
object DataUtil {
14+
private const val TAG = "DataUtil"
15+
16+
fun getData(context: Context, path: String): SortBean {
17+
val assetsData = getAssetsData(context, path)
18+
val gson = Gson()
19+
return gson.fromJson(assetsData, SortBean::class.java)
20+
}
21+
22+
//从资源文件中获取分类json
23+
private fun getAssetsData(context: Context, path: String): String {
24+
var result = ""
25+
return try {
26+
//获取输入流
27+
val mAssets = context.assets.open(path)
28+
//获取文件的字节数
29+
val lenght = mAssets.available()
30+
//创建byte数组
31+
val buffer = ByteArray(lenght)
32+
//将文件中的数据写入到字节数组中
33+
mAssets.read(buffer)
34+
mAssets.close()
35+
result = String(buffer)
36+
result
37+
} catch (e: IOException) {
38+
e.printStackTrace()
39+
Log.e(TAG, e.message!!)
40+
result
41+
}
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
package com.feiyu.ganged
22

33
import android.content.Intent
4-
import androidx.appcompat.app.AppCompatActivity
54
import android.os.Bundle
65
import android.widget.Button
6+
import androidx.appcompat.app.AppCompatActivity
77
import com.feiyu.rv.GangedRvActivity
8+
import com.feiyu.rv.IIntent
89

910
class MainActivity : AppCompatActivity() {
11+
private var path = "sort.json"
12+
private lateinit var btnJump: Button
13+
1014
override fun onCreate(savedInstanceState: Bundle?) {
1115
super.onCreate(savedInstanceState)
1216
setContentView(R.layout.activity_main)
13-
findViewById<Button>(R.id.tv_jump).setOnClickListener {
14-
startActivity(Intent(this,GangedRvActivity::class.java))
17+
initView()
18+
btnJump.setOnClickListener {
19+
val intent = Intent(this, GangedRvActivity::class.java)
20+
val data = DataUtil.getData(this, path)
21+
val bundle = Bundle()
22+
bundle.putSerializable(IIntent.DATA_TAG, data)
23+
intent.putExtras(bundle)
24+
startActivity(intent)
1525
}
1626
}
27+
28+
private fun initView() {
29+
btnJump = findViewById(R.id.tv_jump);
30+
}
1731
}

app/src/main/res/layout/activity_main.xml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<Button
99
android:id="@+id/tv_jump"
1010
android:text="联动RecyclerView"
11+
android:textAllCaps="false"
1112
app:layout_constraintBottom_toBottomOf="parent"
1213
app:layout_constraintTop_toTopOf="parent"
1314
app:layout_constraintLeft_toLeftOf="parent"

docs/device-2022-02-04-190625.mp4

6.69 MB
Binary file not shown.

library/build.gradle

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ plugins {
33
id 'com.github.dcendents.android-maven'
44
}
55

6-
group = 'com.github.wustor'
7-
version = '0.0.1'
8-
9-
106
android {
117
compileSdkVersion 30
128

library/src/main/java/com/feiyu/rv/BaseFragment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import androidx.fragment.app.Fragment;
1212

1313
/**
14-
* author pangchao
14+
* author wustor
1515
* created on 2017/5/20
16-
* email fat_chao@163.com.
16+
* email wustor@126.com.
1717
*/
1818

1919
public abstract class BaseFragment<T extends BasePresenter, V> extends Fragment implements View.OnClickListener, ViewCallBack<V> {

library/src/main/java/com/feiyu/rv/CheckListener.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.feiyu.rv;
22

33
/**
4-
* author pangchao
4+
* author wustor
55
* created on 2017/5/15
6-
* email fat_chao@163.com.
6+
* email wustor@126.com.
77
*/
88

99
public interface CheckListener {

library/src/main/java/com/feiyu/rv/ClassifyPresenter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.feiyu.rv;
22

33
/**
4-
* author pangchao
4+
* author wustor
55
* created on 2017/5/10
6-
* email fat_chao@163.com.
6+
* email wustor@126.com.
77
*/
88

99
public class ClassifyPresenter extends BasePresenter {

library/src/main/java/com/feiyu/rv/FlexibleLayout.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313

1414
/**
15-
* author pangchao
15+
* author wustor
1616
* created on 2017/5/20
17-
* email fat_chao@163.com.
17+
* email wustor@126.com.
1818
*/
1919

2020
public abstract class FlexibleLayout extends LinearLayout {

0 commit comments

Comments
 (0)