If you think the Android project turbo-editor listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2014 Vlad Mihalachi/*fromwww.java2s.com*/
*
* This file is part of Turbo Editor.
*
* Turbo Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Turbo Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/package sharedcode.turboeditor.views;
import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;
publicclass GoodScrollView extends ScrollView {
public ScrollInterface scrollInterface;
int lastY;
boolean listenerEnabled = true;
public GoodScrollView(Context context) {
super(context);
}
public GoodScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public GoodScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
publicvoid setScrollInterface(ScrollInterface scrollInterface) {
this.scrollInterface = scrollInterface;
}
@Override
protectedvoid onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (scrollInterface == null || !listenerEnabled) return;
if (Math.abs(lastY - t) > 100) {
lastY = t;
scrollInterface.onScrollChanged(l, t, oldl, oldt);
}
}
publicboolean hasReachedBottom() {
View firstChild = getChildAt(getChildCount() - 1);
int diff = (firstChild.getBottom() - (getHeight() + getScrollY() + firstChild.getTop()));// Calculate the scrolldiff
return diff <= 0;
}
publicvoid tempDisableListener(int mills) {
listenerEnabled = false;
new Handler().postDelayed(new Runnable() {
@Override
publicvoid run() {
listenerEnabled = true;
}
}, mills);
}
publicinterface ScrollInterface {
publicvoid onScrollChanged(int l, int t, int oldl, int oldt);
}
}