Skip to content

Commit c2720b7

Browse files
committed
Revision 4
Added recommended changes 1. Added constructor to IterableInboxFragment. Now setArguments wont overwrite arguments set by newInstance method. 2. Removed `this` while referencing global variable
1 parent 5a24d19 commit c2720b7

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/inbox/IterableInboxActivity.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import androidx.annotation.Nullable;
66
import androidx.appcompat.app.AppCompatActivity;
77

8+
import com.iterable.iterableapi.IterableConstants;
89
import com.iterable.iterableapi.IterableLogger;
910
import com.iterable.iterableapi.ui.R;
1011

@@ -37,8 +38,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3738
if (inboxModeExtra instanceof InboxMode) {
3839
inboxMode = (InboxMode) inboxModeExtra;
3940
}
40-
inboxFragment = IterableInboxFragment.newInstance(inboxMode, itemLayoutId);
41-
inboxFragment.setArguments(intent.getExtras());
41+
String noMessageTitle = "";
42+
String noMessageBody = "";
43+
Bundle extraBundle = getIntent().getExtras();
44+
if (extraBundle != null) {
45+
noMessageTitle = extraBundle.getString(IterableConstants.NO_MESSAGES_TITLE, "");
46+
noMessageBody = extraBundle.getString(IterableConstants.NO_MESSAGES_BODY, "");
47+
}
48+
inboxFragment = IterableInboxFragment.newInstance(inboxMode, itemLayoutId, noMessageTitle, noMessageBody);
4249

4350
if (intent.getStringExtra(ACTIVITY_TITLE) != null) {
4451
setTitle(intent.getStringExtra(ACTIVITY_TITLE));

iterableapi-ui/src/main/java/com/iterable/iterableapi/ui/inbox/IterableInboxFragment.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,16 @@ public class IterableInboxFragment extends Fragment implements IterableInAppMana
8080
* @return {@link IterableInboxFragment} instance
8181
*/
8282
@NonNull public static IterableInboxFragment newInstance(@NonNull InboxMode inboxMode, @LayoutRes int itemLayoutId) {
83+
return newInstance(inboxMode, itemLayoutId, "", "");
84+
}
85+
86+
@NonNull public static IterableInboxFragment newInstance(@NonNull InboxMode inboxMode, @LayoutRes int itemLayoutId, String noMessagesTitle, String noMessagesBody) {
8387
IterableInboxFragment inboxFragment = new IterableInboxFragment();
8488
Bundle bundle = new Bundle();
8589
bundle.putSerializable(INBOX_MODE, inboxMode);
8690
bundle.putInt(ITEM_LAYOUT_ID, itemLayoutId);
91+
bundle.putString(IterableConstants.NO_MESSAGES_TITLE, noMessagesTitle);
92+
bundle.putString(IterableConstants.NO_MESSAGES_BODY, noMessagesBody);
8793
inboxFragment.setArguments(bundle);
8894

8995
return inboxFragment;
@@ -162,10 +168,10 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
162168
itemLayoutId = arguments.getInt(ITEM_LAYOUT_ID);
163169
}
164170
if (arguments.getString(IterableConstants.NO_MESSAGES_TITLE) != null) {
165-
this.noMessagesTitle = arguments.getString(IterableConstants.NO_MESSAGES_TITLE);
171+
noMessagesTitle = arguments.getString(IterableConstants.NO_MESSAGES_TITLE);
166172
}
167173
if (arguments.getString(IterableConstants.NO_MESSAGES_BODY) != null) {
168-
this.noMessagesBody = arguments.getString(IterableConstants.NO_MESSAGES_BODY);
174+
noMessagesBody = arguments.getString(IterableConstants.NO_MESSAGES_BODY);
169175
}
170176
}
171177

0 commit comments

Comments
 (0)