33import android .app .Activity ;
44import android .graphics .Rect ;
55import android .support .annotation .DrawableRes ;
6- import android .support .v7 .widget .RecyclerView ;
76import android .view .MotionEvent ;
87import android .view .View ;
98import android .view .ViewGroup ;
@@ -33,10 +32,7 @@ public void showOn(View view) {
3332 if (view == null ) return ;
3433 Rect rect = new Rect ();
3534 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 ());
4036 }
4137
4238 public int getId () {
@@ -49,19 +45,22 @@ public static class Builder{
4945 private ArrayList <ArcButton .Builder > btnList = new ArrayList <>();
5046 private OnClickMenuListener onClickMenuListener ;
5147 private Activity activity ;
52- private ArcMenuInterceptLayout arcMenuLayout ;
48+ private ArcMenuInterceptLayout arcMenuInterceptLayout ;
5349 private HashSet <View > onTouchViews = new HashSet <>();
5450 private boolean hideOnTouchUp = true ;
51+ private int radius ;
52+ private double degree = 90 ;
5553
5654
5755 public Builder (Activity activity ) {
5856 this .activity = activity ;
57+ radius = activity .getResources ().getDimensionPixelSize (R .dimen .default_radius );
5958 }
6059
6160 public ArcMenu build () {
6261 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 );
6564 arcMenu = new ArcMenu (this );
6665 return arcMenu ;
6766 }
@@ -71,6 +70,16 @@ public Builder setId(int id){
7170 return this ;
7271 }
7372
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+
7483 public Builder setListener (OnClickMenuListener listener ) {
7584 this .onClickMenuListener = listener ;
7685 return this ;
@@ -103,11 +112,15 @@ public Builder hideOnTouchUp(boolean h) {
103112 return this ;
104113 }
105114
115+ private void show (int x , int y ) {
116+ arcMenuInterceptLayout .show (arcMenu , x , y ,
117+ btnList , hideOnTouchUp , radius , degree );
118+ }
106119
107120 private View .OnLongClickListener longClickListener = new View .OnLongClickListener () {
108121 @ Override
109122 public boolean onLongClick (View v ) {
110- arcMenuLayout . show (arcMenu , lastTouchX , lastTouchY , btnList , hideOnTouchUp );
123+ show (lastTouchX , lastTouchY );
111124 return true ;
112125 }
113126 };
@@ -118,10 +131,7 @@ public boolean onLongClick(View v) {
118131 public boolean onTouch (View v , MotionEvent event ) {
119132 if (event .getAction () == MotionEvent .ACTION_DOWN ){
120133 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 ());
125135 }else {
126136 //Used in onLongClick(View v)
127137 lastTouchX = (int ) event .getRawX ();
0 commit comments