reimplement action mode for headlines selection
This commit is contained in:
parent
721c98ce98
commit
67752b2c57
@ -97,12 +97,6 @@ private final String TAG = this.getClass().getSimpleName();
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getUnreadArticlesOnly() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initMenu() {
|
protected void initMenu() {
|
||||||
super.initMenu();
|
super.initMenu();
|
||||||
@ -138,8 +132,6 @@ private final String TAG = this.getClass().getSimpleName();
|
|||||||
article.unread = false;
|
article.unread = false;
|
||||||
saveArticleUnread(article);
|
saveArticleUnread(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TinyApplication.getInstance().m_activeArticle = article;
|
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
FragmentTransaction ft = getSupportFragmentManager()
|
FragmentTransaction ft = getSupportFragmentManager()
|
||||||
|
@ -26,6 +26,7 @@ import android.os.Bundle;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.ActionMode;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -46,6 +47,48 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
protected boolean m_unreadOnly = true;
|
protected boolean m_unreadOnly = true;
|
||||||
protected boolean m_unreadArticlesOnly = true;
|
protected boolean m_unreadArticlesOnly = true;
|
||||||
|
|
||||||
|
private ActionMode m_headlinesActionMode;
|
||||||
|
private HeadlinesActionModeCallback m_headlinesActionModeCallback;
|
||||||
|
|
||||||
|
private class HeadlinesActionModeCallback implements ActionMode.Callback {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
|
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
|
if (hf != null) {
|
||||||
|
ArticleList selected = hf.getSelectedArticles();
|
||||||
|
if (selected.size() > 0) {
|
||||||
|
selected.clear();
|
||||||
|
initMenu();
|
||||||
|
hf.notifyUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_headlinesActionMode = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
|
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.headlines_action_menu, menu);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||||
|
onOptionsItemSelected(item);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
m_prefs = PreferenceManager
|
m_prefs = PreferenceManager
|
||||||
@ -78,6 +121,10 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
m_unreadArticlesOnly = savedInstanceState.getBoolean("unreadArticlesOnly");
|
m_unreadArticlesOnly = savedInstanceState.getBoolean("unreadArticlesOnly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isCompatMode()) {
|
||||||
|
m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(TAG, "m_sessionId=" + m_sessionId);
|
Log.d(TAG, "m_sessionId=" + m_sessionId);
|
||||||
Log.d(TAG, "m_apiLevel=" + m_apiLevel);
|
Log.d(TAG, "m_apiLevel=" + m_apiLevel);
|
||||||
|
|
||||||
@ -774,6 +821,16 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isCompatMode()) {
|
if (!isCompatMode()) {
|
||||||
|
HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
|
if (hf != null) {
|
||||||
|
if (hf.getSelectedArticles().size() > 0 && m_headlinesActionMode == null) {
|
||||||
|
m_headlinesActionMode = startActionMode(m_headlinesActionModeCallback);
|
||||||
|
} else if (hf.getSelectedArticles().size() == 0 && m_headlinesActionMode != null) {
|
||||||
|
m_headlinesActionMode.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SearchView searchView = (SearchView) search.getActionView();
|
SearchView searchView = (SearchView) search.getActionView();
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
private String query = "";
|
private String query = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user