Skip to content

Commit b92e825

Browse files
committed
update sample.
1 parent 67048a5 commit b92e825

File tree

6 files changed

+38
-59
lines changed

6 files changed

+38
-59
lines changed

app/src/main/java/com/liuguangqiang/swiplebacksample/ListViewActivity.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.liuguangqiang.swiplebacksample;
22

33
import android.graphics.Color;
4-
import android.support.v7.app.ActionBarActivity;
54
import android.os.Bundle;
65
import android.support.v7.widget.Toolbar;
76
import android.view.View;
@@ -23,8 +22,6 @@ public class ListViewActivity extends SwipeBackActivity {
2322

2423
private List<HashMap<String, String>> data;
2524

26-
private SwipeBackLayout swipeBackLayout;
27-
2825
@Override
2926
protected void onCreate(Bundle savedInstanceState) {
3027
super.onCreate(savedInstanceState);
@@ -37,21 +34,20 @@ protected void onCreate(Bundle savedInstanceState) {
3734

3835
initData();
3936
initView();
37+
setDragEdge(SwipeBackLayout.DragEdge.TOP);
4038
}
4139

4240
private void initData() {
4341
data = new ArrayList<>();
42+
HashMap<String, String> map;
4443
for (int i = 0; i < 30; i++) {
45-
HashMap<String, String> map = new HashMap<String, String>();
44+
map = new HashMap<>();
4645
map.put("title", "Test" + i);
4746
data.add(map);
4847
}
4948
}
5049

5150
private void initView() {
52-
swipeBackLayout = (SwipeBackLayout) findViewById(R.id.swipeBackLayout);
53-
swipeBackLayout.setDragEdge(SwipeBackLayout.DragEdge.TOP);
54-
5551
SimpleAdapter adapter = new SimpleAdapter(getApplicationContext(),
5652
data, R.layout.item_test, new String[]{"title"},
5753
new int[]{R.id.tv_test});

app/src/main/java/com/liuguangqiang/swiplebacksample/ViewPagerActivity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protected void onCreate(Bundle savedInstanceState) {
2020
super.onCreate(savedInstanceState);
2121
setContentView(R.layout.activity_viewpager);
2222
initViews();
23+
setDragEdge(SwipeBackLayout.DragEdge.LEFT);
2324
}
2425

2526
private void initViews() {
@@ -28,9 +29,6 @@ private void initViews() {
2829
toolbar.setTitleTextColor(Color.WHITE);
2930
setSupportActionBar(toolbar);
3031

31-
SwipeBackLayout swipeBackLayout = (SwipeBackLayout) findViewById(R.id.swipeBackLayout);
32-
swipeBackLayout.setDragEdge(SwipeBackLayout.DragEdge.LEFT);
33-
3432
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_demo);
3533
TestAdapter adapter = new TestAdapter(getSupportFragmentManager());
3634
viewPager.setAdapter(adapter);
Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
1-
<com.liuguangqiang.swipeback.SwipeBackLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
android:id="@+id/swipeBackLayout"
3-
android:layout_width="match_parent"
4-
android:layout_height="match_parent">
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:layout_width="fill_parent"
3+
android:layout_height="fill_parent"
4+
android:background="@android:color/white"
5+
android:orientation="vertical">
56

6-
<LinearLayout
7-
android:layout_width="fill_parent"
8-
android:layout_height="fill_parent"
9-
android:background="@android:color/white"
10-
android:orientation="vertical">
7+
<android.support.v7.widget.Toolbar
8+
android:id="@+id/toolbar"
9+
android:layout_width="match_parent"
10+
android:layout_height="?attr/actionBarSize"
11+
android:background="?attr/colorPrimary"
12+
android:minHeight="?attr/actionBarSize" />
1113

12-
<android.support.v7.widget.Toolbar
13-
android:id="@+id/toolbar"
14-
android:layout_width="match_parent"
15-
android:layout_height="?attr/actionBarSize"
16-
android:background="?attr/colorPrimary"
17-
android:minHeight="?attr/actionBarSize" />
14+
<ListView
15+
android:id="@+id/listview"
16+
android:layout_width="match_parent"
17+
android:layout_height="match_parent" />
1818

19-
<ListView
20-
android:id="@+id/listview"
21-
android:layout_width="match_parent"
22-
android:layout_height="match_parent" />
23-
24-
</LinearLayout>
25-
26-
27-
</com.liuguangqiang.swipeback.SwipeBackLayout>
19+
</LinearLayout>
Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
<com.liuguangqiang.swipeback.SwipeBackLayout xmlns:android="http://schemas.android.com/apk/res/android"
2-
android:id="@+id/swipeBackLayout"
3-
android:layout_width="match_parent"
4-
android:layout_height="match_parent">
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:layout_width="fill_parent"
3+
android:layout_height="fill_parent"
4+
android:background="@android:color/white"
5+
android:orientation="vertical">
56

6-
<LinearLayout
7-
android:layout_width="fill_parent"
8-
android:layout_height="fill_parent"
9-
android:background="@android:color/white"
10-
android:orientation="vertical">
7+
<android.support.v7.widget.Toolbar
8+
android:id="@+id/toolbar"
9+
android:layout_width="match_parent"
10+
android:layout_height="?attr/actionBarSize"
11+
android:background="?attr/colorPrimary"
12+
android:minHeight="?attr/actionBarSize" />
1113

12-
<android.support.v7.widget.Toolbar
13-
android:id="@+id/toolbar"
14-
android:layout_width="match_parent"
15-
android:layout_height="?attr/actionBarSize"
16-
android:background="?attr/colorPrimary"
17-
android:minHeight="?attr/actionBarSize" />
14+
<android.support.v4.view.ViewPager
15+
android:id="@+id/viewpager_demo"
16+
android:layout_width="match_parent"
17+
android:layout_height="match_parent" />
1818

19-
<android.support.v4.view.ViewPager
20-
android:id="@+id/viewpager_demo"
21-
android:layout_width="match_parent"
22-
android:layout_height="match_parent" />
23-
24-
</LinearLayout>
25-
26-
</com.liuguangqiang.swipeback.SwipeBackLayout>
19+
</LinearLayout>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
22
android:layout_width="match_parent"
33
android:layout_height="match_parent"
4-
android:background="@android:color/darker_gray">
4+
android:background="@android:color/white">
55

66
<TextView
77
android:id="@+id/tv_test"

library/src/main/java/com/liuguangqiang/swipeback/SwipeBackLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ public interface SwipeBackListener {
461461
* @param fractionAnchor relative to the anchor.
462462
* @param fractionScreen relative to the screen.
463463
*/
464-
public void onViewPositionChanged(float fractionAnchor, float fractionScreen);
464+
void onViewPositionChanged(float fractionAnchor, float fractionScreen);
465465

466466
}
467467

0 commit comments

Comments
 (0)