ConfigActivity: Inline PlaceholderFragment into the layout
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
9e36e0d9c6
commit
645e263424
@ -25,7 +25,6 @@ public class ConfigActivity extends BaseConfigActivity {
|
|||||||
private boolean isStateSaved;
|
private boolean isStateSaved;
|
||||||
private ConfigListFragment listFragment;
|
private ConfigListFragment listFragment;
|
||||||
private int mainContainer;
|
private int mainContainer;
|
||||||
private final PlaceholderFragment placeholderFragment = new PlaceholderFragment();
|
|
||||||
private boolean wasUpdateSkipped;
|
private boolean wasUpdateSkipped;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -153,34 +152,34 @@ public class ConfigActivity extends BaseConfigActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void switchToFragment(final int container, final String tag, final boolean push) {
|
private void switchToFragment(final int container, final String tag, final boolean push) {
|
||||||
final Fragment fragment;
|
|
||||||
if (tag.equals(TAG_PLACEHOLDER)) {
|
if (tag.equals(TAG_PLACEHOLDER)) {
|
||||||
fragment = placeholderFragment;
|
final Fragment oldFragment = fm.findFragmentById(container);
|
||||||
} else {
|
if (oldFragment != null)
|
||||||
final BaseConfigFragment configFragment;
|
fm.beginTransaction().remove(oldFragment).commit();
|
||||||
switch (tag) {
|
return;
|
||||||
case TAG_DETAIL:
|
|
||||||
if (detailFragment == null)
|
|
||||||
detailFragment = new ConfigDetailFragment();
|
|
||||||
configFragment = detailFragment;
|
|
||||||
break;
|
|
||||||
case TAG_EDIT:
|
|
||||||
if (editFragment == null)
|
|
||||||
editFragment = new ConfigEditFragment();
|
|
||||||
configFragment = editFragment;
|
|
||||||
break;
|
|
||||||
case TAG_LIST:
|
|
||||||
if (listFragment == null)
|
|
||||||
listFragment = new ConfigListFragment();
|
|
||||||
configFragment = listFragment;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
if (configFragment.getCurrentConfig() != getCurrentConfig())
|
|
||||||
configFragment.setCurrentConfig(getCurrentConfig());
|
|
||||||
fragment = configFragment;
|
|
||||||
}
|
}
|
||||||
|
final BaseConfigFragment fragment;
|
||||||
|
switch (tag) {
|
||||||
|
case TAG_DETAIL:
|
||||||
|
if (detailFragment == null)
|
||||||
|
detailFragment = new ConfigDetailFragment();
|
||||||
|
fragment = detailFragment;
|
||||||
|
break;
|
||||||
|
case TAG_EDIT:
|
||||||
|
if (editFragment == null)
|
||||||
|
editFragment = new ConfigEditFragment();
|
||||||
|
fragment = editFragment;
|
||||||
|
break;
|
||||||
|
case TAG_LIST:
|
||||||
|
if (listFragment == null)
|
||||||
|
listFragment = new ConfigListFragment();
|
||||||
|
fragment = listFragment;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
if (fragment.getCurrentConfig() != getCurrentConfig())
|
||||||
|
fragment.setCurrentConfig(getCurrentConfig());
|
||||||
if (fm.findFragmentById(container) != fragment) {
|
if (fm.findFragmentById(container) != fragment) {
|
||||||
final FragmentTransaction transaction = fm.beginTransaction();
|
final FragmentTransaction transaction = fm.beginTransaction();
|
||||||
if (push) {
|
if (push) {
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package com.wireguard.android;
|
|
||||||
|
|
||||||
import android.app.Fragment;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fragment that shows a placeholder message.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PlaceholderFragment extends Fragment {
|
|
||||||
@Override
|
|
||||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup parent,
|
|
||||||
final Bundle savedInstanceState) {
|
|
||||||
return inflater.inflate(R.layout.placeholder_fragment, parent, false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,5 +20,13 @@
|
|||||||
android:background="?android:attr/colorPrimary"
|
android:background="?android:attr/colorPrimary"
|
||||||
android:paddingEnd="0dp"
|
android:paddingEnd="0dp"
|
||||||
android:paddingStart="4dp"
|
android:paddingStart="4dp"
|
||||||
tools:ignore="InconsistentLayout" />
|
tools:ignore="InconsistentLayout">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/colorBackground"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/placeholder_text" />
|
||||||
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?android:attr/colorBackground"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/placeholder_text" />
|
|
Loading…
Reference in New Issue
Block a user