2020-01-24 16:23:31 +01:00
|
|
|
package com.darkweb.genesissearchengine.dataManager;
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import com.darkweb.genesissearchengine.appManager.activityContextManager;
|
|
|
|
import com.darkweb.genesissearchengine.appManager.databaseManager.databaseController;
|
2021-02-15 21:26:33 +01:00
|
|
|
import com.darkweb.genesissearchengine.appManager.historyManager.historyRowModel;
|
2020-01-24 16:23:31 +01:00
|
|
|
import com.darkweb.genesissearchengine.constants.constants;
|
|
|
|
import com.darkweb.genesissearchengine.constants.status;
|
2021-02-15 21:26:33 +01:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2020-10-05 13:12:00 +02:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2021-01-18 11:07:12 +01:00
|
|
|
import static com.darkweb.genesissearchengine.constants.status.mThemeApplying;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
public class dataController
|
|
|
|
{
|
|
|
|
/*Private Variables*/
|
|
|
|
|
2020-11-11 13:11:13 +01:00
|
|
|
private tabDataModel mTabModel;
|
2020-10-20 16:55:08 +02:00
|
|
|
private preferenceDataModel mPreferenceModel;
|
|
|
|
private historyDataModel mHistoryModel;
|
2021-01-18 11:07:12 +01:00
|
|
|
private imageDataModel mImageDataModel;
|
2021-02-03 11:54:19 +01:00
|
|
|
private bookmarkDataModel mBookmarkDataModel;
|
|
|
|
private suggestionDataModel mSuggestionDataModel;
|
2021-02-07 18:40:35 +01:00
|
|
|
private helpDataModel mHelpDataModel;
|
2021-02-19 08:51:37 +01:00
|
|
|
private referenceWebsiteDataModel mReferenceWebsiteDataModel;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
/*Private Declarations*/
|
|
|
|
|
|
|
|
private static final dataController sOurInstance = new dataController();
|
|
|
|
public static dataController getInstance()
|
|
|
|
{
|
|
|
|
return sOurInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Initializations*/
|
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
public void initialize(AppCompatActivity pAppContext){
|
2020-10-20 16:55:08 +02:00
|
|
|
mHistoryModel = new historyDataModel();
|
2020-11-11 13:11:13 +01:00
|
|
|
mTabModel = new tabDataModel();
|
2021-02-03 11:54:19 +01:00
|
|
|
mPreferenceModel = new preferenceDataModel(pAppContext);
|
2021-01-18 11:07:12 +01:00
|
|
|
mImageDataModel = new imageDataModel();
|
2021-02-03 11:54:19 +01:00
|
|
|
mBookmarkDataModel = new bookmarkDataModel();
|
|
|
|
mSuggestionDataModel = new suggestionDataModel(pAppContext);
|
2021-02-07 18:40:35 +01:00
|
|
|
mHelpDataModel = new helpDataModel();
|
2021-02-19 08:51:37 +01:00
|
|
|
mReferenceWebsiteDataModel = new referenceWebsiteDataModel();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void initializeListData(){
|
2021-02-19 08:51:37 +01:00
|
|
|
mReferenceWebsiteDataModel.onTrigger(dataEnums.eReferenceWebsiteCommands.M_LOAD,Collections.singletonList(activityContextManager.getInstance().getHomeController()));
|
2021-02-03 11:54:19 +01:00
|
|
|
mBookmarkDataModel.initializebookmark(databaseController.getInstance().selectBookmark());
|
2020-11-11 13:11:13 +01:00
|
|
|
if(!status.sClearOnExit)
|
2020-01-24 16:23:31 +01:00
|
|
|
{
|
2020-10-20 16:55:08 +02:00
|
|
|
mHistoryModel.onTrigger(dataEnums.eHistoryCommands.M_INITIALIZE_HISTORY, Arrays.asList(databaseController.getInstance().selectHistory(0,constants.CONST_FETCHABLE_LIST_SIZE), databaseController.getInstance().getLargestHistoryID(),databaseController.getInstance().getLargestHistoryID()));
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
2021-01-18 11:07:12 +01:00
|
|
|
else {
|
2020-01-24 16:23:31 +01:00
|
|
|
databaseController.getInstance().execSQL("delete from history where 1",null);
|
|
|
|
}
|
2021-01-18 11:07:12 +01:00
|
|
|
if(status.sRestoreTabs || mThemeApplying){
|
2020-12-11 08:05:08 +01:00
|
|
|
mTabModel.initializeTab(databaseController.getInstance().selectTabs());
|
|
|
|
activityContextManager.getInstance().getHomeController().initTabCount();
|
|
|
|
}else{
|
|
|
|
invokeTab(dataEnums.eTabCommands.M_CLEAR_TAB, null);
|
|
|
|
}
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-10-05 13:12:00 +02:00
|
|
|
/*Recieving History*/
|
2021-02-03 11:54:19 +01:00
|
|
|
public Object invokeHistory(dataEnums.eHistoryCommands pCommands, List<Object> pData){
|
2020-12-11 08:05:08 +01:00
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
if(pCommands == dataEnums.eHistoryCommands.M_ADD_HISTORY){
|
|
|
|
mTabModel.onTrigger(dataEnums.eTabCommands.M_UPDATE_TAB, pData);
|
2020-12-11 08:05:08 +01:00
|
|
|
}
|
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
if(pCommands.equals(dataEnums.eHistoryCommands.M_LOAD_MORE_HISTORY)){
|
2021-02-19 08:51:37 +01:00
|
|
|
int m_history_size = (int) mHistoryModel.onTrigger(dataEnums.eHistoryCommands.M_HISTORY_SIZE,null) - 1;
|
2021-02-03 11:54:19 +01:00
|
|
|
return mHistoryModel.onTrigger(pCommands, Collections.singletonList(databaseController.getInstance().selectHistory(m_history_size+1,constants.CONST_FETCHABLE_LIST_SIZE)));
|
2020-10-05 13:12:00 +02:00
|
|
|
}else {
|
2021-02-03 11:54:19 +01:00
|
|
|
return mHistoryModel.onTrigger(pCommands, pData);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
2020-10-05 13:12:00 +02:00
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
public Object invokeSuggestions(dataEnums.eSuggestionCommands pCommands, List<Object> pData){
|
|
|
|
return mSuggestionDataModel.onTrigger(pCommands, Arrays.asList(pData.get(0), mHistoryModel.onTrigger(dataEnums.eHistoryCommands.M_GET_HISTORY, null), mBookmarkDataModel.onTrigger(dataEnums.eBookmarkCommands.M_GET_BOOKMARK, null)));
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2021-02-19 08:51:37 +01:00
|
|
|
public Object invokeReferenceWebsite(dataEnums.eReferenceWebsiteCommands pCommands, List<Object> pData){
|
|
|
|
return mReferenceWebsiteDataModel.onTrigger(pCommands, null);
|
|
|
|
}
|
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
/*Recieving Preferences*/
|
|
|
|
public Object invokePrefs(dataEnums.ePreferencesCommands pCommands, List<Object> pData){
|
|
|
|
return mPreferenceModel.onTrigger(pCommands, pData);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
2020-10-05 13:12:00 +02:00
|
|
|
|
2021-02-07 18:40:35 +01:00
|
|
|
/*Recieving Help*/
|
|
|
|
public Object invokeHelp(dataEnums.eHelpCommands pCommands, List<Object> pData){
|
|
|
|
return mHelpDataModel.onTrigger(pCommands, pData);
|
|
|
|
}
|
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
/*Recieving History*/
|
|
|
|
public Object invokeBookmark(dataEnums.eBookmarkCommands pCommands, List<Object> pData){
|
|
|
|
return mBookmarkDataModel.onTrigger(pCommands, pData);
|
2020-10-05 13:12:00 +02:00
|
|
|
}
|
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
public Object invokeTab(dataEnums.eTabCommands pCommands, List<Object> pData){
|
|
|
|
return mTabModel.onTrigger(pCommands, pData);
|
2020-10-05 13:12:00 +02:00
|
|
|
}
|
2021-01-18 11:07:12 +01:00
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
public Object invokeImage(dataEnums.eImageCommands pCommands, List<Object> pData){
|
|
|
|
return mImageDataModel.onTrigger(pCommands, pData);
|
2021-01-18 11:07:12 +01:00
|
|
|
}
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
2020-10-05 13:12:00 +02:00
|
|
|
|