|
@@ -5,7 +5,6 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
import android.support.design.widget.BottomNavigationView;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.view.ViewPager;
|
|
@@ -13,8 +12,6 @@ import android.support.v4.view.ViewPager.OnPageChangeListener;
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
-import android.view.Menu;
|
|
|
-import android.view.MenuInflater;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
@@ -32,8 +29,8 @@ import com.netease.nimlib.sdk.msg.SystemMessageService;
|
|
|
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
|
|
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
|
|
import com.netease.nimlib.sdk.team.TeamService;
|
|
|
-import com.sheishuo.app.cache.AccountCache;
|
|
|
import com.sheishuo.app.R;
|
|
|
+import com.sheishuo.app.cache.AccountCache;
|
|
|
import com.sheishuo.app.common.ui.viewpager.FadeInOutPageTransformer;
|
|
|
import com.sheishuo.app.common.ui.viewpager.PagerSlidingTabStrip;
|
|
|
import com.sheishuo.app.common.views.BottomNavigationViewEx;
|
|
@@ -98,7 +95,6 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
autoJoinAreaChat();
|
|
|
|
|
|
|
|
|
-
|
|
|
//暂时用来解决无法加载首页的bug
|
|
|
getHandler().postDelayed(new Runnable() {
|
|
|
@Override
|
|
@@ -106,40 +102,40 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
pager.setCurrentItem(1);
|
|
|
pager.setCurrentItem(0);
|
|
|
}
|
|
|
- },300);
|
|
|
+ }, 300);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//自动加入地区群聊
|
|
|
- public void autoJoinAreaChat(){
|
|
|
+ public void autoJoinAreaChat() {
|
|
|
List<String> autoJoinList = new ArrayList<>();
|
|
|
autoJoinList.add(AccountCache.getAccount().getCountry_room_id());
|
|
|
autoJoinList.add(AccountCache.getAccount().getProvince_room_id());
|
|
|
autoJoinList.add(AccountCache.getAccount().getCity_room_id());
|
|
|
autoJoinList.add(AccountCache.getAccount().getDistrict_room_id());
|
|
|
|
|
|
- for(String roomId : autoJoinList){
|
|
|
- if (roomId != null)NIMClient.getService(TeamService.class).applyJoinTeam(roomId, null);
|
|
|
+ for (String roomId : autoJoinList) {
|
|
|
+ if (roomId != null) NIMClient.getService(TeamService.class).applyJoinTeam(roomId, null);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//初始化BottomNavigationView
|
|
|
- public void initBottomNavigationView(){
|
|
|
+ public void initBottomNavigationView() {
|
|
|
navigationbarItemList.add(R.id.main_navi_groups);
|
|
|
navigationbarItemList.add(R.id.main_navi_friends);
|
|
|
navigationbarItemList.add(R.id.main_navi_trade);
|
|
|
navigationbarItemList.add(R.id.main_navi_circle_of_friends);
|
|
|
navigationbarItemList.add(R.id.main_navi_me);
|
|
|
- if (navigationView != null){
|
|
|
+ if (navigationView != null) {
|
|
|
navigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
|
|
@Override
|
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
|
- for(int position = 0;position < navigationbarItemList.size();position++){
|
|
|
+ for (int position = 0; position < navigationbarItemList.size(); position++) {
|
|
|
|
|
|
- if (navigationbarItemList.get(position) == item.getItemId()){
|
|
|
+ if (navigationbarItemList.get(position) == item.getItemId()) {
|
|
|
pager.setCurrentItem(position);
|
|
|
}
|
|
|
}
|
|
@@ -157,7 +153,6 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
|
// TO TABS
|
|
@@ -181,12 +176,11 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Toolbar getToolbar(){
|
|
|
- return ((MainActivity)getActivity()).getToolBar();
|
|
|
+ public Toolbar getToolbar() {
|
|
|
+ return ((MainActivity) getActivity()).getToolBar();
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void onPageScrollStateChanged(int state) {
|
|
|
// TO TABS
|
|
@@ -200,7 +194,7 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
private void selectPage(int page) {
|
|
|
// TO PAGE
|
|
|
if (scrollState == ViewPager.SCROLL_STATE_IDLE) {
|
|
|
- Log.e(TAG,"currentItem" + pager.getCurrentItem());
|
|
|
+ Log.e(TAG, "currentItem" + pager.getCurrentItem());
|
|
|
adapter.onPageSelected(pager.getCurrentItem());
|
|
|
}
|
|
|
}
|
|
@@ -223,7 +217,6 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
@@ -360,32 +353,32 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
|
|
|
DropManager.getInstance().init(getContext(), (DropCover) findView(R.id.unread_cover),
|
|
|
new DropCover.IDropCompletedListener() {
|
|
|
- @Override
|
|
|
- public void onCompleted(Object id, boolean explosive) {
|
|
|
- if (id == null || !explosive) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void onCompleted(Object id, boolean explosive) {
|
|
|
+ if (id == null || !explosive) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (id instanceof RecentContact) {
|
|
|
- RecentContact r = (RecentContact) id;
|
|
|
- NIMClient.getService(MsgService.class).clearUnreadCount(r.getContactId(), r.getSessionType());
|
|
|
- LogUtil.i("HomeFragment", "clearUnreadCount, sessionId=" + r.getContactId());
|
|
|
- } else if (id instanceof String) {
|
|
|
- if (((String) id).contentEquals("0")) {
|
|
|
- List<RecentContact> recentContacts = NIMClient.getService(MsgService.class).queryRecentContactsBlock();
|
|
|
- for (RecentContact r : recentContacts) {
|
|
|
- if (r.getUnreadCount() > 0) {
|
|
|
- NIMClient.getService(MsgService.class).clearUnreadCount(r.getContactId(), r.getSessionType());
|
|
|
+ if (id instanceof RecentContact) {
|
|
|
+ RecentContact r = (RecentContact) id;
|
|
|
+ NIMClient.getService(MsgService.class).clearUnreadCount(r.getContactId(), r.getSessionType());
|
|
|
+ LogUtil.i("HomeFragment", "clearUnreadCount, sessionId=" + r.getContactId());
|
|
|
+ } else if (id instanceof String) {
|
|
|
+ if (((String) id).contentEquals("0")) {
|
|
|
+ List<RecentContact> recentContacts = NIMClient.getService(MsgService.class).queryRecentContactsBlock();
|
|
|
+ for (RecentContact r : recentContacts) {
|
|
|
+ if (r.getUnreadCount() > 0) {
|
|
|
+ NIMClient.getService(MsgService.class).clearUnreadCount(r.getContactId(), r.getSessionType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LogUtil.i("HomeFragment", "clearAllUnreadCount");
|
|
|
+ } else if (((String) id).contentEquals("1")) {
|
|
|
+ NIMClient.getService(SystemMessageService.class).resetSystemMessageUnreadCount();
|
|
|
+ LogUtil.i("HomeFragment", "clearAllSystemUnreadCount");
|
|
|
}
|
|
|
}
|
|
|
- LogUtil.i("HomeFragment", "clearAllUnreadCount");
|
|
|
- } else if (((String) id).contentEquals("1")) {
|
|
|
- NIMClient.getService(SystemMessageService.class).resetSystemMessageUnreadCount();
|
|
|
- LogUtil.i("HomeFragment", "clearAllSystemUnreadCount");
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
@@ -393,21 +386,36 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
|
|
|
@Override
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
//super.onActivityResult(requestCode, resultCode, data);
|
|
|
- switch (resultCode){
|
|
|
+ Log.e(TAG, requestCode + " " + resultCode);
|
|
|
+
|
|
|
+ //我的 选择照片回调
|
|
|
+ if (resultCode == Activity.RESULT_OK && (requestCode == MineFragment.AVATAR_SELECTED || requestCode == MineFragment.BANNER_SELECTED)) {
|
|
|
+ for (Fragment fragment : getFragmentManager().getFragments()) {
|
|
|
+ if (fragment instanceof MineFragment)
|
|
|
+ fragment.onActivityResult(requestCode, resultCode, data);
|
|
|
+
|
|
|
+ }
|
|
|
+ //防止往下传递,为什么不会消耗掉这个事件?
|
|
|
+ resultCode = -9999;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ switch (resultCode) {
|
|
|
//创建群回调
|
|
|
case Activity.RESULT_OK:
|
|
|
List<String> memberList = data.getStringArrayListExtra(ContactSelectActivity.RESULT_DATA);
|
|
|
- TeamCreateHelper.createAdvancedTeam(context,memberList);
|
|
|
+ TeamCreateHelper.createAdvancedTeam(context, memberList);
|
|
|
break;
|
|
|
|
|
|
//朋友圈自动刷新回调
|
|
|
case CircleOfFriendsFragment.REFRESH_CIRCLE:
|
|
|
- for (Fragment fragment : getFragmentManager().getFragments()){
|
|
|
+ for (Fragment fragment : getFragmentManager().getFragments()) {
|
|
|
if (fragment instanceof CircleOfFriendsFragment)
|
|
|
- fragment.onActivityResult(requestCode,resultCode,data);
|
|
|
+ fragment.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|