mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Fixing fragment instance restore
This commit is contained in:
@@ -12,6 +12,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
import org.briarproject.android.contact.ContactListAdapter;
|
||||
import org.briarproject.android.contact.ContactListItem;
|
||||
import org.briarproject.android.contact.ConversationItem;
|
||||
@@ -66,9 +67,13 @@ public class ContactChooserFragment extends BaseFragment {
|
||||
@Inject
|
||||
protected volatile ConnectionRegistry connectionRegistry;
|
||||
|
||||
@Inject
|
||||
public ContactChooserFragment() {
|
||||
|
||||
public static ContactChooserFragment newInstance() {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
|
||||
ContactChooserFragment fragment = new ContactChooserFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,6 +147,11 @@ public class ContactChooserFragment extends BaseFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectFragment(ActivityComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void loadContacts() {
|
||||
introductionActivity.runOnDbThread(new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.fragment.BaseFragment;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
|
||||
// TODO extend the BriarFragmentActivity ?
|
||||
public class IntroductionActivity extends BriarActivity implements
|
||||
BaseFragment.BaseFragmentListener {
|
||||
|
||||
@@ -37,7 +38,7 @@ public class IntroductionActivity extends BriarActivity implements
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.introductionContainer,
|
||||
activityComponent.newContactChooserFragment())
|
||||
ContactChooserFragment.newInstance())
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
@@ -57,6 +58,11 @@ public class IntroductionActivity extends BriarActivity implements
|
||||
// this is handled by the recycler view in ContactChooserFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentCreated(String tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
// Handle presses on the action bar items
|
||||
@@ -86,8 +92,8 @@ public class IntroductionActivity extends BriarActivity implements
|
||||
public void showMessageScreen(View view, Contact c1, Contact c2) {
|
||||
|
||||
IntroductionMessageFragment messageFragment =
|
||||
activityComponent.newIntroductionMessageFragment();
|
||||
messageFragment.initBundle(c1.getId().getInt(), c2.getId().getInt());
|
||||
IntroductionMessageFragment
|
||||
.newInstance(c1.getId().getInt(), c2.getId().getInt());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
messageFragment.setSharedElementEnterTransition(new ChangeBounds());
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
import org.briarproject.android.fragment.BaseFragment;
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
@@ -51,19 +52,21 @@ public class IntroductionMessageFragment extends BaseFragment {
|
||||
@Inject
|
||||
protected volatile IntroductionManager introductionManager;
|
||||
|
||||
public void initBundle(int contactId1, int contactId2) {
|
||||
public static IntroductionMessageFragment newInstance(int contactId1, int contactId2) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(CONTACT_ID_1, contactId1);
|
||||
args.putInt(CONTACT_ID_2, contactId2);
|
||||
setArguments(args);
|
||||
IntroductionMessageFragment fragment =
|
||||
new IntroductionMessageFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public IntroductionMessageFragment() {
|
||||
|
||||
@Override
|
||||
public void injectFragment(ActivityComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
@@ -94,6 +97,13 @@ public class IntroductionMessageFragment extends BaseFragment {
|
||||
ui.text.setVisibility(GONE);
|
||||
ui.button.setEnabled(false);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
// get contact IDs from fragment arguments
|
||||
int contactId1 = getArguments().getInt(CONTACT_ID_1, -1);
|
||||
int contactId2 = getArguments().getInt(CONTACT_ID_2, -1);
|
||||
@@ -101,11 +111,8 @@ public class IntroductionMessageFragment extends BaseFragment {
|
||||
throw new java.lang.InstantiationError(
|
||||
"You need to use newInstance() to instantiate");
|
||||
}
|
||||
|
||||
// get contacts and then show view
|
||||
prepareToSetUpViews(contactId1, contactId2);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user