diff options
author | Andrew Dolgov <[email protected]> | 2015-11-27 10:36:53 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-11-27 10:36:53 +0300 |
commit | b28fef66e85854172103114c15f1722ad6375dea (patch) | |
tree | fb5546b000c8ee95b5f945c65653b272a8105925 /org.fox.ttrss/src/main/java | |
parent | a5e6452f978b2212234c6b48d31ed171c1a657b6 (diff) |
switch to nestedscrollview provided by v4 support library
Diffstat (limited to 'org.fox.ttrss/src/main/java')
4 files changed, 21 insertions, 64 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java index 98d721f2..993c7fd9 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java @@ -9,6 +9,7 @@ import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; +import android.support.v4.widget.NestedScrollView; import android.support.v7.app.ActionBar; import android.text.Html; import android.util.Log; @@ -27,14 +28,13 @@ import android.webkit.WebView.HitTestResult; import android.webkit.WebViewClient; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.ScrollView; import android.widget.TextView; import com.shamanland.fab.ShowHideOnScroll; import org.fox.ttrss.types.Article; import org.fox.ttrss.types.Attachment; -import org.fox.ttrss.util.NotifyingScrollView; +import org.fox.ttrss.util.NoChildFocusScrollView; import java.net.MalformedURLException; import java.net.URI; @@ -194,15 +194,15 @@ public class ArticleFragment extends Fragment { return view; } - NotifyingScrollView scrollView = (NotifyingScrollView) view.findViewById(R.id.article_scrollview); + NoChildFocusScrollView scrollView = (NoChildFocusScrollView) view.findViewById(R.id.article_scrollview); m_fab = view.findViewById(R.id.article_fab); if (scrollView != null && m_activity.isSmallScreen()) { view.findViewById(R.id.article_heading_spacer).setVisibility(View.VISIBLE); - scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { + scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() { @Override - public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { + public void onScrollChange(NestedScrollView who, int l, int t, int oldl, int oldt) { ActionBar ab = m_activity.getSupportActionBar(); if (t >= oldt && t >= ab.getHeight()) { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java index 9ec060a0..1e699e5e 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -10,6 +10,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.provider.BaseColumns; import android.support.v4.app.Fragment; +import android.support.v4.widget.NestedScrollView; import android.support.v7.app.ActionBar; import android.util.Log; import android.util.TypedValue; @@ -32,7 +33,7 @@ import com.shamanland.fab.ShowHideOnScroll; import org.fox.ttrss.R; import org.fox.ttrss.util.ImageCacheService; -import org.fox.ttrss.util.NotifyingScrollView; +import org.fox.ttrss.util.NoChildFocusScrollView; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -135,25 +136,25 @@ public class OfflineArticleFragment extends Fragment { if (m_cursor.isFirst()) { final String link = m_cursor.getString(m_cursor.getColumnIndex("link")); - NotifyingScrollView scrollView = (NotifyingScrollView) view.findViewById(R.id.article_scrollview); + NoChildFocusScrollView scrollView = (NoChildFocusScrollView) view.findViewById(R.id.article_scrollview); View fab = view.findViewById(R.id.article_fab); if (scrollView != null && m_activity.isSmallScreen()) { view.findViewById(R.id.article_heading_spacer).setVisibility(View.VISIBLE); - scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { - @Override - public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { - ActionBar ab = m_activity.getSupportActionBar(); + scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() { + @Override + public void onScrollChange(NestedScrollView who, int l, int t, int oldl, int oldt) { + ActionBar ab = m_activity.getSupportActionBar(); - if (t >= oldt && t >= ab.getHeight()) { - ab.hide(); - } else if (t <= ab.getHeight() || oldt - t >= 10) { - ab.show(); - } + if (t >= oldt && t >= ab.getHeight()) { + ab.hide(); + } else if (t <= ab.getHeight() || oldt - t >= 10) { + ab.show(); + } - } - }); + } + }); } if (scrollView != null && fab != null) { diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/util/NoChildFocusScrollView.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/util/NoChildFocusScrollView.java index 5e5c8c48..af0454fa 100644..100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/util/NoChildFocusScrollView.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/util/NoChildFocusScrollView.java @@ -1,12 +1,13 @@ package org.fox.ttrss.util; import android.content.Context; +import android.support.v4.widget.NestedScrollView; import android.util.AttributeSet; import android.view.View; import android.webkit.WebView; import android.widget.ScrollView; -public class NoChildFocusScrollView extends NotifyingScrollView { +public class NoChildFocusScrollView extends NestedScrollView { public NoChildFocusScrollView(Context context) { super(context); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/util/NotifyingScrollView.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/util/NotifyingScrollView.java deleted file mode 100644 index e128856f..00000000 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/util/NotifyingScrollView.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.fox.ttrss.util; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.ScrollView; - -/** - * @author Cyril Mottier - */ -public class NotifyingScrollView extends ScrollView { - - /** - * @author Cyril Mottier - */ - public interface OnScrollChangedListener { - void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt); - } - - private OnScrollChangedListener mOnScrollChangedListener; - - public NotifyingScrollView(Context context) { - super(context); - } - - public NotifyingScrollView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public NotifyingScrollView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onScrollChanged(int l, int t, int oldl, int oldt) { - super.onScrollChanged(l, t, oldl, oldt); - if (mOnScrollChangedListener != null) { - mOnScrollChangedListener.onScrollChanged(this, l, t, oldl, oldt); - } - } - - public void setOnScrollChangedListener(OnScrollChangedListener listener) { - mOnScrollChangedListener = listener; - } - -}
\ No newline at end of file |