blob: f26ae7a57d552b92191d868c38df50a9b9776e0d (
plain)
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
|
package com.mapswithme.maps.bookmarks;
import android.app.Activity;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.dialog.EditTextDialogFragment;
import com.mapswithme.maps.dialog.DialogUtils;
class CategoryValidator implements EditTextDialogFragment.Validator
{
@Override
public boolean validate(@NonNull Activity activity, @Nullable String text)
{
if (TextUtils.isEmpty(text))
{
DialogUtils.showAlertDialog(activity, R.string.bookmarks_error_title_empty_list_name,
R.string.bookmarks_error_message_empty_list_name);
return false;
}
if (BookmarkManager.INSTANCE.isUsedCategoryName(text))
{
DialogUtils.showAlertDialog(activity, R.string.bookmarks_error_title_list_name_already_taken,
R.string.bookmarks_error_message_list_name_already_taken);
return false;
}
return true;
}
}
|