Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/PojavLauncher
Path: blob/v3_openjdk/app_pojavlauncher/src/main/java/com/kdt/DefocusableScrollView.java
2129 views
1
package com.kdt;
2
3
import android.content.Context;
4
import android.graphics.Rect;
5
import android.util.AttributeSet;
6
import android.widget.ScrollView;
7
8
/**
9
Class allowing to ignore the focusing from an item such an EditText within it.
10
Ignoring it will stop the scrollView from refocusing on the view
11
*/
12
public class DefocusableScrollView extends ScrollView {
13
14
15
16
private boolean mKeepFocusing = false;
17
18
19
public DefocusableScrollView(Context context) {
20
super(context);
21
}
22
23
public DefocusableScrollView(Context context, AttributeSet attrs) {
24
super(context, attrs);
25
}
26
27
public DefocusableScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
28
super(context, attrs, defStyleAttr);
29
}
30
31
public DefocusableScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
32
super(context, attrs, defStyleAttr, defStyleRes);
33
}
34
35
public void setKeepFocusing(boolean shouldKeepFocusing){
36
mKeepFocusing = shouldKeepFocusing;
37
}
38
39
public boolean isKeepFocusing(){
40
return mKeepFocusing;
41
}
42
43
@Override
44
protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
45
if(!mKeepFocusing) return 0;
46
return super.computeScrollDeltaToGetChildRectOnScreen(rect);
47
}
48
49
50
}
51
52