-
Notifications
You must be signed in to change notification settings - Fork 2
/
ReleaseDialogBuilder.java
45 lines (38 loc) · 1.45 KB
/
ReleaseDialogBuilder.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
package itmammoth.releaseanimal;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
public class ReleaseDialogBuilder extends AlertDialog.Builder {
private ReleaseNotes releaseNotes;
public ReleaseDialogBuilder(@NonNull Context context) {
super(context);
setDefaultAttributes();
}
private void setDefaultAttributes() {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") final View layout = inflater.inflate(R.layout.release_dialog, null)
.findViewById(R.id.release_dialog_container);
setView(layout);
setTitle("アップデート情報");
setCancelable(false);
setPositiveButton("閉じる", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
releaseNotes.markShown();
}
});
}
@Override
public AlertDialog show() {
releaseNotes = new ReleaseNotes(getContext());
if (releaseNotes.hasUnshownMessages()) {
setMessage(releaseNotes.getUnshownMessages());
return super.show();
}
return null;
}
}