Skip to content

Commit 8df1d79

Browse files
committed
2 parents e0deb6b + 76b4615 commit 8df1d79

34 files changed

Lines changed: 1333 additions & 752 deletions

README-StackLayout.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# StackLayout
2+
3+
**层叠View支持手势左右滑动,自动轮播,过渡动画**
4+
5+
1.onMeasure通过StackAdapter适配器取到itemView加入到StackLayaout容器
6+
7+
onMeasure() through stackAdapter add view to StackLayout
8+
9+
2.onLayout取到childView按照层叠布局
10+
11+
onLayout() get child view layout stack ui
12+
13+
3.onInterceptTouchEvent处理手势支持子View及Velocity
14+
15+
onInterceptTouchEvent() support child view gesture
16+
17+
4.onTouchEvent处理手势,释放后播放动画平滑过渡
18+
19+
onTouchEvent() swipe animation,when release recover animation
20+
21+
### Use
22+
implementation 'com.uis:stacklayout:0.5.0'
23+
24+
*Name*| *Descript*|*Value*
25+
-----|--------|---
26+
stackSpace|间距(space)|默认值(default):10dp
27+
stackEdge|边界距离(edge)|默认值(default):10dp
28+
stackZoomX|x方向缩放(x zoom)| 0<x<=1,1表示等间距,默认值(default):1
29+
stackPadX|x方向偏移(x padding)|表示偏移间距,默认值:0
30+
stackPadX|PadX*(Size-1) < Space|PadX优先级高于ZoomX
31+
stackZoomY|y方向缩放(y zoom)| 0<y<=1,1表示和顶层等高度,默认值:0.9
32+
stackLooper|自动轮播(looper)|false/true
33+
stackSize|层叠数量(stack size)|3
34+
stackEdgeModel|层叠位置(stack model)|left/right
35+
36+
```
37+
<?xml version="1.0" encoding="utf-8"?>
38+
<com.uis.stackview.StackLayout xmlns:android="http://schemas.android.com/apk/res/android"
39+
xmlns:stack="http://schemas.android.com/apk/res-auto"
40+
android:id="@+id/stacklayout"
41+
android:layout_width="match_parent"
42+
android:layout_height="wrap_content"
43+
stack:stackSpace="5dp"
44+
stack:stackEdge="20dp"
45+
stack:stackZoomX="0.1"
46+
stack:stackZoomY="0.1"
47+
stack:stackLooper = "false"
48+
stack:stackSize = "5"
49+
stack:stackEdgeModel = "left">
50+
</com.uis.stackview.StackLayout>
51+
```
52+
53+
```
54+
stackViewLayout.setStackLooper(true);
55+
stackViewLayout.setAdapter(new StackLayout.StackAdapter() {
56+
@Override
57+
public View onCreateView(ViewGroup parent) {
58+
return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fresco_layout,null);
59+
}
60+
61+
@Override
62+
public void onBindView(View view, int position) {
63+
SimpleDraweeView dv = view.findViewById(R.id.imageView);
64+
DraweeController controller = Fresco.newDraweeControllerBuilder()
65+
.setUri(Uri.parse(dataList.get(position).getMapImageUrl()))
66+
.setTapToRetryEnabled(true)
67+
.setOldController(dv.getController())
68+
.build();
69+
dv.setController(controller);
70+
}
71+
72+
@Override
73+
public int getItemCount() {
74+
return dataList.size();
75+
}
76+
77+
@Override
78+
public void onItemDisplay(int position) {
79+
Log.e("xx","display = " + position);
80+
}
81+
82+
@Override
83+
public void onItemClicked(int position) {
84+
Log.e("xx","clicked = " + position);
85+
stackViewLayout.setStackLooper(false);
86+
stackViewLayout.setPosition(position+3);
87+
}
88+
});
89+
stackViewLayout.setPosition(10);//指定位置
90+
```
91+
92+
### License
93+
94+
Copyright 2018, uis
95+
96+
Licensed under the Apache License, Version 2.0 (the "License");
97+
you may not use this file except in compliance with the License.
98+
You may obtain a copy of the License at
99+
100+
http://www.apache.org/licenses/LICENSE-2.0
101+
102+
Unless required by applicable law or agreed to in writing, software
103+
distributed under the License is distributed on an "AS IS" BASIS,
104+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
105+
See the License for the specific language governing permissions and
106+
limitations under the License.

README.md

Lines changed: 15 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,27 @@
11
# StackViewLayout
2-
**A swipe ViewGroup that supports left and right slide.**
2+
1.支持布局预览、宽高比设置、viewType布局
3+
2.支持自动播放、左右布局
4+
3.支持缩放滑动、连续滑动
35

4-
**层叠View支持手势左右滑动,自动轮播,过渡动画**
5-
6-
1.onMeasure通过StackAdapter适配器取到itemView加入到StackLayaout容器
7-
8-
onMeasure() through stackAdapter add view to StackLayout
9-
10-
2.onLayout取到childView按照层叠布局
11-
12-
onLayout() get child view layout stack ui
13-
14-
3.onInterceptTouchEvent处理手势支持子View及Velocity
15-
16-
onInterceptTouchEvent() support child view gesture
17-
18-
4.onTouchEvent处理手势,释放后播放动画平滑过渡
19-
20-
onTouchEvent() swipe animation,when release recover animation
21-
22-
### Captures
23-
24-
![效果图](/pic/pic001.jpeg)
25-
![效果图](/pic/demo20.gif)
26-
27-
![尺寸说明](/pic/biaozhu.png)
28-
29-
<li>注释:此图解释参数意义,展示效果不太精确,图片真实宽度为**上层橙色**
6+
#### Captures
7+
![效果图](/images/image_normal.png) ![效果图](/images/image_left.png) ![效果图](/images/image_right.png)
308

319
### Use
32-
implementation 'com.uis:stacklayout:0.3.4'
10+
implementation 'com.uis:stackviewlayout:0.1.0'
11+
12+
### [老版本](README-StackLayout.md)
3313

3414
*Name*| *Descript*|*Value*
3515
-----|--------|---
36-
stackSpace|间距(space)|默认值(default):10dp
16+
stackEdgeModel|层叠位置(stack model)|left/right
3717
stackEdge|边界距离(edge)|默认值(default):10dp
38-
stackZoomX|x方向缩放(x zoom)| 0<x<=1,1表示等间距,默认值(default):1
39-
stackPadX|x方向偏移(x padding)|表示偏移间距,默认值:0
40-
stackPadX|PadX*(Size-1) < Space|PadX优先级高于ZoomX
41-
stackZoomY|y方向缩放(y zoom)| 0<y<=1,1表示和顶层等高度,默认值:0.9
42-
stackLooper|自动轮播(looper)|false/true
18+
stackPaddingX|x方向偏移距离|10dp
19+
stackOffsetX|x方向偏移因子|2dp
20+
stackPaddingY|y方向偏移距离|10dp
21+
stackOffsetY|y方向偏移因子|2dp
22+
stackAutoPlay|自动轮播(looper)|true
4323
stackSize|层叠数量(stack size)|3
44-
stackEdgeModel|层叠位置(stack model)|left/right
45-
46-
```
47-
<?xml version="1.0" encoding="utf-8"?>
48-
<com.uis.stackview.StackLayout xmlns:android="http://schemas.android.com/apk/res/android"
49-
xmlns:stack="http://schemas.android.com/apk/res-auto"
50-
android:id="@+id/stacklayout"
51-
android:layout_width="match_parent"
52-
android:layout_height="wrap_content"
53-
stack:stackSpace="5dp"
54-
stack:stackEdge="20dp"
55-
stack:stackZoomX="0.1"
56-
stack:stackZoomY="0.1"
57-
stack:stackLooper = "false"
58-
stack:stackSize = "5"
59-
stack:stackEdgeModel = "left">
60-
</com.uis.stackview.StackLayout>
61-
```
62-
63-
```
64-
stackViewLayout.setStackLooper(true);
65-
stackViewLayout.setAdapter(new StackLayout.StackAdapter() {
66-
@Override
67-
public View onCreateView(ViewGroup parent) {
68-
return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fresco_layout,null);
69-
}
70-
71-
@Override
72-
public void onBindView(View view, int position) {
73-
SimpleDraweeView dv = view.findViewById(R.id.imageView);
74-
DraweeController controller = Fresco.newDraweeControllerBuilder()
75-
.setUri(Uri.parse(dataList.get(position).getMapImageUrl()))
76-
.setTapToRetryEnabled(true)
77-
.setOldController(dv.getController())
78-
.build();
79-
dv.setController(controller);
80-
}
81-
82-
@Override
83-
public int getItemCount() {
84-
return dataList.size();
85-
}
86-
87-
@Override
88-
public void onItemDisplay(int position) {
89-
Log.e("xx","display = " + position);
90-
}
91-
92-
@Override
93-
public void onItemClicked(int position) {
94-
Log.e("xx","clicked = " + position);
95-
stackViewLayout.setStackLooper(false);
96-
stackViewLayout.setPosition(position+3);
97-
}
98-
});
99-
stackViewLayout.setPosition(10);//指定位置
100-
```
101-
102-
### Version
103-
*Version*| *Descript*|*Fixed*
104-
----|----|----
105-
0.0.1|自动轮播,滑动从顶部移除,整体上浮|support auto looper and animation
106-
0.0.2|滑动从顶层加入,整体下沉|fixed child view clicked event
107-
0.1.0|zoomX,zoomY呈等比数列|modify attribute
108-
0.1.1|只有一条数据时|fixed adapter itemSize=1
109-
0.1.2|增加动画、轮播时间设置,获取当前选中位置|add animation,looper time
110-
0.2.0|只有一个元素,不支持轮播和滑动|only one child,can't swipe
111-
0.2.1|减少child层级,见child.measure()|child.measure() opt
112-
0.3.0|增加联动效果(缩放+平移)|support whole animation
113-
0.3.1|联动动画平滑过度|fixed animation smooth
114-
0.3.2|联动动画去抖动及adapter数据更新会多出层|opt animation shake
115-
0.3.3|adapter数据更新ui展示错误|opt adapter changed display
116-
0.3.4|滑动促发item点击事件|fixed item clicked event
24+
stackAspectRatio|宽高比,宽度须有值|0
11725

11826
### License
11927

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.4.2'
12+
classpath 'com.android.tools.build:gradle:4.0.0'
1313
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
1414
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1515
}
@@ -29,7 +29,7 @@ task clean(type: Delete) {
2929

3030
ext{
3131
androidx = '1.0.0'
32-
compileVer = 28
32+
compileVer = 29
3333
minVer = 15
34-
buildVer = '28.0.3'
34+
buildVer = '29.0.3'
3535
}

demo/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
implementation 'com.makeramen:roundedimageview:2.3.0'
3030
implementation 'com.google.code.gson:gson:2.8.5'
3131
implementation "androidx.viewpager:viewpager:${androidx}"
32-
implementation 'com.facebook.fresco:fresco:2.0.0'
33-
implementation 'com.huxq17.xrefreshview:xrefreshview:3.6.9'
32+
implementation 'com.facebook.fresco:fresco:2.2.0'
33+
implementation project(':stackviewlayout')
3434
implementation project(':stacklayout')
3535
}

demo/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:theme="@style/AppTheme"
1818
android:networkSecurityConfig="@xml/network_security_config"
1919
>
20-
<activity android:name=".activity.MainActivity"
20+
<activity android:name="com.uis.stackviewlayout.demo.activity.MainActivity"
2121
android:screenOrientation="portrait"
2222
>
2323
<intent-filter>

demo/src/main/java/com/uis/stackview/demo/activity/MainActivity.java renamed to demo/src/main/java/com/uis/stackviewlayout/demo/activity/MainActivity.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
package com.uis.stackview.demo.activity;
1+
package com.uis.stackviewlayout.demo.activity;
22

33
import android.graphics.Color;
44
import android.os.Build;
55
import android.os.Bundle;
66
import android.view.View;
77
import android.view.ViewGroup;
88
import android.view.WindowManager;
9-
10-
import com.andview.refreshview.XRefreshView;
11-
import com.andview.refreshview.utils.LogUtils;
12-
import com.facebook.common.logging.FLog;
139
import com.facebook.drawee.backends.pipeline.Fresco;
1410
import com.facebook.imagepipeline.core.ImagePipelineConfig;
1511
import com.uis.stackview.demo.R;
16-
import com.uis.stackview.demo.entity.ItemEntity;
12+
import com.uis.stackviewlayout.demo.entity.ItemEntity;
1713
import java.util.List;
1814
import androidx.appcompat.app.AppCompatActivity;
1915
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -42,8 +38,6 @@ protected void onCreate(Bundle savedInstanceState) {
4238
ViewGroup.LayoutParams params = findViewById(R.id.view).getLayoutParams();
4339
params.height = getResources().getDimensionPixelSize(R.dimen.status_height);
4440
}
45-
FLog.setMinimumLoggingLevel(FLog.VERBOSE);
46-
LogUtils.enableLog(false);
4741
if(!Fresco.hasBeenInitialized()) {
4842
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(getApplicationContext())
4943
.setDiskCacheEnabled(true)
@@ -55,19 +49,6 @@ protected void onCreate(Bundle savedInstanceState) {
5549
final List<ItemEntity> dataList = StackAdapter.initDataList(this);
5650
final StackAdapter stackAdapter = new StackAdapter();
5751
final RecyclerView recyclerView = findViewById(R.id.recyclerView);
58-
final XRefreshView freshView = findViewById(R.id.refreshView);
59-
60-
freshView.setAutoLoadMore(false);
61-
freshView.setSilenceLoadMore(false);
62-
freshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener(){
63-
@Override
64-
public void onRefresh(boolean isPullDown) {
65-
freshView.stopRefresh();
66-
stackAdapter.dataList = dataList.subList(0,6);
67-
stackAdapter.notifyDataSetChanged();
68-
}
69-
});
70-
7152

7253
ViewPager viewPager = findViewById(R.id.viewPager);
7354
ViewPagerAdapter adapter = new ViewPagerAdapter(dataList);

0 commit comments

Comments
 (0)