mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-05-30 12:04:42 +00:00
fix DialogButtonWithTimer
This commit is contained in:
parent
31a5b423eb
commit
ca3f5761ae
2 changed files with 6 additions and 33 deletions
|
|
@ -22,13 +22,15 @@ public class DialogButtonWithTimer {
|
|||
info.text = text;
|
||||
info.timeout = timeout;
|
||||
|
||||
dialog.setButton(buttonType,text + "(" + timeout + ")", (dlg, which) -> {
|
||||
dialog.setButton(buttonType, text, (dlg, which) -> {
|
||||
if (info.timeout == 0) {
|
||||
listener.onClick(dlg, which);
|
||||
}
|
||||
});
|
||||
dialog.setOnShowListener(dlg -> {
|
||||
TextView button = (TextView)dialog.getButton(buttonType);
|
||||
info.text = button.getText().toString();
|
||||
button.setText(info.text + " (" + timeout + ")");
|
||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextGray3));
|
||||
button.setEnabled(false);
|
||||
TimeoutRunnable timeoutRunnable = new TimeoutRunnable(button, info);
|
||||
|
|
@ -51,10 +53,10 @@ public class DialogButtonWithTimer {
|
|||
info.timeout--;
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (info.timeout > 0) {
|
||||
cancelButton.setText((info.text + " (" + info.timeout + ")").toUpperCase(Locale.ROOT));
|
||||
cancelButton.setText(info.text + " (" + info.timeout + ")");
|
||||
} else {
|
||||
cancelButton.setText(info.text.toUpperCase(Locale.ROOT));
|
||||
cancelButton.setTextColor(Theme.getColor(Theme.key_dialogTextGray));
|
||||
cancelButton.setText(info.text);
|
||||
cancelButton.setTextColor(Theme.getColor(Theme.key_dialogButton));
|
||||
cancelButton.setEnabled(true);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -423,33 +423,4 @@ public class OldTelegramWarningActivity extends BaseFragment implements Notifica
|
|||
public boolean isDismissed = false;
|
||||
public int timeout = 5;
|
||||
}
|
||||
|
||||
private static class TimeoutRunnable implements Runnable {
|
||||
TextView cancelButton;
|
||||
public DialogDismissedInfo dialogInfo;
|
||||
|
||||
public TimeoutRunnable(TextView cancelButton, DialogDismissedInfo dialogInfo) {
|
||||
this.cancelButton = cancelButton;
|
||||
this.dialogInfo = dialogInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!dialogInfo.isDismissed) {
|
||||
dialogInfo.timeout--;
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (dialogInfo.timeout > 0) {
|
||||
cancelButton.setText((getString("Continue") + " (" + dialogInfo.timeout + ")").toUpperCase(Locale.ROOT));
|
||||
} else {
|
||||
cancelButton.setText(getString("Continue").toUpperCase(Locale.ROOT));
|
||||
cancelButton.setTextColor(Theme.getColor(Theme.key_dialogTextGray));
|
||||
cancelButton.setEnabled(true);
|
||||
}
|
||||
});
|
||||
if (dialogInfo.timeout > 0) {
|
||||
Utilities.globalQueue.postRunnable(this, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue