Error message for duplicated entry in polls
This commit is contained in:
parent
e4b90981f1
commit
976612f69b
|
@ -3689,7 +3689,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
||||||
poll_duration.setAdapter(pollduration);
|
poll_duration.setAdapter(pollduration);
|
||||||
poll_duration.setSelection(4);
|
poll_duration.setSelection(4);
|
||||||
poll_choice.setSelection(0);
|
poll_choice.setSelection(0);
|
||||||
if( poll != null){
|
if( poll != null && poll.getOptionsList() != null){
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for(PollOptions pollOptions: poll.getOptionsList()){
|
for(PollOptions pollOptions: poll.getOptionsList()){
|
||||||
if( i == 1){
|
if( i == 1){
|
||||||
|
@ -3760,9 +3760,18 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
alertPoll.setPositiveButton(R.string.validate, null);
|
||||||
|
final AlertDialog alertPollDiaslog = alertPoll.create();
|
||||||
|
alertPollDiaslog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||||
|
|
||||||
alertPoll.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onShow(DialogInterface dialog) {
|
||||||
|
|
||||||
|
Button b = alertPollDiaslog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
b.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
int poll_duration_pos = poll_duration.getSelectedItemPosition();
|
int poll_duration_pos = poll_duration.getSelectedItemPosition();
|
||||||
|
|
||||||
int poll_choice_pos = poll_choice.getSelectedItemPosition();
|
int poll_choice_pos = poll_choice.getSelectedItemPosition();
|
||||||
|
@ -3819,20 +3828,33 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
||||||
pollOptions.add(pollItem);
|
pollOptions.add(pollItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<String> options = new ArrayList<>();
|
||||||
|
boolean doubleTitle = false;
|
||||||
|
for(PollOptions po: pollOptions){
|
||||||
|
if( !options.contains(po.getTitle().trim())){
|
||||||
|
options.add(po.getTitle().trim());
|
||||||
|
}else{
|
||||||
|
doubleTitle = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !doubleTitle) {
|
||||||
poll.setOptionsList(pollOptions);
|
poll.setOptionsList(pollOptions);
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
}else {
|
||||||
|
Toasty.error(getApplicationContext(), getString(R.string.poll_duplicated_entry), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
poll_action.setVisibility(View.VISIBLE);
|
poll_action.setVisibility(View.VISIBLE);
|
||||||
if(social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
|
if(social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
|
||||||
toot_picture.setVisibility(View.GONE);
|
toot_picture.setVisibility(View.GONE);
|
||||||
picture_scrollview.setVisibility(View.GONE);
|
picture_scrollview.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alertPoll.show();
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alertPollDiaslog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeToot(boolean message, boolean forced){
|
private void storeToot(boolean message, boolean forced){
|
||||||
|
|
|
@ -1177,4 +1177,5 @@
|
||||||
|
|
||||||
<string name="join_instance">For joining my instance \"%1$s\", you can download Fedilab:\n\nF-Droid: %2$s\nGoogle: %3$s\n\nThen open the link below with Fedilab and create your account :)\n\n%4$s
|
<string name="join_instance">For joining my instance \"%1$s\", you can download Fedilab:\n\nF-Droid: %2$s\nGoogle: %3$s\n\nThen open the link below with Fedilab and create your account :)\n\n%4$s
|
||||||
</string>
|
</string>
|
||||||
|
<string name="poll_duplicated_entry">Your poll can\'t have duplicated options!</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue