switch to nestedscrollview provided by v4 support library

This commit is contained in:
Andrew Dolgov 2015-11-27 10:36:53 +03:00
parent a5e6452f97
commit b28fef66e8
5 changed files with 23 additions and 66 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss"
android:versionCode="380"
android:versionName="1.152" >
android:versionCode="381"
android:versionName="1.153" >
<uses-sdk
android:minSdkVersion="15"

View File

@ -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()) {

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}
}