3
3
import android .app .Activity ;
4
4
import android .graphics .Rect ;
5
5
import android .support .annotation .DrawableRes ;
6
- import android .support .v7 .widget .RecyclerView ;
7
6
import android .view .MotionEvent ;
8
7
import android .view .View ;
9
8
import android .view .ViewGroup ;
@@ -33,10 +32,7 @@ public void showOn(View view) {
33
32
if (view == null ) return ;
34
33
Rect rect = new Rect ();
35
34
view .getGlobalVisibleRect (rect );
36
- builder .arcMenuLayout .show (this , rect .centerX (),
37
- rect .centerY (),
38
- builder .btnList ,
39
- builder .hideOnTouchUp );
35
+ builder .show (rect .centerX (), rect .centerY ());
40
36
}
41
37
42
38
public int getId () {
@@ -49,19 +45,22 @@ public static class Builder{
49
45
private ArrayList <ArcButton .Builder > btnList = new ArrayList <>();
50
46
private OnClickMenuListener onClickMenuListener ;
51
47
private Activity activity ;
52
- private ArcMenuInterceptLayout arcMenuLayout ;
48
+ private ArcMenuInterceptLayout arcMenuInterceptLayout ;
53
49
private HashSet <View > onTouchViews = new HashSet <>();
54
50
private boolean hideOnTouchUp = true ;
51
+ private int radius ;
52
+ private double degree = 90 ;
55
53
56
54
57
55
public Builder (Activity activity ) {
58
56
this .activity = activity ;
57
+ radius = activity .getResources ().getDimensionPixelSize (R .dimen .default_radius );
59
58
}
60
59
61
60
public ArcMenu build () {
62
61
if (arcMenu != null ) throw new RuntimeException ("ArcMenu.Build already built" );
63
- arcMenuLayout = attachToActivity (activity );
64
- arcMenuLayout .setOnClickBtnListener (onClickMenuListener );
62
+ arcMenuInterceptLayout = attachToActivity (activity );
63
+ arcMenuInterceptLayout .setOnClickBtnListener (onClickMenuListener );
65
64
arcMenu = new ArcMenu (this );
66
65
return arcMenu ;
67
66
}
@@ -71,6 +70,16 @@ public Builder setId(int id){
71
70
return this ;
72
71
}
73
72
73
+ public Builder setRadius (int radius ) {
74
+ this .radius = radius ;
75
+ return this ;
76
+ }
77
+
78
+ public Builder setDegree (double degree ) {
79
+ this .degree = degree ;
80
+ return this ;
81
+ }
82
+
74
83
public Builder setListener (OnClickMenuListener listener ) {
75
84
this .onClickMenuListener = listener ;
76
85
return this ;
@@ -103,11 +112,15 @@ public Builder hideOnTouchUp(boolean h) {
103
112
return this ;
104
113
}
105
114
115
+ private void show (int x , int y ) {
116
+ arcMenuInterceptLayout .show (arcMenu , x , y ,
117
+ btnList , hideOnTouchUp , radius , degree );
118
+ }
106
119
107
120
private View .OnLongClickListener longClickListener = new View .OnLongClickListener () {
108
121
@ Override
109
122
public boolean onLongClick (View v ) {
110
- arcMenuLayout . show (arcMenu , lastTouchX , lastTouchY , btnList , hideOnTouchUp );
123
+ show (lastTouchX , lastTouchY );
111
124
return true ;
112
125
}
113
126
};
@@ -118,10 +131,7 @@ public boolean onLongClick(View v) {
118
131
public boolean onTouch (View v , MotionEvent event ) {
119
132
if (event .getAction () == MotionEvent .ACTION_DOWN ){
120
133
if (onTouchViews .contains (v )) {
121
- arcMenuLayout .show (arcMenu ,
122
- (int ) event .getRawX (),
123
- (int ) event .getRawY (),
124
- btnList , hideOnTouchUp );
134
+ show ((int ) event .getRawX (), (int ) event .getRawY ());
125
135
}else {
126
136
//Used in onLongClick(View v)
127
137
lastTouchX = (int ) event .getRawX ();
0 commit comments