fix: 修复从通知栏进入消息界面不自动刷新

This commit is contained in:
HuanChengFly 2020-07-16 16:12:43 +08:00
parent 2ca8738ecc
commit 6139788b52
2 changed files with 13 additions and 1 deletions

View File

@ -37,7 +37,8 @@ public class MessageActivity extends BaseActivity {
}
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();
}
}
}

View File

@ -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;
}
@ -79,6 +86,7 @@ public class MessageFragment extends BaseFragment implements View.OnClickListene
Bundle args = getArguments();
if (args != null) {
type = args.getInt(PARAM_TYPE, TYPE_REPLY_ME);
isFromNotification = args.getBoolean(PARAM_FROM_NOTIFICATION, false);
}
}
@ -107,6 +115,9 @@ public class MessageFragment extends BaseFragment implements View.OnClickListene
tabLayout.setupWithViewPager(viewPager);
tabLayout.addOnTabSelectedListener(this);
viewPager.setCurrentItem(type, false);
if (isFromNotification) {
refreshIfNeed();
}
}
@Override