Skip to content

Commit

Permalink
Fix several fragment issues (fix #878)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Dec 11, 2016
1 parent ad12ab9 commit 39c420c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
21 changes: 6 additions & 15 deletions app/src/main/java/org/kontalk/ui/AbstractComposeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ public int getValue() {
/** The thread id. */
private long threadId = -1;
protected Conversation mConversation;
private Bundle mArguments;
protected String mUserName;

/** Available resources. */
Expand Down Expand Up @@ -241,7 +240,7 @@ private static AbstractComposeFragment fromConversation(Context context,
args.putString("action", ComposeMessage.ACTION_VIEW_CONVERSATION);
args.putParcelable("data",
ContentUris.withAppendedId(Conversations.CONTENT_URI, threadId));
f.setMyArguments(args);
f.setArguments(args);
return f;
}

Expand Down Expand Up @@ -1095,7 +1094,7 @@ private void scrollToPosition(int position) {
}

private boolean isSearching() {
Bundle args = myArguments();
Bundle args = getArguments();
return args != null && args.getLong(ComposeMessage.EXTRA_MESSAGE, -1) >= 0;
}

Expand Down Expand Up @@ -1172,14 +1171,6 @@ protected void loadConversationMetadata(Uri uri) {
}
}

private Bundle myArguments() {
return (mArguments != null) ? mArguments : getArguments();
}

public void setMyArguments(Bundle args) {
mArguments = args;
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// image from storage/picture from camera
Expand Down Expand Up @@ -1372,7 +1363,7 @@ private void processArguments(Bundle savedInstanceState) {
}
}
else {
args = myArguments();
args = getArguments();
}

if (args != null && args.size() > 0) {
Expand All @@ -1398,7 +1389,7 @@ else if (ComposeMessage.ACTION_VIEW_USERID.equals(action)) {
}

// set title if we are autonomous
if (mArguments != null) {
if (args != null) {
String title = mUserName;
//if (mUserPhone != null) title += " <" + mUserPhone + ">";
setActivityTitle(title, "");
Expand Down Expand Up @@ -1452,7 +1443,7 @@ private void processStart(boolean resuming) {

if (mListAdapter == null) {
Pattern highlight = null;
Bundle args = myArguments();
Bundle args = getArguments();
if (args != null) {
String highlightString = args
.getString(ComposeMessage.EXTRA_HIGHLIGHT);
Expand Down Expand Up @@ -2270,7 +2261,7 @@ protected synchronized void onQueryComplete(int token, Object cookie, Cursor cur
}

// save reloading status for next time
Bundle args = parent.myArguments();
Bundle args = parent.getArguments();

// see if we have to scroll to a specific message
int newSelectionPos = -1;
Expand Down
17 changes: 12 additions & 5 deletions app/src/main/java/org/kontalk/ui/ComposeMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,17 @@ protected void onCreate(Bundle savedInstanceState) {

setupActionBar();

// build chat fragment
AbstractComposeFragment f = getComposeFragment(savedInstanceState);
// insert it into the activity
setComposeFragment(f);
if (savedInstanceState != null) {
mFragment = (AbstractComposeFragment) getSupportFragmentManager()
.findFragmentById(R.id.fragment_compose_message);
}

if (mFragment == null) {
// build chat fragment
AbstractComposeFragment f = getComposeFragment(savedInstanceState);
// insert it into the activity
setComposeFragment(f);
}
}

private void setupActionBar() {
Expand Down Expand Up @@ -227,7 +234,7 @@ else if (ACTION_VIEW_USERID.equals(action)) {
f = new ComposeMessageFragment();
}

f.setMyArguments(args);
f.setArguments(args);
return f;
}

Expand Down

0 comments on commit 39c420c

Please sign in to comment.