Commit 287fe196 authored by Aniket's avatar Aniket

fixes #648

parent d9f9adb6
......@@ -9,6 +9,7 @@ import android.support.v4.app.Fragment;
import chat.rocket.android.R;
import chat.rocket.android.fragment.server_config.LoginFragment;
import chat.rocket.android.fragment.server_config.RetryLoginFragment;
import chat.rocket.android.helper.BackStackHelper;
import chat.rocket.android.service.ConnectivityManager;
import chat.rocket.core.interactors.SessionInteractor;
import chat.rocket.persistence.realm.repositories.RealmSessionRepository;
......@@ -93,10 +94,15 @@ public class LoginActivity extends AbstractFragmentActivity implements LoginCont
@Override
protected boolean onBackPress() {
LoginFragment loginFragment = (LoginFragment) getSupportFragmentManager()
.findFragmentById(getLayoutContainerForFragment());
Context loginActivityContext = this;
loginFragment.goBack(loginActivityContext);
if (BackStackHelper.FRAGMENT_TAG.equals("internal")) {
super.onBackPress();
BackStackHelper.FRAGMENT_TAG = "login";
} else if (BackStackHelper.FRAGMENT_TAG.equals("login")) {
LoginFragment loginFragment = (LoginFragment) getSupportFragmentManager()
.findFragmentById(getLayoutContainerForFragment());
Context loginActivityContext = this;
loginFragment.goBack(loginActivityContext);
}
return true;
}
}
......@@ -6,39 +6,41 @@ import android.support.v4.app.Fragment;
import chat.rocket.android.R;
import chat.rocket.android.fragment.AbstractFragment;
import chat.rocket.android.helper.BackStackHelper;
import chat.rocket.android.helper.TextUtils;
public abstract class AbstractServerConfigFragment extends AbstractFragment {
public static final String KEY_HOSTNAME = "hostname";
public static final String KEY_HOSTNAME = "hostname";
protected String hostname;
protected String hostname;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args == null) {
finish();
return;
Bundle args = getArguments();
if (args == null) {
finish();
return;
}
hostname = args.getString(KEY_HOSTNAME);
if (TextUtils.isEmpty(hostname)) {
finish();
}
}
hostname = args.getString(KEY_HOSTNAME);
if (TextUtils.isEmpty(hostname)) {
finish();
protected void showFragment(Fragment fragment) {
getFragmentManager().beginTransaction()
.add(R.id.content, fragment)
.commit();
}
protected void showFragmentWithBackStack(Fragment fragment) {
BackStackHelper.FRAGMENT_TAG = "internal";
getFragmentManager().beginTransaction()
.add(R.id.content, fragment)
.addToBackStack(null)
.commit();
}
}
protected void showFragment(Fragment fragment) {
getFragmentManager().beginTransaction()
.add(R.id.content, fragment)
.commit();
}
protected void showFragmentWithBackStack(Fragment fragment) {
getFragmentManager().beginTransaction()
.add(R.id.content, fragment)
.addToBackStack(null)
.commit();
}
}
package chat.rocket.android.helper;
/**
* Created by whocares on 28/12/17.
*/
public class BackStackHelper {
public static String FRAGMENT_TAG = "login";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment