Don't create blacklist duplicates
This commit is contained in:
parent
d44121607f
commit
a95ce13628
|
@ -222,7 +222,13 @@ public class EditBlacklistItemActivity extends AppCompatActivity {
|
|||
}
|
||||
} else {
|
||||
if (TextUtils.isEmpty(name) && TextUtils.isEmpty(pattern)) {
|
||||
LOG.warn("save() not creating a new item because fields are empty");
|
||||
LOG.info("save() not creating a new item because fields are empty");
|
||||
return;
|
||||
}
|
||||
|
||||
if (blacklistDao.findByNameAndPattern(name, pattern) != null) {
|
||||
LOG.info("save() not creating a new item because" +
|
||||
" an item with the same name and pattern exists");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,13 @@ public class BlacklistDao {
|
|||
.orderAsc(BlacklistItemDao.Properties.Pattern));
|
||||
}
|
||||
|
||||
public BlacklistItem findByNameAndPattern(String name, String pattern) {
|
||||
return first(getBlacklistItemDao().queryBuilder()
|
||||
.where(BlacklistItemDao.Properties.Name.eq(name))
|
||||
.where(BlacklistItemDao.Properties.Pattern.eq(pattern))
|
||||
.orderAsc(BlacklistItemDao.Properties.Pattern));
|
||||
}
|
||||
|
||||
public void save(BlacklistItem blacklistItem) {
|
||||
getBlacklistItemDao().save(blacklistItem);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue