restart on some more headlines-related prefs

prevent swipe on footers
This commit is contained in:
Andrew Dolgov 2017-06-01 19:21:54 +03:00
parent e8fe00eecd
commit 5d3f580de4
2 changed files with 19 additions and 13 deletions

View File

@ -236,7 +236,8 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d(TAG, "onSharedPreferenceChanged:" + key); Log.d(TAG, "onSharedPreferenceChanged:" + key);
String[] filter = new String[] { "theme", "enable_cats", "headline_mode", "widget_update_interval" }; String[] filter = new String[] { "theme", "enable_cats", "headline_mode", "widget_update_interval",
"headlines_swipe_to_dismiss", "headlines_mark_read_scroll" };
m_needRestart = Arrays.asList(filter).indexOf(key) != -1; m_needRestart = Arrays.asList(filter).indexOf(key) != -1;
} }

View File

@ -350,6 +350,19 @@ public class HeadlinesFragment extends Fragment {
return false; return false;
} }
@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
int position = viewHolder.getAdapterPosition() - m_adapter.getHeaderCount();
Article article = getArticleAtPosition(position);
if (article == null)
return 0;
return super.getSwipeDirs(recyclerView, viewHolder);
}
@Override @Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
@ -455,7 +468,7 @@ public class HeadlinesFragment extends Fragment {
if (firstVisibleItem <= m_articles.size() + m_adapter.getHeaderCount()) { if (firstVisibleItem <= m_articles.size() + m_adapter.getHeaderCount()) {
Article a = (Article) m_articles.get(firstVisibleItem - m_adapter.getHeaderCount() - 1); Article a = getArticleAtPosition(firstVisibleItem - m_adapter.getHeaderCount() - 1);
if (a != null && a.unread) { if (a != null && a.unread) {
Log.d(TAG, "title=" + a.title); Log.d(TAG, "title=" + a.title);
@ -835,16 +848,6 @@ public class HeadlinesFragment extends Fragment {
final Article article = holder.article; final Article article = holder.article;
//holder.position = position;
/*holder.view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
m_activity.openContextMenu(v);
return false;
}
});*/
holder.view.setOnClickListener(new OnClickListener() { holder.view.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -1611,7 +1614,9 @@ public class HeadlinesFragment extends Fragment {
public Article getArticleAtPosition(int position) { public Article getArticleAtPosition(int position) {
try { try {
return m_articles.get(position); return m_articles.get(position);
} catch (ArrayIndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }