-
Notifications
You must be signed in to change notification settings - Fork 102
/
CommonAttachToActivity.java
63 lines (55 loc) · 2.23 KB
/
CommonAttachToActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.gw.swipebacksample.activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import com.gw.swipeback.SwipeBackLayout;
import com.gw.swipebacksample.R;
import com.gw.swipebacksample.base.BaseToolBarActivity;
/**
* Created by GongWen on 17/8/24.
*/
public class CommonAttachToActivity extends BaseToolBarActivity implements CompoundButton.OnCheckedChangeListener {
private SwipeBackLayout mSwipeBackLayout;
private RadioButton fromLeftRb;
private RadioButton fromTopRb;
private RadioButton fromRightRb;
private RadioButton fromBottomRb;
@Override
protected int getLayoutId() {
return R.layout.activity_attach_to_common;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fromLeftRb = (RadioButton) findViewById(R.id.fromLeftRb);
fromLeftRb.setOnCheckedChangeListener(this);
fromTopRb = (RadioButton) findViewById(R.id.fromTopRb);
fromTopRb.setOnCheckedChangeListener(this);
fromRightRb = (RadioButton) findViewById(R.id.fromRightRb);
fromRightRb.setOnCheckedChangeListener(this);
fromBottomRb = (RadioButton) findViewById(R.id.fromBottomRb);
fromBottomRb.setOnCheckedChangeListener(this);
mSwipeBackLayout = new SwipeBackLayout(this);
mSwipeBackLayout.attachToActivity(this);
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
switch (buttonView.getId()) {
case R.id.fromLeftRb:
mSwipeBackLayout.setDirectionMode(SwipeBackLayout.FROM_LEFT);
break;
case R.id.fromTopRb:
mSwipeBackLayout.setDirectionMode(SwipeBackLayout.FROM_TOP);
break;
case R.id.fromRightRb:
mSwipeBackLayout.setDirectionMode(SwipeBackLayout.FROM_RIGHT);
break;
case R.id.fromBottomRb:
mSwipeBackLayout.setDirectionMode(SwipeBackLayout.FROM_BOTTOM);
break;
}
}
}
}