|
@ -133,16 +133,18 @@ public class ChatActivity extends AppCompatActivity implements View.OnClickListe
|
133
|
133
|
if (chatFragment == null) {
|
134
|
134
|
chatFragment = ChatFragment.newInstance(position - 1);
|
135
|
135
|
fragmentManager.beginTransaction().add(R.id.fragment_container, chatFragment).commit();
|
136
|
|
chatFragment.setMenuVisibility(true);
|
137
|
136
|
}
|
138
|
137
|
}
|
139
|
138
|
|
140
|
139
|
private void removeChatFragment() {
|
|
140
|
setFullScreen(false);
|
|
141
|
setStatusBarVisibility(false);
|
|
142
|
fragmentContainer.setVisibility(View.GONE);
|
141
|
143
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
142
|
144
|
if (chatFragment != null) {
|
143
|
145
|
fragmentManager.beginTransaction().remove(chatFragment).commit();
|
144
|
|
chatFragment.setMenuVisibility(false);
|
145
|
146
|
}
|
|
147
|
chatFragment = null;
|
146
|
148
|
}
|
147
|
149
|
|
148
|
150
|
/**
|
|
@ -314,6 +316,10 @@ public class ChatActivity extends AppCompatActivity implements View.OnClickListe
|
314
|
316
|
@Override
|
315
|
317
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
316
|
318
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
319
|
if (chatFragment != null) {
|
|
320
|
removeChatFragment();
|
|
321
|
return false;
|
|
322
|
}
|
317
|
323
|
if ((System.currentTimeMillis() - exitTime) > 2000) {
|
318
|
324
|
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
|
319
|
325
|
exitTime = System.currentTimeMillis();
|