Browse Source

Prevent auto refresh when searching or selecting files (in tabletinterface).

pull/148/merge
Eric Kok 11 years ago
parent
commit
622eca4222
  1. 10
      core/src/org/transdroid/core/gui/DetailsFragment.java
  2. 49
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  3. 12
      core/src/org/transdroid/core/gui/TorrentsFragment.java

10
core/src/org/transdroid/core/gui/DetailsFragment.java

@ -392,6 +392,11 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -392,6 +392,11 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
// Pause autorefresh
if (getActivity() != null && getActivity() instanceof TorrentsActivity) {
((TorrentsActivity) getActivity()).stopRefresh = true;
((TorrentsActivity) getActivity()).stopAutoRefresh();
}
return selectionManagerMode.onPrepareActionMode(mode, menu);
}
@ -487,6 +492,11 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -487,6 +492,11 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
@Override
public void onDestroyActionMode(ActionMode mode) {
// Resume autorefresh
if (getActivity() != null && getActivity() instanceof TorrentsActivity) {
((TorrentsActivity) getActivity()).stopRefresh = false;
((TorrentsActivity) getActivity()).startAutoRefresh();
}
selectionManagerMode.onDestroyActionMode(mode);
}

49
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -44,18 +44,31 @@ import org.apache.http.client.methods.HttpGet; @@ -44,18 +44,31 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.transdroid.core.R;
import org.transdroid.core.app.search.*;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.app.search.SearchHelper_;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.NoProgressHeaderTransformer;
import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.log.*;
import org.transdroid.core.gui.navigation.*;
import org.transdroid.core.gui.rss.*;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.log.Log_;
import org.transdroid.core.gui.navigation.FilterListAdapter;
import org.transdroid.core.gui.navigation.FilterListAdapter_;
import org.transdroid.core.gui.navigation.FilterListDropDownAdapter;
import org.transdroid.core.gui.navigation.FilterListDropDownAdapter_;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.rss.RssfeedsActivity_;
import org.transdroid.core.gui.search.BarcodeHelper;
import org.transdroid.core.gui.search.FilePickerHelper;
import org.transdroid.core.gui.search.UrlEntryDialog;
import org.transdroid.core.gui.settings.*;
import org.transdroid.core.gui.settings.MainSettingsActivity_;
import org.transdroid.core.service.BootReceiver;
import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.core.widget.ListWidgetProvider;
@ -107,6 +120,7 @@ import android.os.AsyncTask; @@ -107,6 +120,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@ -115,6 +129,7 @@ import com.actionbarsherlock.app.ActionBar.OnNavigationListener; @@ -115,6 +129,7 @@ import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuItem.OnActionExpandListener;
import com.actionbarsherlock.view.SherlockListView;
import com.actionbarsherlock.widget.SearchView;
@ -369,6 +384,28 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -369,6 +384,28 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
SearchView searchView = new SearchView(this);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true);
searchView.setOnSearchClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Pause autorefresh
stopRefresh = true;
stopAutoRefresh();
}
});
// NOTE ABS's OnCloseListener is not working, hence using an OnActionExpandListener
item.setOnActionExpandListener(new OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
stopRefresh = false;
startAutoRefresh();
return true;
}
});
item.setActionView(searchView);
searchMenu = item;
}

12
core/src/org/transdroid/core/gui/TorrentsFragment.java

@ -262,8 +262,10 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL @@ -262,8 +262,10 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
menu.findItem(R.id.action_setlabel).setVisible(Daemon.supportsSetLabel(daemonType));
}
// Pause autorefresh
((TorrentsActivity) getActivity()).stopRefresh = true;
((TorrentsActivity) getActivity()).stopAutoRefresh();
if (getActivity() != null && getActivity() instanceof TorrentsActivity) {
((TorrentsActivity) getActivity()).stopRefresh = true;
((TorrentsActivity) getActivity()).stopAutoRefresh();
}
return true;
}
@ -333,8 +335,10 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL @@ -333,8 +335,10 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
@Override
public void onDestroyActionMode(ActionMode mode) {
// Resume autorefresh
((TorrentsActivity) getActivity()).stopRefresh = false;
((TorrentsActivity) getActivity()).startAutoRefresh();
if (getActivity() != null && getActivity() instanceof TorrentsActivity) {
((TorrentsActivity) getActivity()).stopRefresh = false;
((TorrentsActivity) getActivity()).startAutoRefresh();
}
selectionManagerMode.onDestroyActionMode(mode);
}

Loading…
Cancel
Save