mirror of
https://gitlab.com/xynngh/YetAnotherCallBlocker.git
synced 2025-06-05 22:19:12 +02:00
Don't create blacklist duplicates
This commit is contained in:
@@ -222,7 +222,13 @@ public class EditBlacklistItemActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (TextUtils.isEmpty(name) && TextUtils.isEmpty(pattern)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,6 +51,13 @@ public class BlacklistDao {
|
|||||||
.orderAsc(BlacklistItemDao.Properties.Pattern));
|
.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) {
|
public void save(BlacklistItem blacklistItem) {
|
||||||
getBlacklistItemDao().save(blacklistItem);
|
getBlacklistItemDao().save(blacklistItem);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user