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.bookmarkManager.bookmarkRowModel;
|
|
|
|
import com.darkweb.genesissearchengine.appManager.databaseManager.databaseController;
|
|
|
|
import com.darkweb.genesissearchengine.appManager.historyManager.historyRowModel;
|
|
|
|
import com.darkweb.genesissearchengine.appManager.homeManager.geckoSession;
|
|
|
|
import com.darkweb.genesissearchengine.appManager.tabManager.tabRowModel;
|
|
|
|
import com.darkweb.genesissearchengine.constants.constants;
|
|
|
|
import com.darkweb.genesissearchengine.constants.status;
|
2020-02-28 19:10:00 +01:00
|
|
|
import com.darkweb.genesissearchengine.helperManager.helperMethod;
|
2020-01-24 16:23:31 +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;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
public class dataController
|
|
|
|
{
|
|
|
|
/*Private Variables*/
|
|
|
|
|
2020-10-05 13:12:00 +02:00
|
|
|
private dataModel m_data_model;
|
|
|
|
private preferenceDataModel m_preference_model;
|
|
|
|
private historyDataModel m_history_model;
|
|
|
|
private imageCacheModel m_image_cache_model;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
/*Private Declarations*/
|
|
|
|
|
|
|
|
private static final dataController sOurInstance = new dataController();
|
|
|
|
public static dataController getInstance()
|
|
|
|
{
|
|
|
|
return sOurInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Initializations*/
|
|
|
|
|
|
|
|
public void initialize(AppCompatActivity app_context){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_history_model = new historyDataModel();
|
|
|
|
m_data_model = new dataModel();
|
|
|
|
m_preference_model = new preferenceDataModel(app_context);
|
|
|
|
m_image_cache_model = new imageCacheModel();
|
|
|
|
m_data_model.initializeBookmarks();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void initializeListData(){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_data_model.initSuggestions();
|
2020-01-24 16:23:31 +01:00
|
|
|
if(!status.sHistoryStatus)
|
|
|
|
{
|
2020-10-05 13:12:00 +02:00
|
|
|
m_history_model.onTrigger(dataEnums.eHistoryCommands.M_INITIALIZE_HISTORY, Arrays.asList(databaseController.getInstance().selectHistory(0,constants.FETCHABLE_LIST_SIZE), databaseController.getInstance().getLargestHistoryID(),databaseController.getInstance().getLargestHistoryID()));
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
databaseController.getInstance().execSQL("delete from history where 1",null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-05 13:12:00 +02:00
|
|
|
/*Recieving History*/
|
|
|
|
public Object invokeHistory(dataEnums.eHistoryCommands p_commands, List<Object> p_data){
|
|
|
|
if(p_commands.equals(dataEnums.eHistoryCommands.M_LOAD_MORE_HISTORY)){
|
|
|
|
int m_history_size = (int)m_history_model.onTrigger(dataEnums.eHistoryCommands.M_HISTORY_SIZE,null);
|
|
|
|
return m_history_model.onTrigger(p_commands, Collections.singletonList(databaseController.getInstance().selectHistory(m_history_size+1,constants.FETCHABLE_LIST_SIZE)));
|
|
|
|
}else {
|
|
|
|
return m_history_model.onTrigger(p_commands, p_data);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
2020-10-05 13:12:00 +02:00
|
|
|
|
|
|
|
/*Recieving Images*/
|
|
|
|
public Object invokeImageCache(dataEnums.eImageCacheCommands p_commands, List<Object> p_data){
|
|
|
|
return m_image_cache_model.onTrigger(p_commands, p_data);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Recieving Preferences*/
|
2020-10-05 13:12:00 +02:00
|
|
|
public Object invokePrefs(dataEnums.ePreferencesCommands p_commands, List<Object> p_data){
|
|
|
|
return m_preference_model.onTrigger(p_commands, p_data);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-05 13:12:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
/*Recieving Bookmarks*/
|
|
|
|
|
|
|
|
public ArrayList<bookmarkRowModel> getBookmark(){
|
2020-10-05 13:12:00 +02:00
|
|
|
return m_data_model.getBookmark();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void addBookmark(String url,String title){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_data_model.addBookmark(url,title);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void clearBookmark(){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_data_model.clearBookmark();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Recieving Suggestions*/
|
|
|
|
|
|
|
|
public ArrayList<historyRowModel> getSuggestions(){
|
2020-10-05 13:12:00 +02:00
|
|
|
return m_data_model.getmSuggestions();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Recieving Tabs*/
|
|
|
|
|
|
|
|
public ArrayList<tabRowModel> getTab(){
|
2020-10-05 13:12:00 +02:00
|
|
|
return m_data_model.getTab();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void addTab(geckoSession mSession,boolean isHardCopy){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_data_model.addTabs(mSession,isHardCopy);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void clearTabs(){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_data_model.clearTab();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void closeTab(geckoSession session){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_data_model.closeTab(session);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public void moveTabToTop(geckoSession session){
|
2020-10-05 13:12:00 +02:00
|
|
|
m_data_model.moveTabToTop(session);
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public tabRowModel getCurrentTab(){
|
2020-10-05 13:12:00 +02:00
|
|
|
return m_data_model.getCurrentTab();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
public int getTotalTabs(){
|
2020-10-05 13:12:00 +02:00
|
|
|
return m_data_model.getTotalTabs();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateSuggestionURL(String url,String title) {
|
|
|
|
url = helperMethod.removeLastSlash(url);
|
|
|
|
m_data_model.updateSuggestionURL(url,title,false);
|
|
|
|
activityContextManager.getInstance().getHomeController().onSuggestionUpdate();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
2020-10-05 13:12:00 +02:00
|
|
|
public void addSuggesion(String url,String title) {
|
|
|
|
url = helperMethod.removeLastSlash(url);
|
|
|
|
m_data_model.addSuggenstions(url,title,false);
|
|
|
|
activityContextManager.getInstance().getHomeController().onSuggestionUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
2020-10-05 13:12:00 +02:00
|
|
|
|