|
|
@@ -20,6 +20,8 @@ import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
|
import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
|
+import android.view.Menu;
|
|
|
+import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
@@ -53,7 +55,7 @@ import com.xzjmyk.pm.activity.ui.find.MyFriendFragment;
|
|
|
import com.xzjmyk.pm.activity.ui.groupchat.GroupChatFragment;
|
|
|
import com.xzjmyk.pm.activity.ui.me.MeFragment;
|
|
|
import com.xzjmyk.pm.activity.ui.me.ScreenListener;
|
|
|
-import com.xzjmyk.pm.activity.ui.message.MessageFragment;
|
|
|
+import com.xzjmyk.pm.activity.ui.message.uas.NewMessageFragment;
|
|
|
import com.xzjmyk.pm.activity.util.Constants;
|
|
|
import com.xzjmyk.pm.activity.util.PreferenceUtils;
|
|
|
import com.xzjmyk.pm.activity.view.DivideRadioGroup;
|
|
|
@@ -111,7 +113,8 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
* @注释:主界面Fragment
|
|
|
*/
|
|
|
private Fragment mLastFragment;
|
|
|
- private MessageFragment mMessageFragment;
|
|
|
+ // private MessageFragment mMessageFragment;
|
|
|
+ private NewMessageFragment mNewMessageFragment;
|
|
|
private MyFriendFragment mMyFriendFragment;//我的朋友---相互关注,单项关注,房间
|
|
|
private WorksFragment mWorksFragment;//工作
|
|
|
private GroupChatFragment mGroupChatFragment;//群聊
|
|
|
@@ -119,14 +122,13 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
private ContactFragment mBusinessCircleFragment;
|
|
|
public static String BAIDU_PUSH = "BAIDUPUSH";
|
|
|
public static String UU_STEP = "UUSTEP";
|
|
|
+ public static String NEW_FUNCTION_NOTICE = "NEW_FUNCTION_NOTICE";
|
|
|
private boolean mXmppBind;
|
|
|
private CoreService mCoreService;
|
|
|
private boolean isPause = true;// 界面是否暂停
|
|
|
private ScreenListener screenListener;//锁屏开屏监听
|
|
|
private int mRetryCheckDelay = 0;
|
|
|
public static int UPDATA_LIST = 101;
|
|
|
- public static String NEW_FUNCTION_NOTICE = "NEW_FUNCTION_NOTICE";
|
|
|
- private TextView main_tab_three_tv;
|
|
|
private Handler mUserCheckHander = new Handler() {
|
|
|
public void handleMessage(Message msg) {
|
|
|
if (msg.what == MSG_USER_CHECK) {
|
|
|
@@ -139,6 +141,7 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
}
|
|
|
};
|
|
|
private int mImStatus = AuthStateListener.AUTH_STATE_NOT;
|
|
|
+ private TextView main_tab_three_tv;
|
|
|
|
|
|
public int getmImStatus() {
|
|
|
return mImStatus;
|
|
|
@@ -185,10 +188,15 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
@Override
|
|
|
public void onCheckedChanged(DivideRadioGroup group, int checkedId) {
|
|
|
if (checkedId == R.id.main_tab_one) {
|
|
|
- if (mMessageFragment == null) {
|
|
|
- mMessageFragment = new MessageFragment();
|
|
|
+// if (mMessageFragment == null) {
|
|
|
+// mMessageFragment = new MessageFragment();
|
|
|
+// }
|
|
|
+// mMessageFragment.setOnRefreshRedUI(new MessageFragment.OnRefreshUIListener() {
|
|
|
+
|
|
|
+ if (mNewMessageFragment == null) {
|
|
|
+ mNewMessageFragment = new NewMessageFragment();
|
|
|
}
|
|
|
- mMessageFragment.setOnRefreshRedUI(new MessageFragment.OnRefreshUIListener() {
|
|
|
+ mNewMessageFragment.setOnRefreshRedUI(new NewMessageFragment.OnRefreshUIListener() {
|
|
|
@Override
|
|
|
public void updata(int num) {
|
|
|
//当首页有更新,mainactivity跟着更新页面
|
|
|
@@ -198,7 +206,8 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
updateMsgUnReadTv();
|
|
|
}
|
|
|
});
|
|
|
- changeFragment(mMessageFragment, TAG_MESSAGE);//消息
|
|
|
+// changeFragment(mMessageFragment, TAG_MESSAGE);//消息
|
|
|
+ changeFragment(mNewMessageFragment, TAG_MESSAGE);
|
|
|
updateMessageTitle();
|
|
|
} else if (checkedId == R.id.main_tab_two) {
|
|
|
if (mBusinessCircleFragment == null) {
|
|
|
@@ -416,13 +425,8 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
if (isPush == 0) {
|
|
|
PushManager.stopWork(this);
|
|
|
}
|
|
|
- // TODO 判断上一个状态UU运动是否预关闭
|
|
|
- int isUUStep = PreferenceUtils.getInt(MyApplication.getInstance(), MainActivity.UU_STEP);
|
|
|
- if (isUUStep == 1) {
|
|
|
- startService(new Intent(mContext, StepService.class));
|
|
|
- PreferenceUtils.putInt(MyPedometerActivity.UU_STEP_NOTICE, 1);
|
|
|
- PushManager.resumeWork(MyApplication.getInstance());
|
|
|
- }
|
|
|
+
|
|
|
+ doUUStepEvent();
|
|
|
//TODO 发布版本关闭
|
|
|
if (AppConfig.COMPANY) {
|
|
|
// startService(new Intent(this, AlarmService.class));
|
|
|
@@ -501,10 +505,32 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
// }
|
|
|
// dbManager.closeDB();
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ private void doUUStepEvent() {
|
|
|
//开启APP后自动开启UU运动服务,这里为了耗电占内存等情况暂时不设置开启APP自动开启UU运动
|
|
|
// openUUStepService();
|
|
|
|
|
|
+ // 判断上一个状态UU运动是否预关闭
|
|
|
+ int isUUStep = PreferenceUtils.getInt(MyApplication.getInstance(), MainActivity.UU_STEP);
|
|
|
+ if (isUUStep == 1) {
|
|
|
+ startService(new Intent(mContext, StepService.class));
|
|
|
+ PreferenceUtils.putInt(MyPedometerActivity.UU_STEP_NOTICE, 1);
|
|
|
+ PushManager.resumeWork(MyApplication.getInstance());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
+ return super.onCreateOptionsMenu(menu);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
+ switch (item.getItemId()){
|
|
|
+// case android.R.id
|
|
|
+ }
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
|
|
|
private Messenger messenger;
|
|
|
@@ -583,8 +609,11 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
/* 当注销当前用户时,将那些需要当前用户的Fragment销毁,以后重新登陆后,重新加载为初始状态 */
|
|
|
private void removeNeedUserFragment(boolean startAgain) {
|
|
|
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();// 开始事物
|
|
|
- if (mMessageFragment != null) {
|
|
|
- fragmentTransaction.remove(mMessageFragment);
|
|
|
+// if (mMessageFragment != null) {
|
|
|
+// fragmentTransaction.remove(mMessageFragment);
|
|
|
+// }
|
|
|
+ if (mNewMessageFragment != null){
|
|
|
+ fragmentTransaction.remove(mNewMessageFragment);
|
|
|
}
|
|
|
if (mMyFriendFragment != null) {
|
|
|
fragmentTransaction.remove(mMyFriendFragment);
|
|
|
@@ -603,7 +632,8 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
|
|
|
}
|
|
|
fragmentTransaction.commitAllowingStateLoss();
|
|
|
- mMessageFragment = null;
|
|
|
+// mMessageFragment = null;
|
|
|
+ mNewMessageFragment = null;
|
|
|
mMyFriendFragment = null;
|
|
|
mWorksFragment = null;
|
|
|
mGroupChatFragment = null;
|
|
|
@@ -656,7 +686,8 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
|
|
|
private void restoreState(Bundle savedInstanceState) {
|
|
|
mLastFragment = getSupportFragmentManager().findFragmentById(R.id.main_content);
|
|
|
- mMessageFragment = (MessageFragment) getSupportFragmentManager().findFragmentByTag(TAG_MESSAGE);
|
|
|
+// mMessageFragment = (MessageFragment) getSupportFragmentManager().findFragmentByTag(TAG_MESSAGE);
|
|
|
+ mNewMessageFragment = (NewMessageFragment) getSupportFragmentManager().findFragmentByTag(TAG_MESSAGE);
|
|
|
mMyFriendFragment = (MyFriendFragment) getSupportFragmentManager().findFragmentByTag(TAG_MY);
|
|
|
mWorksFragment = (WorksFragment) getSupportFragmentManager().findFragmentByTag(TAG_NEARBY);
|
|
|
mGroupChatFragment = (GroupChatFragment) getSupportFragmentManager().findFragmentByTag(TAG_GROUP_CHAT);
|
|
|
@@ -677,11 +708,10 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
}
|
|
|
mMsgUnReadTv = (TextView) findViewById(R.id.main_tab_one_tv);
|
|
|
unWorkReadTV = (TextView) findViewById(R.id.main_tab_five_tv);
|
|
|
+
|
|
|
main_tab_three_tv = (TextView) findViewById(R.id.main_tab_three_tv);
|
|
|
|
|
|
- //TODO 当前隐藏性功能提醒红点
|
|
|
- PreferenceUtils.putInt(MainActivity.NEW_FUNCTION_NOTICE, 1);
|
|
|
- PushManager.resumeWork(MyApplication.getInstance());
|
|
|
+
|
|
|
int new_function_notice = PreferenceUtils.getInt(MyApplication.getInstance(),MainActivity.NEW_FUNCTION_NOTICE);
|
|
|
if(new_function_notice == 1){
|
|
|
main_tab_three_tv.setVisibility(View.INVISIBLE);
|
|
|
@@ -691,6 +721,7 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
Log.i("new_function_notice",new_function_notice +"");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void changeFragment(Fragment addFragment, String tag) {
|
|
|
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();// 开始事物
|
|
|
if (mLastFragment == addFragment) {
|
|
|
@@ -767,6 +798,7 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
requestMyBusiness();
|
|
|
Runtime.getRuntime().gc();
|
|
|
|
|
|
+
|
|
|
int new_function_notice = PreferenceUtils.getInt(MyApplication.getInstance(),MainActivity.NEW_FUNCTION_NOTICE);
|
|
|
if(new_function_notice == 1){
|
|
|
main_tab_three_tv.setVisibility(View.INVISIBLE);
|
|
|
@@ -825,4 +857,5 @@ public class MainActivity extends BaseActivity implements NetWorkObservable.NetW
|
|
|
return (BusinessCircleFragment) sfmanager.findFragmentByTag(TAG_BusinessCircle);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|