ProfileFragment: Make good use of the cached profile
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.wireguard.android.databinding.ProfileDetailFragmentBinding;
|
||||
import com.wireguard.config.Profile;
|
||||
|
||||
/**
|
||||
* Fragment for viewing information about a WireGuard profile.
|
||||
@@ -16,6 +17,12 @@ import com.wireguard.android.databinding.ProfileDetailFragmentBinding;
|
||||
public class ProfileDetailFragment extends ProfileFragment {
|
||||
private ProfileDetailFragmentBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCachedProfileChanged(Profile cachedProfile) {
|
||||
if (binding != null)
|
||||
binding.setProfile(cachedProfile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -33,17 +40,4 @@ public class ProfileDetailFragment extends ProfileFragment {
|
||||
binding.setProfile(getCachedProfile());
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ProfileServiceInterface service) {
|
||||
super.onServiceConnected(service);
|
||||
binding.setProfile(service.getProfiles().get(getProfile()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfile(String profile) {
|
||||
super.setProfile(profile);
|
||||
if (binding != null)
|
||||
binding.setProfile(getCachedProfile());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user