allow overscroll for headlines list if auto mark as read is enabled

This commit is contained in:
Andrew Dolgov 2014-10-31 13:00:54 +03:00
parent ec156b69b0
commit 436f335903
3 changed files with 53 additions and 29 deletions

View File

@ -20,11 +20,13 @@ import android.util.Log;
import android.util.TypedValue;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
@ -317,27 +319,21 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
ListView list = (ListView)view.findViewById(R.id.headlines);
if (m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
WindowManager wm = (WindowManager) m_activity.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int screenHeight = display.getHeight();
View layout = inflater.inflate(R.layout.headlines_footer, container, false);
layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, screenHeight));
list.addFooterView(layout);
}
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, (ArrayList<Article>)m_articles);
/* if (!m_activity.isCompatMode()) {
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(500);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 50.0f,Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(1000);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
list.setLayoutAnimation(controller);
} */
list.setAdapter(m_adapter);
list.setOnItemClickListener(this);
list.setOnScrollListener(this);
@ -348,11 +344,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
m_activity.setTitle(m_feed.title);
}
//m_activity.m_pullToRefreshAttacher.addRefreshableView(list, this);
//if (m_activity.isSmallScreen())
//view.findViewById(R.id.headlines_fragment).setPadding(0, 0, 0, 0);
Log.d(TAG, "onCreateView, feed=" + m_feed);
return view;
@ -399,7 +390,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (list != null) {
Article article = (Article)list.getItemAtPosition(position);
if (article.id >= 0) {
// could be footer or w/e
if (article != null && article.id >= 0) {
m_listener.onArticleSelected(article);
// only set active article when it makes sense (in HeadlinesActivity)

View File

@ -19,11 +19,13 @@ import android.util.Log;
import android.util.TypedValue;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
@ -296,7 +298,21 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
m_cursor = createCursor();
ListView list = (ListView)view.findViewById(R.id.headlines);
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_cursor,
if (m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
WindowManager wm = (WindowManager) m_activity.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int screenHeight = display.getHeight();
View layout = inflater.inflate(R.layout.headlines_footer, container, false);
layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, screenHeight));
list.addFooterView(layout);
}
m_adapter = new ArticleListAdapter(getActivity(), R.layout.headlines_row, m_cursor,
new String[] { "title" }, new int[] { R.id.title }, 0);
/* if (!m_activity.isCompatMode()) {

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headlines_footer"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<View
android:layout_gravity="top|center_horizontal"
android:layout_marginTop="10dp"
android:layout_width="128dp"
android:layout_height="1dp"
android:background="?unreadCounterBackground"/>
</FrameLayout>