-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/oppia-1667-fix-hori…
…zontal-scroll' into release-7-4-9
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/digitalcampus/oppia/utils/ui/ExtendedWebView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.digitalcampus.oppia.utils.ui; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.webkit.WebView; | ||
|
||
public class ExtendedWebView extends WebView { | ||
public ExtendedWebView(Context context) { | ||
super(context); | ||
} | ||
|
||
public ExtendedWebView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
public boolean canScrollHor(int direction) { | ||
final int offset = computeHorizontalScrollOffset(); | ||
final int range = computeHorizontalScrollRange() - computeHorizontalScrollExtent(); | ||
if (range == 0) return false; | ||
if (direction < 0) { | ||
return offset > 0; | ||
} else { | ||
return offset < range - 1; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/digitalcampus/oppia/utils/ui/WebViewPager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.digitalcampus.oppia.utils.ui; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
import androidx.viewpager.widget.ViewPager; | ||
|
||
public class WebViewPager extends ViewPager { | ||
public WebViewPager(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
} | ||
|
||
@Override | ||
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { | ||
if (v instanceof ExtendedWebView) { | ||
return ((ExtendedWebView) v).canScrollHor(-dx); | ||
} else { | ||
return super.canScroll(v, checkV, dx, x, y); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters