質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Q&A

0回答

149閲覧

Buliderパターンについて

kanekane

総合スコア6

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

0グッド

0クリップ

投稿2018/08/26 13:34

public static final class Builder { @Nullable private View target; @NotNull private List<View> tooltipChilds; private int markerPadding; private boolean tooltipMatchWidth; private float backgroundAlpha; private int backgroundColor; private boolean dismissible; private boolean isCircleMark; private int tooltipMargin; private int tooltipBackgroundColor; @Nullable private String tooltipBackgroundColorString; private int tooltipAlignment; private int pointerTooltipAlignment; private int radius; @Nullable private Function0 onDismissListener; @Nullable private Function0 onAfterDismissListener; @Nullable private Animation tooltipShowAnimation; @Nullable private Animation tooltipDismissAnimation; private Function1 onClickTarget; @NotNull private final Activity activity; @NotNull public final CoachMark.Builder setTarget(@NotNull View target) { this.target = target; return this; } @NotNull public final CoachMark.Builder setCircleMark() { this.isCircleMark = true; return this; } @NotNull public final CoachMark.Builder setMarkerPadding(int dp) { this.markerPadding = dp; return this; } @NotNull public final CoachMark.Builder setOnClickTarget(@NotNull Function1 onClickTarget) { this.onClickTarget = onClickTarget; return this; } @NotNull public final CoachMark.Builder setDismissible() { this.dismissible = true; return this; } @NotNull public final CoachMark.Builder setTooltipAlignment(long tooltipAlignment) { this.tooltipAlignment = tooltipAlignment; return this; } @NotNull public final CoachMark.Builder setTooltipPointer(long pointerTooltipAlignment) { this.pointerTooltipAlignment = pointerTooltipAlignment; return this; } @NotNull public final CoachMark.Builder setTooltipBackgroundColor(int colorResource) { this.tooltipBackgroundColor = colorResource; return this; } @NotNull public final CoachMark.Builder setTooltipBackgroundColor(@NotNull String colorString) { this.tooltipBackgroundColorString = colorString; return this; } @NotNull public final CoachMark.Builder setTooltipMatchWidth() { this.tooltipMatchWidth = true; return this; } @NotNull public final CoachMark.Builder setTooltipChilds(@NotNull List<View> tooltipChilds) { this.tooltipChilds = new ArrayList<>(tooltipChilds); return this; } @NotNull public final CoachMark.Builder setTooltipMargin(int dp) { this.tooltipMargin = dp; return this; } @NotNull public final CoachMark.Builder addTooltipChild(@NotNull View tooltipChild) { this.tooltipChilds.add(tooltipChild); return this; } @NotNull public final CoachMark.Builder setRadius(int value) { this.radius = value; return this; } private final TextView createTooltipChildText(Context context, String message) { int padding = ViewUtils.dpToPx(activity, 8); TextView textView = new TextView(context); textView.setLayoutParams(new ViewGroup.LayoutParams(-2, -2)); textView.setText((CharSequence)message); textView.setPadding(padding, padding, padding, padding); return textView; } @NotNull public final CoachMark.Builder addTooltipChildText(@NotNull Context context, @NotNull String message, @ColorRes int textColor) { TextView textView = this.createTooltipChildText(context, message); textView.setTextColor(ContextCompat.getColor(context, textColor)); return this.addTooltipChild((View)textView); } @NotNull public final CoachMark.Builder addTooltipChildText(@NotNull Context context, @NotNull String message, @NotNull String textColorString) { TextView textView = this.createTooltipChildText(context, message); try { textView.setTextColor(Color.parseColor(textColorString)); } catch (IllegalArgumentException var6) { textView.setTextColor(ContextCompat.getColor(context, android.R.color.black)); } return this.addTooltipChild((View)textView); } @NotNull public final CoachMark.Builder setOnDismissListener(@NotNull Function0 onDismiss) { this.onDismissListener = onDismiss; return this; } @NotNull public final CoachMark.Builder setOnAfterDismissListener(@NotNull Function0 onAfterDismiss) { this.onAfterDismissListener = onAfterDismiss; return this; } @NotNull public final CoachMark.Builder setTooltipShowAnimation(@NotNull Animation tooltipShowAnimation) { this.tooltipShowAnimation = tooltipShowAnimation; return this; } @NotNull public final CoachMark.Builder setTooltipDismissAnimation(@NotNull Animation tooltipDismissAnimation) { this.tooltipDismissAnimation = tooltipDismissAnimation; return this; } @NotNull public final CoachMark.Builder setBackgroundAlpha(float backgroundAlpha) { this.backgroundAlpha = backgroundAlpha; return this; } @NotNull public final CoachMark.Builder setBackgroundColor(@ColorRes int backgroundColor) { this.backgroundColor = backgroundColor; return this; } @NotNull public final CoachMark build() { final CoachMark coachMark = new CoachMark(this); coachMark.setTargetOnClick((View.OnClickListener)(new View.OnClickListener() { public final void onClick(View it) { if (Builder.this.onClickTarget != null) { Function1 var10000 = Builder.this.onClickTarget; if (var10000 != null) { Unit var2 = (Unit)var10000.invoke(coachMark); } } else { CoachMark.dismiss$default(coachMark, (Function0)null, 1, (Object)null); } } })); return coachMark; } @NotNull public final CoachMark show() { return this.build().show(); } @NotNull public final Activity getActivity() { return this.activity; } public Builder(@NotNull Activity activity) { super(); this.activity = activity; this.tooltipChilds = new ArrayList(); this.backgroundAlpha = 0.5F; this.backgroundColor = 17170444; this.tooltipMargin = 5; this.tooltipAlignment = 2L; this.pointerTooltipAlignment = 2L; this.radius = 5; } // $FF: synthetic method public static final void access$setOnClickTarget$p(CoachMark.Builder $this, @Nullable Function1 var1) { $this.onClickTarget = var1; } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2018/08/26 20:35

コードだけ投げられても誰も答えられませんよ。道を聞きたいときにその辺の人を呼び止めただけで道案内してくれると思いますか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問