Adding go back and refresh to the possible actions.
This commit is contained in:
parent
7b162d0e58
commit
d51ff34751
@ -39,4 +39,6 @@ dependencies {
|
|||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
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")
|
||||||
|
|
||||||
}
|
}
|
Binary file not shown.
@ -2,6 +2,10 @@ package info.burguillos.bi;
|
|||||||
|
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
@ -9,15 +13,39 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private WebView webView;
|
||||||
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
private ViewTreeObserver.OnScrollChangedListener mOnScrollChangedListener;
|
||||||
|
boolean isReloading = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
WebView webView = findViewById(R.id.web);
|
webView = findViewById(R.id.web);
|
||||||
|
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||||
|
|
||||||
|
swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
Log.w("BurguillosInfo", "hola");
|
||||||
|
webView.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
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) {
|
||||||
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
|
swipeRefreshLayout.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPageStarted(WebView view, String url) {
|
||||||
|
swipeRefreshLayout.setEnabled(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,11 +6,23 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/swipeContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/nonVideoLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:windowSoftInputMode="adjustResize">
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/web"
|
android:id="@+id/web"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:layout_editor_absoluteX="8dp"
|
tools:layout_editor_absoluteX="8dp"
|
||||||
tools:layout_editor_absoluteY="8dp" />
|
tools:layout_editor_absoluteY="8dp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">b_info_android</string>
|
<string name="app_name">Burguillos.info</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user