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 {
|
dependencies {
|
||||||
|
val core_version = "1.10.1"
|
||||||
|
|
||||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||||
implementation("com.google.android.material:material:1.8.0")
|
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.ext:junit:1.1.5")
|
||||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
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.util.Log;
|
||||||
|
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
@ -15,8 +18,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
private SwipeRefreshLayout swipeRefreshLayout;
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
private ViewTreeObserver.OnScrollChangedListener mOnScrollChangedListener;
|
private RelativeLayout relativeLayout;
|
||||||
boolean isReloading = true;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -25,25 +27,39 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
webView = findViewById(R.id.web);
|
webView = findViewById(R.id.web);
|
||||||
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||||
|
relativeLayout = findViewById(R.id.relative);
|
||||||
|
|
||||||
swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() {
|
swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
Log.w("BurguillosInfo", "hola");
|
webView.reload();
|
||||||
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.loadUrl("https://burguillos.info");
|
||||||
webView.getSettings().setJavaScriptEnabled(true);
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
swipeRefreshLayout.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPageStarted(WebView view, String url) {
|
public void onPageStarted(WebView view, String url) {
|
||||||
swipeRefreshLayout.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/nonVideoLayout"
|
android:id="@+id/relative"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
@ -23,6 +23,6 @@
|
|||||||
tools:layout_editor_absoluteX="8dp"
|
tools:layout_editor_absoluteX="8dp"
|
||||||
tools:layout_editor_absoluteY="8dp" />
|
tools:layout_editor_absoluteY="8dp" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user