mirror of
https://gitlab.com/xynngh/YetAnotherCallBlocker.git
synced 2025-02-03 18:57:47 +01:00
Rename DatabaseSingleton
This commit is contained in:
parent
5cf1d77860
commit
a5af1bc9aa
@ -23,7 +23,7 @@ import org.greenrobot.eventbus.ThreadMode;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.BlacklistService;
|
import dummydomain.yetanothercallblocker.data.BlacklistService;
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.data.db.BlacklistDao;
|
import dummydomain.yetanothercallblocker.data.db.BlacklistDao;
|
||||||
import dummydomain.yetanothercallblocker.data.db.BlacklistItem;
|
import dummydomain.yetanothercallblocker.data.db.BlacklistItem;
|
||||||
import dummydomain.yetanothercallblocker.event.BlacklistChangedEvent;
|
import dummydomain.yetanothercallblocker.event.BlacklistChangedEvent;
|
||||||
@ -31,8 +31,8 @@ import dummydomain.yetanothercallblocker.event.BlacklistChangedEvent;
|
|||||||
public class BlacklistActivity extends AppCompatActivity {
|
public class BlacklistActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private final Settings settings = App.getSettings();
|
private final Settings settings = App.getSettings();
|
||||||
private final BlacklistDao blacklistDao = DatabaseSingleton.getBlacklistDao();
|
private final BlacklistDao blacklistDao = YacbHolder.getBlacklistDao();
|
||||||
private final BlacklistService blacklistService = DatabaseSingleton.getBlacklistService();
|
private final BlacklistService blacklistService = YacbHolder.getBlacklistService();
|
||||||
|
|
||||||
private BlacklistItemRecyclerViewAdapter blacklistAdapter;
|
private BlacklistItemRecyclerViewAdapter blacklistAdapter;
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
|
||||||
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
||||||
import dummydomain.yetanothercallblocker.data.NumberInfoService;
|
import dummydomain.yetanothercallblocker.data.NumberInfoService;
|
||||||
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.event.CallEndedEvent;
|
import dummydomain.yetanothercallblocker.event.CallEndedEvent;
|
||||||
import dummydomain.yetanothercallblocker.event.CallOngoingEvent;
|
import dummydomain.yetanothercallblocker.event.CallOngoingEvent;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class CallReceiver extends BroadcastReceiver {
|
|||||||
boolean showNotifications = settings.getIncomingCallNotifications();
|
boolean showNotifications = settings.getIncomingCallNotifications();
|
||||||
|
|
||||||
if (blockingEnabled || showNotifications) {
|
if (blockingEnabled || showNotifications) {
|
||||||
NumberInfoService numberInfoService = DatabaseSingleton.getNumberInfoService();
|
NumberInfoService numberInfoService = YacbHolder.getNumberInfoService();
|
||||||
NumberInfo numberInfo = numberInfoService.getNumberInfo(incomingNumber, false);
|
NumberInfo numberInfo = numberInfoService.getNumberInfo(incomingNumber, false);
|
||||||
|
|
||||||
boolean blocked = false;
|
boolean blocked = false;
|
||||||
|
@ -17,9 +17,9 @@ import androidx.annotation.RequiresApi;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
|
||||||
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
||||||
import dummydomain.yetanothercallblocker.data.NumberInfoService;
|
import dummydomain.yetanothercallblocker.data.NumberInfoService;
|
||||||
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.event.CallEndedEvent;
|
import dummydomain.yetanothercallblocker.event.CallEndedEvent;
|
||||||
|
|
||||||
import static dummydomain.yetanothercallblocker.EventUtils.postEvent;
|
import static dummydomain.yetanothercallblocker.EventUtils.postEvent;
|
||||||
@ -29,7 +29,7 @@ public class CallScreeningServiceImpl extends CallScreeningService {
|
|||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CallScreeningServiceImpl.class);
|
private static final Logger LOG = LoggerFactory.getLogger(CallScreeningServiceImpl.class);
|
||||||
|
|
||||||
private NumberInfoService numberInfoService = DatabaseSingleton.getNumberInfoService();
|
private NumberInfoService numberInfoService = YacbHolder.getNumberInfoService();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScreenCall(@NonNull Call.Details callDetails) {
|
public void onScreenCall(@NonNull Call.Details callDetails) {
|
||||||
|
@ -14,8 +14,8 @@ import org.greenrobot.eventbus.ThreadMode;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
|
||||||
import dummydomain.yetanothercallblocker.data.SiaNumberCategoryUtils;
|
import dummydomain.yetanothercallblocker.data.SiaNumberCategoryUtils;
|
||||||
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
|
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
|
||||||
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
|
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
|
||||||
import dummydomain.yetanothercallblocker.sia.model.SiaMetadata;
|
import dummydomain.yetanothercallblocker.sia.model.SiaMetadata;
|
||||||
@ -53,7 +53,7 @@ public class DebugActivity extends AppCompatActivity {
|
|||||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
||||||
public void onSecondaryDbUpdateFinished(SecondaryDbUpdateFinished event) {
|
public void onSecondaryDbUpdateFinished(SecondaryDbUpdateFinished event) {
|
||||||
setResult(getString(R.string.debug_update_result,
|
setResult(getString(R.string.debug_update_result,
|
||||||
DatabaseSingleton.getCommunityDatabase().getEffectiveDbVersion()));
|
YacbHolder.getCommunityDatabase().getEffectiveDbVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onQueryDbButtonClick(View view) {
|
public void onQueryDbButtonClick(View view) {
|
||||||
@ -62,10 +62,10 @@ public class DebugActivity extends AppCompatActivity {
|
|||||||
new AsyncTask<Void, Void, Pair<CommunityDatabaseItem, FeaturedDatabaseItem>>() {
|
new AsyncTask<Void, Void, Pair<CommunityDatabaseItem, FeaturedDatabaseItem>>() {
|
||||||
@Override
|
@Override
|
||||||
protected Pair<CommunityDatabaseItem, FeaturedDatabaseItem> doInBackground(Void... voids) {
|
protected Pair<CommunityDatabaseItem, FeaturedDatabaseItem> doInBackground(Void... voids) {
|
||||||
CommunityDatabaseItem item = DatabaseSingleton.getCommunityDatabase()
|
CommunityDatabaseItem item = YacbHolder.getCommunityDatabase()
|
||||||
.getDbItemByNumber(getNumber());
|
.getDbItemByNumber(getNumber());
|
||||||
|
|
||||||
FeaturedDatabaseItem featuredItem = DatabaseSingleton.getFeaturedDatabase()
|
FeaturedDatabaseItem featuredItem = YacbHolder.getFeaturedDatabase()
|
||||||
.getDbItemByNumber(getNumber());
|
.getDbItemByNumber(getNumber());
|
||||||
|
|
||||||
return new Pair<>(item, featuredItem);
|
return new Pair<>(item, featuredItem);
|
||||||
@ -112,12 +112,12 @@ public class DebugActivity extends AppCompatActivity {
|
|||||||
public void onResetDbClick(View view) {
|
public void onResetDbClick(View view) {
|
||||||
clearMessage();
|
clearMessage();
|
||||||
|
|
||||||
DatabaseSingleton.getCommunityDatabase().resetSecondaryDatabase();
|
YacbHolder.getCommunityDatabase().resetSecondaryDatabase();
|
||||||
|
|
||||||
DatabaseSingleton.getDbManager().removeMainDb();
|
YacbHolder.getDbManager().removeMainDb();
|
||||||
DatabaseSingleton.getCommunityDatabase().reload();
|
YacbHolder.getCommunityDatabase().reload();
|
||||||
DatabaseSingleton.getFeaturedDatabase().reload();
|
YacbHolder.getFeaturedDatabase().reload();
|
||||||
DatabaseSingleton.getSiaMetadata().reload();
|
YacbHolder.getSiaMetadata().reload();
|
||||||
|
|
||||||
setResult("Database removed");
|
setResult("Database removed");
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ public class DebugActivity extends AppCompatActivity {
|
|||||||
public void onResetSecondaryDbClick(View view) {
|
public void onResetSecondaryDbClick(View view) {
|
||||||
clearMessage();
|
clearMessage();
|
||||||
|
|
||||||
DatabaseSingleton.getCommunityDatabase().resetSecondaryDatabase();
|
YacbHolder.getCommunityDatabase().resetSecondaryDatabase();
|
||||||
|
|
||||||
setResult("Secondary database removed");
|
setResult("Secondary database removed");
|
||||||
}
|
}
|
||||||
@ -138,8 +138,8 @@ public class DebugActivity extends AppCompatActivity {
|
|||||||
protected String doInBackground(Void... voids) {
|
protected String doInBackground(Void... voids) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
SiaMetadata siaMetadata = DatabaseSingleton.getSiaMetadata();
|
SiaMetadata siaMetadata = YacbHolder.getSiaMetadata();
|
||||||
CommunityDatabase communityDatabase = DatabaseSingleton.getCommunityDatabase();
|
CommunityDatabase communityDatabase = YacbHolder.getCommunityDatabase();
|
||||||
|
|
||||||
sb.append("DB info:\n");
|
sb.append("DB info:\n");
|
||||||
sb.append("Operational: ").append(communityDatabase.isOperational()).append('\n');
|
sb.append("Operational: ").append(communityDatabase.isOperational()).append('\n');
|
||||||
@ -149,7 +149,7 @@ public class DebugActivity extends AppCompatActivity {
|
|||||||
sb.append("Last update time: ").append(dateOrNever(App.getSettings().getLastUpdateTime())).append('\n');
|
sb.append("Last update time: ").append(dateOrNever(App.getSettings().getLastUpdateTime())).append('\n');
|
||||||
sb.append("Last update check time: ").append(dateOrNever(App.getSettings().getLastUpdateCheckTime())).append('\n');
|
sb.append("Last update check time: ").append(dateOrNever(App.getSettings().getLastUpdateCheckTime())).append('\n');
|
||||||
|
|
||||||
FeaturedDatabase featuredDatabase = DatabaseSingleton.getFeaturedDatabase();
|
FeaturedDatabase featuredDatabase = YacbHolder.getFeaturedDatabase();
|
||||||
|
|
||||||
sb.append("\nFeatured DB info:\n");
|
sb.append("\nFeatured DB info:\n");
|
||||||
sb.append("Operational: ").append(featuredDatabase.isOperational()).append('\n');
|
sb.append("Operational: ").append(featuredDatabase.isOperational()).append('\n');
|
||||||
|
@ -24,7 +24,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.BlacklistService;
|
import dummydomain.yetanothercallblocker.data.BlacklistService;
|
||||||
import dummydomain.yetanothercallblocker.data.BlacklistUtils;
|
import dummydomain.yetanothercallblocker.data.BlacklistUtils;
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.data.db.BlacklistDao;
|
import dummydomain.yetanothercallblocker.data.db.BlacklistDao;
|
||||||
import dummydomain.yetanothercallblocker.data.db.BlacklistItem;
|
import dummydomain.yetanothercallblocker.data.db.BlacklistItem;
|
||||||
|
|
||||||
@ -39,8 +39,8 @@ public class EditBlacklistItemActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(EditBlacklistItemActivity.class);
|
private static final Logger LOG = LoggerFactory.getLogger(EditBlacklistItemActivity.class);
|
||||||
|
|
||||||
private BlacklistDao blacklistDao = DatabaseSingleton.getBlacklistDao();
|
private BlacklistDao blacklistDao = YacbHolder.getBlacklistDao();
|
||||||
private BlacklistService blacklistService = DatabaseSingleton.getBlacklistService();
|
private BlacklistService blacklistService = YacbHolder.getBlacklistService();
|
||||||
|
|
||||||
private TextInputLayout nameTextField;
|
private TextInputLayout nameTextField;
|
||||||
private TextInputLayout patternTextField;
|
private TextInputLayout patternTextField;
|
||||||
|
@ -7,8 +7,8 @@ import android.os.Bundle;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
|
||||||
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
||||||
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
|
|
||||||
public class InfoDialogActivity extends AppCompatActivity {
|
public class InfoDialogActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -25,8 +25,7 @@ public class InfoDialogActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
NumberInfo numberInfo = DatabaseSingleton.getNumberInfo(
|
NumberInfo numberInfo = YacbHolder.getNumberInfo(getIntent().getStringExtra(PARAM_NUMBER));
|
||||||
getIntent().getStringExtra(PARAM_NUMBER));
|
|
||||||
|
|
||||||
InfoDialogHelper.showDialog(this, numberInfo, (d) -> finish());
|
InfoDialogHelper.showDialog(this, numberInfo, (d) -> finish());
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
|
||||||
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
import dummydomain.yetanothercallblocker.data.NumberInfo;
|
||||||
import dummydomain.yetanothercallblocker.data.SiaNumberCategoryUtils;
|
import dummydomain.yetanothercallblocker.data.SiaNumberCategoryUtils;
|
||||||
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
|
import dummydomain.yetanothercallblocker.sia.model.NumberCategory;
|
||||||
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabaseItem;
|
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabaseItem;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class InfoDialogHelper {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Runnable webReviewAction = () -> {
|
Runnable webReviewAction = () -> {
|
||||||
Uri uri = Uri.parse(DatabaseSingleton.getWebService().getWebReviewsUrlPart()
|
Uri uri = Uri.parse(YacbHolder.getWebService().getWebReviewsUrlPart()
|
||||||
+ numberInfo.number);
|
+ numberInfo.number);
|
||||||
IntentHelper.startActivity(context, new Intent(Intent.ACTION_VIEW, uri));
|
IntentHelper.startActivity(context, new Intent(Intent.ACTION_VIEW, uri));
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.CallLogHelper;
|
import dummydomain.yetanothercallblocker.data.CallLogHelper;
|
||||||
import dummydomain.yetanothercallblocker.data.CallLogItem;
|
import dummydomain.yetanothercallblocker.data.CallLogItem;
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.event.CallEndedEvent;
|
import dummydomain.yetanothercallblocker.event.CallEndedEvent;
|
||||||
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
|
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
|
||||||
import dummydomain.yetanothercallblocker.event.MainDbDownloadingEvent;
|
import dummydomain.yetanothercallblocker.event.MainDbDownloadingEvent;
|
||||||
@ -145,7 +145,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
= new AsyncTask<Void, Void, Boolean>() {
|
= new AsyncTask<Void, Void, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
return DatabaseSingleton.getCommunityDatabase().isOperational();
|
return YacbHolder.getCommunityDatabase().isOperational();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -232,7 +232,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
MainActivity.this, settings.getNumberOfRecentCalls());
|
MainActivity.this, settings.getNumberOfRecentCalls());
|
||||||
|
|
||||||
for (CallLogItem item : items) {
|
for (CallLogItem item : items) {
|
||||||
item.numberInfo = DatabaseSingleton.getNumberInfo(item.number);
|
item.numberInfo = YacbHolder.getNumberInfo(item.number);
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
@ -18,7 +18,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.sia.model.CommunityReview;
|
import dummydomain.yetanothercallblocker.sia.model.CommunityReview;
|
||||||
|
|
||||||
public class ReviewsActivity extends AppCompatActivity {
|
public class ReviewsActivity extends AppCompatActivity {
|
||||||
@ -97,7 +97,7 @@ public class ReviewsActivity extends AppCompatActivity {
|
|||||||
= new AsyncTask<String, Void, List<CommunityReview>>() {
|
= new AsyncTask<String, Void, List<CommunityReview>>() {
|
||||||
@Override
|
@Override
|
||||||
protected List<CommunityReview> doInBackground(String... params) {
|
protected List<CommunityReview> doInBackground(String... params) {
|
||||||
return DatabaseSingleton.getCommunityReviewsLoader()
|
return YacbHolder.getCommunityReviewsLoader()
|
||||||
.loadReviews(params[0], App.getSettings().getCountryCodeForReviews());
|
.loadReviews(params[0], App.getSettings().getCountryCodeForReviews());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ public class Config {
|
|||||||
wsParameterProvider.setSettings(settings);
|
wsParameterProvider.setSettings(settings);
|
||||||
|
|
||||||
WebService webService = new WebService(wsParameterProvider, okHttpClientFactory);
|
WebService webService = new WebService(wsParameterProvider, okHttpClientFactory);
|
||||||
DatabaseSingleton.setWebService(webService);
|
YacbHolder.setWebService(webService);
|
||||||
|
|
||||||
DatabaseSingleton.setDbManager(new DbManager(storage, SIA_PATH_PREFIX,
|
YacbHolder.setDbManager(new DbManager(storage, SIA_PATH_PREFIX,
|
||||||
new DbDownloader(okHttpClientFactory)));
|
new DbDownloader(okHttpClientFactory)));
|
||||||
|
|
||||||
CommunityDatabase communityDatabase = new CommunityDatabase(
|
CommunityDatabase communityDatabase = new CommunityDatabase(
|
||||||
@ -111,28 +111,28 @@ public class Config {
|
|||||||
SIA_SECONDARY_PATH_PREFIX, siaSettings, webService);
|
SIA_SECONDARY_PATH_PREFIX, siaSettings, webService);
|
||||||
|
|
||||||
wsParameterProvider.setCommunityDatabase(communityDatabase);
|
wsParameterProvider.setCommunityDatabase(communityDatabase);
|
||||||
DatabaseSingleton.setCommunityDatabase(communityDatabase);
|
YacbHolder.setCommunityDatabase(communityDatabase);
|
||||||
|
|
||||||
SiaMetadata siaMetadata = new SiaMetadata(storage, SIA_PATH_PREFIX,
|
SiaMetadata siaMetadata = new SiaMetadata(storage, SIA_PATH_PREFIX,
|
||||||
communityDatabase::isUsingInternal);
|
communityDatabase::isUsingInternal);
|
||||||
|
|
||||||
wsParameterProvider.setSiaMetadata(siaMetadata);
|
wsParameterProvider.setSiaMetadata(siaMetadata);
|
||||||
DatabaseSingleton.setSiaMetadata(siaMetadata);
|
YacbHolder.setSiaMetadata(siaMetadata);
|
||||||
|
|
||||||
FeaturedDatabase featuredDatabase = new FeaturedDatabase(
|
FeaturedDatabase featuredDatabase = new FeaturedDatabase(
|
||||||
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX);
|
storage, AbstractDatabase.Source.ANY, SIA_PATH_PREFIX);
|
||||||
DatabaseSingleton.setFeaturedDatabase(featuredDatabase);
|
YacbHolder.setFeaturedDatabase(featuredDatabase);
|
||||||
|
|
||||||
DatabaseSingleton.setCommunityReviewsLoader(new CommunityReviewsLoader(webService));
|
YacbHolder.setCommunityReviewsLoader(new CommunityReviewsLoader(webService));
|
||||||
|
|
||||||
YacbDaoSessionFactory daoSessionFactory = new YacbDaoSessionFactory(context, "YACB");
|
YacbDaoSessionFactory daoSessionFactory = new YacbDaoSessionFactory(context, "YACB");
|
||||||
|
|
||||||
BlacklistDao blacklistDao = new BlacklistDao(daoSessionFactory::getDaoSession);
|
BlacklistDao blacklistDao = new BlacklistDao(daoSessionFactory::getDaoSession);
|
||||||
DatabaseSingleton.setBlacklistDao(blacklistDao);
|
YacbHolder.setBlacklistDao(blacklistDao);
|
||||||
|
|
||||||
BlacklistService blacklistService = new BlacklistService(
|
BlacklistService blacklistService = new BlacklistService(
|
||||||
settings::setBlacklistIsNotEmpty, blacklistDao);
|
settings::setBlacklistIsNotEmpty, blacklistDao);
|
||||||
DatabaseSingleton.setBlacklistService(blacklistService);
|
YacbHolder.setBlacklistService(blacklistService);
|
||||||
|
|
||||||
ContactsProvider contactsProvider = number -> {
|
ContactsProvider contactsProvider = number -> {
|
||||||
if (settings.getUseContacts() && PermissionHelper.hasContactsPermission(context)) {
|
if (settings.getUseContacts() && PermissionHelper.hasContactsPermission(context)) {
|
||||||
@ -145,7 +145,7 @@ public class Config {
|
|||||||
NumberInfoService numberInfoService = new NumberInfoService(
|
NumberInfoService numberInfoService = new NumberInfoService(
|
||||||
settings, NumberUtils::isHiddenNumber,
|
settings, NumberUtils::isHiddenNumber,
|
||||||
communityDatabase, featuredDatabase, contactsProvider, blacklistService);
|
communityDatabase, featuredDatabase, contactsProvider, blacklistService);
|
||||||
DatabaseSingleton.setNumberInfoService(numberInfoService);
|
YacbHolder.setNumberInfoService(numberInfoService);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import dummydomain.yetanothercallblocker.sia.model.database.DbManager;
|
|||||||
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabase;
|
import dummydomain.yetanothercallblocker.sia.model.database.FeaturedDatabase;
|
||||||
import dummydomain.yetanothercallblocker.sia.network.WebService;
|
import dummydomain.yetanothercallblocker.sia.network.WebService;
|
||||||
|
|
||||||
public class DatabaseSingleton {
|
public class YacbHolder {
|
||||||
|
|
||||||
private static WebService webService;
|
private static WebService webService;
|
||||||
private static DbManager dbManager;
|
private static DbManager dbManager;
|
||||||
@ -23,39 +23,39 @@ public class DatabaseSingleton {
|
|||||||
private static NumberInfoService numberInfoService;
|
private static NumberInfoService numberInfoService;
|
||||||
|
|
||||||
static void setWebService(WebService webService) {
|
static void setWebService(WebService webService) {
|
||||||
DatabaseSingleton.webService = webService;
|
YacbHolder.webService = webService;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setDbManager(DbManager dbManager) {
|
static void setDbManager(DbManager dbManager) {
|
||||||
DatabaseSingleton.dbManager = dbManager;
|
YacbHolder.dbManager = dbManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setSiaMetadata(SiaMetadata siaMetadata) {
|
static void setSiaMetadata(SiaMetadata siaMetadata) {
|
||||||
DatabaseSingleton.siaMetadata = siaMetadata;
|
YacbHolder.siaMetadata = siaMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setCommunityDatabase(CommunityDatabase communityDatabase) {
|
static void setCommunityDatabase(CommunityDatabase communityDatabase) {
|
||||||
DatabaseSingleton.communityDatabase = communityDatabase;
|
YacbHolder.communityDatabase = communityDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setFeaturedDatabase(FeaturedDatabase featuredDatabase) {
|
static void setFeaturedDatabase(FeaturedDatabase featuredDatabase) {
|
||||||
DatabaseSingleton.featuredDatabase = featuredDatabase;
|
YacbHolder.featuredDatabase = featuredDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setCommunityReviewsLoader(CommunityReviewsLoader communityReviewsLoader) {
|
static void setCommunityReviewsLoader(CommunityReviewsLoader communityReviewsLoader) {
|
||||||
DatabaseSingleton.communityReviewsLoader = communityReviewsLoader;
|
YacbHolder.communityReviewsLoader = communityReviewsLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setBlacklistDao(BlacklistDao blacklistDao) {
|
static void setBlacklistDao(BlacklistDao blacklistDao) {
|
||||||
DatabaseSingleton.blacklistDao = blacklistDao;
|
YacbHolder.blacklistDao = blacklistDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setBlacklistService(BlacklistService blacklistService) {
|
static void setBlacklistService(BlacklistService blacklistService) {
|
||||||
DatabaseSingleton.blacklistService = blacklistService;
|
YacbHolder.blacklistService = blacklistService;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setNumberInfoService(NumberInfoService numberInfoService) {
|
static void setNumberInfoService(NumberInfoService numberInfoService) {
|
||||||
DatabaseSingleton.numberInfoService = numberInfoService;
|
YacbHolder.numberInfoService = numberInfoService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WebService getWebService() {
|
public static WebService getWebService() {
|
@ -17,7 +17,7 @@ import dummydomain.yetanothercallblocker.App;
|
|||||||
import dummydomain.yetanothercallblocker.NotificationHelper;
|
import dummydomain.yetanothercallblocker.NotificationHelper;
|
||||||
import dummydomain.yetanothercallblocker.R;
|
import dummydomain.yetanothercallblocker.R;
|
||||||
import dummydomain.yetanothercallblocker.Settings;
|
import dummydomain.yetanothercallblocker.Settings;
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
|
import dummydomain.yetanothercallblocker.event.MainDbDownloadFinishedEvent;
|
||||||
import dummydomain.yetanothercallblocker.event.MainDbDownloadingEvent;
|
import dummydomain.yetanothercallblocker.event.MainDbDownloadingEvent;
|
||||||
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
|
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
|
||||||
@ -88,10 +88,10 @@ public class TaskService extends IntentService {
|
|||||||
|
|
||||||
postStickyEvent(sticky);
|
postStickyEvent(sticky);
|
||||||
try {
|
try {
|
||||||
DatabaseSingleton.getDbManager().downloadMainDb();
|
YacbHolder.getDbManager().downloadMainDb();
|
||||||
DatabaseSingleton.getCommunityDatabase().reload();
|
YacbHolder.getCommunityDatabase().reload();
|
||||||
DatabaseSingleton.getFeaturedDatabase().reload();
|
YacbHolder.getFeaturedDatabase().reload();
|
||||||
DatabaseSingleton.getSiaMetadata().reload();
|
YacbHolder.getSiaMetadata().reload();
|
||||||
} finally {
|
} finally {
|
||||||
removeStickyEvent(sticky);
|
removeStickyEvent(sticky);
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ public class TaskService extends IntentService {
|
|||||||
|
|
||||||
postStickyEvent(sticky);
|
postStickyEvent(sticky);
|
||||||
try {
|
try {
|
||||||
if (DatabaseSingleton.getCommunityDatabase().updateSecondaryDb()) {
|
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
||||||
settings.setLastUpdateTime(System.currentTimeMillis());
|
settings.setLastUpdateTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
||||||
|
@ -11,7 +11,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import dummydomain.yetanothercallblocker.App;
|
import dummydomain.yetanothercallblocker.App;
|
||||||
import dummydomain.yetanothercallblocker.Settings;
|
import dummydomain.yetanothercallblocker.Settings;
|
||||||
import dummydomain.yetanothercallblocker.data.DatabaseSingleton;
|
import dummydomain.yetanothercallblocker.data.YacbHolder;
|
||||||
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
|
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdateFinished;
|
||||||
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdatingEvent;
|
import dummydomain.yetanothercallblocker.event.SecondaryDbUpdatingEvent;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class UpdateWorker extends Worker {
|
|||||||
|
|
||||||
postStickyEvent(sticky);
|
postStickyEvent(sticky);
|
||||||
try {
|
try {
|
||||||
if (DatabaseSingleton.getCommunityDatabase().updateSecondaryDb()) {
|
if (YacbHolder.getCommunityDatabase().updateSecondaryDb()) {
|
||||||
settings.setLastUpdateTime(System.currentTimeMillis());
|
settings.setLastUpdateTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
settings.setLastUpdateCheckTime(System.currentTimeMillis());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user