예제 #1
0
 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())));
   }
 }
예제 #2
0
 @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);
   }
 }
예제 #3
0
 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;
   }
 }
예제 #4
0
  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());
    }
  }
예제 #5
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   BusProvider.getInstance().unregister(this);
 }
예제 #6
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   BusProvider.getInstance().register(this);
 }