mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Prevent WebView from reloading the website after orientation change in WebViewActivity.
This commit is contained in:
parent
b4915859da
commit
59ed4c53ff
@ -76,7 +76,8 @@
|
|||||||
android:name=".activities.WebViewActivity"
|
android:name=".activities.WebViewActivity"
|
||||||
android:label=""
|
android:label=""
|
||||||
android:parentActivityName=".activities.MainActivity"
|
android:parentActivityName=".activities.MainActivity"
|
||||||
android:theme="@style/AppTheme.NoActionBar" />
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
android:configChanges="orientation|screenSize" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.SuicidePreventionActivity"
|
android:name=".activities.SuicidePreventionActivity"
|
||||||
android:parentActivityName=".activities.MainActivity"
|
android:parentActivityName=".activities.MainActivity"
|
||||||
|
@ -19,6 +19,7 @@ import android.webkit.WebView;
|
|||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
@ -79,8 +80,10 @@ public class WebViewActivity extends BaseActivity {
|
|||||||
webView.getSettings().setDomStorageEnabled(true);
|
webView.getSettings().setDomStorageEnabled(true);
|
||||||
|
|
||||||
url = getIntent().getDataString();
|
url = getIntent().getDataString();
|
||||||
toolbar.setTitle(url);
|
if (savedInstanceState == null) {
|
||||||
webView.loadUrl(url);
|
toolbar.setTitle(url);
|
||||||
|
webView.loadUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
WebViewClient client = new WebViewClient() {
|
WebViewClient client = new WebViewClient() {
|
||||||
@Override
|
@Override
|
||||||
@ -177,4 +180,16 @@ public class WebViewActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
webView.saveState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
||||||
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
|
webView.restoreState(savedInstanceState);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user