private void actionDelete() { if (urlType == URLTYPE.FEED) { BusProvider.getInstance().post(new UnSaveStoryEvent(DDGControlVar.currentFeedObject.getId())); } else if (urlType == URLTYPE.SERP) { BusProvider.getInstance() .post(new UnSaveSearchEvent(DDGUtils.getQueryIfSerp(mainWebView.getUrl()))); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { HashMap<Integer, Boolean> newStates; switch (item.getItemId()) { case R.id.action_reload: actionReload(); overflowMenu.dismiss(); return true; case R.id.action_add_favorite: actionSave(); return true; case R.id.action_remove_favorite: actionDelete(); return true; case R.id.action_share: actionShare(); return true; case R.id.action_external: actionExternalBrowser(); return true; case R.id.action_back: mainWebView.backPressAction(false); newStates = new HashMap<Integer, Boolean>(); newStates.put(R.id.action_back, mainWebView.canGoBack()); newStates.put(R.id.action_forward, mainWebView.canGoForward()); BusProvider.getInstance().post(new WebViewUpdateMenuNavigationEvent(newStates)); return true; case R.id.action_forward: mainWebView.forwardPressAction(); newStates = new HashMap<Integer, Boolean>(); newStates.put(R.id.action_back, mainWebView.canGoBack()); newStates.put(R.id.action_forward, mainWebView.canGoForward()); BusProvider.getInstance().post(new WebViewUpdateMenuNavigationEvent(newStates)); return true; /* case R.id.action_close: overflowMenu.dismiss();*/ default: return super.onOptionsItemSelected(item); } }
private void actionShare() { String webViewUrl = mainWebView.getUrl(); if (webViewUrl == null) { webViewUrl = ""; } switch (urlType) { case FEED: BusProvider.getInstance() .post( new ShareFeedEvent( DDGControlVar.currentFeedObject.getTitle(), DDGControlVar.currentFeedObject.getUrl())); break; case SERP: BusProvider.getInstance().post(new ShareSearchEvent(webViewUrl)); break; case WEBPAGE: BusProvider.getInstance().post(new ShareWebPageEvent(webViewUrl, webViewUrl)); break; default: break; } }
public void showHistoryObject(HistoryObject historyObject) { if (historyObject.isWebSearch()) { searchWebTerm(historyObject.getData()); } else if (historyObject.isFeedObject()) { DDGApplication.getDB().insertHistoryObject(historyObject); // DDGControlVar.mDuckDuckGoContainer.historyAdapter.sync(); String feedId = historyObject.getFeedId(); if (feedId != null) { BusProvider.getInstance().post(new FeedItemSelectedEvent(feedId)); } } else { DDGApplication.getDB().insertHistoryObject(historyObject); // DDGControlVar.mDuckDuckGoContainer.historyAdapter.sync(); showWebUrl(historyObject.getUrl()); } }
@Override public void onDestroy() { super.onDestroy(); BusProvider.getInstance().unregister(this); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BusProvider.getInstance().register(this); }