Fixes tunnel listing in landscape mode bot not in portrait mode
This commit is contained in:
@ -64,6 +64,8 @@ public class TunnelListFragment extends Fragment implements
|
||||
private TunnelEntryAdapter mAdapter;
|
||||
private boolean mClientTunnels;
|
||||
|
||||
private static final String KEY_SELECTED_TUNNEL = "selected_tunnel";
|
||||
|
||||
// Container Activity must implement this interface
|
||||
public interface OnTunnelSelectedListener {
|
||||
void onTunnelSelected(int tunnelId, Pair<View, String>[] pairs);
|
||||
@ -107,6 +109,12 @@ public class TunnelListFragment extends Fragment implements
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
int tunnelId = savedInstanceState.getInt(KEY_SELECTED_TUNNEL, -1);
|
||||
if (tunnelId != -1) {
|
||||
mCallback.onTunnelSelected(tunnelId, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,8 @@ import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.core.util.Pair;
|
||||
//import android.support.v4.view.ViewPager;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@ -293,9 +295,14 @@ public class TunnelsContainer extends Fragment implements
|
||||
// In two-pane mode, show the detail view in this activity by
|
||||
// adding or replacing the detail fragment using a
|
||||
// fragment transaction.
|
||||
try {
|
||||
TunnelDetailFragment detailFrag = TunnelDetailFragment.newInstance(tunnelId);
|
||||
getChildFragmentManager().beginTransaction()
|
||||
.replace(R.id.detail_fragment, detailFrag).commit();
|
||||
.replace(R.id.detail_fragment, detailFrag)
|
||||
.commitNow(); // Use commitNow() to execute synchronously
|
||||
} catch (Exception e) {
|
||||
Log.e("TunnelsContainer", "Failed to update detail fragment", e);
|
||||
}
|
||||
} else {
|
||||
// In single-pane mode, simply start the detail activity
|
||||
// for the selected item ID.
|
||||
|
Reference in New Issue
Block a user