Fixing bug, refresh was being made always swiping down.
That is really bad.
This commit is contained in:
parent
d51ff34751
commit
f6108d809c
@ -32,6 +32,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val core_version = "1.10.1"
|
||||
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
implementation("com.google.android.material:material:1.8.0")
|
||||
@ -40,5 +41,6 @@ dependencies {
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||
|
||||
}
|
||||
|
Binary file not shown.
@ -5,7 +5,10 @@ import android.webkit.WebViewClient;
|
||||
import android.util.Log;
|
||||
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.MotionEvent;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@ -15,8 +18,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private WebView webView;
|
||||
private SwipeRefreshLayout swipeRefreshLayout;
|
||||
private ViewTreeObserver.OnScrollChangedListener mOnScrollChangedListener;
|
||||
boolean isReloading = true;
|
||||
private RelativeLayout relativeLayout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -25,25 +27,39 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
webView = findViewById(R.id.web);
|
||||
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||
relativeLayout = findViewById(R.id.relative);
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
Log.w("BurguillosInfo", "hola");
|
||||
webView.reload();
|
||||
}
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
webView.reload();
|
||||
}
|
||||
});
|
||||
|
||||
webView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
final int action = event.getAction() & MotionEvent.ACTION_MASK;
|
||||
if (action != MotionEvent.ACTION_DOWN) {
|
||||
return false;
|
||||
}
|
||||
if (event.getY() > 70) {
|
||||
swipeRefreshLayout.setEnabled(false);
|
||||
return false;
|
||||
}
|
||||
swipeRefreshLayout.setEnabled(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
webView.loadUrl("https://burguillos.info");
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
swipeRefreshLayout.setEnabled(true);
|
||||
}
|
||||
|
||||
public void onPageStarted(WebView view, String url) {
|
||||
swipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
<RelativeLayout
|
||||
android:id="@+id/nonVideoLayout"
|
||||
android:id="@+id/relative"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
@ -23,6 +23,6 @@
|
||||
tools:layout_editor_absoluteX="8dp"
|
||||
tools:layout_editor_absoluteY="8dp" />
|
||||
</RelativeLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user