change custom text menu btn to private(unfinished)

This commit is contained in:
Dacer
2016-11-17 23:25:15 +08:00
parent 7edc708db0
commit deefdd1346

View File

@@ -1,7 +1,9 @@
package com.hackplan.androidarcmenu;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.DrawableRes;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
@@ -26,19 +28,46 @@ public class ArcButton extends View{
public static class Builder {
@DrawableRes private int resId;
@DrawableRes private int resId = -1;
private int id;
private int backgroundColor = -1;
private String text;
private View customView;
public Builder(@DrawableRes int resId, int id) {
this.resId = resId;
this.id = id;
}
public View getButton(Context context) {
ImageView arcButton = new ImageView(context);
arcButton.setImageResource(resId);
arcButton.setTag(id);
return arcButton;
/**
* NOT COMPLETED
* @param text
* @param backgroundColor
* @param id
*/
private Builder(String text, int backgroundColor, int id) {
this.text = text;
this.backgroundColor = backgroundColor;
this.id = id;
}
public Builder(View customView, int id) {
this.customView = customView;
this.id = id;
}
View getButton(Context context) {
if (customView != null) {
customView.setTag(id);
return customView;
} else if (resId != -1) {
ImageView arcButton = new ImageView(context);
arcButton.setImageResource(resId);
arcButton.setTag(id);
return arcButton;
}
throw new RuntimeException("ArcButton does not init correctly");
}
}
}