fix: 修复从通知栏进入消息界面不自动刷新
This commit is contained in:
parent
2ca8738ecc
commit
6139788b52
|
|
@ -37,7 +37,8 @@ public class MessageActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
getSupportFragmentManager().beginTransaction()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -40,19 +40,26 @@ public class MessageFragment extends BaseFragment implements View.OnClickListene
|
||||||
public static final String TAG = MessageFragment.class.getSimpleName();
|
public static final String TAG = MessageFragment.class.getSimpleName();
|
||||||
|
|
||||||
private static final String PARAM_TYPE = "type";
|
private static final String PARAM_TYPE = "type";
|
||||||
|
public static final String PARAM_FROM_NOTIFICATION = "from_notification";
|
||||||
@BindView(R.id.fragment_message_tab)
|
@BindView(R.id.fragment_message_tab)
|
||||||
TabLayout tabLayout;
|
TabLayout tabLayout;
|
||||||
private MessageListHelper replyMe;
|
private MessageListHelper replyMe;
|
||||||
private MessageListHelper atMe;
|
private MessageListHelper atMe;
|
||||||
private int type;
|
private int type;
|
||||||
|
private boolean isFromNotification;
|
||||||
|
|
||||||
public MessageFragment() {
|
public MessageFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageFragment newInstance(int type) {
|
public static MessageFragment newInstance(int type) {
|
||||||
|
return newInstance(type, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageFragment newInstance(int type, boolean isFromNotification) {
|
||||||
MessageFragment fragment = new MessageFragment();
|
MessageFragment fragment = new MessageFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putInt(PARAM_TYPE, type);
|
bundle.putInt(PARAM_TYPE, type);
|
||||||
|
bundle.putBoolean(PARAM_FROM_NOTIFICATION, isFromNotification);
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
@ -79,6 +86,7 @@ public class MessageFragment extends BaseFragment implements View.OnClickListene
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
type = args.getInt(PARAM_TYPE, TYPE_REPLY_ME);
|
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.setupWithViewPager(viewPager);
|
||||||
tabLayout.addOnTabSelectedListener(this);
|
tabLayout.addOnTabSelectedListener(this);
|
||||||
viewPager.setCurrentItem(type, false);
|
viewPager.setCurrentItem(type, false);
|
||||||
|
if (isFromNotification) {
|
||||||
|
refreshIfNeed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue