Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
fix: 修复从通知栏进入消息界面不自动刷新
Browse files Browse the repository at this point in the history
  • Loading branch information
HuanCheng65 committed Jul 16, 2020
1 parent 2ca8738 commit 6139788
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ protected void onCreate(Bundle savedInstanceState) {
}
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.activity_message_list_content, MessageFragment.newInstance(getIntent().getIntExtra("type", MessageFragment.TYPE_REPLY_ME)), MessageFragment.class.getSimpleName()).commit();
.replace(R.id.activity_message_list_content,
MessageFragment.newInstance(getIntent().getIntExtra("type", MessageFragment.TYPE_REPLY_ME), true), MessageFragment.class.getSimpleName()).commit();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,26 @@ public class MessageFragment extends BaseFragment implements View.OnClickListene
public static final String TAG = MessageFragment.class.getSimpleName();

private static final String PARAM_TYPE = "type";
public static final String PARAM_FROM_NOTIFICATION = "from_notification";
@BindView(R.id.fragment_message_tab)
TabLayout tabLayout;
private MessageListHelper replyMe;
private MessageListHelper atMe;
private int type;
private boolean isFromNotification;

public MessageFragment() {
}

public static MessageFragment newInstance(int type) {
return newInstance(type, false);
}

public static MessageFragment newInstance(int type, boolean isFromNotification) {
MessageFragment fragment = new MessageFragment();
Bundle bundle = new Bundle();
bundle.putInt(PARAM_TYPE, type);
bundle.putBoolean(PARAM_FROM_NOTIFICATION, isFromNotification);
fragment.setArguments(bundle);
return fragment;
}
Expand All @@ -79,6 +86,7 @@ public void onCreate(Bundle savedInstanceState) {
Bundle args = getArguments();
if (args != null) {
type = args.getInt(PARAM_TYPE, TYPE_REPLY_ME);
isFromNotification = args.getBoolean(PARAM_FROM_NOTIFICATION, false);
}
}

Expand Down Expand Up @@ -107,6 +115,9 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
tabLayout.setupWithViewPager(viewPager);
tabLayout.addOnTabSelectedListener(this);
viewPager.setCurrentItem(type, false);
if (isFromNotification) {
refreshIfNeed();
}
}

@Override
Expand Down

0 comments on commit 6139788

Please sign in to comment.