Browse Source

no message

Fenix Wang 8 years ago
parent
commit
96199a5505
100 changed files with 0 additions and 11734 deletions
  1. 0 7
      app/app.iml
  2. 0 17
      app/src/com/sheishuo/app/PrivatizationConfig.java
  3. 0 375
      app/src/com/sheishuo/app/SheishuoApplication.java
  4. 0 57
      app/src/com/sheishuo/app/SheishuoCache.java
  5. 0 12
      app/src/com/sheishuo/app/about/CustomActions.java
  6. 0 372
      app/src/com/sheishuo/app/avchat/AVChatAudio.java
  7. 0 96
      app/src/com/sheishuo/app/avchat/AVChatFileVideoRender.java
  8. 0 124
      app/src/com/sheishuo/app/avchat/AVChatNotification.java
  9. 0 47
      app/src/com/sheishuo/app/avchat/AVChatProfile.java
  10. 0 167
      app/src/com/sheishuo/app/avchat/AVChatSoundPlayer.java
  11. 0 419
      app/src/com/sheishuo/app/avchat/AVChatSurface.java
  12. 0 979
      app/src/com/sheishuo/app/avchat/AVChatUI.java
  13. 0 17
      app/src/com/sheishuo/app/avchat/AVChatUIListener.java
  14. 0 350
      app/src/com/sheishuo/app/avchat/AVChatVideo.java
  15. 0 655
      app/src/com/sheishuo/app/avchat/activity/AVChatActivity.java
  16. 0 90
      app/src/com/sheishuo/app/avchat/activity/AVChatExitCode.java
  17. 0 27
      app/src/com/sheishuo/app/avchat/activity/AVChatSettingsActivity.java
  18. 0 64
      app/src/com/sheishuo/app/avchat/activity/AVChatSettingsFragment.java
  19. 0 50
      app/src/com/sheishuo/app/avchat/constant/CallStateEnum.java
  20. 0 23
      app/src/com/sheishuo/app/avchat/receiver/IncomingCallReceiver.java
  21. 0 142
      app/src/com/sheishuo/app/avchat/receiver/PhoneCallStateObserver.java
  22. 0 402
      app/src/com/sheishuo/app/avchat/widgets/MultiSelectDialog.java
  23. 0 36
      app/src/com/sheishuo/app/avchat/widgets/MultiSelectDialogViewHolder.java
  24. 0 12
      app/src/com/sheishuo/app/avchat/widgets/ToggleListener.java
  25. 0 10
      app/src/com/sheishuo/app/avchat/widgets/ToggleState.java
  26. 0 121
      app/src/com/sheishuo/app/avchat/widgets/ToggleView.java
  27. 0 39
      app/src/com/sheishuo/app/cache/AccountCache.java
  28. 0 25
      app/src/com/sheishuo/app/cache/GiftCache.java
  29. 0 53
      app/src/com/sheishuo/app/cache/HobbyCache.java
  30. 0 19
      app/src/com/sheishuo/app/cache/MineSocialCache.java
  31. 0 107
      app/src/com/sheishuo/app/cache/SocialInfoCache.java
  32. 0 238
      app/src/com/sheishuo/app/chatroom/activity/ChatRoomActivity.java
  33. 0 234
      app/src/com/sheishuo/app/chatroom/adapter/ChatRoomMsgAdapter.java
  34. 0 50
      app/src/com/sheishuo/app/chatroom/adapter/ChatRoomOnlinePeopleAdapter.java
  35. 0 69
      app/src/com/sheishuo/app/chatroom/adapter/ChatRoomTabPagerAdapter.java
  36. 0 44
      app/src/com/sheishuo/app/chatroom/adapter/ChatRoomsAdapter.java
  37. 0 44
      app/src/com/sheishuo/app/chatroom/constant/ChatRoomTab.java
  38. 0 179
      app/src/com/sheishuo/app/chatroom/fragment/ChatRoomFragment.java
  39. 0 30
      app/src/com/sheishuo/app/chatroom/fragment/ChatRoomInputPanel.java
  40. 0 199
      app/src/com/sheishuo/app/chatroom/fragment/ChatRoomMessageFragment.java
  41. 0 130
      app/src/com/sheishuo/app/chatroom/fragment/ChatRoomsFragment.java
  42. 0 134
      app/src/com/sheishuo/app/chatroom/fragment/MasterFragment.java
  43. 0 685
      app/src/com/sheishuo/app/chatroom/fragment/OnlinePeopleFragment.java
  44. 0 58
      app/src/com/sheishuo/app/chatroom/fragment/tab/ChatRoomTabFragment.java
  45. 0 24
      app/src/com/sheishuo/app/chatroom/fragment/tab/MasterTabFragment.java
  46. 0 54
      app/src/com/sheishuo/app/chatroom/fragment/tab/MessageTabFragment.java
  47. 0 29
      app/src/com/sheishuo/app/chatroom/fragment/tab/OnlinePeopleTabFragment.java
  48. 0 60
      app/src/com/sheishuo/app/chatroom/helper/ChatRoomHelper.java
  49. 0 293
      app/src/com/sheishuo/app/chatroom/helper/ChatRoomMemberCache.java
  50. 0 126
      app/src/com/sheishuo/app/chatroom/helper/ChatRoomNotificationHelper.java
  51. 0 95
      app/src/com/sheishuo/app/chatroom/helper/ExtensionHelper.java
  52. 0 426
      app/src/com/sheishuo/app/chatroom/module/ChatRoomMsgListPanel.java
  53. 0 150
      app/src/com/sheishuo/app/chatroom/thridparty/ChatRoomHttpClient.java
  54. 0 365
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderBase.java
  55. 0 74
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderBaseText.java
  56. 0 71
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderFactory.java
  57. 0 21
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderGuess.java
  58. 0 38
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderNotification.java
  59. 0 51
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderText.java
  60. 0 36
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderUnknown.java
  61. 0 56
      app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomViewHolderHelper.java
  62. 0 39
      app/src/com/sheishuo/app/chatroom/widget/ChatRoomImageView.java
  63. 0 31
      app/src/com/sheishuo/app/common/beans/BeFollowedBean.java
  64. 0 14
      app/src/com/sheishuo/app/common/beans/CircleBean.java
  65. 0 14
      app/src/com/sheishuo/app/common/beans/CircleUnreadBean.java
  66. 0 71
      app/src/com/sheishuo/app/common/beans/CircleUserLikedBean.java
  67. 0 62
      app/src/com/sheishuo/app/common/beans/CityDataBean.java
  68. 0 44
      app/src/com/sheishuo/app/common/beans/ContactRelationshipBean.java
  69. 0 12
      app/src/com/sheishuo/app/common/beans/GiftBean.java
  70. 0 83
      app/src/com/sheishuo/app/common/beans/NearbyGroupsBean.java
  71. 0 106
      app/src/com/sheishuo/app/common/beans/RequestBean.java
  72. 0 336
      app/src/com/sheishuo/app/common/beans/SocialInfoBean.java
  73. 0 72
      app/src/com/sheishuo/app/common/beans/SocialPhoto.java
  74. 0 13
      app/src/com/sheishuo/app/common/beans/TradeBean.java
  75. 0 180
      app/src/com/sheishuo/app/common/imageView/GroupHeadImageView.java
  76. 0 59
      app/src/com/sheishuo/app/common/infra/AbstractTaskWorker.java
  77. 0 15
      app/src/com/sheishuo/app/common/infra/CallbackWrapper.java
  78. 0 26
      app/src/com/sheishuo/app/common/infra/CompoundTaskWorker.java
  79. 0 22
      app/src/com/sheishuo/app/common/infra/DefaultTask.java
  80. 0 5
      app/src/com/sheishuo/app/common/infra/DefaultTaskCallback.java
  81. 0 15
      app/src/com/sheishuo/app/common/infra/DefaultTaskManager.java
  82. 0 69
      app/src/com/sheishuo/app/common/infra/DefaultTaskRegistry.java
  83. 0 94
      app/src/com/sheishuo/app/common/infra/DefaultTaskScheduler.java
  84. 0 15
      app/src/com/sheishuo/app/common/infra/DefaultTaskWorker.java
  85. 0 95
      app/src/com/sheishuo/app/common/infra/Handlers.java
  86. 0 244
      app/src/com/sheishuo/app/common/infra/ManagedTask.java
  87. 0 53
      app/src/com/sheishuo/app/common/infra/Observable.java
  88. 0 39
      app/src/com/sheishuo/app/common/infra/ObservableTask.java
  89. 0 46
      app/src/com/sheishuo/app/common/infra/Params.java
  90. 0 258
      app/src/com/sheishuo/app/common/infra/Task.java
  91. 0 233
      app/src/com/sheishuo/app/common/infra/TaskExecutor.java
  92. 0 65
      app/src/com/sheishuo/app/common/infra/TaskFrequencyController.java
  93. 0 82
      app/src/com/sheishuo/app/common/infra/TaskManager.java
  94. 0 67
      app/src/com/sheishuo/app/common/infra/TaskManagerRegistry.java
  95. 0 17
      app/src/com/sheishuo/app/common/infra/TaskObservable.java
  96. 0 17
      app/src/com/sheishuo/app/common/infra/TaskObserver.java
  97. 0 47
      app/src/com/sheishuo/app/common/infra/TaskRegistry.java
  98. 0 44
      app/src/com/sheishuo/app/common/infra/TaskScheduler.java
  99. 0 19
      app/src/com/sheishuo/app/common/infra/TaskWorker.java
  100. 0 34
      app/src/com/sheishuo/app/common/infra/TraceTaskRegistry.java

+ 0 - 7
app/app.iml

@@ -146,12 +146,5 @@
     <orderEntry type="library" exported="" name="support-compat-25.3.1" level="project" />
     <orderEntry type="library" exported="" name="animated-vector-drawable-25.3.1" level="project" />
     <orderEntry type="module" module-name="uikit" exported="" />
-    <orderEntry type="library" exported="" name="java-json" level="project" />
-    <orderEntry type="library" exported="" name="renderscript-v8" level="project" />
-    <orderEntry type="library" exported="" name="glide-3.7.0" level="project" />
-    <orderEntry type="library" exported="" name="nim-avchat-4.0.0" level="project" />
-    <orderEntry type="library" exported="" name="nim-basesdk-4.0.0" level="project" />
-    <orderEntry type="library" exported="" name="fastjson-1.1.34.android" level="project" />
-    <orderEntry type="library" exported="" name="nim-lucene-4.0.0" level="project" />
   </component>
 </module>

+ 0 - 17
app/src/com/sheishuo/app/PrivatizationConfig.java

@@ -1,17 +0,0 @@
-package com.sheishuo.app;
-
-import com.netease.nimlib.sdk.ServerAddresses;
-
-/**
- * 网易云信私有化配置项
- */
-class PrivatizationConfig {
-
-    static ServerAddresses getServerAddresses() {
-        return null;
-    }
-
-    static String getAppKey() {
-        return null;
-    }
-}

+ 0 - 375
app/src/com/sheishuo/app/SheishuoApplication.java

@@ -1,375 +0,0 @@
-package com.sheishuo.app;
-
-import android.app.ActivityManager;
-import android.app.Application;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.graphics.Color;
-import android.os.Environment;
-import android.os.Handler;
-import android.support.multidex.MultiDex;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.View;
-
-import com.netease.nim.uikit.ContextCache;
-import com.netease.nim.uikit.common.ui.dialog.DialogMaker;
-import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialogHelper;
-import com.netease.nim.uikit.common.util.storage.StorageUtil;
-import com.sheishuo.app.avchat.AVChatProfile;
-import com.sheishuo.app.common.util.location.CityDataHelper;
-import com.sheishuo.app.config.preference.UserPreferences;
-import com.sheishuo.app.main.activity.WelcomeActivity;
-import com.sheishuo.app.avchat.activity.AVChatActivity;
-import com.sheishuo.app.avchat.receiver.PhoneCallStateObserver;
-import com.sheishuo.app.common.util.crash.AppCrashHandler;
-import com.sheishuo.app.common.util.sys.SystemUtil;
-import com.sheishuo.app.config.ExtraOptions;
-import com.sheishuo.app.config.preference.Preferences;
-import com.sheishuo.app.contact.ContactHelper;
-import com.sheishuo.app.event.DemoOnlineStateContentProvider;
-import com.sheishuo.app.event.OnlineStateEventManager;
-import com.sheishuo.app.rts.activity.RTSActivity;
-import com.sheishuo.app.session.NimDemoLocationProvider;
-import com.sheishuo.app.session.SessionHelper;
-import com.sheishuo.app.team.TeamAVChatHelper;
-import com.netease.nim.uikit.NimUIKit;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nim.uikit.contact.core.query.PinYin;
-import com.netease.nim.uikit.custom.DefaultUserInfoProvider;
-import com.netease.nim.uikit.session.viewholder.MsgViewHolderThumbBase;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.NimStrings;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.SDKOptions;
-import com.netease.nimlib.sdk.ServerAddresses;
-import com.netease.nimlib.sdk.StatusBarNotificationConfig;
-import com.netease.nimlib.sdk.auth.LoginInfo;
-import com.netease.nimlib.sdk.avchat.AVChatManager;
-import com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand;
-import com.netease.nimlib.sdk.avchat.model.AVChatAttachment;
-import com.netease.nimlib.sdk.avchat.model.AVChatData;
-import com.netease.nimlib.sdk.mixpush.NIMPushClient;
-import com.netease.nimlib.sdk.msg.MessageNotifierCustomization;
-import com.netease.nimlib.sdk.msg.MsgService;
-import com.netease.nimlib.sdk.msg.model.IMMessage;
-import com.netease.nimlib.sdk.rts.RTSManager;
-import com.netease.nimlib.sdk.rts.model.RTSData;
-import com.netease.nimlib.sdk.team.constant.TeamFieldEnum;
-import com.netease.nimlib.sdk.team.model.IMMessageFilter;
-import com.netease.nimlib.sdk.team.model.UpdateTeamAttachment;
-
-import java.util.List;
-import java.util.Map;
-
-public class SheishuoApplication extends Application {
-
-    private static final String TAG = "SheishuoApplication";
-    private static Context context;
-
-    protected void attachBaseContext(Context newBase) {
-        super.attachBaseContext(newBase);
-        MultiDex.install(this);
-    }
-
-    public void onCreate() {
-        super.onCreate();
-
-        context = this;
-
-        ContextCache.init(context);
-        /**
-         * 初始化各种工具
-         */
-        //初始化LocationHelper
-        //LocationHelper.init(context);
-        //初始化全国省份数据
-        CityDataHelper.init(context);
-
-
-
-        SheishuoCache.setContext(this);
-        // 注册小米推送appID 、appKey 以及在云信管理后台添加的小米推送证书名称,该逻辑放在 NIMClient init 之前
-        //NIMPushClient.registerMiPush(this, "DEMO_MI_PUSH", "2882303761517502883", "5671750254883");
-        NIMPushClient.registerMiPush(this, "DEMO_MI_PUSH", "2882303761517616375", "5221761611375");
-        // 注册华为推送
-        NIMPushClient.registerHWPush(this, "DEMO_HW_PUSH");
-        // 注册自定义小米推送消息处理,这个是可选项
-        //NIMPushClient.registerMixPushMessageHandler(new DemoMixPushMessageHandler());
-        NIMClient.init(this, getLoginInfo(), getOptions());
-        ExtraOptions.provide();
-        // crash handler
-        AppCrashHandler.getInstance(this);
-
-        if (inMainProcess()) {
-
-            // init pinyin
-            PinYin.init(this);
-            PinYin.validate();
-
-            // 初始化UIKit模块
-            initUIKit();
-
-            // 注册通知消息过滤器
-            registerIMMessageFilter();
-
-            // 初始化消息提醒
-            NIMClient.toggleNotification(UserPreferences.getNotificationToggle());
-
-            // 注册网络通话来电
-            registerAVChatIncomingCallObserver(true);
-
-            // 注册白板会话
-            registerRTSIncomingObserver(true);
-
-            // 注册语言变化监听
-            registerLocaleReceiver(true);
-
-            OnlineStateEventManager.init();
-        }
-    }
-
-    public static Context getContext(){
-        return context;
-    }
-
-    private LoginInfo getLoginInfo() {
-        String account = Preferences.getUserAccount();
-        String token = Preferences.getUserToken();
-
-        if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(token)) {
-            SheishuoCache.setAccount(account.toLowerCase());
-            return new LoginInfo(account, token);
-        } else {
-            return null;
-        }
-    }
-
-    private SDKOptions getOptions() {
-        SDKOptions options = new SDKOptions();
-
-        // 如果将新消息通知提醒托管给SDK完成,需要添加以下配置。
-        initStatusBarNotificationConfig(options);
-
-        // 配置保存图片,文件,log等数据的目录
-        options.sdkStorageRootPath = Environment.getExternalStorageDirectory() + "/" + getPackageName() + "/nim";
-
-        // 配置数据库加密秘钥
-        options.databaseEncryptKey = "NETEASE";
-
-        // 配置是否需要预下载附件缩略图
-        options.preloadAttach = true;
-
-        // 配置附件缩略图的尺寸大小,
-        options.thumbnailSize = MsgViewHolderThumbBase.getImageMaxEdge();
-
-        // 用户信息提供者
-        options.userInfoProvider = new DefaultUserInfoProvider(this);
-
-        // 定制通知栏提醒文案(可选,如果不定制将采用SDK默认文案)
-        options.messageNotifierCustomization = messageNotifierCustomization;
-
-        // 在线多端同步未读数
-        options.sessionReadAck = true;
-
-        // 云信私有化配置项
-        configServerAddress(options);
-
-        return options;
-    }
-
-    private void configServerAddress(final SDKOptions options) {
-        String appKey = PrivatizationConfig.getAppKey();
-        if (!TextUtils.isEmpty(appKey)) {
-            options.appKey = appKey;
-        }
-
-        ServerAddresses serverConfig = PrivatizationConfig.getServerAddresses();
-        if (serverConfig != null) {
-            options.serverConfig = serverConfig;
-        }
-    }
-
-    private void initStatusBarNotificationConfig(SDKOptions options) {
-        // load 应用的状态栏配置
-        StatusBarNotificationConfig config = loadStatusBarNotificationConfig();
-
-        // load 用户的 StatusBarNotificationConfig 设置项
-        StatusBarNotificationConfig userConfig = UserPreferences.getStatusConfig();
-        if (userConfig == null) {
-            userConfig = config;
-        } else {
-            // 新增的 UserPreferences 存储项更新,兼容 3.4 及以前版本
-            // 新增 notificationColor 存储,兼容3.6以前版本
-            // APP默认 StatusBarNotificationConfig 配置修改后,使其生效
-            userConfig.notificationEntrance = config.notificationEntrance;
-            userConfig.notificationFolded = config.notificationFolded;
-            userConfig.notificationColor = getResources().getColor(R.color.color_blue_3a9efb);
-        }
-        // 持久化生效
-        UserPreferences.setStatusConfig(userConfig);
-        // SDK statusBarNotificationConfig 生效
-        options.statusBarNotificationConfig = userConfig;
-    }
-
-    // 这里开发者可以自定义该应用初始的 StatusBarNotificationConfig
-    private StatusBarNotificationConfig loadStatusBarNotificationConfig() {
-        StatusBarNotificationConfig config = new StatusBarNotificationConfig();
-        // 点击通知需要跳转到的界面
-        config.notificationEntrance = WelcomeActivity.class;
-        config.notificationSmallIconId = R.drawable.ic_stat_notify_msg;
-        config.notificationColor = getResources().getColor(R.color.color_blue_3a9efb);
-        // 通知铃声的uri字符串
-        config.notificationSound = "android.resource://com.sheishuo.app/raw/msg";
-
-        // 呼吸灯配置
-        config.ledARGB = Color.GREEN;
-        config.ledOnMs = 1000;
-        config.ledOffMs = 1500;
-
-        // save cache,留做切换账号备用
-        SheishuoCache.setNotificationConfig(config);
-        return config;
-    }
-
-    @Override
-    public void onTerminate() {
-        super.onTerminate();
-    }
-
-    @Override
-    public void onLowMemory() {
-        super.onLowMemory();
-    }
-
-    public boolean inMainProcess() {
-        String packageName = getPackageName();
-        String processName = SystemUtil.getProcessName(this);
-        return packageName.equals(processName);
-    }
-
-    /**
-     * 通知消息过滤器(如果过滤则该消息不存储不上报)
-     */
-    private void registerIMMessageFilter() {
-        NIMClient.getService(MsgService.class).registerIMMessageFilter(new IMMessageFilter() {
-            @Override
-            public boolean shouldIgnore(IMMessage message) {
-                if (UserPreferences.getMsgIgnore() && message.getAttachment() != null) {
-                    if (message.getAttachment() instanceof UpdateTeamAttachment) {
-                        UpdateTeamAttachment attachment = (UpdateTeamAttachment) message.getAttachment();
-                        for (Map.Entry<TeamFieldEnum, Object> field : attachment.getUpdatedFields().entrySet()) {
-                            if (field.getKey() == TeamFieldEnum.ICON) {
-                                return true;
-                            }
-                        }
-                    } else if (message.getAttachment() instanceof AVChatAttachment) {
-                        return true;
-                    }
-                }
-                return false;
-            }
-        });
-    }
-
-    private void registerAVChatIncomingCallObserver(boolean register) {
-        AVChatManager.getInstance().observeIncomingCall(new Observer<AVChatData>() {
-            @Override
-            public void onEvent(AVChatData data) {
-                String extra = data.getExtra();
-                Log.e("Extra", "Extra Message->" + extra);
-                if (PhoneCallStateObserver.getInstance().getPhoneCallState() != PhoneCallStateObserver.PhoneCallStateEnum.IDLE
-                        || AVChatProfile.getInstance().isAVChatting()
-                        || TeamAVChatHelper.sharedInstance().isTeamAVChatting()
-                        || AVChatManager.getInstance().getCurrentChatId() != 0) {
-                    LogUtil.i(TAG, "reject incoming call data =" + data.toString() + " as local phone is not idle");
-                    AVChatManager.getInstance().sendControlCommand(data.getChatId(), AVChatControlCommand.BUSY, null);
-                    return;
-                }
-                // 有网络来电打开AVChatActivity
-                AVChatProfile.getInstance().setAVChatting(true);
-                AVChatProfile.getInstance().launchActivity(data, AVChatActivity.FROM_BROADCASTRECEIVER);
-            }
-        }, register);
-    }
-
-    private void registerRTSIncomingObserver(boolean register) {
-        RTSManager.getInstance().observeIncomingSession(new Observer<RTSData>() {
-            @Override
-            public void onEvent(RTSData rtsData) {
-                RTSActivity.incomingSession(SheishuoCache.getContext(), rtsData, RTSActivity.FROM_BROADCAST_RECEIVER);
-            }
-        }, register);
-    }
-
-    private void registerLocaleReceiver(boolean register) {
-        if (register) {
-            updateLocale();
-            IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
-            registerReceiver(localeReceiver, filter);
-        } else {
-            unregisterReceiver(localeReceiver);
-        }
-    }
-
-    private BroadcastReceiver localeReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (intent.getAction().equals(Intent.ACTION_LOCALE_CHANGED)) {
-                updateLocale();
-            }
-        }
-    };
-
-    private void updateLocale() {
-        NimStrings strings = new NimStrings();
-        strings.status_bar_multi_messages_incoming = getString(R.string.nim_status_bar_multi_messages_incoming);
-        strings.status_bar_image_message = getString(R.string.nim_status_bar_image_message);
-        strings.status_bar_audio_message = getString(R.string.nim_status_bar_audio_message);
-        strings.status_bar_custom_message = getString(R.string.nim_status_bar_custom_message);
-        strings.status_bar_file_message = getString(R.string.nim_status_bar_file_message);
-        strings.status_bar_location_message = getString(R.string.nim_status_bar_location_message);
-        strings.status_bar_notification_message = getString(R.string.nim_status_bar_notification_message);
-        strings.status_bar_ticker_text = getString(R.string.nim_status_bar_ticker_text);
-        strings.status_bar_unsupported_message = getString(R.string.nim_status_bar_unsupported_message);
-        strings.status_bar_video_message = getString(R.string.nim_status_bar_video_message);
-        strings.status_bar_hidden_message_content = getString(R.string.nim_status_bar_hidden_msg_content);
-        NIMClient.updateStrings(strings);
-    }
-
-    private void initUIKit() {
-
-        // 初始化,使用 uikit 默认的用户信息提供者
-        NimUIKit.init(this);
-
-        // 设置地理位置提供者。如果需要发送地理位置消息,该参数必须提供。如果不需要,可以忽略。
-        NimUIKit.setLocationProvider(new NimDemoLocationProvider());
-
-        // 会话窗口的定制初始化。
-        SessionHelper.init();
-
-        // 通讯录列表定制初始化
-        ContactHelper.init();
-
-        // 添加自定义推送文案以及选项,请开发者在各端(Android、IOS、PC、Web)消息发送时保持一致,以免出现通知不一致的情况
-        // NimUIKit.CustomPushContentProvider(new DemoPushContentProvider());
-
-        NimUIKit.setOnlineStateContentProvider(new DemoOnlineStateContentProvider());
-    }
-
-    private MessageNotifierCustomization messageNotifierCustomization = new MessageNotifierCustomization() {
-        @Override
-        public String makeNotifyContent(String nick, IMMessage message) {
-            return null; // 采用SDK默认文案
-        }
-
-        @Override
-        public String makeTicker(String nick, IMMessage message) {
-            return null; // 采用SDK默认文案
-        }
-    };
-
-
-}

+ 0 - 57
app/src/com/sheishuo/app/SheishuoCache.java

@@ -1,57 +0,0 @@
-package com.sheishuo.app;
-
-import android.content.Context;
-
-import com.netease.nim.uikit.NimUIKit;
-import com.netease.nimlib.sdk.StatusBarNotificationConfig;
-
-/**
- * Created by KN on 2017/08/01.
- */
-public class SheishuoCache {
-
-    private static Context context;
-
-    private static String account;
-
-    private static StatusBarNotificationConfig notificationConfig;
-
-    public static void clear() {
-        account = null;
-    }
-
-    public static String getAccount() {
-        return account;
-    }
-
-    private static boolean mainTaskLaunching;
-
-    public static void setAccount(String account) {
-        SheishuoCache.account = account;
-        NimUIKit.setAccount(account);
-    }
-
-    public static void setNotificationConfig(StatusBarNotificationConfig notificationConfig) {
-        SheishuoCache.notificationConfig = notificationConfig;
-    }
-
-    public static StatusBarNotificationConfig getNotificationConfig() {
-        return notificationConfig;
-    }
-
-    public static Context getContext() {
-        return context;
-    }
-
-    public static void setContext(Context context) {
-        SheishuoCache.context = context.getApplicationContext();
-    }
-
-    public static void setMainTaskLaunching(boolean mainTaskLaunching) {
-        SheishuoCache.mainTaskLaunching = mainTaskLaunching;
-    }
-
-    public static boolean isMainTaskLaunching() {
-        return mainTaskLaunching;
-    }
-}

+ 0 - 12
app/src/com/sheishuo/app/about/CustomActions.java

@@ -1,12 +0,0 @@
-package com.sheishuo.app.about;
-
-import android.widget.Button;
-
-/**
- * Created by jezhee on 4/19/15.
- */
-public class CustomActions {
-    public static void customButton(Button button) {
-        /// EMPTY NOW
-    }
-}

+ 0 - 372
app/src/com/sheishuo/app/avchat/AVChatAudio.java

@@ -1,372 +0,0 @@
-package com.sheishuo.app.avchat;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.view.View;
-import android.widget.Button;
-import android.widget.Chronometer;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.sheishuo.app.avchat.widgets.ToggleView;
-import com.sheishuo.app.SheishuoCache;
-import com.netease.nim.uikit.cache.NimUserInfoCache;
-import com.sheishuo.app.R;
-import com.sheishuo.app.avchat.constant.CallStateEnum;
-import com.sheishuo.app.avchat.widgets.ToggleListener;
-import com.sheishuo.app.avchat.widgets.ToggleState;
-import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
-import com.netease.nim.uikit.common.util.sys.NetworkUtil;
-
-/**
- * 音频管理器, 音频界面初始化和管理
- * Created by hzxuwen on 2015/4/24.
- */
-public class AVChatAudio implements View.OnClickListener, ToggleListener{
-    // constant
-    private static final int[] NETWORK_GRADE_DRAWABLE = new int[]{R.drawable.network_grade_0,R.drawable.network_grade_1,R.drawable.network_grade_2,R.drawable.network_grade_3};
-    private static final int[] NETWORK_GRADE_LABEL = new int[]{R.string.avchat_network_grade_0,R.string.avchat_network_grade_1,R.string.avchat_network_grade_2,R.string.avchat_network_grade_3};
-
-    private Context context;
-    // view
-    private View rootView ;
-    private View switchVideo;
-    private HeadImageView headImg;
-    private TextView nickNameTV;
-    private Chronometer time;
-    private TextView wifiUnavailableNotifyTV;
-    private TextView notifyTV;
-    private TextView netUnstableTV;
-
-    private View mute_speaker_hangup;
-    private ToggleView muteToggle;
-    private ToggleView speakerToggle;
-    private View recordToggle;
-    private Button recordToggleButton;
-    private View hangup;
-
-    private View refuse_receive;
-    private TextView refuseTV;
-    private TextView receiveTV;
-
-    //record
-    private View recordView;
-    private View recordTip;
-    private View recordWarning;
-
-    // data
-    private AVChatUI manager;
-    private AVChatUIListener listener;
-
-    // state
-    private boolean init = false;
-
-    // is in switch
-    private boolean isInSwitch = false;
-
-    public AVChatAudio(Context context, View root, AVChatUIListener listener, AVChatUI manager) {
-        this.context = context;
-        this.rootView = root;
-        this.listener = listener;
-        this.manager = manager;
-    }
-
-    /**
-     * 音视频状态变化及界面刷新
-     * @param state
-     */
-    public void onCallStateChange(CallStateEnum state){
-        if(CallStateEnum.isAudioMode(state))
-            findViews();
-        switch (state){
-            case OUTGOING_AUDIO_CALLING: //拨打出的免费通话
-                setSwitchVideo(false);
-                showProfile();//对方的详细信息
-                showNotify(R.string.avchat_wait_recieve);
-                setWifiUnavailableNotifyTV(true);
-                setMuteSpeakerHangupControl(true);
-                setRefuseReceive(false);
-                break;
-            case INCOMING_AUDIO_CALLING://免费通话请求
-                setSwitchVideo(false);
-                showProfile();//对方的详细信息
-                showNotify(R.string.avchat_audio_call_request);
-                setMuteSpeakerHangupControl(false);
-                setRefuseReceive(true);
-                receiveTV.setText(R.string.avchat_pickup);
-                break;
-            case AUDIO:
-                isInSwitch = false;
-                setWifiUnavailableNotifyTV(false);
-                showNetworkCondition(1);
-                showProfile();
-                setSwitchVideo(true);
-                setTime(true);
-                hideNotify();
-                setMuteSpeakerHangupControl(true);
-                setRefuseReceive(false);
-                enableToggle();
-                break;
-            case AUDIO_CONNECTING:
-                showNotify(R.string.avchat_connecting);
-                break;
-            case INCOMING_AUDIO_TO_VIDEO:
-                isInSwitch = true;
-                showNotify(R.string.avchat_audio_to_video_invitation);
-                setMuteSpeakerHangupControl(false);
-                setRefuseReceive(true);
-                receiveTV.setText(R.string.avchat_receive);
-                break;
-            default:
-                break;
-        }
-        setRoot(CallStateEnum.isAudioMode(state));
-    }
-
-    private boolean isEnabled = false;
-
-    private void enableToggle() {
-        if(!isEnabled) {
-            recordToggle.setEnabled(true);
-        }
-        isEnabled = true;
-    }
-
-    /**
-     * 界面初始化
-     */
-    private void findViews() {
-        if(init || rootView == null){
-            return;
-        }
-        switchVideo = rootView.findViewById(R.id.avchat_audio_switch_video);
-        switchVideo.setOnClickListener(this);
-
-        headImg = (HeadImageView) rootView.findViewById(R.id.avchat_audio_head);
-        nickNameTV = (TextView) rootView.findViewById(R.id.avchat_audio_nickname);
-        time = (Chronometer) rootView.findViewById(R.id.avchat_audio_time);
-        wifiUnavailableNotifyTV = (TextView) rootView.findViewById(R.id.avchat_audio_wifi_unavailable);
-        notifyTV = (TextView) rootView.findViewById(R.id.avchat_audio_notify);
-        netUnstableTV = (TextView) rootView.findViewById(R.id.avchat_audio_netunstable);
-
-        mute_speaker_hangup = rootView.findViewById(R.id.avchat_audio_mute_speaker_huangup);
-        View mute = mute_speaker_hangup.findViewById(R.id.avchat_audio_mute);
-        muteToggle = new ToggleView(mute, ToggleState.OFF, this);
-        View speaker = mute_speaker_hangup.findViewById(R.id.avchat_audio_speaker);
-        speakerToggle = new ToggleView(speaker, ToggleState.OFF, this);
-        recordToggle = mute_speaker_hangup.findViewById(R.id.avchat_audio_record);
-        recordToggleButton = (Button) mute_speaker_hangup.findViewById(R.id.avchat_audio_record_button);
-
-        hangup = mute_speaker_hangup.findViewById(R.id.avchat_audio_hangup);
-        hangup.setOnClickListener(this);
-        recordToggle.setOnClickListener(this);
-        recordToggle.setEnabled(false);
-
-        refuse_receive = rootView.findViewById(R.id.avchat_audio_refuse_receive);
-        refuseTV = (TextView) refuse_receive.findViewById(R.id.refuse);
-        receiveTV = (TextView) refuse_receive.findViewById(R.id.receive);
-        refuseTV.setOnClickListener(this);
-        receiveTV.setOnClickListener(this);
-
-        recordView = rootView.findViewById(R.id.avchat_record_layout);
-        recordTip = rootView.findViewById(R.id.avchat_record_tip);
-        recordWarning = rootView.findViewById(R.id.avchat_record_warning);
-
-        init = true;
-    }
-
-    /**
-     * ********************************* 界面设置 *************************************
-     */
-
-    /**
-     * 个人信息设置
-     */
-    private void showProfile(){
-        String account = manager.getAccount();
-        headImg.loadBuddyAvatar(account);
-        nickNameTV.setText(NimUserInfoCache.getInstance().getUserDisplayName(account));
-    }
-
-    /**
-     * 界面状态文案设置
-     * @param resId 文案
-     */
-    private void showNotify(int resId) {
-        notifyTV.setText(resId);
-        notifyTV.setVisibility(View.VISIBLE);
-    }
-
-    /**
-     * 隐藏界面文案
-     */
-    private void hideNotify(){
-        notifyTV.setVisibility(View.GONE);
-    }
-
-    public void showRecordView(boolean show, boolean warning) {
-        if(show) {
-            recordToggle.setSelected(true);
-            recordToggleButton.setText("结束");
-            recordView.setVisibility(View.VISIBLE);
-            recordTip.setVisibility(View.VISIBLE);
-            if(warning) {
-                recordWarning.setVisibility(View.VISIBLE);
-            } else {
-                recordWarning.setVisibility(View.GONE);
-            }
-        } else {
-            recordToggle.setSelected(false);
-            recordToggleButton.setText("录制");
-            recordView.setVisibility(View.INVISIBLE);
-            recordTip.setVisibility(View.INVISIBLE);
-            recordWarning.setVisibility(View.GONE);
-        }
-    }
-
-    /**
-     * 显示网络状态
-     * @param grade
-     */
-    public void showNetworkCondition(int grade){
-        if(grade >= 0 && grade < NETWORK_GRADE_DRAWABLE.length){
-            netUnstableTV.setText(NETWORK_GRADE_LABEL[grade]);
-            Drawable drawable = SheishuoCache.getContext().getResources().getDrawable(NETWORK_GRADE_DRAWABLE[grade]);
-            if(drawable != null){
-                drawable.setBounds(0,0,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());
-                netUnstableTV.setCompoundDrawables(null,null,drawable,null);
-            }
-            netUnstableTV.setVisibility(View.VISIBLE);
-        }
-    }
-
-    /**
-     * ***************************** 布局显隐设置 ***********************************
-     */
-
-    private void setRoot(boolean visible){
-        rootView.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    /**
-     * 显示或隐藏音视频切换
-     * @param visible
-     */
-    private void setSwitchVideo(boolean visible){
-        switchVideo.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    /**
-     * 显示或者隐藏是否为wifi的提示
-     * @param show
-     */
-    private void setWifiUnavailableNotifyTV(boolean show){
-        if(show && !NetworkUtil.isWifi(SheishuoCache.getContext())){
-            wifiUnavailableNotifyTV.setVisibility(View.VISIBLE);
-        }else {
-            wifiUnavailableNotifyTV.setVisibility(View.GONE);
-        }
-    }
-
-    /**
-     * 显示或隐藏禁音,结束通话布局
-     * @param visible
-     */
-    private void setMuteSpeakerHangupControl(boolean visible){
-        mute_speaker_hangup.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    /**
-     * 显示或隐藏拒绝,开启布局
-     * @param visible
-     */
-    private void setRefuseReceive(boolean visible){
-        refuse_receive.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    /**
-     * 设置通话时间显示
-     * @param visible
-     */
-    private void setTime(boolean visible){
-        time.setVisibility(visible ? View.VISIBLE : View.GONE);
-        if(visible){
-            time.setBase(manager.getTimeBase());
-            time.start();
-        }
-    }
-
-    /**
-     * 视频切换为音频时,禁音与扬声器按钮状态
-     * @param muteOn
-     * @param speakerOn
-     */
-    public void onVideoToAudio(boolean muteOn , boolean speakerOn, boolean recordOn, boolean recordWarning) {
-
-        muteToggle.toggle(muteOn ? ToggleState.ON : ToggleState.OFF);
-        speakerToggle.toggle(speakerOn ? ToggleState.ON : ToggleState.OFF);
-        recordToggle.setSelected(recordOn);
-        showRecordView(recordOn, recordWarning);
-    }
-
-    @Override
-    public void onClick(View v) {
-        switch (v.getId()) {
-            case R.id.avchat_audio_hangup:
-                listener.onHangUp();
-                break;
-            case R.id.refuse:
-                listener.onRefuse();
-                break;
-            case R.id.receive:
-                listener.onReceive();
-                break;
-            case R.id.avchat_audio_mute:
-                listener.toggleMute();
-                break;
-            case R.id.avchat_audio_speaker:
-                listener.toggleSpeaker();
-                break;
-            case R.id.avchat_audio_switch_video:
-                if(isInSwitch) {
-                    Toast.makeText(context, R.string.avchat_in_switch, Toast.LENGTH_SHORT).show();
-                }else {
-                    listener.audioSwitchVideo();
-                }
-                break;
-            case R.id.avchat_audio_record:
-                listener.toggleRecord();
-                break;
-            default:
-                break;
-        }
-    }
-
-    public void closeSession(int exitCode){
-        if(init){
-            time.stop();
-            muteToggle.disable(false);
-            speakerToggle.disable(false);
-            recordToggle.setEnabled(false);
-            refuseTV.setEnabled(false);
-            receiveTV.setEnabled(false);
-            hangup.setEnabled(false);
-        }
-    }
-
-    /******************************* toggle listener *************************/
-    @Override
-    public void toggleOn(View v) {
-        onClick(v);
-    }
-
-    @Override
-    public void toggleOff(View v) {
-        onClick(v);
-    }
-
-    @Override
-    public void toggleDisable(View v) {
-
-    }
-}

+ 0 - 96
app/src/com/sheishuo/app/avchat/AVChatFileVideoRender.java

@@ -1,96 +0,0 @@
-package com.sheishuo.app.avchat;
-
-
-import android.os.Environment;
-import android.os.SystemClock;
-import android.util.Log;
-
-import com.netease.nimlib.sdk.avchat.model.AVChatExternalVideoRender;
-import com.netease.nimlib.sdk.avchat.model.AVChatI420Frame;
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-/**
- * Created by liuqijun on 2/27/17.
- */
-public class AVChatFileVideoRender extends AVChatExternalVideoRender {
-
-    private OutputStream outputStream;
-    private int width;
-    private int height;
-
-    @Override
-    public void onFrame(AVChatI420Frame i420Frame, int rotation) {
-        int size = i420Frame.calcBufferSize(AVChatI420Frame.AVChatVideoFormat.kVideoI420);
-        ByteBuffer i420Buffer = ByteBuffer.allocateDirect(size);
-        if (i420Frame.convertFrame(AVChatI420Frame.AVChatVideoFormat.kVideoI420, 0, i420Buffer)) {
-            if (needCreateFile(i420Frame.width(), i420Frame.height())) {
-                createFile(i420Frame.width(), i420Frame.height());
-            }
-
-            if (outputStream != null) {
-                try {
-                    outputStream.write("FRAME\n".getBytes());
-                    byte[] data = new byte[size];
-                    i420Buffer.get(data);
-                    outputStream.write(data);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        i420Frame.release();
-    }
-
-    @Override
-    public boolean initialize() {
-        return true;
-    }
-
-    @Override
-    public void release() {
-        super.release();
-        if (outputStream != null) {
-            try {
-                outputStream.close();
-                outputStream = null;
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private boolean needCreateFile(int w, int h) {
-        return outputStream == null || width != w || height != h;
-    }
-
-    private boolean createFile(int w, int h) {
-        String fileName = getAttachedSession() + "_" + w + "x" + h + "_" + SystemClock.elapsedRealtime() + ".y4m";
-        Log.i("AVChatFileVideoRender", "create file -> " + fileName);
-        if (outputStream != null) {
-            try {
-                outputStream.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-
-        final String videoOutPath = Environment.getExternalStorageDirectory().getPath() + "/" + fileName;
-        try {
-            outputStream = new BufferedOutputStream(new FileOutputStream(videoOutPath));
-            outputStream.write(("YUV4MPEG2 C420 W" + w + " H" + h + " Ip F30:1 A1:1\n").getBytes());
-            width = w;
-            height = h;
-            return true;
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        return false;
-    }
-
-
-}

+ 0 - 124
app/src/com/sheishuo/app/avchat/AVChatNotification.java

@@ -1,124 +0,0 @@
-package com.sheishuo.app.avchat;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.support.v4.app.NotificationCompat;
-
-import com.sheishuo.app.main.activity.WelcomeActivity;
-import com.sheishuo.app.R;
-import com.sheishuo.app.avchat.activity.AVChatActivity;
-import com.sheishuo.app.main.model.Extras;
-import com.netease.nim.uikit.cache.NimUserInfoCache;
-import com.netease.nim.uikit.session.activity.P2PMessageActivity;
-
-/**
- * 音视频聊天通知栏
- * Created by huangjun on 2015/5/14.
- */
-public class AVChatNotification {
-
-    private Context context;
-
-    private NotificationManager notificationManager;
-    private Notification callingNotification;
-    private Notification missCallNotification;
-    private String account;
-    private String displayName;
-    private static final int CALLING_NOTIFY_ID = 111;
-    private static final int MISS_CALL_NOTIFY_ID = 112;
-
-    public AVChatNotification(Context context) {
-        this.context = context;
-    }
-
-    public void init(String account) {
-        this.account = account;
-        this.displayName = NimUserInfoCache.getInstance().getUserDisplayName(account);
-
-        notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
-    }
-
-    private void buildCallingNotification() {
-        if (callingNotification == null) {
-            Intent localIntent = new Intent();
-            localIntent.setClass(context, AVChatActivity.class);
-            localIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
-
-            String tickerText = String.format(context.getString(R.string.avchat_notification), displayName);
-            int iconId = R.drawable.ic_stat_notify_msg;
-
-            PendingIntent pendingIntent = PendingIntent.getActivity(context, CALLING_NOTIFY_ID, localIntent, PendingIntent
-                    .FLAG_UPDATE_CURRENT);
-            callingNotification = makeNotification(pendingIntent, context.getString(R.string.avchat_call), tickerText, tickerText,
-                    iconId, false, false);
-        }
-    }
-
-    private void buildMissCallNotification() {
-        if (missCallNotification == null) {
-            Intent notifyIntent = new Intent(context, WelcomeActivity.class);
-            Intent data = new Intent(context, P2PMessageActivity.class);
-            data.putExtra(Extras.EXTRA_ACCOUNT, account);
-            data.putExtra(Extras.EXTRA_FROM, Extras.EXTRA_FROM_NOTIFICATION);
-            notifyIntent.putExtra(Extras.EXTRA_DATA, data);
-            notifyIntent.putExtra(Extras.EXTRA_JUMP_P2P, true);
-            notifyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
-            notifyIntent.setAction(Intent.ACTION_VIEW);
-            notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-            PendingIntent pendingIntent = PendingIntent.getActivity(context, CALLING_NOTIFY_ID, notifyIntent, PendingIntent
-                    .FLAG_UPDATE_CURRENT);
-
-            String title = context.getString(R.string.avchat_no_pickup_call);
-            String tickerText = NimUserInfoCache.getInstance().getUserDisplayName(account) + ": 【网络通话】";
-            int iconId = R.drawable.avchat_no_pickup;
-
-            missCallNotification = makeNotification(pendingIntent, title, tickerText, tickerText, iconId, true, true);
-        }
-    }
-
-    private Notification makeNotification(PendingIntent pendingIntent, String title, String content, String tickerText,
-                                          int iconId, boolean ring, boolean vibrate) {
-        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
-        builder.setContentTitle(title)
-                .setContentText(content)
-                .setAutoCancel(true)
-                .setContentIntent(pendingIntent)
-                .setTicker(tickerText)
-                .setSmallIcon(iconId);
-        int defaults = Notification.DEFAULT_LIGHTS;
-        if (vibrate) {
-            defaults |= Notification.DEFAULT_VIBRATE;
-        }
-        if (ring) {
-            defaults |= Notification.DEFAULT_SOUND;
-        }
-        builder.setDefaults(defaults);
-
-        return builder.build();
-    }
-
-    public void activeCallingNotification(boolean active) {
-        if (notificationManager != null) {
-            if (active) {
-                buildCallingNotification();
-                notificationManager.notify(CALLING_NOTIFY_ID, callingNotification);
-            } else {
-                notificationManager.cancel(CALLING_NOTIFY_ID);
-            }
-        }
-    }
-
-    public void activeMissCallNotification(boolean active) {
-        if (notificationManager != null) {
-            if (active) {
-                buildMissCallNotification();
-                notificationManager.notify(MISS_CALL_NOTIFY_ID, missCallNotification);
-            } else {
-                notificationManager.cancel(MISS_CALL_NOTIFY_ID);
-            }
-        }
-    }
-}

+ 0 - 47
app/src/com/sheishuo/app/avchat/AVChatProfile.java

@@ -1,47 +0,0 @@
-package com.sheishuo.app.avchat;
-
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.avchat.activity.AVChatActivity;
-import com.sheishuo.app.common.infra.Handlers;
-import com.netease.nimlib.sdk.avchat.model.AVChatData;
-
-/**
- * Created by huangjun on 2015/5/12.
- */
-public class AVChatProfile {
-
-    private final String TAG = "AVChatProfile";
-
-    private boolean isAVChatting = false; // 是否正在音视频通话
-
-    public static AVChatProfile getInstance() {
-        return InstanceHolder.instance;
-    }
-
-    public boolean isAVChatting() {
-        return isAVChatting;
-    }
-
-    public void setAVChatting(boolean chating) {
-        isAVChatting = chating;
-    }
-
-    private static class InstanceHolder {
-        public final static AVChatProfile instance = new AVChatProfile();
-    }
-
-    public void launchActivity(final AVChatData data, final int source) {
-        Runnable runnable = new Runnable() {
-            @Override
-            public void run() {
-                // 启动,如果 task正在启动,则稍等一下
-                if (!SheishuoCache.isMainTaskLaunching()) {
-                    AVChatActivity.launch(SheishuoCache.getContext(), data, source);
-                } else {
-                    launchActivity(data, source);
-                }
-            }
-        };
-        Handlers.sharedHandler(SheishuoCache.getContext()).postDelayed(runnable, 200);
-    }
-}

+ 0 - 167
app/src/com/sheishuo/app/avchat/AVChatSoundPlayer.java

@@ -1,167 +0,0 @@
-package com.sheishuo.app.avchat;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.media.AudioManager;
-import android.media.SoundPool;
-
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-
-
-/**
- * SoundPool 铃声尽量不要超过1M
- * 在不同的系统下 SoundPool 表现可能存在不一致
- */
-public class AVChatSoundPlayer {
-
-    private static final String TAG = "AVChatSoundPlayer";
-
-    public enum RingerTypeEnum {
-        CONNECTING,
-        NO_RESPONSE,
-        PEER_BUSY,
-        PEER_REJECT,
-        RING,
-        ;
-    }
-    private Context context;
-
-    private SoundPool soundPool;
-    private AudioManager audioManager;
-    private int streamId;
-    private int soundId;
-    private boolean loop;
-    private RingerTypeEnum ringerTypeEnum;
-    private boolean isRingModeRegister = false;
-    private int ringMode = -1;
-
-    private static AVChatSoundPlayer instance = null;
-    private RingModeChangeReceiver ringModeChangeReceiver;
-
-    public static AVChatSoundPlayer instance() {
-        if(instance == null) {
-            synchronized (AVChatSoundPlayer.class) {
-                if(instance == null) {
-                    instance = new AVChatSoundPlayer();
-                }
-            }
-        }
-        return instance;
-    }
-
-    public AVChatSoundPlayer() {
-        this.context = SheishuoCache.getContext();
-    }
-
-    public synchronized void play(RingerTypeEnum type) {
-        LogUtil.d(TAG, "play type->" + type.name());
-        this.ringerTypeEnum = type;
-        int ringId = 0;
-        switch (type) {
-        case NO_RESPONSE:
-            ringId = R.raw.avchat_no_response;
-            loop = false;
-            break;
-        case PEER_BUSY:
-            ringId = R.raw.avchat_peer_busy;
-            loop = false;
-            break;
-        case PEER_REJECT:
-            ringId = R.raw.avchat_peer_reject;
-            loop = false;
-            break;
-        case CONNECTING:
-            ringId = R.raw.avchat_connecting;
-            loop = true;
-            break;
-        case RING:
-            ringId = R.raw.avchat_ring;
-            loop = true;
-            break;
-        }
-
-        if(ringId != 0) {
-            play(ringId);
-        }
-
-    }
-
-    public void stop() {
-        LogUtil.d(TAG, "stop");
-        if (soundPool != null) {
-            if (streamId != 0) {
-                soundPool.stop(streamId);
-                streamId = 0;
-            }
-            if (soundId != 0) {
-                soundPool.unload(soundId);
-                soundId = 0;
-            }
-        }
-        if (isRingModeRegister) {
-            registerVolumeReceiver(false);
-        }
-    }
-
-    private void play(int ringId) {
-        initSoundPool();
-        if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
-            soundId = soundPool.load(context, ringId, 1);
-        }
-    }
-
-    private void initSoundPool() {
-        stop();
-        if (soundPool == null) {
-            soundPool = new SoundPool(1, AudioManager.STREAM_RING, 0);
-            soundPool.setOnLoadCompleteListener(onLoadCompleteListener);
-
-            audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
-            ringMode = audioManager.getRingerMode();
-        }
-        registerVolumeReceiver(true);
-    }
-
-    SoundPool.OnLoadCompleteListener onLoadCompleteListener = new SoundPool.OnLoadCompleteListener() {
-        @Override
-        public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
-            if (soundId != 0 && status == 0) {
-                if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) {
-                    int curVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);
-                    streamId = soundPool.play(soundId, curVolume, curVolume, 1, loop ? -1 : 0, 1f);
-                }
-            }
-        }
-    };
-
-    private void registerVolumeReceiver(boolean register){
-        if (ringModeChangeReceiver == null) {
-            ringModeChangeReceiver = new RingModeChangeReceiver() ;
-        }
-
-        if (register) {
-            isRingModeRegister = true;
-            IntentFilter filter = new IntentFilter() ;
-            filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION) ;
-            context.registerReceiver(ringModeChangeReceiver, filter) ;
-        } else {
-            context.unregisterReceiver(ringModeChangeReceiver);
-            isRingModeRegister = false;
-        }
-    }
-
-    private class RingModeChangeReceiver extends BroadcastReceiver {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (ringMode != -1 && ringMode != audioManager.getRingerMode()
-                    && intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
-                ringMode = audioManager.getRingerMode();
-                play(ringerTypeEnum);
-            }
-        }
-    }
-}

+ 0 - 419
app/src/com/sheishuo/app/avchat/AVChatSurface.java

@@ -1,419 +0,0 @@
-package com.sheishuo.app.avchat;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.os.Handler;
-import android.view.Gravity;
-import android.view.MotionEvent;
-import android.view.SurfaceView;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.avchat.constant.CallStateEnum;
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.common.util.sys.ScreenUtil;
-import com.netease.nimlib.sdk.avchat.AVChatManager;
-import com.netease.nimlib.sdk.avchat.constant.AVChatVideoScalingType;
-import com.netease.nimlib.sdk.avchat.model.AVChatVideoRender;
-
-/**
- * 视频绘制管理
- * Created by hzxuwen on 2015/5/6.
- */
-public class AVChatSurface {
-
-    private Context context;
-    private AVChatUI manager;
-    private View surfaceRoot;
-    private Handler uiHandler;
-
-    // constant
-    private static final int PEER_CLOSE_CAMERA = 0;
-    private static final int LOCAL_CLOSE_CAMERA = 1;
-    private static final int AUDIO_TO_VIDEO_WAIT = 2;
-    private static final int TOUCH_SLOP = 10;
-
-    // view
-    private LinearLayout largeSizePreviewLayout;
-    private FrameLayout smallSizePreviewFrameLayout;
-    private LinearLayout smallSizePreviewLayout;
-    private ImageView smallSizePreviewCoverImg;//stands for peer or local close camera
-    private View largeSizePreviewCoverLayout;//stands for peer or local close camera
-
-    //render
-    private AVChatVideoRender smallRender;
-    private AVChatVideoRender largeRender;
-
-    // state
-    private boolean init = false;
-    private boolean localPreviewInSmallSize = true;
-    private boolean isPeerVideoOff = false;
-    private boolean isLocalVideoOff = false;
-
-    // move
-    private int lastX, lastY;
-    private int inX, inY;
-    private Rect paddingRect;
-
-    // data
-    private String largeAccount; // 显示在大图像的用户id
-    private String smallAccount; // 显示在小图像的用户id
-
-    public AVChatSurface(Context context, AVChatUI manager, View surfaceRoot) {
-        this.context = context;
-        this.manager = manager;
-        this.surfaceRoot = surfaceRoot;
-        this.uiHandler = new Handler(context.getMainLooper());
-        this.smallRender = new AVChatVideoRender(context);
-        this.largeRender = new AVChatVideoRender(context);
-    }
-
-    private void findViews() {
-        if (init)
-            return;
-        if (surfaceRoot != null) {
-
-            smallSizePreviewFrameLayout = (FrameLayout) surfaceRoot.findViewById(R.id.small_size_preview_layout);
-            smallSizePreviewLayout = (LinearLayout) surfaceRoot.findViewById(R.id.small_size_preview);
-            smallSizePreviewCoverImg = (ImageView) surfaceRoot.findViewById(R.id.smallSizePreviewCoverImg);
-            smallSizePreviewFrameLayout.setOnTouchListener(touchListener);
-
-            largeSizePreviewLayout = (LinearLayout) surfaceRoot.findViewById(R.id.large_size_preview);
-            largeSizePreviewCoverLayout = surfaceRoot.findViewById(R.id.notificationLayout);
-
-            init = true;
-        }
-    }
-
-    private View.OnTouchListener touchListener = new View.OnTouchListener() {
-        @Override
-        public boolean onTouch(final View v, MotionEvent event) {
-            int x = (int) event.getRawX();
-            int y = (int) event.getRawY();
-
-            switch (event.getAction()) {
-                case MotionEvent.ACTION_DOWN:
-                    lastX = x;
-                    lastY = y;
-                    int[] p = new int[2];
-                    smallSizePreviewFrameLayout.getLocationOnScreen(p);
-                    inX = x - p[0];
-                    inY = y - p[1];
-
-                    break;
-                case MotionEvent.ACTION_MOVE:
-                    final int diff = Math.max(Math.abs(lastX - x), Math.abs(lastY - y));
-                    if (diff < TOUCH_SLOP)
-                        break;
-
-                    if (paddingRect == null) {
-                        paddingRect = new Rect(ScreenUtil.dip2px(10), ScreenUtil.dip2px(20), ScreenUtil.dip2px(10),
-                                ScreenUtil.dip2px(70));
-                    }
-
-                    int destX, destY;
-                    if (x - inX <= paddingRect.left) {
-                        destX = paddingRect.left;
-                    } else if (x - inX + v.getWidth() >= ScreenUtil.screenWidth - paddingRect.right) {
-                        destX = ScreenUtil.screenWidth - v.getWidth() - paddingRect.right;
-                    } else {
-                        destX = x - inX;
-                    }
-
-                    if (y - inY <= paddingRect.top) {
-                        destY = paddingRect.top;
-                    } else if (y - inY + v.getHeight() >= ScreenUtil.screenHeight - paddingRect.bottom) {
-                        destY = ScreenUtil.screenHeight - v.getHeight() - paddingRect.bottom;
-                    } else {
-                        destY = y - inY;
-                    }
-
-                    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams();
-                    params.gravity = Gravity.NO_GRAVITY;
-                    params.leftMargin = destX;
-                    params.topMargin = destY;
-                    v.setLayoutParams(params);
-
-                    break;
-                case MotionEvent.ACTION_UP:
-                    if (Math.max(Math.abs(lastX - x), Math.abs(lastY - y)) <= 5) {
-                        if (largeAccount == null || smallAccount == null) {
-                            return true;
-                        }
-                        String temp;
-                        switchRender(smallAccount, largeAccount);
-                        temp = largeAccount;
-                        largeAccount = smallAccount;
-                        smallAccount = temp;
-                        switchAndSetLayout();
-                    } else {
-
-                    }
-
-                    break;
-            }
-
-            return true;
-        }
-    };
-
-    public void onCallStateChange(CallStateEnum state) {
-        if (CallStateEnum.isVideoMode(state))
-            findViews();
-        switch (state) {
-            case VIDEO:
-                largeSizePreviewCoverLayout.setVisibility(View.GONE);
-                break;
-            case OUTGOING_AUDIO_TO_VIDEO:
-                showNotificationLayout(AUDIO_TO_VIDEO_WAIT);
-                break;
-            case INCOMING_AUDIO_TO_VIDEO:
-                break;
-            case AUDIO:
-                if(smallSizePreviewFrameLayout != null) {
-                    smallSizePreviewFrameLayout.setVisibility(View.INVISIBLE);
-                }
-                break;
-            default:
-                break;
-        }
-        setSurfaceRoot(CallStateEnum.isVideoMode(state));
-    }
-
-    /**
-     * 大图像surfaceview 初始化
-     *
-     * @param account 显示视频的用户id
-     */
-    public void initLargeSurfaceView(String account) {
-        largeAccount = account;
-        findViews();
-        /**
-         * 设置画布,加入到自己的布局中,用于呈现视频图像
-         * account 要显示视频的用户帐号
-         */
-        if (SheishuoCache.getAccount().equals(account)) {
-            AVChatManager.getInstance().setupLocalVideoRender(largeRender, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        } else {
-            AVChatManager.getInstance().setupRemoteVideoRender(account, largeRender, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        }
-        addIntoLargeSizePreviewLayout(largeRender);
-
-    }
-
-    /**
-     * 小图像surfaceview 初始化
-     *
-     * @param account
-     * @return
-     */
-    public void initSmallSurfaceView(String account) {
-        smallAccount = account;
-        findViews();
-        smallSizePreviewFrameLayout.setVisibility(View.VISIBLE);
-        /**
-         * 设置画布,加入到自己的布局中,用于呈现视频图像
-         * account 要显示视频的用户帐号
-         */
-        if (SheishuoCache.getAccount().equals(account)) {
-            AVChatManager.getInstance().setupLocalVideoRender(smallRender, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        } else {
-            AVChatManager.getInstance().setupRemoteVideoRender(account, smallRender, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        }
-        addIntoSmallSizePreviewLayout(smallRender);
-
-    }
-
-
-    /**
-     * 添加surfaceview到largeSizePreviewLayout
-     *
-     * @param surfaceView
-     */
-    private void addIntoLargeSizePreviewLayout(SurfaceView surfaceView) {
-        if (surfaceView.getParent() != null) {
-            ((ViewGroup) surfaceView.getParent()).removeView(surfaceView);
-        }
-        largeSizePreviewLayout.addView(surfaceView);
-        surfaceView.setZOrderMediaOverlay(false);
-        if (manager.getCallingState() == CallStateEnum.VIDEO || manager.getCallingState() == CallStateEnum.OUTGOING_VIDEO_CALLING) {
-            largeSizePreviewCoverLayout.setVisibility(View.GONE);
-        }
-    }
-
-    /**
-     * 添加surfaceview到smallSizePreviewLayout
-     */
-    private void addIntoSmallSizePreviewLayout(SurfaceView surfaceView) {
-        smallSizePreviewCoverImg.setVisibility(View.GONE);
-        if (surfaceView.getParent() != null) {
-            ((ViewGroup) surfaceView.getParent()).removeView(surfaceView);
-        }
-        smallSizePreviewLayout.addView(surfaceView);
-        surfaceView.setZOrderMediaOverlay(true);
-        smallSizePreviewLayout.setVisibility(View.VISIBLE);
-    }
-
-    /**
-     * 关闭小窗口
-     */
-    private void closeSmallSizePreview() {
-        smallSizePreviewCoverImg.setVisibility(View.VISIBLE);
-    }
-
-    /**
-     * 对方打开了摄像头
-     */
-    public void peerVideoOn() {
-        isPeerVideoOff = false;
-        if (localPreviewInSmallSize) {
-            largeSizePreviewCoverLayout.setVisibility(View.GONE);
-        } else {
-            smallSizePreviewCoverImg.setVisibility(View.GONE);
-        }
-    }
-
-    /**
-     * 对方关闭了摄像头
-     */
-    public void peerVideoOff() {
-        isPeerVideoOff = true;
-        if (localPreviewInSmallSize) { //local preview in small size layout, then peer preview should in large size layout
-            showNotificationLayout(PEER_CLOSE_CAMERA);
-        } else {  // peer preview in small size layout
-            closeSmallSizePreview();
-        }
-    }
-
-    /**
-     * 对方打开了摄像头
-     */
-    public void localVideoOn() {
-        isLocalVideoOff = false;
-        if (localPreviewInSmallSize) {
-            smallSizePreviewCoverImg.setVisibility(View.GONE);
-        } else {
-            largeSizePreviewCoverLayout.setVisibility(View.GONE);
-        }
-    }
-
-    /**
-     * 本地关闭了摄像头
-     */
-    public void localVideoOff() {
-        isLocalVideoOff = true;
-        if (localPreviewInSmallSize)
-            closeSmallSizePreview();
-        else
-            showNotificationLayout(LOCAL_CLOSE_CAMERA);
-    }
-
-    /**
-     * 摄像头切换时,布局显隐
-     */
-    private void switchAndSetLayout() {
-        localPreviewInSmallSize = !localPreviewInSmallSize;
-        largeSizePreviewCoverLayout.setVisibility(View.GONE);
-        smallSizePreviewCoverImg.setVisibility(View.GONE);
-        if (isPeerVideoOff) {
-            peerVideoOff();
-        }
-        if (isLocalVideoOff) {
-            localVideoOff();
-        }
-    }
-
-    /**
-     * 界面提示
-     *
-     * @param closeType
-     */
-    private void showNotificationLayout(int closeType) {
-        if(largeSizePreviewCoverLayout == null) {
-            return;
-        }
-        TextView textView = (TextView) largeSizePreviewCoverLayout;
-        switch (closeType) {
-            case PEER_CLOSE_CAMERA:
-                textView.setText(R.string.avchat_peer_close_camera);
-                break;
-            case LOCAL_CLOSE_CAMERA:
-                textView.setText(R.string.avchat_local_close_camera);
-                break;
-            case AUDIO_TO_VIDEO_WAIT:
-                textView.setText(R.string.avchat_audio_to_video_wait);
-                break;
-            default:
-                return;
-        }
-        largeSizePreviewCoverLayout.setVisibility(View.VISIBLE);
-    }
-
-    /**
-     * 布局是否可见
-     *
-     * @param visible
-     */
-    private void setSurfaceRoot(boolean visible) {
-        surfaceRoot.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    /**
-     * 大小图像显示切换
-     *
-     * @param user1 用户1的account
-     * @param user2 用户2的account
-     */
-    private void switchRender(String user1, String user2) {
-
-        //先取消用户的画布
-        if (SheishuoCache.getAccount().equals(user1)) {
-            AVChatManager.getInstance().setupLocalVideoRender(null, false, 0);
-        } else {
-            AVChatManager.getInstance().setupRemoteVideoRender(user1, null, false, 0);
-        }
-        if (SheishuoCache.getAccount().equals(user2)) {
-            AVChatManager.getInstance().setupLocalVideoRender(null, false, 0);
-        } else {
-            AVChatManager.getInstance().setupRemoteVideoRender(user2, null, false, 0);
-        }
-        //交换画布
-        //如果存在多个用户,建议用Map维护account,render关系.
-        //目前只有两个用户,并且认为这两个account肯定是对的
-        AVChatVideoRender render1;
-        AVChatVideoRender render2;
-        if(user1.equals(smallAccount)) {
-            render1 = largeRender;
-            render2 = smallRender;
-        } else {
-            render1 = smallRender;
-            render2 = largeRender;
-        }
-
-        //重新设置上画布
-        if (user1 == SheishuoCache.getAccount()) {
-            AVChatManager.getInstance().setupLocalVideoRender(render1, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        } else {
-            AVChatManager.getInstance().setupRemoteVideoRender(user1, render1, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        }
-        if (user2 == SheishuoCache.getAccount()) {
-            AVChatManager.getInstance().setupLocalVideoRender(render2, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        } else {
-            AVChatManager.getInstance().setupRemoteVideoRender(user2, render2, false, AVChatVideoScalingType.SCALE_ASPECT_BALANCED);
-        }
-    }
-
-    /**
-     * 是否本地预览图像在小图像(UI上层)
-     *
-     * @return
-     */
-    public boolean isLocalPreviewInSmallSize() {
-        return localPreviewInSmallSize;
-    }
-}

+ 0 - 979
app/src/com/sheishuo/app/avchat/AVChatUI.java

@@ -1,979 +0,0 @@
-package com.sheishuo.app.avchat;
-
-import android.Manifest;
-import android.app.Activity;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.Pair;
-import android.view.View;
-import android.widget.Toast;
-
-import com.sheishuo.app.avchat.activity.AVChatExitCode;
-import com.sheishuo.app.avchat.widgets.MultiSelectDialog;
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.R;
-import com.sheishuo.app.avchat.constant.CallStateEnum;
-import com.netease.nim.uikit.common.ui.dialog.DialogMaker;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nim.uikit.permission.BaseMPermission;
-import com.netease.nimlib.sdk.ResponseCode;
-import com.netease.nimlib.sdk.avchat.AVChatCallback;
-import com.netease.nimlib.sdk.avchat.AVChatManager;
-import com.netease.nimlib.sdk.avchat.constant.AVChatAudioEffectMode;
-import com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand;
-import com.netease.nimlib.sdk.avchat.constant.AVChatMediaCodecMode;
-import com.netease.nimlib.sdk.avchat.constant.AVChatType;
-import com.netease.nimlib.sdk.avchat.constant.AVChatUserRole;
-import com.netease.nimlib.sdk.avchat.model.AVChatCameraCapturer;
-import com.netease.nimlib.sdk.avchat.model.AVChatData;
-import com.netease.nimlib.sdk.avchat.model.AVChatNotifyOption;
-import com.netease.nimlib.sdk.avchat.model.AVChatParameters;
-import com.netease.nimlib.sdk.avchat.model.AVChatVideoCapturerFactory;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * 音视频管理器, 音视频相关功能管理
- * Created by hzxuwen on 2015/4/23.
- */
-public class AVChatUI implements AVChatUIListener {
-    // constant
-    private static final String TAG = "AVChatUI";
-
-    // data
-    private Context context;
-    private AVChatData avChatData;
-    private final AVChatListener aVChatListener;
-    private String receiverId;
-    private AVChatAudio avChatAudio;
-    private AVChatVideo avChatVideo;
-    private AVChatSurface avChatSurface;
-    private AVChatParameters avChatParameters;
-    private String videoAccount; // 发送视频请求,onUserJoin回调的user account
-
-    private CallStateEnum callingState = CallStateEnum.INVALID;
-
-    private long timeBase = 0;
-
-    // view
-    private View root;
-
-    // state
-    public boolean canSwitchCamera = false;
-    private boolean isClosedCamera = false;
-    public AtomicBoolean isCallEstablish = new AtomicBoolean(false);
-
-    private final String[] BASIC_PERMISSIONS = new String[]{Manifest.permission.CAMERA,};
-
-    //是否在录制
-    private boolean isRecording = false;
-
-    // 检查存储
-    private boolean recordWarning = false;
-
-    List<Pair<String, Boolean>> recordList = new LinkedList<Pair<String, Boolean>>();
-
-    private AVChatCameraCapturer mVideoCapturer;
-
-    public interface AVChatListener {
-        void uiExit();
-    }
-
-    public AVChatUI(Context context, View root, AVChatListener listener) {
-        this.context = context;
-        this.root = root;
-        this.aVChatListener = listener;
-        this.avChatParameters = new AVChatParameters();
-        configFromPreference(PreferenceManager.getDefaultSharedPreferences(context));
-        updateAVChatOptionalConfig();
-    }
-
-
-    //Config from Preference
-    private int videoCropRatio;
-    private boolean videoAutoRotate;
-    private int videoQuality;
-    private boolean serverRecordAudio;
-    private boolean serverRecordVideo;
-    private boolean defaultFrontCamera;
-    private boolean autoCallProximity;
-    private int videoHwEncoderMode;
-    private int videoHwDecoderMode;
-    private boolean videoFpsReported;
-    private int audioEffectAecMode;
-    private int audioEffectNsMode;
-    private int videoMaxBitrate;
-    private int deviceDefaultRotation;
-    private int deviceRotationOffset;
-    private boolean audioHighQuality;
-    private boolean audioDtx;
-    private boolean webrtcCompat;
-
-    private void configFromPreference(SharedPreferences preferences) {
-        videoCropRatio = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_crop_ratio_key), "0"));
-        videoAutoRotate = preferences.getBoolean(context.getString(R.string.nrtc_setting_vie_rotation_key), true);
-        videoQuality = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_quality_key), 0 + ""));
-        serverRecordAudio = preferences.getBoolean(context.getString(R.string.nrtc_setting_other_server_record_audio_key), false);
-        serverRecordVideo = preferences.getBoolean(context.getString(R.string.nrtc_setting_other_server_record_video_key), false);
-        defaultFrontCamera = preferences.getBoolean(context.getString(R.string.nrtc_setting_vie_default_front_camera_key), true);
-        autoCallProximity = preferences.getBoolean(context.getString(R.string.nrtc_setting_voe_call_proximity_key), true);
-        videoHwEncoderMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_hw_encoder_key), 0 + ""));
-        videoHwDecoderMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_vie_hw_decoder_key), 0 + ""));
-        videoFpsReported = preferences.getBoolean(context.getString(R.string.nrtc_setting_vie_fps_reported_key), true);
-        audioEffectAecMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_voe_audio_aec_key), 2 + ""));
-        audioEffectNsMode = Integer.parseInt(preferences.getString(context.getString(R.string.nrtc_setting_voe_audio_ns_key), 2 + ""));
-        String value1 = preferences.getString(context.getString(R.string.nrtc_setting_vie_max_bitrate_key), 0 + "");
-        videoMaxBitrate = Integer.parseInt(TextUtils.isDigitsOnly(value1) && !TextUtils.isEmpty(value1) ? value1 : 0 + "");
-        String value2 = preferences.getString(context.getString(R.string.nrtc_setting_other_device_default_rotation_key), 0 + "");
-        deviceDefaultRotation = Integer.parseInt(TextUtils.isDigitsOnly(value2) && !TextUtils.isEmpty(value2) ? value2 : 0 + "");
-        String value3 = preferences.getString(context.getString(R.string.nrtc_setting_other_device_rotation_fixed_offset_key), 0 + "");
-        deviceRotationOffset = Integer.parseInt(TextUtils.isDigitsOnly(value3) && !TextUtils.isEmpty(value3) ? value3 : 0 + "");
-        audioHighQuality = preferences.getBoolean(context.getString(R.string.nrtc_setting_voe_high_quality_key), false);
-        audioDtx = preferences.getBoolean(context.getString(R.string.nrtc_setting_voe_dtx_key), true);
-        webrtcCompat = preferences.getBoolean(context.getString(R.string.nrtc_setting_other_webrtc_compat_key), true);
-    }
-
-
-    /**
-     * 1, autoCallProximity: 语音通话时使用, 距离感应自动黑屏
-     * 2, videoCropRatio: 制定固定的画面裁剪比例,发送端有效
-     * 3, videoAutoRotate: 结合自己设备角度和对方设备角度自动旋转画面
-     * 4, serverRecordAudio: 需要服务器录制语音, 同时需要 APP KEY 下面开通了服务器录制功能
-     * 5, serverRecordVideo: 需要服务器录制视频, 同时需要 APP KEY 下面开通了服务器录制功能
-     * 6, defaultFrontCamera: 默认是否使用前置摄像头
-     * 7, videoQuality: 视频质量调整, 最高建议使用480P
-     * 8, videoFpsReported: 是否开启视频绘制帧率汇报
-     * 9, deviceDefaultRotation: 99.99%情况下你不需要设置这个参数, 当设备固定在水平方向时,并且设备不会移动, 这时是无法确定设备角度的,可以设置一个默认角度
-     * 10, deviceRotationOffset: 99.99%情况下你不需要设置这个参数, 当你的设备传感器获取的角度永远偏移固定值时设置,用于修正旋转角度
-     * 11, videoMaxBitrate: 视频最大码率设置, 100K ~ 5M. 如果没有特殊需求不要去设置,会影响SDK内部的调节机制
-     * 12, audioEffectAecMode: 语音处理选择, 默认使用平台内置,当你发现平台内置不好用时可以设置到SDK内置
-     * 13, audioEffectNsMode: 语音处理选择, 默认使用平台内置,当你发现平台内置不好用时可以设置到SDK内置
-     * 14, videoHwEncoderMode: 视频编码类型, 默认情况下不用设置.
-     * 15, videoHwDecoderMode: 视频解码类型, 默认情况下不用设置.
-     * 16, audioHighQuality: 高清语音,采用更高的采样率来传输语音
-     * 17, audioDtx: 非连续发送,当监测到人声非活跃状态时减少数据包的发送
-     */
-    private void updateAVChatOptionalConfig() {
-        avChatParameters.setBoolean(AVChatParameters.KEY_AUDIO_CALL_PROXIMITY, autoCallProximity);
-        avChatParameters.setInteger(AVChatParameters.KEY_VIDEO_FIXED_CROP_RATIO, videoCropRatio);
-        avChatParameters.setBoolean(AVChatParameters.KEY_VIDEO_ROTATE_IN_RENDING, videoAutoRotate);
-        avChatParameters.setBoolean(AVChatParameters.KEY_SERVER_AUDIO_RECORD, serverRecordAudio);
-        avChatParameters.setBoolean(AVChatParameters.KEY_SERVER_VIDEO_RECORD, serverRecordVideo);
-        avChatParameters.setBoolean(AVChatParameters.KEY_VIDEO_DEFAULT_FRONT_CAMERA, defaultFrontCamera);
-        avChatParameters.setInteger(AVChatParameters.KEY_VIDEO_QUALITY, videoQuality);
-        avChatParameters.setBoolean(AVChatParameters.KEY_VIDEO_FPS_REPORTED, videoFpsReported);
-        avChatParameters.setInteger(AVChatParameters.KEY_DEVICE_DEFAULT_ROTATION, deviceDefaultRotation);
-        avChatParameters.setInteger(AVChatParameters.KEY_DEVICE_ROTATION_FIXED_OFFSET, deviceRotationOffset);
-
-        if (videoMaxBitrate > 0) {
-            avChatParameters.setInteger(AVChatParameters.KEY_VIDEO_MAX_BITRATE, videoMaxBitrate * 1024);
-        }
-        switch (audioEffectAecMode) {
-            case 0:
-                avChatParameters.setString(AVChatParameters.KEY_AUDIO_EFFECT_ACOUSTIC_ECHO_CANCELER, AVChatAudioEffectMode.DISABLE);
-                break;
-            case 1:
-                avChatParameters.setString(AVChatParameters.KEY_AUDIO_EFFECT_ACOUSTIC_ECHO_CANCELER, AVChatAudioEffectMode.SDK_BUILTIN);
-                break;
-            case 2:
-                avChatParameters.setString(AVChatParameters.KEY_AUDIO_EFFECT_ACOUSTIC_ECHO_CANCELER, AVChatAudioEffectMode.PLATFORM_BUILTIN);
-                break;
-        }
-        switch (audioEffectNsMode) {
-            case 0:
-                avChatParameters.setString(AVChatParameters.KEY_AUDIO_EFFECT_NOISE_SUPPRESSOR, AVChatAudioEffectMode.DISABLE);
-                break;
-            case 1:
-                avChatParameters.setString(AVChatParameters.KEY_AUDIO_EFFECT_NOISE_SUPPRESSOR, AVChatAudioEffectMode.SDK_BUILTIN);
-                break;
-            case 2:
-                avChatParameters.setString(AVChatParameters.KEY_AUDIO_EFFECT_NOISE_SUPPRESSOR, AVChatAudioEffectMode.PLATFORM_BUILTIN);
-                break;
-        }
-        switch (videoHwEncoderMode) {
-            case 0:
-                avChatParameters.setString(AVChatParameters.KEY_VIDEO_ENCODER_MODE, AVChatMediaCodecMode.MEDIA_CODEC_AUTO);
-                break;
-            case 1:
-                avChatParameters.setString(AVChatParameters.KEY_VIDEO_ENCODER_MODE, AVChatMediaCodecMode.MEDIA_CODEC_SOFTWARE);
-                break;
-            case 2:
-                avChatParameters.setString(AVChatParameters.KEY_VIDEO_ENCODER_MODE, AVChatMediaCodecMode.MEDIA_CODEC_HARDWARE);
-                break;
-        }
-        switch (videoHwDecoderMode) {
-            case 0:
-                avChatParameters.setString(AVChatParameters.KEY_VIDEO_DECODER_MODE, AVChatMediaCodecMode.MEDIA_CODEC_AUTO);
-                break;
-            case 1:
-                avChatParameters.setString(AVChatParameters.KEY_VIDEO_DECODER_MODE, AVChatMediaCodecMode.MEDIA_CODEC_SOFTWARE);
-                break;
-            case 2:
-                avChatParameters.setString(AVChatParameters.KEY_VIDEO_DECODER_MODE, AVChatMediaCodecMode.MEDIA_CODEC_HARDWARE);
-                break;
-        }
-        avChatParameters.setBoolean(AVChatParameters.KEY_AUDIO_HIGH_QUALITY, audioHighQuality);
-        avChatParameters.setBoolean(AVChatParameters.KEY_AUDIO_DTX_ENABLE, audioDtx);
-
-        //观众角色,多人模式下使用. IM Demo没有多人通话, 全部设置为AVChatUserRole.NORMAL.
-        avChatParameters.setInteger(AVChatParameters.KEY_SESSION_MULTI_MODE_USER_ROLE, AVChatUserRole.NORMAL);
-    }
-
-
-    /**
-     * ******************************初始化******************************
-     */
-
-    /**
-     * 初始化,包含初始化音频管理器, 视频管理器和视频界面绘制管理器。
-     *
-     * @return boolean
-     */
-    public boolean initiation() {
-        AVChatProfile.getInstance().setAVChatting(true);
-        avChatAudio = new AVChatAudio(context, root.findViewById(R.id.avchat_audio_layout), this, this);
-        avChatVideo = new AVChatVideo(context, root.findViewById(R.id.avchat_video_layout), this, this);
-        avChatSurface = new AVChatSurface(context, this, root.findViewById(R.id.avchat_surface_layout));
-
-        return true;
-    }
-
-    /**
-     * ******************************拨打和接听***************************
-     */
-
-    /**
-     * 来电
-     */
-    public void inComingCalling(AVChatData avChatData) {
-        this.avChatData = avChatData;
-        receiverId = avChatData.getAccount();
-
-        AVChatSoundPlayer.instance().play(AVChatSoundPlayer.RingerTypeEnum.RING);
-
-        if (avChatData.getChatType() == AVChatType.AUDIO) {
-            onCallStateChange(CallStateEnum.INCOMING_AUDIO_CALLING);
-        } else {
-            onCallStateChange(CallStateEnum.INCOMING_VIDEO_CALLING);
-        }
-    }
-
-
-    /**
-     * 拨打音视频
-     */
-    public void outGoingCalling(String account, final AVChatType callTypeEnum) {
-
-        DialogMaker.showProgressDialog(context, null);
-
-        AVChatSoundPlayer.instance().play(AVChatSoundPlayer.RingerTypeEnum.CONNECTING);
-
-        this.receiverId = account;
-
-        AVChatNotifyOption notifyOption = new AVChatNotifyOption();
-        notifyOption.extendMessage = "extra_data";
-        notifyOption.webRTCCompat = webrtcCompat;
-//        默认forceKeepCalling为true,开发者如果不需要离线持续呼叫功能可以将forceKeepCalling设为false
-//        notifyOption.forceKeepCalling = false;
-
-        AVChatManager.getInstance().enableRtc();
-        if (mVideoCapturer == null) {
-            mVideoCapturer = AVChatVideoCapturerFactory.createCameraCapturer();
-            AVChatManager.getInstance().setupVideoCapturer(mVideoCapturer);
-        }
-        this.callingState = (callTypeEnum == AVChatType.VIDEO ? CallStateEnum.VIDEO : CallStateEnum.AUDIO);
-        AVChatManager.getInstance().setParameters(avChatParameters);
-        if (callTypeEnum == AVChatType.VIDEO) {
-            AVChatManager.getInstance().enableVideo();
-            AVChatManager.getInstance().startVideoPreview();
-        }
-
-        AVChatManager.getInstance().call2(account, callTypeEnum, notifyOption, new AVChatCallback<AVChatData>() {
-            @Override
-            public void onSuccess(AVChatData data) {
-                avChatData = data;
-                DialogMaker.dismissProgressDialog();
-                //如果需要使用视频预览功能,在此进行设置,调用setupLocalVideoRender
-                //如果不需要视频预览功能,那么删掉下面if语句代码即可
-                if (callTypeEnum == AVChatType.VIDEO) {
-                    List<String> deniedPermissions = BaseMPermission.getDeniedPermissions((Activity) context, BASIC_PERMISSIONS);
-                    if (deniedPermissions != null && !deniedPermissions.isEmpty()) {
-                        avChatVideo.showNoneCameraPermissionView(true);
-                        return;
-                    }
-
-                    initLargeSurfaceView(SheishuoCache.getAccount());
-                    canSwitchCamera = true;
-                    onCallStateChange(CallStateEnum.OUTGOING_VIDEO_CALLING);
-                }
-            }
-
-            @Override
-            public void onFailed(int code) {
-                LogUtil.d(TAG, "avChat call failed code->" + code);
-
-                if (code == ResponseCode.RES_FORBIDDEN) {
-                    Toast.makeText(context, R.string.avchat_no_permission, Toast.LENGTH_SHORT).show();
-                } else {
-                    Toast.makeText(context, R.string.avchat_call_failed, Toast.LENGTH_SHORT).show();
-                }
-                handlCallFailed();
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.d(TAG, "avChat call onException->" + exception);
-                handlCallFailed();
-            }
-        });
-
-        if (callTypeEnum == AVChatType.AUDIO) {
-            onCallStateChange(CallStateEnum.OUTGOING_AUDIO_CALLING);
-        } else {
-            onCallStateChange(CallStateEnum.OUTGOING_VIDEO_CALLING);
-        }
-    }
-
-    private void handlCallFailed() {
-        if (callingState == CallStateEnum.VIDEO) {
-            AVChatManager.getInstance().stopVideoPreview();
-            AVChatManager.getInstance().disableVideo();
-        }
-        AVChatManager.getInstance().disableRtc();
-        DialogMaker.dismissProgressDialog();
-
-        AVChatSoundPlayer.instance().stop();
-        closeSessions(-1);
-    }
-
-    /**
-     * 状态改变
-     *
-     * @param stateEnum
-     */
-    public void onCallStateChange(CallStateEnum stateEnum) {
-        callingState = stateEnum;
-        avChatSurface.onCallStateChange(stateEnum);
-        avChatAudio.onCallStateChange(stateEnum);
-        avChatVideo.onCallStateChange(stateEnum);
-    }
-
-    /**
-     * 挂断
-     *
-     * @param type 音视频类型
-     */
-    private void hangUp(final int type) {
-        if (callingState == CallStateEnum.INCOMING_VIDEO_CALLING || callingState == CallStateEnum.VIDEO) {
-            AVChatManager.getInstance().stopVideoPreview();
-        }
-        if ((type == AVChatExitCode.HANGUP || type == AVChatExitCode.PEER_NO_RESPONSE || type == AVChatExitCode.CANCEL) && avChatData != null) {
-            AVChatManager.getInstance().hangUp2(avChatData.getChatId(), new AVChatCallback<Void>() {
-                @Override
-                public void onSuccess(Void aVoid) {
-                }
-
-                @Override
-                public void onFailed(int code) {
-                    LogUtil.d(TAG, "hangup onFailed->" + code);
-                }
-
-                @Override
-                public void onException(Throwable exception) {
-                    LogUtil.d(TAG, "hangup onException->" + exception);
-                }
-            });
-        }
-        AVChatManager.getInstance().disableRtc();
-        closeSessions(type);
-        AVChatSoundPlayer.instance().stop();
-    }
-
-    /**
-     * 关闭本地音视频各项功能
-     *
-     * @param exitCode 音视频类型
-     */
-    public void closeSessions(int exitCode) {
-        //not  user  hang up active  and warning tone is playing,so wait its end
-        Log.i(TAG, "close session -> " + AVChatExitCode.getExitString(exitCode));
-        if (avChatAudio != null)
-            avChatAudio.closeSession(exitCode);
-        if (avChatVideo != null)
-            avChatVideo.closeSession(exitCode);
-        showQuitToast(exitCode);
-        isCallEstablish.set(false);
-        canSwitchCamera = false;
-        isClosedCamera = false;
-        aVChatListener.uiExit();
-    }
-
-    /**
-     * 给出结束的提醒
-     *
-     * @param code
-     */
-    public void showQuitToast(int code) {
-        switch (code) {
-            case AVChatExitCode.NET_CHANGE: // 网络切换
-            case AVChatExitCode.NET_ERROR: // 网络异常
-            case AVChatExitCode.CONFIG_ERROR: // 服务器返回数据错误
-                Toast.makeText(context, R.string.avchat_net_error_then_quit, Toast.LENGTH_SHORT).show();
-                break;
-            case AVChatExitCode.PEER_HANGUP:
-            case AVChatExitCode.HANGUP:
-                if (isCallEstablish.get()) {
-                    Toast.makeText(context, R.string.avchat_call_finish, Toast.LENGTH_SHORT).show();
-                }
-                break;
-            case AVChatExitCode.PEER_BUSY:
-                Toast.makeText(context, R.string.avchat_peer_busy, Toast.LENGTH_SHORT).show();
-                break;
-            case AVChatExitCode.PROTOCOL_INCOMPATIBLE_PEER_LOWER:
-                Toast.makeText(context, R.string.avchat_peer_protocol_low_version, Toast.LENGTH_SHORT).show();
-                break;
-            case AVChatExitCode.PROTOCOL_INCOMPATIBLE_SELF_LOWER:
-                Toast.makeText(context, R.string.avchat_local_protocol_low_version, Toast.LENGTH_SHORT).show();
-                break;
-            case AVChatExitCode.INVALIDE_CHANNELID:
-                Toast.makeText(context, R.string.avchat_invalid_channel_id, Toast.LENGTH_SHORT).show();
-                break;
-            case AVChatExitCode.LOCAL_CALL_BUSY:
-                Toast.makeText(context, R.string.avchat_local_call_busy, Toast.LENGTH_SHORT).show();
-                break;
-            default:
-                break;
-        }
-    }
-
-    /**
-     * ******************************* 接听与拒绝操作 *********************************
-     */
-
-    /**
-     * 拒绝来电
-     */
-    private void rejectInComingCall() {
-        /**
-         * 接收方拒绝通话
-         * AVChatCallback 回调函数
-         */
-        AVChatManager.getInstance().hangUp2(avChatData.getChatId(), new AVChatCallback<Void>() {
-            @Override
-            public void onSuccess(Void aVoid) {
-                LogUtil.d(TAG, "reject onSuccess-");
-            }
-
-            @Override
-            public void onFailed(int code) {
-                LogUtil.d(TAG, "reject onFailed->" + code);
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.d(TAG, "reject onException");
-            }
-        });
-        closeSessions(AVChatExitCode.REJECT);
-        AVChatSoundPlayer.instance().stop();
-    }
-
-    /**
-     * 拒绝音视频切换
-     */
-    private void rejectAudioToVideo() {
-        AVChatManager.getInstance().sendControlCommand(avChatData.getChatId(), AVChatControlCommand.SWITCH_AUDIO_TO_VIDEO_REJECT, new AVChatCallback<Void>() {
-            @Override
-            public void onSuccess(Void aVoid) {
-                LogUtil.i(TAG, "rejectAudioToVideo success");
-                onCallStateChange(CallStateEnum.AUDIO);
-                updateRecordTip();
-            }
-
-            @Override
-            public void onFailed(int code) {
-                LogUtil.i(TAG, "rejectAudioToVideo onFailed");
-
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.i(TAG, "rejectAudioToVideo onException");
-            }
-        });
-    }
-
-    /**
-     * 接听来电
-     */
-    private void receiveInComingCall() {
-        //接听,告知服务器,以便通知其他端
-
-        if (callingState == CallStateEnum.INCOMING_AUDIO_CALLING) {
-            onCallStateChange(CallStateEnum.AUDIO_CONNECTING);
-        } else {
-            onCallStateChange(CallStateEnum.VIDEO_CONNECTING);
-        }
-
-        AVChatManager.getInstance().enableRtc();
-        if (mVideoCapturer == null) {
-            mVideoCapturer = AVChatVideoCapturerFactory.createCameraCapturer();
-            AVChatManager.getInstance().setupVideoCapturer(mVideoCapturer);
-        }
-        AVChatManager.getInstance().setParameters(avChatParameters);
-        if (callingState == CallStateEnum.VIDEO_CONNECTING) {
-            AVChatManager.getInstance().enableVideo();
-            AVChatManager.getInstance().startVideoPreview();
-        }
-
-        AVChatManager.getInstance().accept2(avChatData.getChatId(), new AVChatCallback<Void>() {
-            @Override
-            public void onSuccess(Void aVoid) {
-                LogUtil.i(TAG, "accept success");
-
-                isCallEstablish.set(true);
-                canSwitchCamera = true;
-            }
-
-            @Override
-            public void onFailed(int code) {
-                if (code == -1) {
-                    Toast.makeText(context, "本地音视频启动失败", Toast.LENGTH_SHORT).show();
-                } else {
-                    Toast.makeText(context, "建立连接失败", Toast.LENGTH_SHORT).show();
-                }
-                LogUtil.e(TAG, "accept onFailed->" + code);
-                handleAcceptFailed();
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.d(TAG, "accept exception->" + exception);
-                handleAcceptFailed();
-            }
-        });
-        AVChatSoundPlayer.instance().stop();
-    }
-
-    private void handleAcceptFailed() {
-        if (callingState == CallStateEnum.VIDEO_CONNECTING) {
-            AVChatManager.getInstance().stopVideoPreview();
-            AVChatManager.getInstance().disableVideo();
-        }
-        AVChatManager.getInstance().disableRtc();
-        closeSessions(AVChatExitCode.CANCEL);
-    }
-
-    /*************************** AVChatUIListener ******************************/
-
-    /**
-     * 点击挂断或取消
-     */
-    @Override
-    public void onHangUp() {
-        if (isCallEstablish.get()) {
-            hangUp(AVChatExitCode.HANGUP);
-        } else {
-            hangUp(AVChatExitCode.CANCEL);
-        }
-    }
-
-    /**
-     * 拒绝操作,根据当前状态来选择合适的操作
-     */
-    @Override
-    public void onRefuse() {
-        switch (callingState) {
-            case INCOMING_AUDIO_CALLING:
-            case AUDIO_CONNECTING:
-                rejectInComingCall();
-                break;
-            case INCOMING_AUDIO_TO_VIDEO:
-                rejectAudioToVideo();
-                break;
-            case INCOMING_VIDEO_CALLING:
-            case VIDEO_CONNECTING: // 连接中点击拒绝
-                rejectInComingCall();
-                break;
-            default:
-                break;
-        }
-    }
-
-    /**
-     * 开启操作,根据当前状态来选择合适的操作
-     */
-    @Override
-    public void onReceive() {
-        switch (callingState) {
-            case INCOMING_AUDIO_CALLING:
-                receiveInComingCall();
-                onCallStateChange(CallStateEnum.AUDIO_CONNECTING);
-                break;
-            case AUDIO_CONNECTING: // 连接中,继续点击开启 无反应
-                break;
-            case INCOMING_VIDEO_CALLING:
-                receiveInComingCall();
-                onCallStateChange(CallStateEnum.VIDEO_CONNECTING);
-                break;
-            case VIDEO_CONNECTING: // 连接中,继续点击开启 无反应
-                break;
-            case INCOMING_AUDIO_TO_VIDEO:
-                receiveAudioToVideo();
-            default:
-                break;
-        }
-    }
-
-    @Override
-    public void toggleMute() {
-        if (!isCallEstablish.get()) { // 连接未建立,在这里记录静音状态
-            return;
-        } else { // 连接已经建立
-            if (!AVChatManager.getInstance().isLocalAudioMuted()) { // isMute是否处于静音状态
-                // 关闭音频
-                AVChatManager.getInstance().muteLocalAudio(true);
-            } else {
-                // 打开音频
-                AVChatManager.getInstance().muteLocalAudio(false);
-            }
-        }
-    }
-
-    @Override
-    public void toggleSpeaker() {
-        AVChatManager.getInstance().setSpeaker(!AVChatManager.getInstance().speakerEnabled()); // 设置扬声器是否开启
-    }
-
-    @Override
-    public void toggleRecord() {
-
-        if (isRecording) {
-            //停止录制
-            isRecording = false;
-            updateRecordTip();
-            if (recordList.size() == 3) {
-                if (recordList.get(0).second) {
-                    AVChatManager.getInstance().stopAudioRecording();
-                }
-                if (recordList.get(1).second) {
-                    AVChatManager.getInstance().stopAVRecording(SheishuoCache.getAccount());
-                }
-                if (recordList.get(2).second) {
-                    AVChatManager.getInstance().stopAVRecording(receiverId);
-                }
-            }
-
-        } else {
-            //探测对话框
-            final MultiSelectDialog selectDialog = new MultiSelectDialog(context);
-            selectDialog.setTitle("选择录制内容");
-            selectDialog.setMessage("录制的内容会被单独保存");
-            selectDialog.setMessageTextColor(context.getResources().getColor(R.color.color_grey_999999));
-            selectDialog.addItem("语音对话", false);
-            if (CallStateEnum.isAudioMode(callingState)) {
-                selectDialog.addItem("我的音频", false);
-            } else {
-                selectDialog.addItem("我的音视频", false);
-            }
-            if (CallStateEnum.isAudioMode(callingState)) {
-                selectDialog.addItem("对方音频", false);
-            } else {
-                selectDialog.addItem("对方音视频", false);
-            }
-            selectDialog.addPositiveButton("开始录制", MultiSelectDialog.NO_TEXT_COLOR, MultiSelectDialog.NO_TEXT_SIZE,
-                    new View.OnClickListener() {
-                        @Override
-                        public void onClick(View view) {
-                            isRecording = true;
-                            updateRecordTip();
-                            List<Pair<String, Boolean>> selectDialogList = selectDialog.getItemTextList();
-                            if (selectDialogList.size() == 3) {
-                                if (selectDialogList.get(0).second) {
-                                    AVChatManager.getInstance().startAudioRecording();
-                                }
-                                if (selectDialogList.get(1).second) {
-                                    AVChatManager.getInstance().startAVRecording(SheishuoCache.getAccount());
-                                }
-                                if (selectDialogList.get(2).second) {
-                                    AVChatManager.getInstance().startAVRecording(receiverId);
-                                }
-                            }
-                            recordList.clear();
-                            recordList.addAll(selectDialogList);
-                            selectDialog.dismiss();
-                        }
-                    });
-            selectDialog.addNegativeButton(context.getString(com.netease.nim.uikit.R.string.cancel), MultiSelectDialog.NO_TEXT_COLOR,
-                    MultiSelectDialog.NO_TEXT_SIZE, new View.OnClickListener() {
-                        @Override
-                        public void onClick(View view) {
-                            selectDialog.dismiss();
-                        }
-                    });
-            selectDialog.show();
-        }
-    }
-
-    private void updateRecordTip() {
-        if (CallStateEnum.isAudioMode(callingState)) {
-            avChatAudio.showRecordView(isRecording, recordWarning);
-        }
-        if (CallStateEnum.isVideoMode(callingState)) {
-            avChatVideo.showRecordView(isRecording, recordWarning);
-        }
-    }
-
-    public void showRecordWarning() {
-        recordWarning = true;
-        updateRecordTip();
-    }
-
-    public void resetRecordTip() {
-        recordWarning = false;
-        isRecording = false;
-        updateRecordTip();
-    }
-
-    @Override
-    public void videoSwitchAudio() {
-        /**
-         * 请求视频切换到音频
-         */
-        AVChatManager.getInstance().sendControlCommand(avChatData.getChatId(), AVChatControlCommand.SWITCH_VIDEO_TO_AUDIO, new AVChatCallback<Void>() {
-            @Override
-            public void onSuccess(Void aVoid) {
-                LogUtil.d(TAG, "videoSwitchAudio onSuccess");
-                //直接切换
-                AVChatManager.getInstance().disableVideo();
-
-                // 界面布局切换。
-                onCallStateChange(CallStateEnum.AUDIO);
-                onVideoToAudio();
-            }
-
-            @Override
-            public void onFailed(int code) {
-                LogUtil.d(TAG, "videoSwitchAudio onFailed");
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.d(TAG, "videoSwitchAudio onException");
-            }
-        });
-    }
-
-    @Override
-    public void audioSwitchVideo() {
-        /**
-         * 请求音频切换到视频
-         */
-        AVChatManager.getInstance().sendControlCommand(avChatData.getChatId(), AVChatControlCommand.SWITCH_AUDIO_TO_VIDEO, new AVChatCallback<Void>() {
-            @Override
-            public void onSuccess(Void aVoid) {
-                LogUtil.d(TAG, "requestSwitchToVideo onSuccess");
-                onCallStateChange(CallStateEnum.OUTGOING_AUDIO_TO_VIDEO);
-                updateRecordTip();
-            }
-
-            @Override
-            public void onFailed(int code) {
-                LogUtil.d(TAG, "requestSwitchToVideo onFailed" + code);
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.d(TAG, "requestSwitchToVideo onException" + exception);
-            }
-        });
-    }
-
-    @Override
-    public void switchCamera() {
-        mVideoCapturer.switchCamera(); // 切换摄像头(主要用于前置和后置摄像头切换)
-    }
-
-    @Override
-    public void closeCamera() {
-        if (!isClosedCamera) {
-            // 关闭摄像头
-            AVChatManager.getInstance().muteLocalVideo(true);
-            isClosedCamera = true;
-            avChatSurface.localVideoOff();
-        } else {
-            // 打开摄像头
-            AVChatManager.getInstance().muteLocalVideo(false);
-            isClosedCamera = false;
-            avChatSurface.localVideoOn();
-        }
-
-    }
-
-    /**
-     * 音频切换为视频的请求
-     */
-    public void incomingAudioToVideo() {
-        onCallStateChange(CallStateEnum.INCOMING_AUDIO_TO_VIDEO);
-    }
-
-    /**
-     * 同意音频切换为视频
-     */
-    private void receiveAudioToVideo() {
-        AVChatManager.getInstance().sendControlCommand(avChatData.getChatId(), AVChatControlCommand.SWITCH_AUDIO_TO_VIDEO_AGREE, new AVChatCallback<Void>() {
-            @Override
-            public void onSuccess(Void aVoid) {
-                LogUtil.d(TAG, "receiveAudioToVideo onSuccess");
-                // 切换
-                AVChatManager.getInstance().enableVideo();
-
-                onAudioToVideo();
-                initAllSurfaceView(videoAccount);
-            }
-
-            @Override
-            public void onFailed(int code) {
-                LogUtil.d(TAG, "receiveAudioToVideo onFailed");
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.d(TAG, "receiveAudioToVideo onException");
-            }
-        });
-
-    }
-
-    /**
-     * 初始化大小图像
-     *
-     * @param largeAccount 对方的帐号
-     */
-    public void initAllSurfaceView(String largeAccount) {
-        avChatSurface.initLargeSurfaceView(largeAccount);
-        avChatSurface.initSmallSurfaceView(SheishuoCache.getAccount());
-    }
-
-    public void initLargeSurfaceView(String account) {
-        avChatSurface.initLargeSurfaceView(account);
-    }
-
-    public void initSmallSurfaceView() {
-        avChatSurface.initSmallSurfaceView(SheishuoCache.getAccount());
-    }
-
-    /**
-     * 音频切换为视频
-     */
-    public void onAudioToVideo() {
-        onCallStateChange(CallStateEnum.VIDEO);
-        avChatVideo.onAudioToVideo(AVChatManager.getInstance().isLocalAudioMuted(),
-                isRecording, recordWarning); // isMute是否处于静音状态
-
-        //打开视频
-        AVChatManager.getInstance().enableVideo();
-        AVChatManager.getInstance().startVideoPreview();
-
-        // 是否在发送视频 即摄像头是否开启
-        if (AVChatManager.getInstance().isLocalVideoMuted()) {
-            AVChatManager.getInstance().muteLocalVideo(false);
-            avChatSurface.localVideoOn();
-            isClosedCamera = false;
-        }
-    }
-
-    /**
-     * 视频切换为音频
-     */
-    public void onVideoToAudio() {
-
-        //关闭视频
-        AVChatManager.getInstance().stopVideoPreview();
-        AVChatManager.getInstance().disableVideo();
-
-        // 判断是否静音,扬声器是否开启,对界面相应控件进行显隐处理。
-        avChatAudio.onVideoToAudio(AVChatManager.getInstance().isLocalAudioMuted(),
-                AVChatManager.getInstance().speakerEnabled(),
-                isRecording, recordWarning);
-    }
-
-    public void peerVideoOff() {
-        avChatSurface.peerVideoOff();
-    }
-
-    public void peerVideoOn() {
-        avChatSurface.peerVideoOn();
-    }
-
-
-    private boolean needRestoreLocalVideo = false;
-    private boolean needRestoreLocalAudio = false;
-
-    //恢复视频和语音发送
-    public void resumeVideo() {
-        if (needRestoreLocalVideo) {
-            AVChatManager.getInstance().muteLocalVideo(false);
-            needRestoreLocalVideo = false;
-        }
-
-        if (needRestoreLocalAudio) {
-            AVChatManager.getInstance().muteLocalAudio(false);
-            needRestoreLocalAudio = false;
-        }
-
-    }
-
-    //关闭视频和语音发送. 
-    public void pauseVideo() {
-
-        if (!AVChatManager.getInstance().isLocalVideoMuted()) {
-            AVChatManager.getInstance().muteLocalVideo(true);
-            needRestoreLocalVideo = true;
-        }
-
-        if (!AVChatManager.getInstance().isLocalAudioMuted()) {
-            AVChatManager.getInstance().muteLocalAudio(true);
-            needRestoreLocalAudio = true;
-        }
-    }
-
-    public boolean canSwitchCamera() {
-        return canSwitchCamera;
-    }
-
-    public CallStateEnum getCallingState() {
-        return callingState;
-    }
-
-    public String getVideoAccount() {
-        return videoAccount;
-    }
-
-    public void setVideoAccount(String videoAccount) {
-        this.videoAccount = videoAccount;
-    }
-
-    public String getAccount() {
-        if (receiverId != null)
-            return receiverId;
-        return null;
-    }
-
-    public long getTimeBase() {
-        return timeBase;
-    }
-
-    public void setTimeBase(long timeBase) {
-        this.timeBase = timeBase;
-    }
-
-    public AVChatData getAvChatData() {
-        return avChatData;
-    }
-}

+ 0 - 17
app/src/com/sheishuo/app/avchat/AVChatUIListener.java

@@ -1,17 +0,0 @@
-package com.sheishuo.app.avchat;
-
-/**
- * 音视频界面操作
- */
-public interface AVChatUIListener {
-    void onHangUp();
-    void onRefuse();
-    void onReceive();
-    void toggleMute();
-    void toggleSpeaker();
-    void toggleRecord();
-    void videoSwitchAudio();
-    void audioSwitchVideo();
-    void switchCamera();
-    void closeCamera();
-}

+ 0 - 350
app/src/com/sheishuo/app/avchat/AVChatVideo.java

@@ -1,350 +0,0 @@
-package com.sheishuo.app.avchat;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.view.View;
-import android.widget.Chronometer;
-import android.widget.ImageView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.sheishuo.app.avchat.constant.CallStateEnum;
-import com.sheishuo.app.avchat.widgets.ToggleView;
-import com.sheishuo.app.R;
-import com.sheishuo.app.avchat.widgets.ToggleListener;
-import com.sheishuo.app.avchat.widgets.ToggleState;
-import com.netease.nim.uikit.cache.NimUserInfoCache;
-import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
-import com.netease.nimlib.sdk.avchat.model.AVChatCameraCapturer;
-
-/**
- * 视频管理器, 视频界面初始化和相关管理
- * Created by hzxuwen on 2015/5/5.
- */
-public class AVChatVideo implements View.OnClickListener, ToggleListener{
-
-    // data
-    private Context context;
-    private View root;
-    private AVChatUI manager;
-    //顶部控制按钮
-    private View topRoot;
-    private View switchAudio;
-    private Chronometer time;
-    private TextView netUnstableTV;
-    //中间控制按钮
-    private View middleRoot;
-    private HeadImageView headImg;
-    private  TextView nickNameTV;
-    private  TextView notifyTV;
-    private View refuse_receive;
-    private TextView refuseTV;
-    private TextView receiveTV;
-    //底部控制按钮
-    private View bottomRoot;
-    ToggleView switchCameraToggle;
-    ToggleView closeCameraToggle;
-    ToggleView muteToggle;
-    ImageView recordToggle;
-    ImageView hangUpImg;
-
-    //摄像头权限提示显示
-    private View permissionRoot;
-
-    //record
-    private View recordView;
-    private View recordTip;
-    private View recordWarning;
-
-    private int topRootHeight = 0;
-    private int bottomRootHeight = 0;
-
-    private AVChatUIListener listener;
-
-    // state
-    private boolean init = false;
-    private boolean shouldEnableToggle = false;
-    private boolean isInSwitch = false;
-
-    public AVChatVideo(Context context, View root, AVChatUIListener listener, AVChatUI manager) {
-        this.context = context;
-        this.root = root;
-        this.listener = listener;
-        this.manager = manager;
-    }
-
-    private void findViews() {
-        if(init || root == null )
-            return;
-        topRoot = root.findViewById(R.id.avchat_video_top_control);
-        switchAudio = topRoot.findViewById(R.id.avchat_video_switch_audio);
-        switchAudio.setOnClickListener(this);
-        time = (Chronometer) topRoot.findViewById(R.id.avchat_video_time);
-        netUnstableTV = (TextView) topRoot.findViewById(R.id.avchat_video_netunstable);
-
-        middleRoot = root.findViewById(R.id.avchat_video_middle_control);
-        headImg = (HeadImageView) middleRoot.findViewById(R.id.avchat_video_head);
-        nickNameTV = (TextView) middleRoot.findViewById(R.id.avchat_video_nickname);
-        notifyTV = (TextView) middleRoot.findViewById(R.id.avchat_video_notify);
-
-        refuse_receive = middleRoot.findViewById(R.id.avchat_video_refuse_receive);
-        refuseTV = (TextView) refuse_receive.findViewById(R.id.refuse);
-        receiveTV = (TextView) refuse_receive.findViewById(R.id.receive);
-        refuseTV.setOnClickListener(this);
-        receiveTV.setOnClickListener(this);
-
-        recordView = root.findViewById(R.id.avchat_record_layout);
-        recordTip = recordView.findViewById(R.id.avchat_record_tip);
-        recordWarning = recordView.findViewById(R.id.avchat_record_warning);
-
-        bottomRoot = root.findViewById(R.id.avchat_video_bottom_control);
-        switchCameraToggle = new ToggleView(bottomRoot.findViewById(R.id.avchat_switch_camera), ToggleState.DISABLE, this);
-        closeCameraToggle = new ToggleView(bottomRoot.findViewById(R.id.avchat_close_camera), ToggleState.DISABLE, this);
-        muteToggle = new ToggleView(bottomRoot.findViewById(R.id.avchat_video_mute), ToggleState.DISABLE, this);
-        recordToggle = (ImageView) bottomRoot.findViewById(R.id.avchat_video_record);
-        recordToggle.setEnabled(false);
-        recordToggle.setOnClickListener(this);
-        hangUpImg = (ImageView) bottomRoot.findViewById(R.id.avchat_video_logout);
-        hangUpImg.setOnClickListener(this);
-
-        permissionRoot = root.findViewById(R.id.avchat_video_permission_control);
-        init = true;
-    }
-
-    /**
-     * 音视频状态变化及界面刷新
-     * @param state
-     */
-    public void onCallStateChange(CallStateEnum state) {
-        if(CallStateEnum.isVideoMode(state))
-            findViews();
-        switch (state){
-            case OUTGOING_VIDEO_CALLING:
-                showProfile();//对方的详细信息
-                showNotify(R.string.avchat_wait_recieve);
-                setRefuseReceive(false);
-                shouldEnableToggle = true;
-                enableCameraToggle();   //使用音视频预览时这里可以开启切换摄像头按钮
-                setTopRoot(false);
-                setMiddleRoot(true);
-                setBottomRoot(true);
-                break;
-            case INCOMING_VIDEO_CALLING:
-                showProfile();//对方的详细信息
-                showNotify(R.string.avchat_video_call_request);
-                setRefuseReceive(true);
-                receiveTV.setText(R.string.avchat_pickup);
-                setTopRoot(false);
-                setMiddleRoot(true);
-                setBottomRoot(false);
-                break;
-            case VIDEO:
-                isInSwitch = false;
-                enableToggle();
-                setTime(true);
-                setTopRoot(true);
-                setMiddleRoot(false);
-                setBottomRoot(true);
-                showNoneCameraPermissionView(false);
-                break;
-            case VIDEO_CONNECTING:
-                showNotify(R.string.avchat_connecting);
-                shouldEnableToggle = true;
-                break;
-            case OUTGOING_AUDIO_TO_VIDEO:
-                isInSwitch = true;
-                setTime(true);
-                setTopRoot(true);
-                setMiddleRoot(false);
-                setBottomRoot(true);
-                break;
-            default:
-                break;
-        }
-        setRoot(CallStateEnum.isVideoMode(state));
-    }
-
-    /********************** 界面显示 **********************************/
-
-    /**
-     * 显示个人信息
-     */
-    private void showProfile(){
-        String account = manager.getAccount();
-        headImg.loadBuddyAvatar(account);
-        nickNameTV.setText(NimUserInfoCache.getInstance().getUserDisplayName(account));
-    }
-
-    /**
-     * 显示通知
-     * @param resId
-     */
-    private void showNotify(int resId){
-        notifyTV.setText(resId);
-        notifyTV.setVisibility(View.VISIBLE);
-    }
-
-    /************************ 布局显隐设置 ****************************/
-
-    private void setRoot(boolean visible) {
-        root.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    private void setRefuseReceive(boolean visible){
-        refuse_receive.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    private void setTopRoot(boolean visible){
-        topRoot.setVisibility(visible ? View.VISIBLE : View.GONE);
-        if(topRootHeight == 0){
-            Rect rect = new Rect();
-            topRoot.getGlobalVisibleRect(rect);
-            topRootHeight = rect.bottom;
-        }
-    }
-
-    private void setMiddleRoot(boolean visible){
-        middleRoot.setVisibility(visible ? View.VISIBLE : View.GONE);
-    }
-
-    private void setBottomRoot(boolean visible){
-        bottomRoot.setVisibility(visible ? View.VISIBLE : View.GONE);
-        if(bottomRootHeight == 0){
-            bottomRootHeight = bottomRoot.getHeight();
-        }
-    }
-
-    private void setTime(boolean visible){
-        time.setVisibility(visible ? View.VISIBLE : View.GONE);
-        if(visible){
-            time.setBase(manager.getTimeBase());
-            time.start();
-        }
-    }
-
-    /**
-     * 底部控制开关可用
-     */
-    private void enableToggle() {
-        if (shouldEnableToggle) {
-            if (manager.canSwitchCamera() && AVChatCameraCapturer.hasMultipleCameras())
-                switchCameraToggle.enable();
-            closeCameraToggle.enable();
-            muteToggle.enable();
-            recordToggle.setEnabled(true);
-            shouldEnableToggle = false;
-        }
-    }
-
-    private void enableCameraToggle() {
-        if (shouldEnableToggle) {
-            if (manager.canSwitchCamera() && AVChatCameraCapturer.hasMultipleCameras())
-                switchCameraToggle.enable();
-        }
-    }
-
-    @Override
-    public void onClick(View v) {
-        switch (v.getId()) {
-            case R.id.avchat_video_logout:
-                listener.onHangUp();
-                break;
-            case R.id.refuse:
-                listener.onRefuse();
-                break;
-            case R.id.receive:
-                listener.onReceive();
-                break;
-            case R.id.avchat_video_mute:
-                listener.toggleMute();
-                break;
-            case R.id.avchat_video_switch_audio:
-                if(isInSwitch) {
-                    Toast.makeText(context, R.string.avchat_in_switch, Toast.LENGTH_SHORT).show();
-                } else {
-                    listener.videoSwitchAudio();
-                }
-                break;
-            case R.id.avchat_switch_camera:
-                listener.switchCamera();
-                break;
-            case R.id.avchat_close_camera:
-                listener.closeCamera();
-                break;
-            case R.id.avchat_video_record:
-                listener.toggleRecord();
-                break;
-            default:
-                break;
-        }
-
-    }
-
-    public void showRecordView(boolean show, boolean warning) {
-        if(show) {
-            recordToggle.setEnabled(true);
-            recordToggle.setSelected(true);
-            recordView.setVisibility(View.VISIBLE);
-            recordTip.setVisibility(View.VISIBLE);
-            if(warning) {
-                recordWarning.setVisibility(View.VISIBLE);
-            } else {
-                recordWarning.setVisibility(View.GONE);
-            }
-        } else {
-            recordToggle.setSelected(false);
-            recordView.setVisibility(View.INVISIBLE);
-            recordTip.setVisibility(View.INVISIBLE);
-            recordWarning.setVisibility(View.GONE);
-        }
-    }
-
-    public void showNoneCameraPermissionView(boolean show) {
-        permissionRoot.setVisibility(show ? View.VISIBLE : View.GONE);
-    }
-
-    /**
-     * 音频切换为视频, 界面控件是否开启显示
-     * @param muteOn
-     */
-    public void onAudioToVideo(boolean muteOn, boolean recordOn, boolean recordWarning){
-        muteToggle.toggle(muteOn ? ToggleState.ON : ToggleState.OFF);
-        closeCameraToggle.toggle(ToggleState.OFF);
-        if(manager.canSwitchCamera()){
-            switchCameraToggle.off(false);
-        }
-        recordToggle.setEnabled(true);
-        recordToggle.setSelected(recordOn);
-        showRecordView(recordOn, recordWarning);
-
-    }
-
-    /******************************* toggle listener *************************/
-    @Override
-    public void toggleOn(View v) {
-        onClick(v);
-    }
-
-    @Override
-    public void toggleOff(View v) {
-        onClick(v);
-    }
-
-    @Override
-    public void toggleDisable(View v) {
-
-    }
-
-    public void closeSession(int exitCode){
-        if(init){
-            time.stop();
-            switchCameraToggle.disable(false);
-            muteToggle.disable(false);
-            recordToggle.setEnabled(false);
-            closeCameraToggle.disable(false);
-            receiveTV.setEnabled(false);
-            refuseTV.setEnabled(false);
-            hangUpImg.setEnabled(false);
-        }
-    }
-}

+ 0 - 655
app/src/com/sheishuo/app/avchat/activity/AVChatActivity.java

@@ -1,655 +0,0 @@
-package com.sheishuo.app.avchat.activity;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.Toast;
-
-import com.sheishuo.app.R;
-import com.sheishuo.app.avchat.AVChatNotification;
-import com.sheishuo.app.avchat.AVChatProfile;
-import com.sheishuo.app.avchat.AVChatSoundPlayer;
-import com.sheishuo.app.avchat.AVChatUI;
-import com.sheishuo.app.avchat.constant.CallStateEnum;
-import com.sheishuo.app.avchat.receiver.PhoneCallStateObserver;
-import com.netease.nim.uikit.common.activity.UI;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nim.uikit.common.util.sys.NetworkUtil;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.StatusCode;
-import com.netease.nimlib.sdk.auth.AuthServiceObserver;
-import com.netease.nimlib.sdk.auth.ClientType;
-import com.netease.nimlib.sdk.avchat.AVChatManager;
-import com.netease.nimlib.sdk.avchat.AVChatStateObserver;
-import com.netease.nimlib.sdk.avchat.constant.AVChatControlCommand;
-import com.netease.nimlib.sdk.avchat.constant.AVChatEventType;
-import com.netease.nimlib.sdk.avchat.constant.AVChatType;
-import com.netease.nimlib.sdk.avchat.model.AVChatAudioFrame;
-import com.netease.nimlib.sdk.avchat.model.AVChatCalleeAckEvent;
-import com.netease.nimlib.sdk.avchat.model.AVChatCommonEvent;
-import com.netease.nimlib.sdk.avchat.model.AVChatControlEvent;
-import com.netease.nimlib.sdk.avchat.model.AVChatData;
-import com.netease.nimlib.sdk.avchat.model.AVChatNetworkStats;
-import com.netease.nimlib.sdk.avchat.model.AVChatOnlineAckEvent;
-import com.netease.nimlib.sdk.avchat.model.AVChatSessionStats;
-import com.netease.nimlib.sdk.avchat.model.AVChatVideoFrame;
-
-import java.util.Map;
-
-/**
- * 音视频界面
- * Created by hzxuwen on 2015/4/21.
- */
-public class AVChatActivity extends UI implements AVChatUI.AVChatListener, AVChatStateObserver {
-    // constant
-    private static final String TAG = "AVChatActivity";
-    private static final String KEY_IN_CALLING = "KEY_IN_CALLING";
-    private static final String KEY_ACCOUNT = "KEY_ACCOUNT";
-    private static final String KEY_CALL_TYPE = "KEY_CALL_TYPE";
-    private static final String KEY_SOURCE = "source";
-    private static final String KEY_CALL_CONFIG = "KEY_CALL_CONFIG";
-    public static final String INTENT_ACTION_AVCHAT = "INTENT_ACTION_AVCHAT";
-
-    /**
-     * 来自广播
-     */
-    public static final int FROM_BROADCASTRECEIVER = 0;
-    /**
-     * 来自发起方
-     */
-    public static final int FROM_INTERNAL = 1;
-    /**
-     * 来自通知栏
-     */
-    public static final int FROM_NOTIFICATION = 2;
-    /**
-     * 未知的入口
-     */
-    public static final int FROM_UNKNOWN = -1;
-
-    // data
-    private AVChatUI avChatUI; // 音视频总管理器
-    private AVChatData avChatData; // config for connect video server
-    private int state; // calltype 音频或视频
-    private String receiverId; // 对方的account
-
-    // state
-    private boolean isUserFinish = false;
-    private boolean mIsInComingCall = false;// is incoming call or outgoing call
-    private boolean isCallEstablished = false; // 电话是否接通
-    private static boolean needFinish = true; // 若来电或去电未接通时,点击home。另外一方挂断通话。从最近任务列表恢复,则finish
-    private boolean hasOnPause = false; // 是否暂停音视频
-
-    // notification
-    private AVChatNotification notifier;
-
-    public static void launch(Context context, String account, int callType, int source) {
-        needFinish = false;
-        Intent intent = new Intent();
-        intent.setClass(context, AVChatActivity.class);
-        intent.putExtra(KEY_ACCOUNT, account);
-        intent.putExtra(KEY_IN_CALLING, false);
-        intent.putExtra(KEY_CALL_TYPE, callType);
-        intent.putExtra(KEY_SOURCE, source);
-        context.startActivity(intent);
-    }
-
-    /**
-     * incoming call
-     *
-     * @param context
-     */
-    public static void launch(Context context, AVChatData config, int source) {
-        needFinish = false;
-        Intent intent = new Intent();
-        intent.setClass(context, AVChatActivity.class);
-        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.putExtra(KEY_CALL_CONFIG, config);
-        intent.putExtra(KEY_IN_CALLING, true);
-        intent.putExtra(KEY_SOURCE, source);
-        context.startActivity(intent);
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        if (needFinish || !checkSource()) {
-            finish();
-            return;
-        }
-        View root = LayoutInflater.from(this).inflate(R.layout.avchat_activity, null);
-        setContentView(root);
-        mIsInComingCall = getIntent().getBooleanExtra(KEY_IN_CALLING, false);
-        avChatUI = new AVChatUI(this, root, this);
-        if (!avChatUI.initiation()) {
-            this.finish();
-            return;
-        }
-
-        registerNetCallObserver(true);
-        if (mIsInComingCall) {
-            inComingCalling();
-        } else {
-            outgoingCalling();
-        }
-
-        notifier = new AVChatNotification(this);
-        notifier.init(receiverId != null ? receiverId : avChatData.getAccount());
-        isCallEstablished = false;
-        //放到所有UI的基类里面注册,所有的UI实现onKickOut接口
-        NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus(userStatusObserver, true);
-    }
-
-    @Override
-    protected void onPause() {
-        super.onPause();
-        avChatUI.pauseVideo(); // 暂停视频聊天(用于在视频聊天过程中,APP退到后台时必须调用)
-        hasOnPause = true;
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        activeCallingNotifier();
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        cancelCallingNotifier();
-        if (hasOnPause) {
-            avChatUI.resumeVideo();
-            hasOnPause = false;
-        }
-    }
-
-    @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus(userStatusObserver, false);
-        AVChatProfile.getInstance().setAVChatting(false);
-        registerNetCallObserver(false);
-        cancelCallingNotifier();
-        needFinish = true;
-    }
-
-    @Override
-    public void onBackPressed() {
-    }
-
-    /**
-     * 判断来电还是去电
-     *
-     * @return
-     */
-    private boolean checkSource() {
-        switch (getIntent().getIntExtra(KEY_SOURCE, FROM_UNKNOWN)) {
-            case FROM_BROADCASTRECEIVER: // incoming call
-                parseIncomingIntent();
-                return true;
-            case FROM_INTERNAL: // outgoing call
-                parseOutgoingIntent();
-                if (state == AVChatType.VIDEO.getValue() || state == AVChatType.AUDIO.getValue()) {
-                    return true;
-                }
-                return false;
-            default:
-                return false;
-        }
-    }
-
-    /**
-     * 来电参数解析
-     */
-    private void parseIncomingIntent() {
-        avChatData = (AVChatData) getIntent().getSerializableExtra(KEY_CALL_CONFIG);
-        state = avChatData.getChatType().getValue();
-    }
-
-    /**
-     * 去电参数解析
-     */
-    private void parseOutgoingIntent() {
-        receiverId = getIntent().getStringExtra(KEY_ACCOUNT);
-        state = getIntent().getIntExtra(KEY_CALL_TYPE, -1);
-    }
-
-    /**
-     * 注册监听
-     *
-     * @param register
-     */
-    private void registerNetCallObserver(boolean register) {
-        AVChatManager.getInstance().observeAVChatState(this, register);
-        AVChatManager.getInstance().observeCalleeAckNotification(callAckObserver, register);
-        AVChatManager.getInstance().observeControlNotification(callControlObserver, register);
-        AVChatManager.getInstance().observeHangUpNotification(callHangupObserver, register);
-        AVChatManager.getInstance().observeOnlineAckNotification(onlineAckObserver, register);
-        AVChatManager.getInstance().observeTimeoutNotification(timeoutObserver, register);
-        PhoneCallStateObserver.getInstance().observeAutoHangUpForLocalPhone(autoHangUpForLocalPhoneObserver, register);
-    }
-
-    /**
-     * 注册/注销网络通话被叫方的响应(接听、拒绝、忙)
-     */
-    Observer<AVChatCalleeAckEvent> callAckObserver = new Observer<AVChatCalleeAckEvent>() {
-        @Override
-        public void onEvent(AVChatCalleeAckEvent ackInfo) {
-
-            AVChatSoundPlayer.instance().stop();
-
-            if (ackInfo.getEvent() == AVChatEventType.CALLEE_ACK_BUSY) {
-
-                AVChatSoundPlayer.instance().play(AVChatSoundPlayer.RingerTypeEnum.PEER_BUSY);
-
-                avChatUI.closeSessions(AVChatExitCode.PEER_BUSY);
-            } else if (ackInfo.getEvent() == AVChatEventType.CALLEE_ACK_REJECT) {
-                avChatUI.closeSessions(AVChatExitCode.REJECT);
-            } else if (ackInfo.getEvent() == AVChatEventType.CALLEE_ACK_AGREE) {
-                avChatUI.isCallEstablish.set(true);
-                avChatUI.canSwitchCamera = true;
-            }
-        }
-    };
-
-    Observer<Long> timeoutObserver = new Observer<Long>() {
-        @Override
-        public void onEvent(Long chatId) {
-
-            AVChatData info = avChatUI.getAvChatData();
-            if (info != null && info.getChatId() == chatId) {
-
-                avChatUI.closeSessions(AVChatExitCode.PEER_NO_RESPONSE);
-
-                // 来电超时,自己未接听
-                if (mIsInComingCall) {
-                    activeMissCallNotifier();
-                }
-
-                AVChatSoundPlayer.instance().stop();
-            }
-
-        }
-    };
-
-    Observer<Integer> autoHangUpForLocalPhoneObserver = new Observer<Integer>() {
-        @Override
-        public void onEvent(Integer integer) {
-
-            AVChatSoundPlayer.instance().stop();
-
-            avChatUI.closeSessions(AVChatExitCode.PEER_BUSY);
-        }
-    };
-
-    /**
-     * 注册/注销网络通话控制消息(音视频模式切换通知)
-     */
-    Observer<AVChatControlEvent> callControlObserver = new Observer<AVChatControlEvent>() {
-        @Override
-        public void onEvent(AVChatControlEvent netCallControlNotification) {
-            handleCallControl(netCallControlNotification);
-        }
-    };
-
-    /**
-     * 注册/注销网络通话对方挂断的通知
-     */
-    Observer<AVChatCommonEvent> callHangupObserver = new Observer<AVChatCommonEvent>() {
-        @Override
-        public void onEvent(AVChatCommonEvent avChatHangUpInfo) {
-
-            AVChatSoundPlayer.instance().stop();
-
-            avChatUI.closeSessions(AVChatExitCode.HANGUP);
-            cancelCallingNotifier();
-            // 如果是incoming call主叫方挂断,那么通知栏有通知
-            if (mIsInComingCall && !isCallEstablished) {
-                activeMissCallNotifier();
-            }
-        }
-    };
-
-    /**
-     * 注册/注销同时在线的其他端对主叫方的响应
-     */
-    Observer<AVChatOnlineAckEvent> onlineAckObserver = new Observer<AVChatOnlineAckEvent>() {
-        @Override
-        public void onEvent(AVChatOnlineAckEvent ackInfo) {
-
-            AVChatSoundPlayer.instance().stop();
-
-            String client = null;
-            switch (ackInfo.getClientType()) {
-                case ClientType.Web:
-                    client = "Web";
-                    break;
-                case ClientType.Windows:
-                    client = "Windows";
-                    break;
-                case ClientType.Android:
-                    client = "Android";
-                    break;
-                case ClientType.iOS:
-                    client = "iOS";
-                    break;
-                default:
-                    break;
-            }
-            if (client != null) {
-                String option = ackInfo.getEvent() == AVChatEventType.CALLEE_ONLINE_CLIENT_ACK_AGREE ? "接听!" : "拒绝!";
-                Toast.makeText(AVChatActivity.this, "通话已在" + client + "端被" + option, Toast.LENGTH_SHORT).show();
-            }
-            avChatUI.closeSessions(-1);
-        }
-    };
-
-
-    /**
-     * 接听
-     */
-    private void inComingCalling() {
-        avChatUI.inComingCalling(avChatData);
-    }
-
-    /**
-     * 拨打
-     */
-    private void outgoingCalling() {
-        if (!NetworkUtil.isNetAvailable(AVChatActivity.this)) { // 网络不可用
-            Toast.makeText(this, R.string.network_is_not_available, Toast.LENGTH_SHORT).show();
-            finish();
-            return;
-        }
-        avChatUI.outGoingCalling(receiverId, AVChatType.typeOfValue(state));
-    }
-
-    /**
-     * *************************** AVChatListener *********************************
-     */
-
-    @Override
-    public void uiExit() {
-        finish();
-    }
-
-
-    /****************************** 连接建立处理 ********************/
-
-    /**
-     * 处理连接服务器的返回值
-     *
-     * @param auth_result
-     */
-    protected void handleWithConnectServerResult(int auth_result) {
-        LogUtil.i(TAG, "result code->" + auth_result);
-        if (auth_result == 200) {
-            Log.d(TAG, "onConnectServer success");
-        } else if (auth_result == 101) { // 连接超时
-            avChatUI.closeSessions(AVChatExitCode.PEER_NO_RESPONSE);
-        } else if (auth_result == 401) { // 验证失败
-            avChatUI.closeSessions(AVChatExitCode.CONFIG_ERROR);
-        } else if (auth_result == 417) { // 无效的channelId
-            avChatUI.closeSessions(AVChatExitCode.INVALIDE_CHANNELID);
-        } else { // 连接服务器错误,直接退出
-            avChatUI.closeSessions(AVChatExitCode.CONFIG_ERROR);
-        }
-    }
-
-    /**************************** 处理音视频切换 *********************************/
-
-    /**
-     * 处理音视频切换请求
-     *
-     * @param notification
-     */
-    private void handleCallControl(AVChatControlEvent notification) {
-        switch (notification.getControlCommand()) {
-            case AVChatControlCommand.SWITCH_AUDIO_TO_VIDEO:
-                avChatUI.incomingAudioToVideo();
-                break;
-            case AVChatControlCommand.SWITCH_AUDIO_TO_VIDEO_AGREE:
-                onAudioToVideo();
-                break;
-            case AVChatControlCommand.SWITCH_AUDIO_TO_VIDEO_REJECT:
-                avChatUI.onCallStateChange(CallStateEnum.AUDIO);
-                Toast.makeText(AVChatActivity.this, R.string.avchat_switch_video_reject, Toast.LENGTH_SHORT).show();
-                break;
-            case AVChatControlCommand.SWITCH_VIDEO_TO_AUDIO:
-                onVideoToAudio();
-                break;
-            case AVChatControlCommand.NOTIFY_VIDEO_OFF:
-                avChatUI.peerVideoOff();
-                break;
-            case AVChatControlCommand.NOTIFY_VIDEO_ON:
-                avChatUI.peerVideoOn();
-                break;
-            default:
-                Toast.makeText(this, "对方发来指令值:" + notification.getControlCommand(), Toast.LENGTH_SHORT).show();
-                break;
-        }
-    }
-
-    /**
-     * 音频切换为视频
-     */
-    private void onAudioToVideo() {
-        avChatUI.onAudioToVideo();
-        avChatUI.initAllSurfaceView(avChatUI.getVideoAccount());
-    }
-
-    /**
-     * 视频切换为音频
-     */
-    private void onVideoToAudio() {
-        avChatUI.onCallStateChange(CallStateEnum.AUDIO);
-        avChatUI.onVideoToAudio();
-    }
-
-    /**
-     * 通知栏
-     */
-    private void activeCallingNotifier() {
-        if (notifier != null && !isUserFinish) {
-            notifier.activeCallingNotification(true);
-        }
-    }
-
-    private void cancelCallingNotifier() {
-        if (notifier != null) {
-            notifier.activeCallingNotification(false);
-        }
-    }
-
-    private void activeMissCallNotifier() {
-        if (notifier != null) {
-            notifier.activeMissCallNotification(true);
-        }
-    }
-
-    @Override
-    public void finish() {
-        isUserFinish = true;
-        super.finish();
-    }
-
-
-    /**
-     * ************************ AVChatStateObserver ****************************
-     */
-
-    @Override
-    public void onTakeSnapshotResult(String account, boolean success, String file) {
-
-    }
-
-    @Override
-    public void onConnectionTypeChanged(int netType) {
-
-    }
-
-    @Override
-    public void onAVRecordingCompletion(String account, String filePath) {
-        if (account != null && filePath != null && filePath.length() > 0) {
-            String msg = "音视频录制已结束, " + "账号:" + account + " 录制文件已保存至:" + filePath;
-            Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
-        } else {
-            Toast.makeText(this, "录制已结束.", Toast.LENGTH_SHORT).show();
-        }
-        if (avChatUI != null) {
-            avChatUI.resetRecordTip();
-        }
-    }
-
-    @Override
-    public void onAudioRecordingCompletion(String filePath) {
-        if (filePath != null && filePath.length() > 0) {
-            String msg = "音频录制已结束, 录制文件已保存至:" + filePath;
-            Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
-        } else {
-            Toast.makeText(this, "录制已结束.", Toast.LENGTH_SHORT).show();
-        }
-        if (avChatUI != null) {
-            avChatUI.resetRecordTip();
-        }
-    }
-
-    @Override
-    public void onLowStorageSpaceWarning(long availableSize) {
-        if (avChatUI != null) {
-            avChatUI.showRecordWarning();
-        }
-    }
-
-
-    @Override
-    public void onFirstVideoFrameAvailable(String account) {
-
-    }
-
-    @Override
-    public void onVideoFpsReported(String account, int fps) {
-
-    }
-
-    @Override
-    public void onJoinedChannel(int code, String audioFile, String videoFile) {
-        handleWithConnectServerResult(code);
-    }
-
-    @Override
-    public void onLeaveChannel() {
-
-    }
-
-    @Override
-    public void onUserJoined(String account) {
-        Log.d(TAG, "onUserJoin -> " + account);
-        avChatUI.setVideoAccount(account);
-        avChatUI.initLargeSurfaceView(avChatUI.getVideoAccount());
-    }
-
-    @Override
-    public void onUserLeave(String account, int event) {
-        Log.d(TAG, "onUserLeave -> " + account);
-    }
-
-    @Override
-    public void onProtocolIncompatible(int status) {
-
-    }
-
-    @Override
-    public void onDisconnectServer() {
-
-    }
-
-    @Override
-    public void onNetworkQuality(String user, int quality, AVChatNetworkStats stats) {
-
-    }
-
-    @Override
-    public void onCallEstablished() {
-        Log.d(TAG, "onCallEstablished");
-        if (avChatUI.getTimeBase() == 0)
-            avChatUI.setTimeBase(SystemClock.elapsedRealtime());
-
-        if (state == AVChatType.AUDIO.getValue()) {
-            avChatUI.onCallStateChange(CallStateEnum.AUDIO);
-        } else {
-            avChatUI.initSmallSurfaceView();
-            avChatUI.onCallStateChange(CallStateEnum.VIDEO);
-        }
-        isCallEstablished = true;
-    }
-
-    @Override
-    public void onDeviceEvent(int code, String desc) {
-
-    }
-
-    @Override
-    public void onFirstVideoFrameRendered(String user) {
-
-    }
-
-    @Override
-    public void onVideoFrameResolutionChanged(String user, int width, int height, int rotate) {
-
-    }
-
-    @Override
-    public boolean onVideoFrameFilter(AVChatVideoFrame frame,boolean maybeDualInput) {
-        return true;
-    }
-
-    @Override
-    public boolean onAudioFrameFilter(AVChatAudioFrame frame) {
-        return true;
-    }
-
-    @Override
-    public void onAudioDeviceChanged(int device) {
-
-    }
-
-    @Override
-    public void onReportSpeaker(Map<String, Integer> speakers, int mixedEnergy) {
-
-    }
-
-    @Override
-    public void onAudioMixingEvent(int event) {
-
-    }
-
-    @Override
-    public void onSessionStats(AVChatSessionStats sessionStats) {
-
-    }
-
-    @Override
-    public void onLiveEvent(int event) {
-
-    }
-
-
-    Observer<StatusCode> userStatusObserver = new Observer<StatusCode>() {
-
-        @Override
-        public void onEvent(StatusCode code) {
-            if (code.wontAutoLogin()) {
-                AVChatSoundPlayer.instance().stop();
-                finish();
-            }
-        }
-    };
-
-}
-

+ 0 - 90
app/src/com/sheishuo/app/avchat/activity/AVChatExitCode.java

@@ -1,90 +0,0 @@
-package com.sheishuo.app.avchat.activity;
-
-/**
- * Created by hzxuwen on 2015/4/24.
- */
-public class AVChatExitCode {
-    public static final int PEER_HANGUP = 0;
-
-    public static final int PEER_REJECT = 1;
-
-    public static final int HANGUP = 2;
-
-    public static final int NET_CHANGE = 4;
-
-    public static final int REJECT = 5;
-
-    public static final int PEER_BUSY = 6;
-
-    public static final int NET_ERROR = 8;
-
-    public static final int KICKED_OUT = 9;
-
-    public static final int CONFIG_ERROR = 10;
-
-    public static final int PROTOCOL_INCOMPATIBLE_SELF_LOWER = 12;
-
-    public static final int PROTOCOL_INCOMPATIBLE_PEER_LOWER = 13;
-
-    public static final int INVALIDE_CHANNELID = 14;
-
-    public static final int OPEN_DEVICE_ERROR = 15;
-
-    public static final int SYNC_REJECT = 16;
-
-    public static final int SYNC_ACCEPT = 17;
-
-    public static final int SYNC_HANGUP = 18;
-
-    public static final int PEER_NO_RESPONSE = 19; //超时,无人接听
-
-    public static final int CANCEL = 20; //取消
-
-    public static final int LOCAL_CALL_BUSY = 21; // 正在进行本地通话
-
-    public static String getExitString(int code){
-        switch (code){
-            case PEER_HANGUP:
-                return "PEER_HANGUP";
-            case PEER_REJECT:
-                return "PEER_REJECT";
-            case HANGUP:
-                return "HANGUP";
-            case NET_CHANGE:
-                return "NET_CHANGE";
-            case REJECT:
-                return "REJECT";
-            case PEER_BUSY:
-                return "PEER_BUSY";
-            case NET_ERROR:
-                return "NET_ERROR";
-            case KICKED_OUT:
-                return "KICKED_OUT";
-            case CONFIG_ERROR:
-                return "CONFIG_ERROR";
-            case PROTOCOL_INCOMPATIBLE_SELF_LOWER:
-                return "PROTOCOL_INCOMPATIBLE_SELF_LOWER";
-            case PROTOCOL_INCOMPATIBLE_PEER_LOWER:
-                return "PROTOCOL_INCOMPATIBLE_PEER_LOWER";
-            case INVALIDE_CHANNELID:
-                return "INVALIDE_CHANNELID";
-            case OPEN_DEVICE_ERROR:
-                return "OPEN_DEVICE_ERROR";
-            case SYNC_REJECT:
-                return "SYNC_REJECT";
-            case SYNC_ACCEPT:
-                return "SYNC_ACCEPT";
-            case SYNC_HANGUP:
-                return "SYNC_HANGUP";
-            case CANCEL:
-                return "CANCEL";
-            case PEER_NO_RESPONSE:
-                return "PEER_NO_RESPONSE";
-            case LOCAL_CALL_BUSY:
-                return "LOCAL_CALL_BUSY";
-            default:
-                return "UNKNOWN";
-        }
-    }
-
-}

+ 0 - 27
app/src/com/sheishuo/app/avchat/activity/AVChatSettingsActivity.java

@@ -1,27 +0,0 @@
-package com.sheishuo.app.avchat.activity;
-
-import android.os.Bundle;
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.common.activity.UI;
-import com.netease.nim.uikit.model.ToolBarOptions;
-
-/**
- * Created by liuqijun on 7/19/16.
- * 注意:全局配置,不区分用户
- */
-public class AVChatSettingsActivity extends UI {
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.avchat_settings_layout);
-
-        ToolBarOptions options = new ToolBarOptions();
-        options.titleId = R.string.nrtc_settings;
-        setToolBar(R.id.toolbar, options);
-
-
-    }
-
-}

+ 0 - 64
app/src/com/sheishuo/app/avchat/activity/AVChatSettingsFragment.java

@@ -1,64 +0,0 @@
-package com.sheishuo.app.avchat.activity;
-
-import android.annotation.TargetApi;
-import android.os.Build;
-import android.os.Bundle;
-import android.preference.ListPreference;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-import android.preference.PreferenceManager;
-
-import com.sheishuo.app.R;
-
-/**
- * Created by liuqijun on 7/19/16.
- */
-@TargetApi(Build.VERSION_CODES.HONEYCOMB)
-public class AVChatSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener {
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        addPreferencesFromResource(R.xml.nrtc_setting_pref);
-
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_vie_crop_ratio_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_vie_quality_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_vie_hw_encoder_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_vie_hw_decoder_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_voe_audio_aec_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_voe_audio_ns_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_vie_max_bitrate_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_other_device_default_rotation_key)));
-        bindPreferenceSummaryToValue(findPreference(getString(R.string.nrtc_setting_other_device_rotation_fixed_offset_key)));
-
-    }
-
-
-    private void bindPreferenceSummaryToValue(Preference preference) {
-
-        preference.setOnPreferenceChangeListener(this);
-
-        onPreferenceChange(preference,
-                PreferenceManager
-                        .getDefaultSharedPreferences(preference.getContext())
-                        .getString(preference.getKey(), ""));
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        String stringValue = newValue.toString();
-
-        if (preference instanceof ListPreference) {
-            ListPreference listPreference = (ListPreference) preference;
-            int prefIndex = listPreference.findIndexOfValue(stringValue);
-            if (prefIndex >= 0) {
-                preference.setSummary(listPreference.getEntries()[prefIndex]);
-            }
-        } else {
-            preference.setSummary(stringValue);
-        }
-        return true;
-    }
-
-}

+ 0 - 50
app/src/com/sheishuo/app/avchat/constant/CallStateEnum.java

@@ -1,50 +0,0 @@
-package com.sheishuo.app.avchat.constant;
-
-/**
- * 呼叫状态,用来控制刷新界面
- * Created by hzxuwen on 2015/4/27.
- */
-public enum CallStateEnum {
-    INVALID(-1), //无效的状态,该状态下无界面显示
-
-    VIDEO(0), //正在进行视频通话(发起者)
-    OUTGOING_VIDEO_CALLING(2), //邀请好友视频通话
-    INCOMING_VIDEO_CALLING(4),
-    OUTGOING_AUDIO_TO_VIDEO(6), //向好友发起从语音切换到视频的邀请
-    VIDEO_CONNECTING(8), //视频通话连接中
-    VIDEO_OFF(10), // 对方关闭摄像头
-
-    AUDIO(1), //正在进行语音通话(发起者)
-    OUTGOING_AUDIO_CALLING(3), //邀请好友语音通话
-    INCOMING_AUDIO_CALLING(5), //来自好友的视频通话、语音通话邀请
-    INCOMING_AUDIO_TO_VIDEO(7), //音频切换为视频的邀请
-    AUDIO_CONNECTING(9); //语音通话连接中
-
-    private int value;
-
-    CallStateEnum(int value) {
-        this.value = value;
-    }
-
-    public int getValue() {
-        return value;
-    }
-
-    public static boolean isVideoMode(CallStateEnum value) {
-        return value.getValue() % 2 == 0;
-    }
-
-    public static boolean isAudioMode(CallStateEnum value) {
-        return value.getValue() % 2 == 1;
-    }
-
-    public static CallStateEnum getCallStateEnum(int value) {
-        for (CallStateEnum e : values()) {
-            if (e.getValue() == value) {
-                return e;
-            }
-        }
-
-        return INVALID;
-    }
-}

+ 0 - 23
app/src/com/sheishuo/app/avchat/receiver/IncomingCallReceiver.java

@@ -1,23 +0,0 @@
-package com.sheishuo.app.avchat.receiver;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.telephony.TelephonyManager;
-
-/**
- * 来电状态监听
- * <p/>
- * Created by huangjun on 2015/5/13.
- */
-public class IncomingCallReceiver extends BroadcastReceiver {
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        String action = intent.getAction();
-        if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
-            final String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
-            PhoneCallStateObserver.getInstance().onCallStateChanged(state);
-        }
-    }
-}

+ 0 - 142
app/src/com/sheishuo/app/avchat/receiver/PhoneCallStateObserver.java

@@ -1,142 +0,0 @@
-package com.sheishuo.app.avchat.receiver;
-
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.avchat.AVChatCallback;
-import com.netease.nimlib.sdk.avchat.AVChatManager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by huangjun on 2015/5/13.
- */
-public class PhoneCallStateObserver {
-
-    public enum PhoneCallStateEnum {
-        IDLE,           // 空闲
-        INCOMING_CALL,  // 有来电
-        DIALING_OUT,    // 呼出电话已经接通
-        DIALING_IN      // 来电已接通
-    }
-
-    private final String TAG = "PhoneCallStateObserver";
-
-    private int phoneState = TelephonyManager.CALL_STATE_IDLE;
-    private PhoneCallStateEnum  stateEnum = PhoneCallStateObserver.PhoneCallStateEnum.IDLE;;
-    private List<Observer<Integer>> autoHangUpObservers = new ArrayList<>(1); // 与本地电话互斥的挂断监听
-
-    private static class InstanceHolder {
-        public final static PhoneCallStateObserver instance = new PhoneCallStateObserver();
-    }
-
-    public static PhoneCallStateObserver getInstance() {
-        return InstanceHolder.instance;
-    }
-
-    public void onCallStateChanged(String state) {
-        Log.i(TAG, "onCallStateChanged, now state =" + state);
-
-        stateEnum = PhoneCallStateEnum.IDLE;
-        if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) {
-            phoneState = TelephonyManager.CALL_STATE_IDLE;
-            stateEnum = PhoneCallStateEnum.IDLE;
-        } else if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
-            phoneState = TelephonyManager.CALL_STATE_RINGING;
-            stateEnum = PhoneCallStateEnum.INCOMING_CALL;
-        } else if (TelephonyManager.EXTRA_STATE_OFFHOOK.equals(state)) {
-            int lastPhoneState = phoneState;
-            phoneState = TelephonyManager.CALL_STATE_OFFHOOK;
-            if (lastPhoneState == TelephonyManager.CALL_STATE_IDLE) {
-                stateEnum = PhoneCallStateEnum.DIALING_OUT;
-            } else if (lastPhoneState == TelephonyManager.CALL_STATE_RINGING) {
-                stateEnum = PhoneCallStateEnum.DIALING_IN;
-            }
-        }
-
-        handleLocalCall();
-    }
-    /**
-     * 处理本地电话与网络通话的互斥
-     */
-    public void handleLocalCall() {
-        LogUtil.i(TAG, "notify phone state changed, state=" + stateEnum.name());
-
-        if (stateEnum != PhoneCallStateEnum.IDLE) {
-            AVChatManager.getInstance().hangUp2(AVChatManager.getInstance().getCurrentChatId(), new HandleLocalCallCallback(1));
-        }
-    }
-
-    public PhoneCallStateEnum getPhoneCallState() {
-        return stateEnum;
-    }
-
-    private class HandleLocalCallCallback implements AVChatCallback<Void> {
-        private int reason;
-        private String log;
-
-        public HandleLocalCallCallback(int reason) {
-            this.reason = reason;
-            this.log = "handle local call";
-        }
-
-        @Override
-        public void onSuccess(Void param) {
-            notifyObservers(autoHangUpObservers, reason);
-        }
-
-        @Override
-        public void onFailed(int code) {
-            notifyObservers(autoHangUpObservers, -1 * reason);
-        }
-
-        @Override
-        public void onException(Throwable exception) {
-            notifyObservers(autoHangUpObservers, 0);
-
-            if (!TextUtils.isEmpty(log)) {
-                LogUtil.i(TAG, log + " throws exception, e=" + exception.getMessage());
-            }
-        }
-    }
-
-    private <T> void notifyObservers(List<Observer<T>> observers, T result) {
-        if (observers == null || observers.isEmpty()) {
-            return;
-        }
-
-        // 创建副本,为了使得回调到app后,app如果立即注销观察者,会造成List异常。
-        List<Observer<T>> copy = new ArrayList<>(observers.size());
-        copy.addAll(observers);
-
-        for (Observer<T> o : copy) {
-            o.onEvent(result);
-        }
-    }
-
-    private <T> void registerObservers(List<Observer<T>> observers, final Observer<T> observer, boolean register) {
-        if (observers == null || observer == null) {
-            return;
-        }
-
-        if (register) {
-            observers.add(observer);
-        } else {
-            observers.remove(observer);
-        }
-    }
-
-    /**
-     * 监听网络通话发起,接听或正在进行时有本地来电的通知
-     * 网络通话发起或者正在接通时,需要监听是否有本地来电(用户接通本地来电)。
-     * 若有本地来电,目前Demo中示例代码的处理是网络通话自动拒绝或者挂断,开发者可以自行灵活处理。
-     */
-    public void observeAutoHangUpForLocalPhone(Observer<Integer> observer, boolean register) {
-        LogUtil.i(TAG, "observeAutoHangUpForLocalPhone->" + observer + "#" + register);
-        registerObservers(this.autoHangUpObservers, observer, register);
-    }
-}

+ 0 - 402
app/src/com/sheishuo/app/avchat/widgets/MultiSelectDialog.java

@@ -1,402 +0,0 @@
-package com.sheishuo.app.avchat.widgets;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Pair;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.Button;
-import android.widget.ImageButton;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.common.adapter.TAdapter;
-import com.netease.nim.uikit.common.adapter.TAdapterDelegate;
-import com.netease.nim.uikit.common.adapter.TViewHolder;
-import com.netease.nim.uikit.common.util.sys.ScreenUtil;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 多选对话框.
- */
-
-public class MultiSelectDialog extends Dialog {
-    private ListView listView;
-    private int itemSize = 0;
-    private List<Pair<String, Boolean>> itemTextList = new LinkedList<Pair<String, Boolean>>();
-    private BaseAdapter listAdapter;
-    private AdapterView.OnItemClickListener itemListener;
-
-    private Context context;
-
-    public static final int NO_TEXT_COLOR = -99999999;
-
-    public static final int NO_TEXT_SIZE = -99999999;
-
-    private View titleView;
-
-    private ImageButton titleBtn;
-
-    private TextView titleTV;
-
-    private TextView messageTV;
-
-    private TextView message2TV;
-
-    private Button positiveBtn, negativeBtn;
-
-    private View btnDivideView;
-
-    private CharSequence title = "", message = "", message2 = "", positiveBtnTitle = "", negativeBtnTitle = "";
-
-    private int titleTextColor = NO_TEXT_COLOR, msgTextColor = NO_TEXT_COLOR,
-            positiveBtnTitleTextColor = NO_TEXT_COLOR, negativeBtnTitleTextColor = NO_TEXT_COLOR;
-
-    private float titleTextSize = NO_TEXT_SIZE, msgTextSize = NO_TEXT_SIZE, positiveBtnTitleTextSize = NO_TEXT_SIZE,
-            negativeBtnTitleTextSize = NO_TEXT_SIZE;
-
-    private int resourceId;
-
-    private boolean isPositiveBtnVisible = true, isNegativeBtnVisible = false;
-
-    private boolean isTitleVisible = false , isMessageVisble = true, isTitleBtnVisible = false;
-
-    private View.OnClickListener positiveBtnListener, negativeBtnListener;
-
-    private HashMap<Integer, View.OnClickListener> mViewListener = new HashMap<Integer, View.OnClickListener>();
-
-    public MultiSelectDialog(Context context, int resourceId) {
-        super(context, R.style.dialog_default_style);
-        this.context = context;
-        if (-1 != resourceId) {
-            setContentView(resourceId);
-            this.resourceId = resourceId;
-        }
-        WindowManager.LayoutParams Params = getWindow().getAttributes();
-        Params.width = WindowManager.LayoutParams.MATCH_PARENT;
-        Params.height = WindowManager.LayoutParams.MATCH_PARENT;
-        getWindow().setAttributes((WindowManager.LayoutParams) Params);
-        initAdapter();
-    }
-    public void setTitle(CharSequence title) {
-        isTitleVisible = TextUtils.isEmpty(title) ? false : true;
-        setTitleVisible(isTitleVisible);
-        if (null != title) {
-            this.title = title;
-            if (null != titleTV)
-                titleTV.setText(title);
-        }
-    }
-
-    public void setTitleVisible(boolean visible){
-        isTitleVisible = visible;
-        if(titleView != null){
-            titleView.setVisibility(isTitleVisible ? View.VISIBLE : View.GONE);
-        }
-    }
-
-    public void setTitleBtnVisible(boolean visible) {
-        isTitleBtnVisible = visible;
-        if (titleBtn != null) {
-            titleBtn.setVisibility(isTitleBtnVisible ? View.VISIBLE : View.GONE);
-        }
-    }
-
-    public void setTitleTextColor(int color) {
-        titleTextColor = color;
-        if (null != titleTV && NO_TEXT_COLOR != color)
-            titleTV.setTextColor(color);
-    }
-
-    public void setMessageTextColor(int color) {
-        msgTextColor = color;
-        if (null != messageTV && NO_TEXT_COLOR != color)
-            messageTV.setTextColor(color);
-
-    }
-
-    public void setMessageTextSize(float size) {
-        msgTextSize = size;
-        if (null != messageTV && NO_TEXT_SIZE != size)
-            messageTV.setTextSize(size);
-    }
-
-    public void setTitleTextSize(float size) {
-        titleTextSize = size;
-        if (null != titleTV && NO_TEXT_SIZE != size)
-            titleTV.setTextSize(size);
-    }
-
-    public void setMessageVisible(boolean visible){
-        isMessageVisble = visible;
-        if(messageTV != null){
-            messageTV.setVisibility(visible ? View.VISIBLE : View.GONE);
-        }
-    }
-
-    public void setMessage(CharSequence message) {
-        if (null != message) {
-            this.message = message;
-            if (null != messageTV)
-                messageTV.setText(message);
-        }
-    }
-
-    public void setMessage2(CharSequence message) {
-        if(!TextUtils.isEmpty(message)) {
-            this.message2 = message;
-            if(null != message2TV) {
-                message2TV.setText(message);
-            }
-        }
-    }
-
-    public void addPositiveButton(CharSequence title, int color, float size,
-                                  View.OnClickListener positiveBtnListener) {
-        isPositiveBtnVisible = true;
-        positiveBtnTitle = TextUtils.isEmpty(title) ? context
-                .getString(R.string.ok) : title;
-        positiveBtnTitleTextColor = color;
-        positiveBtnTitleTextSize = size;
-        this.positiveBtnListener = positiveBtnListener;
-
-        if (positiveBtn != null) {
-            positiveBtn.setText(positiveBtnTitle);
-            positiveBtn.setTextColor(positiveBtnTitleTextColor);
-            positiveBtn.setTextSize(positiveBtnTitleTextSize);
-            positiveBtn.setOnClickListener(positiveBtnListener);
-        }
-    }
-
-    public void addNegativeButton(CharSequence title, int color, float size,
-                                  View.OnClickListener negativeBtnListener) {
-        isNegativeBtnVisible = true;
-        negativeBtnTitle = TextUtils.isEmpty(title) ? context
-                .getString(R.string.cancel) : title;
-        negativeBtnTitleTextColor = color;
-        negativeBtnTitleTextSize = size;
-        this.negativeBtnListener = negativeBtnListener;
-
-        if (negativeBtn != null) {
-            negativeBtn.setText(negativeBtnTitle);
-            negativeBtn.setTextColor(negativeBtnTitleTextColor);
-            negativeBtn.setTextSize(negativeBtnTitleTextSize);
-            negativeBtn.setOnClickListener(negativeBtnListener);
-        }
-    }
-
-    public void addPositiveButton(CharSequence title,
-                                  View.OnClickListener positiveBtnListener) {
-        addPositiveButton(title, NO_TEXT_COLOR, NO_TEXT_SIZE,
-                positiveBtnListener);
-    }
-
-    public void addNegativeButton(CharSequence title,
-                                  View.OnClickListener negativeBtnListener) {
-        addNegativeButton(title, NO_TEXT_COLOR, NO_TEXT_SIZE,
-                negativeBtnListener);
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(resourceId);
-        try {
-            ViewGroup root = (ViewGroup) findViewById(R.id.multi_select_dialog_layout);
-            if (root != null) {
-                ViewGroup.LayoutParams params = root.getLayoutParams();
-                params.width = (int) ScreenUtil.getDialogWidth();
-                root.setLayoutParams(params);
-            }
-
-            titleView = findViewById(R.id.multi_select_dialog_title_view);
-            if (titleView != null) {
-                setTitleVisible(isTitleVisible);
-            }
-            titleBtn = (ImageButton) findViewById(R.id.multi_select_dialog_title_button);
-            if (titleBtn != null) {
-                setTitleBtnVisible(isTitleBtnVisible);
-            }
-            titleTV = (TextView) findViewById(R.id.multi_select_dialog_title_text_view);
-            if (titleTV != null) {
-                titleTV.setText(title);
-                if (NO_TEXT_COLOR != titleTextColor)
-                    titleTV.setTextColor(titleTextColor);
-                if (NO_TEXT_SIZE != titleTextSize)
-                    titleTV.setTextSize(titleTextSize);
-            }
-
-            messageTV = (TextView) findViewById(R.id.multi_select_dialog_message_text_view);
-            if (messageTV != null) {
-                messageTV.setText(message);
-                setMessageVisible(isMessageVisble);
-                if (NO_TEXT_COLOR != msgTextColor)
-                    messageTV.setTextColor(msgTextColor);
-                if (NO_TEXT_SIZE != msgTextSize)
-                    messageTV.setTextSize(msgTextSize);
-            }
-
-            message2TV = (TextView) findViewById(R.id.multi_select_dialog_message_2);
-            if(message2TV != null && !TextUtils.isEmpty(message2)) {
-                message2TV.setVisibility(View.VISIBLE);
-                message2TV.setText(message2);
-            }
-
-            positiveBtn = (Button) findViewById(R.id.multi_select_dialog_positive_btn);
-            if (isPositiveBtnVisible && positiveBtn != null) {
-                positiveBtn.setVisibility(View.VISIBLE);
-                if (NO_TEXT_COLOR != positiveBtnTitleTextColor) {
-                    positiveBtn.setTextColor(positiveBtnTitleTextColor);
-                }
-                if (NO_TEXT_SIZE != positiveBtnTitleTextSize) {
-                    positiveBtn.setTextSize(positiveBtnTitleTextSize);
-                }
-                positiveBtn.setText(positiveBtnTitle);
-                positiveBtn.setOnClickListener(positiveBtnListener);
-            }
-
-            boolean hasChecked = false;
-            for(Pair<String, Boolean> pair:itemTextList) {
-                if(pair.second == true) {
-                    hasChecked = true;
-                }
-            }
-            positiveBtn.setEnabled(hasChecked);
-
-
-            negativeBtn = (Button) findViewById(R.id.multi_select_dialog_negative_btn);
-            btnDivideView = findViewById(R.id.multi_select_dialog_btn_divide_view);
-            if (isNegativeBtnVisible) {
-                negativeBtn.setVisibility(View.VISIBLE);
-                btnDivideView.setVisibility(View.VISIBLE);
-                if (NO_TEXT_COLOR != this.negativeBtnTitleTextColor) {
-                    negativeBtn.setTextColor(negativeBtnTitleTextColor);
-                }
-                if (NO_TEXT_SIZE != this.negativeBtnTitleTextSize) {
-                    negativeBtn.setTextSize(negativeBtnTitleTextSize);
-                }
-                negativeBtn.setText(negativeBtnTitle);
-                negativeBtn.setOnClickListener(negativeBtnListener);
-            }
-
-            if (mViewListener != null && mViewListener.size() != 0) {
-                Iterator iter = mViewListener.entrySet().iterator();
-                View view = null;
-                while (iter.hasNext()) {
-                    Map.Entry<Integer, View.OnClickListener> entry = (Map.Entry) iter.next();
-                    view = findViewById(entry.getKey());
-                    if(view != null && entry.getValue() != null) {
-                        view.setOnClickListener(entry.getValue());
-                    }
-                }
-            }
-            listView = (ListView) findViewById(R.id.multi_select_dialog_list_view);
-            if (itemSize > 0) {
-                updateListView();
-            }
-        } catch (Exception e) {
-
-        }
-    }
-
-    public int getResourceId() {
-        return resourceId;
-    }
-
-    public void setResourceId(int resourceId) {
-        this.resourceId = resourceId;
-    }
-
-    public Button getPositiveBtn() {
-        return positiveBtn;
-    }
-
-    public Button getNegativeBtn() {
-        return negativeBtn;
-    }
-
-    public void setViewListener(int viewId, View.OnClickListener listener) {
-        mViewListener.put(viewId, listener);
-    }
-
-
-
-    private void initAdapter() {
-        listAdapter = new TAdapter<>(context, itemTextList, new TAdapterDelegate() {
-            @Override
-            public int getViewTypeCount() {
-                return itemTextList.size();
-            }
-
-            @Override
-            public Class<? extends TViewHolder> viewHolderAtPosition(int position) {
-                return MultiSelectDialogViewHolder.class;
-            }
-
-            @Override
-            public boolean enabled(int position) {
-                return true;
-            }
-        });
-        itemListener = new AdapterView.OnItemClickListener() {
-            @Override
-            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                itemTextList.set(position,new Pair<String, Boolean>(itemTextList.get(position).first,!itemTextList.get(position).second));
-                boolean hasChecked = false;
-                for(Pair<String, Boolean> pair:itemTextList) {
-                    if(pair.second == true) {
-                        hasChecked = true;
-                    }
-                }
-                positiveBtn.setEnabled(hasChecked);
-                listAdapter.notifyDataSetChanged();
-            }
-        };
-    }
-
-    public MultiSelectDialog(Context context) {
-        this(context, R.layout.multi_select_dialog_default_layout);
-    }
-
-    private void updateListView() {
-        listAdapter.notifyDataSetChanged();
-        if (listView != null) {
-            listView.setAdapter(listAdapter);
-            listView.setOnItemClickListener(itemListener);
-        }
-    }
-
-    public void addItem(String itemText, boolean isChecked) {
-        itemTextList.add(new Pair<String, Boolean>(itemText, isChecked));
-        itemSize = itemTextList.size();
-    }
-
-    public void clearData() {
-        itemTextList.clear();
-        itemSize = 0;
-    }
-
-    @Override
-    public void show() {
-        if (itemSize <= 0) {
-            return;
-        }
-        updateListView();
-        super.show();
-    }
-
-    public List<Pair<String, Boolean>> getItemTextList() {
-        return itemTextList;
-    }
-}

+ 0 - 36
app/src/com/sheishuo/app/avchat/widgets/MultiSelectDialogViewHolder.java

@@ -1,36 +0,0 @@
-package com.sheishuo.app.avchat.widgets;
-
-import android.util.Pair;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.common.adapter.TViewHolder;
-
-public class MultiSelectDialogViewHolder extends TViewHolder {
-
-	private TextView textView;
-	private ImageView imageView;
-
-
-	@Override
-	protected int getResId() {
-		return R.layout.multi_select_dialog_list_item;
-	}
-
-	@Override
-	protected void inflate() {
-		textView = (TextView) view.findViewById(R.id.select_dialog_text_view);
-		imageView = (ImageView) view.findViewById(R.id.select_dialog_image_view);
-	}
-
-	@Override
-	protected void refresh(Object item) {
-        if(item instanceof Pair<?,?>){
-            Pair<String,Boolean> pair = (Pair<String, Boolean>) item;
-            textView.setText(pair.first);
-			imageView.setPressed(pair.second);
-        }
-	}
-
-}

+ 0 - 12
app/src/com/sheishuo/app/avchat/widgets/ToggleListener.java

@@ -1,12 +0,0 @@
-package com.sheishuo.app.avchat.widgets;
-
-import android.view.View;
-
-/**
-* Created by hzlichengda on 14-3-31.
-*/
-public interface ToggleListener {
-    void toggleOn(View v);
-    void toggleOff(View v);
-    void toggleDisable(View v);
-}

+ 0 - 10
app/src/com/sheishuo/app/avchat/widgets/ToggleState.java

@@ -1,10 +0,0 @@
-package com.sheishuo.app.avchat.widgets;
-
-/**
-* Created by hzlichengda on 14-3-31.
-*/
-public enum ToggleState {
-    DISABLE, //禁用
-    OFF, // normal
-    ON;  //selected
-}

+ 0 - 121
app/src/com/sheishuo/app/avchat/widgets/ToggleView.java

@@ -1,121 +0,0 @@
-package com.sheishuo.app.avchat.widgets;
-
-import android.view.View;
-import android.view.ViewGroup;
-
-/**
- * Created by hzlichengda on 14-3-14.
- * if you want to use this parentView with an inner parentView inside ,the inner parentView's id must be R.id.childView
- */
-public class ToggleView {
-
-    private View parentView = null;
-    private View childView = null;
-    private ToggleState state = ToggleState.DISABLE;
-    private ToggleListener listener = null;
-
-    public ToggleView(View parentView, ToggleState initState, ToggleListener listener) {
-        this.parentView = parentView;
-        this.state = initState;
-        this.listener = listener;
-        init();
-    }
-
-    private void init(){
-        if(parentView != null){
-            parentView.setOnClickListener( new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    onToggleStateChange();
-                }
-            });
-            if(parentView instanceof ViewGroup){
-                ViewGroup viewGroup = (ViewGroup) parentView;
-                childView = viewGroup.getChildAt(0);
-            }
-            toggle(state);
-        }
-    }
-
-    public void toggle(ToggleState state){
-        switch (state){
-            case DISABLE:
-                disable(false);
-                break;
-            case OFF:
-                off(false);
-                break;
-            case ON:
-                on(false);
-                break;
-        }
-    }
-
-    private void onToggleStateChange(){
-        switch (state){
-            case DISABLE:
-                disable(true);
-                break;
-            case OFF:
-                on(true);
-                break;
-            case ON:
-                off(true);
-                break;
-        }
-    }
-
-    public void on(boolean callback){
-        state = ToggleState.ON;
-
-        parentView.setEnabled(true);
-        parentView.setSelected(true);
-
-        if(childView != null){
-            childView.setEnabled(true);
-            childView.setSelected(true);
-        }
-
-        if(listener != null && callback)
-            listener.toggleOn(parentView);
-    }
-
-    public void off(boolean callback){
-        state = ToggleState.OFF;
-
-        parentView.setEnabled(true);
-        parentView.setSelected(false);
-
-        if(childView != null){
-            childView.setEnabled(true);
-            childView.setSelected(false);
-        }
-
-        if(listener != null && callback)
-            listener.toggleOff(parentView);
-    }
-
-    public void disable(boolean callback){
-        state = ToggleState.DISABLE;
-
-        parentView.setSelected(false);
-        parentView.setEnabled(false);
-
-        if(childView != null){
-            childView.setSelected(false);
-            childView.setEnabled(false);
-        }
-
-        if(listener != null && callback)
-            listener.toggleDisable(parentView);
-    }
-
-    public void enable(){
-        off(false);
-    }
-
-    public boolean isEnable(){
-        return state != ToggleState.DISABLE;
-    }
-
-}

+ 0 - 39
app/src/com/sheishuo/app/cache/AccountCache.java

@@ -1,39 +0,0 @@
-package com.sheishuo.app.cache;
-
-import com.google.gson.Gson;
-import com.netease.nim.uikit.UIKitCache;
-import com.sheishuo.app.login.beans.LoginBean;
-
-/**
- * Created by KN on 2017/7/17.
- */
-
-public class AccountCache{
-
-    public final static int PasswordMinLength = 8;
-
-    private static LoginBean.DBean account;
-
-    public static int lastPulishedTradeId;
-
-    public static void setCache(LoginBean.DBean account){
-        AccountCache.account =account;
-    }
-
-    public static String getId()
-    {
-        if(account != null)
-            return account.getId();
-        return "0";
-    }
-
-    public static LoginBean.DBean getAccount(){
-        return account;
-    }
-
-    public static void sync(){
-        //同步UIKit中的缓存
-        UIKitCache.setAccount(new Gson().toJson(account));
-    }
-
-}

+ 0 - 25
app/src/com/sheishuo/app/cache/GiftCache.java

@@ -1,25 +0,0 @@
-package com.sheishuo.app.cache;
-
-import com.google.gson.Gson;
-import com.netease.nim.uikit.UIKitCache;
-import com.sheishuo.app.common.beans.GiftBean;
-
-/**
- * Created by KN on 2017/7/25.
- */
-
-public class GiftCache {
-    private static GiftBean.DBean gift;
-
-    public static void setCache(GiftBean.DBean gift){
-        GiftCache.gift = gift;
-
-        //同时存入UIKitCache便于调用
-        UIKitCache.setGifts(new Gson().toJson(gift));
-    }
-
-    public static GiftBean.DBean getGift(){
-        return gift;
-    }
-
-}

+ 0 - 53
app/src/com/sheishuo/app/cache/HobbyCache.java

@@ -1,53 +0,0 @@
-package com.sheishuo.app.cache;
-
-import com.sheishuo.app.common.util.net.NetImpl;
-import com.sheishuo.app.common.util.net.ResponseCallback;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Created by KN on 2017/8/28.
- */
-
-public class HobbyCache {
-    private static boolean inited = false;
-
-    private static Map<String,List<String>> hobbyMap = new HashMap<>();
-
-
-
-    public static List<String> getHobbyCategory() throws Exception {
-        if (inited){
-            List<String> categoryList = new ArrayList<>();
-            Iterator<String> iterator = hobbyMap.keySet().iterator();
-            while (iterator.hasNext()){
-                categoryList.add(iterator.next());
-            }
-
-            return categoryList;
-        }
-        throw new Exception("HobbyCache not inited");
-    }
-
-
-    public static List<String> getHobbyItems(String category) throws Exception {
-        if (inited){
-            return hobbyMap.get(category);
-        }
-        throw new Exception("HobbyCache not inited");
-    }
-
-
-    public static void put(String category,List<String> items){
-        hobbyMap.put(category,items);
-        inited = true;
-    }
-
-
-
-}

+ 0 - 19
app/src/com/sheishuo/app/cache/MineSocialCache.java

@@ -1,19 +0,0 @@
-package com.sheishuo.app.cache;
-
-import com.sheishuo.app.common.beans.SocialInfoBean;
-
-/**
- * Created by KN on 2017/8/20.
- */
-
-public class MineSocialCache {
-    private static SocialInfoBean info;
-
-    public static SocialInfoBean getInfo() {
-        return info;
-    }
-
-    public static void setInfo(SocialInfoBean info) {
-        MineSocialCache.info = info;
-    }
-}

+ 0 - 107
app/src/com/sheishuo/app/cache/SocialInfoCache.java

@@ -1,107 +0,0 @@
-package com.sheishuo.app.cache;
-
-import com.netease.nim.uikit.cache.NimUserInfoCache;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.uinfo.UserService;
-import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
-import com.sheishuo.app.common.beans.SocialInfoBean;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by KN on 2017/8/21.
- */
-
-public class SocialInfoCache {
-    private static Map<String,SocialInfoBean> socialInfoMap = new HashMap<>();
-    private static Map<String, String> followCache;
-
-    public static void reset()
-    {
-        socialInfoMap.clear();
-        if(followCache != null)
-            followCache.clear();
-        NimUserInfoCache.getInstance().clear();
-    }
-
-    public static void put(String id, SocialInfoBean info){
-        NimUserInfoCache.getInstance().setAlias(id, info.getAlias());
-        socialInfoMap.put(id,info);
-    }
-
-    public static SocialInfoBean get(String id){
-        if (socialInfoMap.containsKey(id)){
-            return socialInfoMap.get(id);
-        }
-        return null;
-    }
-
-    public static String getNick(String id)
-    {
-        SocialInfoBean bean = get(id);
-        if(bean != null && bean.getAlias() != null && bean.getAlias().length() > 0)
-        {
-            return bean.getAlias();
-        }
-
-        NimUserInfo user = NIMClient.getService(UserService.class).getUserInfo(id);
-        if (user != null && user.getName() != null && user.getName().length() > 0)
-        {
-            return user.getName();
-        }
-        return getSsid(id);
-    }
-
-    public static String getSsid(String id)
-    {
-        SocialInfoBean bean = SocialInfoCache.get(id);
-        if(bean != null)
-            return bean.getSsid();
-        return id;
-    }
-
-    public static Collection<String> followList()
-    {
-        if(followCache == null)
-            return null;
-
-        return followCache.values();
-    }
-
-    public static void initFollowList(Collection<String> list)
-    {
-        followCache = new HashMap<String, String>();
-        for(String userId : list)
-        {
-            setFollow(userId, true);
-        }
-    }
-
-    public static void setFollow(String userId, Boolean value)
-    {
-        if(followCache == null)
-            return;
-
-        if(!value)
-        {
-            followCache.remove(userId);
-        }
-        else if(!followCache.containsKey(userId))
-        {
-            followCache.put(userId, userId);
-        }
-    }
-
-    public static void setAlias(String userId, String alias)
-    {
-        SocialInfoBean bean = SocialInfoCache.get(userId);
-        NimUserInfoCache.getInstance().setAlias(userId, alias);
-        if(bean != null)
-            bean.setAlias(alias);
-    }
-
-
-}
-

+ 0 - 238
app/src/com/sheishuo/app/chatroom/activity/ChatRoomActivity.java

@@ -1,238 +0,0 @@
-package com.sheishuo.app.chatroom.activity;
-
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.widget.Toast;
-
-import com.sheishuo.app.chatroom.fragment.ChatRoomMessageFragment;
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.fragment.ChatRoomFragment;
-import com.sheishuo.app.chatroom.helper.ChatRoomMemberCache;
-import com.netease.nim.uikit.common.activity.UI;
-import com.netease.nim.uikit.common.ui.dialog.DialogMaker;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nimlib.sdk.AbortableFuture;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.RequestCallback;
-import com.netease.nimlib.sdk.ResponseCode;
-import com.netease.nimlib.sdk.StatusCode;
-import com.netease.nimlib.sdk.chatroom.ChatRoomService;
-import com.netease.nimlib.sdk.chatroom.ChatRoomServiceObserver;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomInfo;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomKickOutEvent;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomStatusChangeData;
-import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomData;
-import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomResultData;
-
-/**
- * 聊天室
- * Created by hzxuwen on 2015/12/14.
- */
-public class ChatRoomActivity extends UI {
-    private final static String EXTRA_ROOM_ID = "ROOM_ID";
-    private static final String TAG = ChatRoomActivity.class.getSimpleName();
-
-    /**
-     * 聊天室基本信息
-     */
-    private String roomId;
-    private ChatRoomInfo roomInfo;
-    private boolean hasEnterSuccess = false; // 是否已经成功登录聊天室
-    private ChatRoomFragment fragment;
-
-    /**
-     * 子页面
-     */
-    private ChatRoomMessageFragment messageFragment;
-    private AbortableFuture<EnterChatRoomResultData> enterRequest;
-
-    public static void start(Context context, String roomId) {
-        Intent intent = new Intent();
-        intent.setClass(context, ChatRoomActivity.class);
-        intent.putExtra(EXTRA_ROOM_ID, roomId);
-        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
-        context.startActivity(intent);
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.chat_room_activity);
-        roomId = getIntent().getStringExtra(EXTRA_ROOM_ID);
-
-        // 注册监听
-        registerObservers(true);
-
-        // 登录聊天室
-        enterRoom();
-    }
-
-    @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        registerObservers(false);
-    }
-
-    @Override
-    public void onBackPressed() {
-        if (messageFragment == null || !messageFragment.onBackPressed()) {
-            super.onBackPressed();
-        }
-
-        logoutChatRoom();
-    }
-
-    private void enterRoom() {
-        DialogMaker.showProgressDialog(this, null, "", true, new DialogInterface.OnCancelListener() {
-            @Override
-            public void onCancel(DialogInterface dialog) {
-                if (enterRequest != null) {
-                    enterRequest.abort();
-                    onLoginDone();
-                    finish();
-                }
-            }
-        }).setCanceledOnTouchOutside(false);
-        hasEnterSuccess = false;
-        EnterChatRoomData data = new EnterChatRoomData(roomId);
-        enterRequest = NIMClient.getService(ChatRoomService.class).enterChatRoomEx(data, 1);
-        enterRequest.setCallback(new RequestCallback<EnterChatRoomResultData>() {
-            @Override
-            public void onSuccess(EnterChatRoomResultData result) {
-                onLoginDone();
-                roomInfo = result.getRoomInfo();
-                ChatRoomMember member = result.getMember();
-                member.setRoomId(roomInfo.getRoomId());
-                ChatRoomMemberCache.getInstance().saveMyMember(member);
-                initChatRoomFragment();
-                initMessageFragment();
-                hasEnterSuccess = true;
-            }
-
-            @Override
-            public void onFailed(int code) {
-                // test
-                LogUtil.ui("enter chat room failed, callback code=" + code);
-
-                onLoginDone();
-                if (code == ResponseCode.RES_CHATROOM_BLACKLIST) {
-                    Toast.makeText(ChatRoomActivity.this, "你已被拉入黑名单,不能再进入", Toast.LENGTH_SHORT).show();
-                } else if (code == ResponseCode.RES_ENONEXIST) {
-                    Toast.makeText(ChatRoomActivity.this, "聊天室不存在", Toast.LENGTH_SHORT).show();
-                } else {
-                    Toast.makeText(ChatRoomActivity.this, "enter chat room failed, code=" + code, Toast.LENGTH_SHORT).show();
-                }
-                finish();
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                onLoginDone();
-                Toast.makeText(ChatRoomActivity.this, "enter chat room exception, e=" + exception.getMessage(), Toast.LENGTH_SHORT).show();
-                finish();
-            }
-        });
-    }
-
-    private void registerObservers(boolean register) {
-        NIMClient.getService(ChatRoomServiceObserver.class).observeOnlineStatus(onlineStatus, register);
-        NIMClient.getService(ChatRoomServiceObserver.class).observeKickOutEvent(kickOutObserver, register);
-    }
-
-    private void logoutChatRoom() {
-        NIMClient.getService(ChatRoomService.class).exitChatRoom(roomId);
-        clearChatRoom();
-    }
-
-    public void clearChatRoom() {
-        ChatRoomMemberCache.getInstance().clearRoomCache(roomId);
-        finish();
-    }
-
-    Observer<ChatRoomStatusChangeData> onlineStatus = new Observer<ChatRoomStatusChangeData>() {
-        @Override
-        public void onEvent(ChatRoomStatusChangeData chatRoomStatusChangeData) {
-            if (!chatRoomStatusChangeData.roomId.equals(roomId)) {
-                return;
-            }
-            if (chatRoomStatusChangeData.status == StatusCode.CONNECTING) {
-                DialogMaker.updateLoadingMessage("连接中...");
-            } else if (chatRoomStatusChangeData.status == StatusCode.LOGINING) {
-                DialogMaker.updateLoadingMessage("登录中...");
-            } else if (chatRoomStatusChangeData.status == StatusCode.LOGINED) {
-                if (fragment != null) {
-                    fragment.updateOnlineStatus(true);
-                }
-            } else if (chatRoomStatusChangeData.status == StatusCode.UNLOGIN) {
-                if (fragment != null) {
-                    fragment.updateOnlineStatus(false);
-                }
-
-                // 登录成功后,断网重连交给云信SDK,如果重连失败,可以查询具体失败的原因
-                if (hasEnterSuccess) {
-                    int code = NIMClient.getService(ChatRoomService.class).getEnterErrorCode(roomId);
-                    Toast.makeText(ChatRoomActivity.this, "getEnterErrorCode=" + code, Toast.LENGTH_LONG).show();
-                    LogUtil.d(TAG, "chat room enter error code:" + code);
-                }
-            } else if (chatRoomStatusChangeData.status == StatusCode.NET_BROKEN) {
-                if (fragment != null) {
-                    fragment.updateOnlineStatus(false);
-                }
-                Toast.makeText(ChatRoomActivity.this, R.string.net_broken, Toast.LENGTH_SHORT).show();
-            }
-
-            LogUtil.i(TAG, "chat room online status changed to " + chatRoomStatusChangeData.status.name());
-        }
-    };
-
-    Observer<ChatRoomKickOutEvent> kickOutObserver = new Observer<ChatRoomKickOutEvent>() {
-        @Override
-        public void onEvent(ChatRoomKickOutEvent chatRoomKickOutEvent) {
-            Toast.makeText(ChatRoomActivity.this, "被踢出聊天室,原因:" + chatRoomKickOutEvent.getReason(), Toast.LENGTH_SHORT).show();
-            clearChatRoom();
-        }
-    };
-
-    private void initChatRoomFragment() {
-        fragment = (ChatRoomFragment) getSupportFragmentManager().findFragmentById(R.id.chat_rooms_fragment);
-        if (fragment != null) {
-            fragment.updateView();
-        } else {
-            // 如果Fragment还未Create完成,延迟初始化
-            getHandler().postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    initChatRoomFragment();
-                }
-            }, 50);
-        }
-    }
-
-    private void initMessageFragment() {
-        messageFragment = (ChatRoomMessageFragment) getSupportFragmentManager().findFragmentById(R.id.chat_room_message_fragment);
-        if (messageFragment != null) {
-            messageFragment.init(roomId);
-        } else {
-            // 如果Fragment还未Create完成,延迟初始化
-            getHandler().postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    initMessageFragment();
-                }
-            }, 50);
-        }
-    }
-
-    private void onLoginDone() {
-        enterRequest = null;
-        DialogMaker.dismissProgressDialog();
-    }
-
-    public ChatRoomInfo getRoomInfo() {
-        return roomInfo;
-    }
-}

+ 0 - 234
app/src/com/sheishuo/app/chatroom/adapter/ChatRoomMsgAdapter.java

@@ -1,234 +0,0 @@
-package com.sheishuo.app.chatroom.adapter;
-
-import android.support.v7.widget.RecyclerView;
-import android.view.View;
-
-import com.sheishuo.app.chatroom.viewholder.ChatRoomMsgViewHolderBase;
-import com.sheishuo.app.chatroom.viewholder.ChatRoomMsgViewHolderFactory;
-import com.netease.nim.uikit.R;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
-import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
-import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
-import com.netease.nimlib.sdk.msg.model.IMMessage;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Created by huangjun on 2016/12/21.
- */
-public class ChatRoomMsgAdapter extends BaseMultiItemFetchLoadAdapter<ChatRoomMessage, BaseViewHolder> {
-
-    private Map<Class<? extends ChatRoomMsgViewHolderBase>, Integer> holder2ViewType;
-
-    private ViewHolderEventListener eventListener;
-    private Map<String, Float> progresses; // 有文件传输,需要显示进度条的消息ID map
-    private String messageId;
-
-    public ChatRoomMsgAdapter(RecyclerView recyclerView, List<ChatRoomMessage> data) {
-        super(recyclerView, data);
-
-        timedItems = new HashSet<>();
-        progresses = new HashMap<>();
-
-        // view type, view holder
-        holder2ViewType = new HashMap<>();
-        List<Class<? extends ChatRoomMsgViewHolderBase>> holders = ChatRoomMsgViewHolderFactory.getAllViewHolders();
-        int viewType = 0;
-        for (Class<? extends ChatRoomMsgViewHolderBase> holder : holders) {
-            viewType++;
-            addItemType(viewType, R.layout.nim_message_item, holder);
-            holder2ViewType.put(holder, viewType);
-        }
-    }
-
-    @Override
-    protected int getViewType(ChatRoomMessage message) {
-        return holder2ViewType.get(ChatRoomMsgViewHolderFactory.getViewHolderByType(message));
-    }
-
-    @Override
-    protected String getItemKey(ChatRoomMessage item) {
-        return item.getUuid();
-    }
-
-    public void setEventListener(ViewHolderEventListener eventListener) {
-        this.eventListener = eventListener;
-    }
-
-    public ViewHolderEventListener getEventListener() {
-        return eventListener;
-    }
-
-    public void deleteItem(IMMessage message, boolean isRelocateTime) {
-        if (message == null) {
-            return;
-        }
-
-        int index = 0;
-        for (IMMessage item : getData()) {
-            if (item.isTheSame(message)) {
-                break;
-            }
-            ++index;
-        }
-
-        if (index < getDataSize()) {
-            remove(index);
-            if (isRelocateTime) {
-                relocateShowTimeItemAfterDelete(message, index);
-            }
-            notifyDataSetChanged(); // 可以不要!!!
-        }
-    }
-
-    public float getProgress(IMMessage message) {
-        Float progress = progresses.get(message.getUuid());
-        return progress == null ? 0 : progress;
-    }
-
-    public void putProgress(IMMessage message, float progress) {
-        progresses.put(message.getUuid(), progress);
-    }
-
-    /**
-     * *********************** 时间显示处理 ***********************
-     */
-
-    private Set<String> timedItems; // 需要显示消息时间的消息ID
-    private IMMessage lastShowTimeItem; // 用于消息时间显示,判断和上条消息间的时间间隔
-
-    public boolean needShowTime(IMMessage message) {
-        return timedItems.contains(message.getUuid());
-    }
-
-    /**
-     * 列表加入新消息时,更新时间显示
-     */
-    public void updateShowTimeItem(List<IMMessage> items, boolean fromStart, boolean update) {
-        IMMessage anchor = fromStart ? null : lastShowTimeItem;
-        for (IMMessage message : items) {
-            if (setShowTimeFlag(message, anchor)) {
-                anchor = message;
-            }
-        }
-
-        if (update) {
-            lastShowTimeItem = anchor;
-        }
-    }
-
-    /**
-     * 是否显示时间item
-     */
-    private boolean setShowTimeFlag(IMMessage message, IMMessage anchor) {
-        boolean update = false;
-
-        if (hideTimeAlways(message)) {
-            setShowTime(message, false);
-        } else {
-            if (anchor == null) {
-                setShowTime(message, true);
-                update = true;
-            } else {
-                long time = anchor.getTime();
-                long now = message.getTime();
-
-                if (now - time == 0) {
-                    // 消息撤回时使用
-                    setShowTime(message, true);
-                    lastShowTimeItem = message;
-                    update = true;
-                } else if (now - time < (long) (5 * 60 * 1000)) {
-                    setShowTime(message, false);
-                } else {
-                    setShowTime(message, true);
-                    update = true;
-                }
-            }
-        }
-
-        return update;
-    }
-
-    private void setShowTime(IMMessage message, boolean show) {
-        if (show) {
-            timedItems.add(message.getUuid());
-        } else {
-            timedItems.remove(message.getUuid());
-        }
-    }
-
-    private void relocateShowTimeItemAfterDelete(IMMessage messageItem, int index) {
-        // 如果被删的项显示了时间,需要继承
-        if (needShowTime(messageItem)) {
-            setShowTime(messageItem, false);
-            if (getDataSize() > 0) {
-                IMMessage nextItem;
-                if (index == getDataSize()) {
-                    //删除的是最后一项
-                    nextItem = getItem(index - 1);
-                } else {
-                    //删除的不是最后一项
-                    nextItem = getItem(index);
-                }
-
-                // 增加其他不需要显示时间的消息类型判断
-                if (hideTimeAlways(nextItem)) {
-                    setShowTime(nextItem, false);
-                    if (lastShowTimeItem != null && lastShowTimeItem != null
-                            && lastShowTimeItem.isTheSame(messageItem)) {
-                        lastShowTimeItem = null;
-                        for (int i = getDataSize() - 1; i >= 0; i--) {
-                            IMMessage item = getItem(i);
-                            if (needShowTime(item)) {
-                                lastShowTimeItem = item;
-                                break;
-                            }
-                        }
-                    }
-                } else {
-                    setShowTime(nextItem, true);
-                    if (lastShowTimeItem == null
-                            || (lastShowTimeItem != null && lastShowTimeItem.isTheSame(messageItem))) {
-                        lastShowTimeItem = nextItem;
-                    }
-                }
-            } else {
-                lastShowTimeItem = null;
-            }
-        }
-    }
-
-    private boolean hideTimeAlways(IMMessage message) {
-        if (message.getSessionType() == SessionTypeEnum.ChatRoom) {
-            return true;
-        }
-        switch (message.getMsgType()) {
-            case notification:
-                return true;
-            default:
-                return false;
-        }
-    }
-
-    public interface ViewHolderEventListener {
-        // 长按事件响应处理
-        boolean onViewHolderLongClick(View clickView, View viewHolderView, IMMessage item);
-
-        // 发送失败或者多媒体文件下载失败指示按钮点击响应处理
-        void onFailedBtnClick(IMMessage resendMessage);
-    }
-
-    public void setUuid(String messageId) {
-        this.messageId = messageId;
-    }
-
-    public String getUuid() {
-        return messageId;
-    }
-}

+ 0 - 50
app/src/com/sheishuo/app/chatroom/adapter/ChatRoomOnlinePeopleAdapter.java

@@ -1,50 +0,0 @@
-package com.sheishuo.app.chatroom.adapter;
-
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.view.View;
-import android.widget.ImageView;
-
-import com.sheishuo.app.chatroom.widget.ChatRoomImageView;
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseQuickAdapter;
-import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder;
-import com.netease.nimlib.sdk.chatroom.constant.MemberType;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
-
-import java.util.List;
-
-/**
- * Created by huangjun on 2016/12/29.
- */
-public class ChatRoomOnlinePeopleAdapter extends BaseQuickAdapter<ChatRoomMember, BaseViewHolder> {
-
-    public ChatRoomOnlinePeopleAdapter(RecyclerView recyclerView, List<ChatRoomMember> members) {
-        super(recyclerView, R.layout.online_people_item, members);
-    }
-
-    @Override
-    protected void convert(BaseViewHolder holder, ChatRoomMember member, int position, boolean isScrolling) {
-        // bg selector
-        holder.getConvertView().setBackgroundResource(com.netease.nim.uikit.R.drawable.touch_bg);
-
-        // identity image
-        ImageView identityImage = holder.getView(R.id.identity_image);
-        if (member.getMemberType() == MemberType.CREATOR) {
-            identityImage.setVisibility(View.VISIBLE);
-            identityImage.setImageDrawable(holder.getContext().getResources().getDrawable(R.drawable.master_icon));
-        } else if (member.getMemberType() == MemberType.ADMIN) {
-            identityImage.setVisibility(View.VISIBLE);
-            identityImage.setImageDrawable(holder.getContext().getResources().getDrawable(R.drawable.admin_icon));
-        } else {
-            identityImage.setVisibility(View.GONE);
-        }
-
-        // head image
-        ChatRoomImageView userHeadImage = holder.getView(R.id.user_head);
-        userHeadImage.loadAvatarByUrl(member.getAvatar());
-
-        // user name
-        holder.setText(R.id.user_name, TextUtils.isEmpty(member.getNick()) ? "" : member.getNick());
-    }
-}

+ 0 - 69
app/src/com/sheishuo/app/chatroom/adapter/ChatRoomTabPagerAdapter.java

@@ -1,69 +0,0 @@
-package com.sheishuo.app.chatroom.adapter;
-
-import android.content.Context;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.view.ViewPager;
-
-import com.sheishuo.app.chatroom.constant.ChatRoomTab;
-import com.sheishuo.app.chatroom.fragment.tab.ChatRoomTabFragment;
-import com.sheishuo.app.common.ui.viewpager.SlidingTabPagerAdapter;
-
-import java.util.List;
-
-/**
- * Created by hzxuwen on 2015/12/14.
- */
-public class ChatRoomTabPagerAdapter extends SlidingTabPagerAdapter {
-    public ChatRoomTabPagerAdapter(FragmentManager fm, Context context, ViewPager pager) {
-        super(fm, ChatRoomTab.values().length, context.getApplicationContext(), pager);
-
-        for (ChatRoomTab tab : ChatRoomTab.values()) {
-            try {
-                ChatRoomTabFragment fragment = null;
-
-                List<Fragment> fs = fm.getFragments();
-                if (fs != null) {
-                    for (Fragment f : fs) {
-                        if (f.getClass() == tab.clazz) {
-                            fragment = (ChatRoomTabFragment) f;
-                            break;
-                        }
-                    }
-                }
-
-                if (fragment == null) {
-                    fragment = tab.clazz.newInstance();
-                }
-
-                fragment.setState(this);
-                fragment.attachTabData(tab);
-
-                fragments[tab.tabIndex] = fragment;
-            } catch (InstantiationException e) {
-                e.printStackTrace();
-            } catch (IllegalAccessException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    @Override
-    public int getCacheCount() {
-        return ChatRoomTab.values().length;
-    }
-
-    @Override
-    public int getCount() {
-        return ChatRoomTab.values().length;
-    }
-
-    @Override
-    public CharSequence getPageTitle(int position) {
-        ChatRoomTab tab = ChatRoomTab.fromTabIndex(position);
-
-        int resId = tab != null ? tab.resId : 0;
-
-        return resId != 0 ? context.getText(resId) : "";
-    }
-}

+ 0 - 44
app/src/com/sheishuo/app/chatroom/adapter/ChatRoomsAdapter.java

@@ -1,44 +0,0 @@
-package com.sheishuo.app.chatroom.adapter;
-
-import android.support.v7.widget.RecyclerView;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.helper.ChatRoomHelper;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseQuickAdapter;
-import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomInfo;
-
-/**
- * Created by huangjun on 2016/12/9.
- */
-public class ChatRoomsAdapter extends BaseQuickAdapter<ChatRoomInfo, BaseViewHolder> {
-    private final static int COUNT_LIMIT = 10000;
-
-    public ChatRoomsAdapter(RecyclerView recyclerView) {
-        super(recyclerView, R.layout.chat_room_item, null);
-    }
-
-    @Override
-    protected void convert(BaseViewHolder holder, ChatRoomInfo room, int position, boolean isScrolling) {
-        // bg
-        holder.getConvertView().setBackgroundResource(R.drawable.list_item_bg_selecter);
-        // cover
-        ImageView coverImage = holder.getView(R.id.cover_image);
-        ChatRoomHelper.setCoverImage(room.getRoomId(), coverImage, false);
-        // name
-        holder.setText(R.id.tv_name, room.getName());
-        // online count
-        TextView onlineCountText = holder.getView(R.id.tv_online_count);
-        setOnlineCount(onlineCountText, room);
-    }
-
-    private void setOnlineCount(TextView onlineCountText, ChatRoomInfo room) {
-        if (room.getOnlineUserCount() < COUNT_LIMIT) {
-            onlineCountText.setText(String.valueOf(room.getOnlineUserCount()));
-        } else if (room.getOnlineUserCount() >= COUNT_LIMIT) {
-            onlineCountText.setText(String.format("%.1f", room.getOnlineUserCount() / (float) COUNT_LIMIT) + "万");
-        }
-    }
-}

+ 0 - 44
app/src/com/sheishuo/app/chatroom/constant/ChatRoomTab.java

@@ -1,44 +0,0 @@
-package com.sheishuo.app.chatroom.constant;
-
-import com.sheishuo.app.chatroom.fragment.tab.ChatRoomTabFragment;
-import com.sheishuo.app.chatroom.fragment.tab.MasterTabFragment;
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.fragment.tab.MessageTabFragment;
-import com.sheishuo.app.chatroom.fragment.tab.OnlinePeopleTabFragment;
-
-/**
- * Created by hzxuwen on 2015/12/14.
- */
-public enum ChatRoomTab {
-    CHAT_ROOM_MESSAGE(0, MessageTabFragment.class, R.string.chat_room_message, R.layout.chat_room_message_tab),
-    MASTER(1, MasterTabFragment.class, R.string.chat_room_master, R.layout.chat_room_master_tab),
-    ONLINE_PEOPLE(2, OnlinePeopleTabFragment.class, R.string.chat_room_online_people, R.layout.chat_room_people_tab);
-
-    public final int tabIndex;
-
-    public final Class<? extends ChatRoomTabFragment> clazz;
-
-    public final int resId;
-
-    public final int fragmentId;
-
-    public final int layoutId;
-
-    ChatRoomTab(int index, Class<? extends ChatRoomTabFragment> clazz, int resId, int layoutId) {
-        this.tabIndex = index;
-        this.clazz = clazz;
-        this.resId = resId;
-        this.fragmentId = index;
-        this.layoutId = layoutId;
-    }
-
-    public static final ChatRoomTab fromTabIndex(int tabIndex) {
-        for (ChatRoomTab value : ChatRoomTab.values()) {
-            if (value.tabIndex == tabIndex) {
-                return value;
-            }
-        }
-
-        return null;
-    }
-}

+ 0 - 179
app/src/com/sheishuo/app/chatroom/fragment/ChatRoomFragment.java

@@ -1,179 +0,0 @@
-package com.sheishuo.app.chatroom.fragment;
-
-import android.os.Bundle;
-import android.support.v4.view.ViewPager;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewStub;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.sheishuo.app.chatroom.activity.ChatRoomActivity;
-import com.sheishuo.app.chatroom.fragment.tab.ChatRoomTabFragment;
-import com.sheishuo.app.chatroom.helper.ChatRoomHelper;
-import com.sheishuo.app.common.infra.Handlers;
-import com.sheishuo.app.common.ui.viewpager.PagerSlidingTabStrip;
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.adapter.ChatRoomTabPagerAdapter;
-import com.sheishuo.app.common.ui.viewpager.FadeInOutPageTransformer;
-import com.netease.nim.uikit.common.ui.barrage.BarrageConfig;
-import com.netease.nim.uikit.common.ui.barrage.BarrageSurfaceView;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.chatroom.ChatRoomService;
-
-/**
- * 聊天室顶层fragment
- * Created by hzxuwen on 2015/12/14.
- */
-public class ChatRoomFragment extends ChatRoomTabFragment implements ViewPager.OnPageChangeListener {
-    private PagerSlidingTabStrip tabs;
-    private ViewPager viewPager;
-    private ChatRoomTabPagerAdapter adapter;
-    private int scrollState;
-    private ImageView imageView;
-    private TextView statusText;
-    private static final boolean SHOW_BARRAGE = false;
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-    }
-
-    @Override
-    protected void onInit() {
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        return inflater.inflate(R.layout.chat_room_fragment, container, false);
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-
-        findViews();
-        setupPager();
-        setupTabs();
-    }
-
-    public void updateOnlineStatus(boolean isOnline) {
-        statusText.setVisibility(isOnline ? View.GONE : View.VISIBLE);
-    }
-
-    public void updateView() {
-        ChatRoomHelper.setCoverImage(((ChatRoomActivity) getActivity()).getRoomInfo().getRoomId(), imageView, true);
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-    }
-
-    private void findViews() {
-        imageView = findView(R.id.chat_room_view);
-        statusText = findView(R.id.online_status);
-        final ImageView backImage = findView(R.id.back_arrow);
-        tabs = findView(R.id.chat_room_tabs);
-        viewPager = findView(R.id.chat_room_viewpager);
-
-        backImage.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                NIMClient.getService(ChatRoomService.class).exitChatRoom(((ChatRoomActivity) getActivity()).getRoomInfo().getRoomId());
-                ((ChatRoomActivity) getActivity()).clearChatRoom();
-            }
-        });
-
-        // 是否演示弹幕控件
-        if (SHOW_BARRAGE) {
-            ViewStub barrageViewStub = findView(R.id.barrage_view_stub);
-            barrageViewStub.inflate();
-
-            View barrageViewRoot = findView(R.id.barrage_view_after_inflate);
-            final BarrageSurfaceView barrageView = (BarrageSurfaceView) barrageViewRoot.findViewById(R.id.barrage_view);
-
-            final String barrageText1 = "欢迎进入直播间";
-            final String barrageText2 = "Welcome to live room";
-            Handlers.sharedHandler(getActivity()).postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    BarrageConfig config = new BarrageConfig();
-                    config.setDuration(4500);
-                    // 初始化弹幕控件
-                    barrageView.init(config);
-                    for (int i = 1; i <= 200; i++) {
-                        barrageView.addTextBarrage((i % 2 == 0 ? barrageText1 : barrageText2) + i);
-                    }
-                }
-            }, 1000);
-        }
-    }
-
-    private void setupPager() {
-        // CACHE COUNT
-        adapter = new ChatRoomTabPagerAdapter(getFragmentManager(), getActivity(), viewPager);
-        viewPager.setOffscreenPageLimit(adapter.getCacheCount());
-        // page swtich animation
-        viewPager.setPageTransformer(true, new FadeInOutPageTransformer());
-        // ADAPTER
-        viewPager.setAdapter(adapter);
-        // TAKE OVER CHANGE
-        viewPager.setOnPageChangeListener(this);
-    }
-
-    private void setupTabs() {
-        tabs.setOnCustomTabListener(new PagerSlidingTabStrip.OnCustomTabListener() {
-            @Override
-            public int getTabLayoutResId(int position) {
-                return R.layout.chat_room_tab_layout;
-            }
-
-            @Override
-            public boolean screenAdaptation() {
-                return true;
-            }
-        });
-        tabs.setViewPager(viewPager);
-        tabs.setOnTabClickListener(adapter);
-        tabs.setOnTabDoubleTapListener(adapter);
-    }
-
-    /********************
-     * OnPageChangeListener
-     **************************/
-
-    @Override
-    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-        // TO TABS
-        tabs.onPageScrolled(position, positionOffset, positionOffsetPixels);
-        // TO ADAPTER
-        adapter.onPageScrolled(position);
-    }
-
-    @Override
-    public void onPageSelected(int position) {
-        // TO TABS
-        tabs.onPageSelected(position);
-
-        selectPage(position);
-    }
-
-    @Override
-    public void onPageScrollStateChanged(int state) {
-        // TO TABS
-        tabs.onPageScrollStateChanged(state);
-
-        scrollState = state;
-
-        selectPage(viewPager.getCurrentItem());
-    }
-
-    private void selectPage(int page) {
-        // TO PAGE
-        if (scrollState == ViewPager.SCROLL_STATE_IDLE) {
-            adapter.onPageSelected(viewPager.getCurrentItem());
-        }
-    }
-}

+ 0 - 30
app/src/com/sheishuo/app/chatroom/fragment/ChatRoomInputPanel.java

@@ -1,30 +0,0 @@
-package com.sheishuo.app.chatroom.fragment;
-
-import android.view.View;
-
-import com.netease.nim.uikit.session.actions.BaseAction;
-import com.netease.nim.uikit.session.module.Container;
-import com.netease.nim.uikit.session.module.input.InputPanel;
-import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
-import com.netease.nimlib.sdk.msg.model.IMMessage;
-
-import java.util.List;
-
-/**
- * Created by zhoujianghua on 2016/6/8.
- */
-public class ChatRoomInputPanel extends InputPanel {
-
-    public ChatRoomInputPanel(Container container, View view, List<BaseAction> actions, boolean isTextAudioSwitchShow) {
-        super(container, view, actions, isTextAudioSwitchShow);
-    }
-
-    public ChatRoomInputPanel(Container container, View view, List<BaseAction> actions) {
-        super(container, view, actions);
-    }
-
-    @Override
-    protected IMMessage createTextMessage(String text) {
-        return ChatRoomMessageBuilder.createChatRoomTextMessage(container.account, text);
-    }
-}

+ 0 - 199
app/src/com/sheishuo/app/chatroom/fragment/ChatRoomMessageFragment.java

@@ -1,199 +0,0 @@
-package com.sheishuo.app.chatroom.fragment;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Toast;
-
-import com.sheishuo.app.session.action.GuessAction;
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.helper.ChatRoomMemberCache;
-import com.sheishuo.app.chatroom.module.ChatRoomMsgListPanel;
-import com.netease.nim.uikit.common.fragment.TFragment;
-import com.netease.nim.uikit.session.actions.BaseAction;
-import com.netease.nim.uikit.session.module.Container;
-import com.netease.nim.uikit.session.module.ModuleProxy;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.RequestCallback;
-import com.netease.nimlib.sdk.ResponseCode;
-import com.netease.nimlib.sdk.chatroom.ChatRoomService;
-import com.netease.nimlib.sdk.chatroom.ChatRoomServiceObserver;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
-import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
-import com.netease.nimlib.sdk.msg.model.IMMessage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 聊天室直播互动fragment
- * Created by hzxuwen on 2015/12/16.
- */
-public class ChatRoomMessageFragment extends TFragment implements ModuleProxy {
-    private View rootView;
-    // modules
-    protected ChatRoomInputPanel inputPanel;
-    protected ChatRoomMsgListPanel messageListPanel;
-
-    private String roomId;
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        rootView = inflater.inflate(R.layout.chat_room_message_fragment, container, false);
-        return rootView;
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        if (inputPanel != null) {
-            inputPanel.onPause();
-        }
-        if (messageListPanel != null) {
-            messageListPanel.onPause();
-        }
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        if (messageListPanel != null) {
-            messageListPanel.onResume();
-        }
-    }
-
-    public boolean onBackPressed() {
-        if (inputPanel != null && inputPanel.collapse(true)) {
-            return true;
-        }
-
-        if (messageListPanel != null && messageListPanel.onBackPressed()) {
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        registerObservers(false);
-
-        if (messageListPanel != null) {
-            messageListPanel.onDestroy();
-        }
-    }
-
-    public void onLeave() {
-        if (inputPanel != null) {
-            inputPanel.collapse(false);
-        }
-    }
-
-    public void init(String roomId) {
-        this.roomId = roomId;
-        registerObservers(true);
-        findViews();
-    }
-
-    private void findViews() {
-        Container container = new Container(getActivity(), roomId, SessionTypeEnum.ChatRoom, this);
-        if (messageListPanel == null) {
-            messageListPanel = new ChatRoomMsgListPanel(container, rootView);
-        } else {
-            messageListPanel.reload(container);
-        }
-
-        if (inputPanel == null) {
-            inputPanel = new ChatRoomInputPanel(container, rootView, getActionList(), false);
-        } else {
-            inputPanel.reload(container, null);
-        }
-    }
-
-    private void registerObservers(boolean register) {
-        NIMClient.getService(ChatRoomServiceObserver.class).observeReceiveMessage(incomingChatRoomMsg, register);
-    }
-
-    Observer<List<ChatRoomMessage>> incomingChatRoomMsg = new Observer<List<ChatRoomMessage>>() {
-        @Override
-        public void onEvent(List<ChatRoomMessage> messages) {
-            if (messages == null || messages.isEmpty()) {
-                return;
-            }
-
-            messageListPanel.onIncomingMessage(messages);
-        }
-    };
-
-    /************************** Module proxy ***************************/
-
-    @Override
-    public boolean sendMessage(IMMessage msg) {
-        ChatRoomMessage message = (ChatRoomMessage) msg;
-
-        Map<String, Object> ext = new HashMap<>();
-        ChatRoomMember chatRoomMember = ChatRoomMemberCache.getInstance().getChatRoomMember(roomId, SheishuoCache.getAccount());
-        if (chatRoomMember != null && chatRoomMember.getMemberType() != null) {
-            ext.put("type", chatRoomMember.getMemberType().getValue());
-            message.setRemoteExtension(ext);
-        }
-
-        NIMClient.getService(ChatRoomService.class).sendMessage(message, false)
-                .setCallback(new RequestCallback<Void>() {
-                    @Override
-                    public void onSuccess(Void param) {
-                    }
-
-                    @Override
-                    public void onFailed(int code) {
-                        if (code == ResponseCode.RES_CHATROOM_MUTED) {
-                            Toast.makeText(SheishuoCache.getContext(), "用户被禁言", Toast.LENGTH_SHORT).show();
-                        } else if (code == ResponseCode.RES_CHATROOM_ROOM_MUTED) {
-                            Toast.makeText(SheishuoCache.getContext(), "全体禁言", Toast.LENGTH_SHORT).show();
-                        } else {
-                            Toast.makeText(SheishuoCache.getContext(), "消息发送失败:code:" + code, Toast.LENGTH_SHORT).show();
-                        }
-                    }
-
-                    @Override
-                    public void onException(Throwable exception) {
-                        Toast.makeText(SheishuoCache.getContext(), "消息发送失败!", Toast.LENGTH_SHORT).show();
-                    }
-                });
-        messageListPanel.onMsgSend(message);
-        return true;
-    }
-
-    @Override
-    public void onInputPanelExpand() {
-        messageListPanel.scrollToBottom();
-    }
-
-    @Override
-    public void shouldCollapseInputPanel() {
-        inputPanel.collapse(false);
-    }
-
-    @Override
-    public boolean isLongClickEnabled() {
-        return !inputPanel.isRecording();
-    }
-
-    // 操作面板集合
-    protected List<BaseAction> getActionList() {
-        List<BaseAction> actions = new ArrayList<>();
-        actions.add(new GuessAction());
-        return actions;
-    }
-}

+ 0 - 130
app/src/com/sheishuo/app/chatroom/fragment/ChatRoomsFragment.java

@@ -1,130 +0,0 @@
-package com.sheishuo.app.chatroom.fragment;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Toast;
-
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.activity.ChatRoomActivity;
-import com.sheishuo.app.chatroom.adapter.ChatRoomsAdapter;
-import com.sheishuo.app.chatroom.thridparty.ChatRoomHttpClient;
-import com.netease.nim.uikit.common.fragment.TFragment;
-import com.netease.nim.uikit.common.ui.ptr2.PullToRefreshLayout;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseQuickAdapter;
-import com.netease.nim.uikit.common.ui.recyclerview.decoration.SpacingDecoration;
-import com.netease.nim.uikit.common.ui.recyclerview.listener.OnItemClickListener;
-import com.netease.nim.uikit.common.util.sys.ScreenUtil;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomInfo;
-
-import java.util.List;
-
-/**
- * 直播间列表fragment
- * <p>
- * Created by huangjun on 2015/12/11.
- */
-public class ChatRoomsFragment extends TFragment {
-    private static final String TAG = ChatRoomsFragment.class.getSimpleName();
-
-    private ChatRoomsAdapter adapter;
-    private PullToRefreshLayout swipeRefreshLayout;
-    private RecyclerView recyclerView;
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        return inflater.inflate(R.layout.chat_rooms, container, false);
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-
-        findViews();
-    }
-
-    public void onCurrent() {
-        fetchData();
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-    }
-
-    private void findViews() {
-        // swipeRefreshLayout
-        swipeRefreshLayout = findView(R.id.swipe_refresh);
-        swipeRefreshLayout.setPullUpEnable(false);
-        swipeRefreshLayout.setOnRefreshListener(new PullToRefreshLayout.OnRefreshListener() {
-            @Override
-            public void onPullDownToRefresh() {
-                fetchData();
-            }
-
-            @Override
-            public void onPullUpToRefresh() {
-
-            }
-        });
-
-        // recyclerView
-        recyclerView = findView(R.id.recycler_view);
-        adapter = new ChatRoomsAdapter(recyclerView);
-        adapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
-        recyclerView.setAdapter(adapter);
-        recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
-        recyclerView.addItemDecoration(new SpacingDecoration(ScreenUtil.dip2px(10), ScreenUtil.dip2px(10), true));
-        recyclerView.addOnItemTouchListener(new OnItemClickListener<ChatRoomsAdapter>() {
-            @Override
-            public void onItemClick(ChatRoomsAdapter adapter, View view, int position) {
-                ChatRoomInfo room = adapter.getItem(position);
-                ChatRoomActivity.start(getActivity(), room.getRoomId());
-            }
-        });
-    }
-
-    private void fetchData() {
-        ChatRoomHttpClient.getInstance().fetchChatRoomList(new ChatRoomHttpClient.ChatRoomHttpCallback<List<ChatRoomInfo>>() {
-            @Override
-            public void onSuccess(List<ChatRoomInfo> rooms) {
-                onFetchDataDone(true, rooms);
-            }
-
-            @Override
-            public void onFailed(int code, String errorMsg) {
-                onFetchDataDone(false, null);
-                if (getActivity() != null) {
-                    Toast.makeText(getActivity(), "fetch chat room list failed, code=" + code, Toast.LENGTH_SHORT).show();
-                }
-            }
-        });
-    }
-
-    private void onFetchDataDone(final boolean success, final List<ChatRoomInfo> data) {
-        Activity context = getActivity();
-        if (context != null) {
-            context.runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    swipeRefreshLayout.setRefreshing(false); // 刷新结束
-
-                    if (success) {
-                        adapter.setNewData(data); // 刷新数据源
-
-                        postRunnable(new Runnable() {
-                            @Override
-                            public void run() {
-                                adapter.closeLoadAnimation();
-                            }
-                        });
-                    }
-                }
-            });
-        }
-    }
-}

+ 0 - 134
app/src/com/sheishuo/app/chatroom/fragment/MasterFragment.java

@@ -1,134 +0,0 @@
-package com.sheishuo.app.chatroom.fragment;
-
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.sheishuo.app.chatroom.activity.ChatRoomActivity;
-import com.sheishuo.app.chatroom.helper.ChatRoomMemberCache;
-import com.sheishuo.app.chatroom.widget.ChatRoomImageView;
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.cache.SimpleCallback;
-import com.netease.nim.uikit.common.fragment.TFragment;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.RequestCallback;
-import com.netease.nimlib.sdk.chatroom.ChatRoomService;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomInfo;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
-
-/**
- * 聊天室主播fragment
- * Created by hzxuwen on 2015/12/17.
- */
-public class MasterFragment extends TFragment {
-    private static final String TAG = MasterFragment.class.getSimpleName();
-    private ChatRoomImageView imageView;
-    private TextView nameText;
-    private TextView countText;
-    private TextView announceText;
-    private LinearLayout announceLayout;
-    private LinearLayout noAnnounceLayout;
-
-    private ChatRoomMember master;
-    private long lastClickTime = 0;
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        return inflater.inflate(R.layout.master_fragment, container, false);
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-
-        findViews();
-    }
-
-    public void onCurrent() {
-        if (!isFastClick()) {
-            fetchRoomInfo();
-        }
-    }
-
-    /**
-     * 频率控制,至少间隔一分钟
-     * @return
-     */
-    private boolean isFastClick() {
-        long current = System.currentTimeMillis();
-        long time = current - lastClickTime;
-        if ( 0 < time && time < 60000) {
-            return true;
-        }
-        lastClickTime = current;
-        return false;
-    }
-
-    private void findViews() {
-        imageView = findView(R.id.master_head_image);
-        imageView.loadAvatarByUrl(""); // 网络不好的时候,设置一个默认头像
-        nameText = findView(R.id.master_name);
-        countText = findView(R.id.online_total);
-        announceText = findView(R.id.announce_content);
-        announceLayout = findView(R.id.announce_layout);
-        noAnnounceLayout = findView(R.id.no_announce_layout);
-    }
-
-    private void fetchRoomInfo() {
-        String roomId = ((ChatRoomActivity) getActivity()).getRoomInfo().getRoomId();
-        NIMClient.getService(ChatRoomService.class).fetchRoomInfo(roomId).setCallback(new RequestCallback<ChatRoomInfo>() {
-            @Override
-            public void onSuccess(ChatRoomInfo param) {
-                getChatRoomMaster(param);
-            }
-
-            @Override
-            public void onFailed(int code) {
-                LogUtil.d(TAG, "fetch room info failed:" + code);
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                LogUtil.d(TAG, "fetch room info exception:" + exception);
-            }
-        });
-    }
-
-    private void getChatRoomMaster(final ChatRoomInfo roomInfo) {
-        master = ChatRoomMemberCache.getInstance().getChatRoomMember(roomInfo.getRoomId(), roomInfo.getCreator());
-        if (master != null) {
-            updateView(roomInfo);
-        } else {
-            ChatRoomMemberCache.getInstance().fetchMember(roomInfo.getRoomId(), roomInfo.getCreator(),
-                    new SimpleCallback<ChatRoomMember>() {
-                        @Override
-                        public void onResult(boolean success, ChatRoomMember result) {
-                            if (success) {
-                                master = result;
-                                updateView(roomInfo);
-                            }
-                        }
-                    });
-        }
-    }
-
-    private void updateView(ChatRoomInfo chatRoomInfo) {
-        imageView.loadAvatarByUrl(master.getAvatar());
-        nameText.setText(TextUtils.isEmpty(master.getNick()) ? "" : master.getNick());
-        countText.setText(String.valueOf(chatRoomInfo.getOnlineUserCount()));
-
-        if (TextUtils.isEmpty(chatRoomInfo.getAnnouncement())) {
-            noAnnounceLayout.setVisibility(View.VISIBLE);
-            announceLayout.setVisibility(View.GONE);
-        } else {
-            announceLayout.setVisibility(View.VISIBLE);
-            noAnnounceLayout.setVisibility(View.GONE);
-            announceText.setText(chatRoomInfo.getAnnouncement());
-        }
-    }
-}

+ 0 - 685
app/src/com/sheishuo/app/chatroom/fragment/OnlinePeopleFragment.java

@@ -1,685 +0,0 @@
-package com.sheishuo.app.chatroom.fragment;
-
-import android.app.Activity;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.text.InputType;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.Toast;
-
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.chatroom.activity.ChatRoomActivity;
-import com.sheishuo.app.chatroom.adapter.ChatRoomOnlinePeopleAdapter;
-import com.sheishuo.app.chatroom.helper.ChatRoomMemberCache;
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.cache.SimpleCallback;
-import com.netease.nim.uikit.common.fragment.TFragment;
-import com.netease.nim.uikit.common.ui.dialog.CustomAlertDialog;
-import com.netease.nim.uikit.common.ui.dialog.EasyEditDialog;
-import com.netease.nim.uikit.common.ui.ptr2.PullToRefreshLayout;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseQuickAdapter;
-import com.netease.nim.uikit.common.ui.recyclerview.listener.SimpleClickListener;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.RequestCallback;
-import com.netease.nimlib.sdk.chatroom.ChatRoomService;
-import com.netease.nimlib.sdk.chatroom.constant.MemberQueryType;
-import com.netease.nimlib.sdk.chatroom.constant.MemberType;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
-import com.netease.nimlib.sdk.chatroom.model.MemberOption;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * 聊天室在线人数fragment
- * <p>
- * Created by huangjun on 2016/12/29.
- */
-public class OnlinePeopleFragment extends TFragment {
-    private static final String TAG = OnlinePeopleFragment.class.getSimpleName();
-    private static final int LIMIT = 20;
-
-    private PullToRefreshLayout swipeRefreshLayout;
-    private RecyclerView recyclerView;
-    private ChatRoomOnlinePeopleAdapter adapter;
-    private List<ChatRoomMember> items = new ArrayList<>();
-
-    private String roomId;
-    private long updateTime = 0; // 非游客的updateTime
-    private long enterTime = 0; // 游客的enterTime
-    private boolean isNormalEmpty = false; // 固定成员是否拉取完
-    private Map<String, ChatRoomMember> memberCache = new ConcurrentHashMap<>();
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        return inflater.inflate(R.layout.online_people_fragment, container, false);
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-
-        findViews();
-        registerObservers(true);
-    }
-
-    public void onCurrent() {
-        clearCache();
-        roomId = ((ChatRoomActivity) getActivity()).getRoomInfo().getRoomId();
-        refreshData();
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        registerObservers(false);
-    }
-
-    private void resetStatus() {
-        updateTime = 0;
-        enterTime = 0;
-        isNormalEmpty = false;
-    }
-
-    private void clearCache() {
-        resetStatus();
-        adapter.clearData();
-        memberCache.clear();
-    }
-
-    private void findViews() {
-        // swipeRefreshLayout
-        swipeRefreshLayout = findView(R.id.swipe_refresh);
-        swipeRefreshLayout.setPullUpEnable(false);
-        swipeRefreshLayout.setOnRefreshListener(new PullToRefreshLayout.OnRefreshListener() {
-            @Override
-            public void onPullDownToRefresh() {
-                refreshData();
-            }
-
-            @Override
-            public void onPullUpToRefresh() {
-
-            }
-        });
-
-        // recyclerView
-        recyclerView = findView(R.id.recycler_view);
-        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
-        recyclerView.addOnItemTouchListener(touchListener);
-        adapter = new ChatRoomOnlinePeopleAdapter(recyclerView, items);
-        adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
-            @Override
-            public void onLoadMoreRequested() {
-                loadMoreData();
-            }
-        });
-        recyclerView.setAdapter(adapter);
-    }
-
-    private void updateCache(List<ChatRoomMember> members) {
-        if (members == null || members.isEmpty()) {
-            return;
-        }
-
-        for (ChatRoomMember member : members) {
-            if (member.getMemberType() == MemberType.GUEST) {
-                enterTime = member.getEnterTime();
-            } else {
-                updateTime = member.getUpdateTime();
-            }
-
-            if (memberCache.containsKey(member.getAccount())) {
-                items.remove(memberCache.get(member.getAccount()));
-            }
-            memberCache.put(member.getAccount(), member);
-            items.add(member);
-        }
-        Collections.sort(items, comp);
-    }
-
-    private void refreshData() {
-        adapter.setEnableLoadMore(false);
-        getData(true, new SimpleCallback<List<ChatRoomMember>>() {
-            @Override
-            public void onResult(final boolean success, final List<ChatRoomMember> result) {
-                final Activity context = getActivity();
-                if (context == null) {
-                    return;
-                } else {
-                    context.runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            // 刷新结束
-                            swipeRefreshLayout.setRefreshing(false);
-
-                            if (success) {
-                                clearCache();
-                                updateCache(result);
-                                adapter.notifyDataSetChanged();
-
-                                postDelayed(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        if (!isLastMessageVisible()) {
-                                            adapter.setEnableLoadMore(true); // 开启上拉加载
-                                        }
-                                    }
-                                }, 200);
-                            }
-                        }
-                    });
-                }
-            }
-        });
-    }
-
-    private void loadMoreData() {
-        getData(false, new SimpleCallback<List<ChatRoomMember>>() {
-            @Override
-            public void onResult(final boolean success, final List<ChatRoomMember> result) {
-                Activity context = getActivity();
-                if (context == null) {
-                    return;
-                } else {
-                    context.runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            if (success) {
-                                if (result == null || result.isEmpty()) {
-                                    adapter.loadMoreEnd(true); // 没有更多数据了
-                                } else {
-                                    updateCache(result);
-                                    adapter.loadMoreComplete(); // 加载成功
-                                }
-                            } else {
-                                adapter.loadMoreFail(); // 加载失败
-                            }
-                        }
-                    });
-                }
-            }
-        });
-    }
-
-    private void getData(final boolean fetching, final SimpleCallback<List<ChatRoomMember>> callback) {
-        // reset status
-        if (fetching) {
-            resetStatus();
-        }
-
-        // query type
-        final MemberQueryType memberQueryType = isNormalEmpty ? MemberQueryType.GUEST : MemberQueryType.ONLINE_NORMAL;
-        final long time = isNormalEmpty ? enterTime : updateTime;
-        final int expectNum = LIMIT;
-        final List<ChatRoomMember> resultList = new ArrayList<>();
-        ChatRoomMemberCache.getInstance().fetchRoomMembers(roomId, memberQueryType, time, expectNum, new
-                SimpleCallback<List<ChatRoomMember>>() {
-                    @Override
-                    public void onResult(boolean success, List<ChatRoomMember> result) {
-                        if (success) {
-                            // 结果集
-                            resultList.addAll(result);
-
-                            // 固定成员已经拉完,不满预期数量,开始拉游客
-                            if (memberQueryType == MemberQueryType.ONLINE_NORMAL && result.size() < expectNum) {
-                                isNormalEmpty = true;
-                                final int expectNum2 = expectNum - result.size();
-                                ChatRoomMemberCache.getInstance().fetchRoomMembers(roomId, MemberQueryType.GUEST, enterTime, expectNum2, new
-                                        SimpleCallback<List<ChatRoomMember>>() {
-                                            @Override
-                                            public void onResult(boolean success, List<ChatRoomMember> result) {
-                                                if (success) {
-                                                    // 结果集
-                                                    resultList.addAll(result);
-                                                    callback.onResult(true, resultList);
-                                                } else {
-                                                    callback.onResult(false, null);
-                                                }
-                                            }
-                                        });
-                            } else {
-                                // 固定成员拉取到位或者拉取游客成功
-                                callback.onResult(true, resultList);
-                            }
-                        } else {
-                            callback.onResult(false, null);
-                        }
-                    }
-                });
-    }
-
-    private boolean isLastMessageVisible() {
-        LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
-        int lastVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition();
-        return lastVisiblePosition >= adapter.getBottomDataPosition();
-    }
-
-    /**
-     * *************************** 成员操作监听 ****************************
-     */
-    private void registerObservers(boolean register) {
-        ChatRoomMemberCache.getInstance().registerRoomMemberChangedObserver(roomMemberChangedObserver, register);
-    }
-
-    ChatRoomMemberCache.RoomMemberChangedObserver roomMemberChangedObserver = new ChatRoomMemberCache.RoomMemberChangedObserver() {
-        @Override
-        public void onRoomMemberIn(ChatRoomMember member) {
-        }
-
-        @Override
-        public void onRoomMemberExit(ChatRoomMember member) {
-        }
-    };
-
-
-    /**
-     * ****************************************** 长按菜单 ***************************************
-     */
-
-    private SimpleClickListener<ChatRoomOnlinePeopleAdapter> touchListener = new SimpleClickListener<ChatRoomOnlinePeopleAdapter>() {
-        @Override
-        public void onItemClick(ChatRoomOnlinePeopleAdapter adapter, View view, int position) {
-
-        }
-
-        @Override
-        public void onItemLongClick(ChatRoomOnlinePeopleAdapter adapter, View view, int position) {
-            fetchMemberInfo(adapter.getItem(position));
-        }
-
-        @Override
-        public void onItemChildClick(ChatRoomOnlinePeopleAdapter adapter, View view, int position) {
-
-        }
-
-        @Override
-        public void onItemChildLongClick(ChatRoomOnlinePeopleAdapter adapter, View view, int position) {
-
-        }
-    };
-
-    // 弹出菜单前,获取成员最新数据
-    private void fetchMemberInfo(final ChatRoomMember member) {
-        ChatRoomMemberCache.getInstance().fetchMember(roomId, member.getAccount(), new SimpleCallback<ChatRoomMember>() {
-            @Override
-            public void onResult(boolean success, ChatRoomMember result) {
-                if (success) {
-                    showLongClickMenu(result);
-                } else {
-                    Toast.makeText(getActivity(), R.string.chatroom_fetch_member_failed, Toast.LENGTH_SHORT).show();
-                }
-            }
-        });
-    }
-
-    // 显示长按菜单
-    private void showLongClickMenu(final ChatRoomMember currentMember) {
-        // 不能操作的条件
-        // 1、被操作用户是主播
-        // 2、被操作者是自己
-        // 3、用户自己是普通成员
-        // 4、用户自己是受限用户
-        // 5、用户自己是游客
-        if (currentMember.getMemberType() == MemberType.CREATOR
-                || currentMember.getAccount().equals(SheishuoCache.getAccount())
-                || ChatRoomMemberCache.getInstance().getChatRoomMember(roomId, SheishuoCache.getAccount()).getMemberType() == MemberType.NORMAL
-                || ChatRoomMemberCache.getInstance().getChatRoomMember(roomId, SheishuoCache.getAccount()).getMemberType() == MemberType.LIMITED
-                || ChatRoomMemberCache.getInstance().getChatRoomMember(roomId, SheishuoCache.getAccount()).getMemberType() == MemberType.GUEST) {
-            return;
-        }
-        CustomAlertDialog alertDialog = new CustomAlertDialog(getActivity());
-        alertDialog.addItem(R.string.chatroom_kick_member, new CustomAlertDialog.onSeparateItemClickListener() {
-            @Override
-            public void onClick() {
-                kickMember(currentMember);
-            }
-        });
-
-        // 设置/取消禁言
-        addMutedItem(currentMember, alertDialog);
-
-        // 设置/移出黑名单
-        addBlackListItem(currentMember, alertDialog);
-
-        // 设置/取消管理员
-        addAdminItem(currentMember, alertDialog);
-
-        // 设为/取消普通成员
-        addNormalItem(currentMember, alertDialog);
-
-        // 设置临时禁言(含通知)
-        addTempMuteItemNotify(currentMember, alertDialog);
-
-        // 设置临时禁言(不通知)
-        addTemMuteItem(currentMember, alertDialog);
-
-        alertDialog.show();
-    }
-
-    // 添加禁言菜单
-    private void addMutedItem(final ChatRoomMember chatRoomMember, CustomAlertDialog alertDialog) {
-        int titleId = chatRoomMember.isMuted() ? R.string.cancel_muted : R.string.chatroom_muted;
-        alertDialog.addItem(titleId, new CustomAlertDialog.onSeparateItemClickListener() {
-            @Override
-            public void onClick() {
-                setMuted(chatRoomMember);
-            }
-        });
-    }
-
-    // 添加黑名单菜单
-    private void addBlackListItem(final ChatRoomMember chatRoomMember, CustomAlertDialog alertDialog) {
-        int titleId = chatRoomMember.isInBlackList() ? R.string.move_out_blacklist : R.string.chatroom_blacklist;
-        alertDialog.addItem(titleId, new CustomAlertDialog.onSeparateItemClickListener() {
-            @Override
-            public void onClick() {
-                setBlackList(chatRoomMember);
-            }
-        });
-    }
-
-    // 添加管理员菜单
-    private void addAdminItem(final ChatRoomMember chatRoomMember, CustomAlertDialog alertDialog) {
-        // 被操作者比操作者权限大, 则返回
-        if (chatRoomMember.getMemberType() == MemberType.ADMIN
-                && ChatRoomMemberCache.getInstance().getChatRoomMember(roomId, SheishuoCache.getAccount()).getMemberType() != MemberType.CREATOR) {
-            return;
-        }
-        final boolean isAdmin = chatRoomMember.getMemberType() == MemberType.ADMIN;
-        int titleId = isAdmin ? R.string.cancel_admin : R.string.chatroom_set_admin;
-        alertDialog.addItem(titleId, new CustomAlertDialog.onSeparateItemClickListener() {
-            @Override
-            public void onClick() {
-                setAdmin(chatRoomMember, isAdmin);
-            }
-        });
-    }
-
-    private void addNormalItem(final ChatRoomMember chatRoomMember, CustomAlertDialog alertDialog) {
-        final boolean isNormal = chatRoomMember.getMemberType() == MemberType.NORMAL;
-        int titleId = isNormal ? R.string.cancel_normal_member : R.string.set_normal_member;
-        alertDialog.addItem(titleId, new CustomAlertDialog.onSeparateItemClickListener() {
-            @Override
-            public void onClick() {
-                setNormalMember(chatRoomMember, isNormal);
-            }
-        });
-    }
-
-    // 设置临时禁言(含通知)
-    private void addTempMuteItemNotify(final ChatRoomMember chatRoomMember, CustomAlertDialog alertDialog) {
-        alertDialog.addItem(R.string.set_temp_mute_notify, new CustomAlertDialog.onSeparateItemClickListener() {
-            @Override
-            public void onClick() {
-                final EasyEditDialog requestDialog = new EasyEditDialog(getActivity());
-                requestDialog.setEditTextMaxLength(200);
-                requestDialog.setTitle(getString(R.string.mute_duration));
-                requestDialog.setInputType(InputType.TYPE_CLASS_NUMBER);
-                requestDialog.addNegativeButtonListener(R.string.cancel, new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        requestDialog.dismiss();
-                        getActivity().getWindow().setSoftInputMode(
-                                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
-                    }
-                });
-                requestDialog.addPositiveButtonListener(R.string.send, new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        requestDialog.dismiss();
-                        String content = requestDialog.getEditMessage();
-                        if (!TextUtils.isEmpty(content)) {
-                            setTempMute(chatRoomMember.getAccount(), content, true);
-                        }
-                        getActivity().getWindow().setSoftInputMode(
-                                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
-                    }
-                });
-                requestDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
-                    @Override
-                    public void onCancel(DialogInterface dialog) {
-                    }
-                });
-                requestDialog.show();
-            }
-        });
-    }
-
-    // 设置临时禁言(不通知)
-    private void addTemMuteItem(final ChatRoomMember chatRoomMember, CustomAlertDialog alertDialog) {
-        alertDialog.addItem(R.string.set_temp_mute_not_notify, new CustomAlertDialog.onSeparateItemClickListener() {
-            @Override
-            public void onClick() {
-                final EasyEditDialog requestDialog = new EasyEditDialog(getActivity());
-                requestDialog.setEditTextMaxLength(200);
-                requestDialog.setTitle(getString(R.string.mute_duration));
-                requestDialog.setInputType(InputType.TYPE_CLASS_NUMBER);
-                requestDialog.addNegativeButtonListener(R.string.cancel, new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        requestDialog.dismiss();
-                        getActivity().getWindow().setSoftInputMode(
-                                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
-                    }
-                });
-                requestDialog.addPositiveButtonListener(R.string.send, new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        requestDialog.dismiss();
-                        String content = requestDialog.getEditMessage();
-                        if (!TextUtils.isEmpty(content)) {
-                            setTempMute(chatRoomMember.getAccount(), content, false);
-                        }
-                        getActivity().getWindow().setSoftInputMode(
-                                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
-                    }
-                });
-                requestDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
-                    @Override
-                    public void onCancel(DialogInterface dialog) {
-                    }
-                });
-                requestDialog.show();
-            }
-        });
-    }
-
-    // 踢人
-    private void kickMember(final ChatRoomMember chatRoomMember) {
-        Map<String, Object> reason = new HashMap<>();
-        reason.put("reason", "就是不爽!");
-        NIMClient.getService(ChatRoomService.class).kickMember(roomId, chatRoomMember.getAccount(), reason).setCallback(new RequestCallback<Void>() {
-            @Override
-            public void onSuccess(Void param) {
-                Toast.makeText(getActivity(), R.string.chatroom_kick_member, Toast.LENGTH_SHORT).show();
-                ChatRoomMember del = null;
-                for (ChatRoomMember member : items) {
-                    if (member.getAccount().equals(chatRoomMember.getAccount())) {
-                        del = member;
-                        break;
-                    }
-                }
-
-                if (del != null) {
-                    items.remove(del);
-                    memberCache.remove(del.getAccount());
-                }
-                adapter.notifyDataSetChanged();
-            }
-
-            @Override
-            public void onFailed(int code) {
-                Log.d(TAG, "kick member failed:" + code);
-            }
-
-            @Override
-            public void onException(Throwable exception) {
-                Log.d(TAG, "kick member exception:" + exception);
-            }
-        });
-    }
-
-    // 设置/取消禁言
-    private void setMuted(final ChatRoomMember chatRoomMember) {
-        MemberOption option = new MemberOption(roomId, chatRoomMember.getAccount());
-        NIMClient.getService(ChatRoomService.class).markChatRoomMutedList(!chatRoomMember.isMuted(), option)
-                .setCallback(new RequestCallback<ChatRoomMember>() {
-                    @Override
-                    public void onSuccess(ChatRoomMember param) {
-                        Toast.makeText(getActivity(), R.string.set_success, Toast.LENGTH_SHORT).show();
-                        refreshList(param, chatRoomMember);
-                    }
-
-                    @Override
-                    public void onFailed(int code) {
-                        Log.d(TAG, "set muted failed:" + code);
-                    }
-
-                    @Override
-                    public void onException(Throwable exception) {
-
-                    }
-                });
-    }
-
-    // 设置/移出黑名单
-    private void setBlackList(ChatRoomMember chatRoomMember) {
-        MemberOption option = new MemberOption(roomId, chatRoomMember.getAccount());
-        NIMClient.getService(ChatRoomService.class).markChatRoomBlackList(!chatRoomMember.isInBlackList(), option)
-                .setCallback(new RequestCallback<ChatRoomMember>() {
-                    @Override
-                    public void onSuccess(ChatRoomMember param) {
-                        Toast.makeText(getActivity(), R.string.set_success, Toast.LENGTH_SHORT).show();
-                    }
-
-                    @Override
-                    public void onFailed(int code) {
-                        Log.d(TAG, "set black list failed:" + code);
-                    }
-
-                    @Override
-                    public void onException(Throwable exception) {
-
-                    }
-                });
-    }
-
-    // 设置/取消管理员
-    private void setAdmin(final ChatRoomMember member, boolean isAdmin) {
-        NIMClient.getService(ChatRoomService.class)
-                .markChatRoomManager(!isAdmin, new MemberOption(roomId, member.getAccount()))
-                .setCallback(new RequestCallback<ChatRoomMember>() {
-                    @Override
-                    public void onSuccess(ChatRoomMember param) {
-                        Toast.makeText(getActivity(), R.string.set_success, Toast.LENGTH_SHORT).show();
-                        refreshList(param, member);
-                    }
-
-                    @Override
-                    public void onFailed(int code) {
-                        Log.d(TAG, "set admin failed:" + code);
-                    }
-
-                    @Override
-                    public void onException(Throwable exception) {
-
-                    }
-                });
-    }
-
-    // 设置/取消普通成员
-    private void setNormalMember(final ChatRoomMember member, boolean isNormal) {
-        NIMClient.getService(ChatRoomService.class).markNormalMember(!isNormal, new MemberOption(roomId, member.getAccount()))
-                .setCallback(new RequestCallback<ChatRoomMember>() {
-                    @Override
-                    public void onSuccess(ChatRoomMember param) {
-                        Toast.makeText(getActivity(), R.string.set_success, Toast.LENGTH_SHORT).show();
-                        refreshList(param, member);
-                    }
-
-                    @Override
-                    public void onFailed(int code) {
-
-                    }
-
-                    @Override
-                    public void onException(Throwable exception) {
-
-                    }
-                });
-    }
-
-    // 设置临时禁言
-    private void setTempMute(String account, String content, boolean needNotify) {
-        MemberOption option = new MemberOption(roomId, account);
-        NIMClient.getService(ChatRoomService.class).markChatRoomTempMute(needNotify, Long.parseLong(content), option)
-                .setCallback(new RequestCallback<Void>() {
-                    @Override
-                    public void onSuccess(Void param) {
-                        Toast.makeText(getActivity(), "设置临时禁言成功", Toast.LENGTH_SHORT).show();
-                    }
-
-                    @Override
-                    public void onFailed(int code) {
-                        Toast.makeText(getActivity(), "设置临时禁言失败,code:" + code, Toast.LENGTH_SHORT).show();
-                    }
-
-                    @Override
-                    public void onException(Throwable exception) {
-
-                    }
-                });
-    }
-
-    private void refreshList(ChatRoomMember param, ChatRoomMember member) {
-        ChatRoomMember temp = null;
-        for (ChatRoomMember m : items) {
-            if (m.getAccount().equals(param.getAccount())) {
-                temp = m;
-            }
-        }
-        member.setMemberType(param.getMemberType());
-        items.remove(temp);
-        items.add(member);
-        Collections.sort(items, comp);
-        adapter.notifyDataSetChanged();
-    }
-
-    private static Map<MemberType, Integer> compMap = new HashMap<>();
-
-    static {
-        compMap.put(MemberType.CREATOR, 0);
-        compMap.put(MemberType.ADMIN, 1);
-        compMap.put(MemberType.NORMAL, 2);
-        compMap.put(MemberType.LIMITED, 3);
-        compMap.put(MemberType.GUEST, 4);
-    }
-
-    private static Comparator<ChatRoomMember> comp = new Comparator<ChatRoomMember>() {
-        @Override
-        public int compare(ChatRoomMember lhs, ChatRoomMember rhs) {
-            if (lhs == null) {
-                return 1;
-            }
-
-            if (rhs == null) {
-                return -1;
-            }
-
-            return compMap.get(lhs.getMemberType()) - compMap.get(rhs.getMemberType());
-        }
-    };
-}

+ 0 - 58
app/src/com/sheishuo/app/chatroom/fragment/tab/ChatRoomTabFragment.java

@@ -1,58 +0,0 @@
-package com.sheishuo.app.chatroom.fragment.tab;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.constant.ChatRoomTab;
-import com.netease.nim.uikit.common.fragment.TabFragment;
-
-/**
- * Created by hzxuwen on 2015/12/14.
- */
-public abstract class ChatRoomTabFragment extends TabFragment {
-    private boolean loaded = false;
-
-    private ChatRoomTab tabData;
-
-    protected abstract void onInit();
-
-    protected boolean inited() {
-        return loaded;
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        return inflater.inflate(R.layout.main_tab_fragment_container, container, false);
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-    }
-
-    public void attachTabData(ChatRoomTab tabData) {
-        this.tabData = tabData;
-    }
-
-    @Override
-    public void onCurrent() {
-        super.onCurrent();
-
-        if (!loaded && loadRealLayout()) {
-            loaded = true;
-            onInit();
-        }
-    }
-
-    private boolean loadRealLayout() {
-        ViewGroup root = (ViewGroup) getView();
-        if (root != null) {
-            root.removeAllViewsInLayout();
-            View.inflate(root.getContext(), tabData.layoutId, root);
-        }
-        return root != null;
-    }
-}

+ 0 - 24
app/src/com/sheishuo/app/chatroom/fragment/tab/MasterTabFragment.java

@@ -1,24 +0,0 @@
-package com.sheishuo.app.chatroom.fragment.tab;
-
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.fragment.MasterFragment;
-
-/**
- * 主播基类fragment
- * Created by hzxuwen on 2015/12/14.
- */
-public class MasterTabFragment extends ChatRoomTabFragment {
-    private MasterFragment fragment;
-    @Override
-    protected void onInit() {
-        fragment = (MasterFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.master_fragment);
-    }
-
-    @Override
-    public void onCurrent() {
-        super.onCurrent();
-        if (fragment != null) {
-            fragment.onCurrent();
-        }
-    }
-}

+ 0 - 54
app/src/com/sheishuo/app/chatroom/fragment/tab/MessageTabFragment.java

@@ -1,54 +0,0 @@
-package com.sheishuo.app.chatroom.fragment.tab;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.sheishuo.app.chatroom.constant.ChatRoomTab;
-import com.sheishuo.app.chatroom.fragment.ChatRoomMessageFragment;
-import com.sheishuo.app.R;
-
-/**
- * 直播互动基类fragment
- * Created by hzxuwen on 2015/12/14.
- */
-public class MessageTabFragment extends ChatRoomTabFragment {
-    private ChatRoomMessageFragment fragment;
-
-    public MessageTabFragment() {
-        this.setContainerId(ChatRoomTab.CHAT_ROOM_MESSAGE.fragmentId);
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        return super.onCreateView(inflater, container, savedInstanceState);
-    }
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-        onCurrent();
-    }
-
-    @Override
-    protected void onInit() {
-        findViews();
-    }
-
-    @Override
-    public void onCurrent() {
-        super.onCurrent();
-    }
-
-    @Override
-    public void onLeave() {
-        super.onLeave();
-        if (fragment != null) {
-            fragment.onLeave();
-        }
-    }
-
-    private void findViews() {
-        fragment = (ChatRoomMessageFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.chat_room_message_fragment);
-    }
-}

+ 0 - 29
app/src/com/sheishuo/app/chatroom/fragment/tab/OnlinePeopleTabFragment.java

@@ -1,29 +0,0 @@
-package com.sheishuo.app.chatroom.fragment.tab;
-
-import com.sheishuo.app.R;
-import com.sheishuo.app.chatroom.fragment.OnlinePeopleFragment;
-
-/**
- * 在线成员基类fragment
- * Created by hzxuwen on 2015/12/14.
- */
-public class OnlinePeopleTabFragment extends ChatRoomTabFragment {
-    private OnlinePeopleFragment fragment;
-
-    @Override
-    protected void onInit() {
-        findViews();
-    }
-
-    @Override
-    public void onCurrent() {
-        super.onCurrent();
-        if (fragment != null) {
-            fragment.onCurrent();
-        }
-    }
-
-    private void findViews() {
-        fragment = (OnlinePeopleFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.online_people_fragment);
-    }
-}

+ 0 - 60
app/src/com/sheishuo/app/chatroom/helper/ChatRoomHelper.java

@@ -1,60 +0,0 @@
-package com.sheishuo.app.chatroom.helper;
-
-import android.content.Context;
-import android.widget.ImageView;
-
-import com.bumptech.glide.Glide;
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.R;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import jp.wasabeef.glide.transformations.BlurTransformation;
-
-/**
- * Created by hzxuwen on 2016/1/19.
- */
-public class ChatRoomHelper {
-    private static final int[] imageRes = {R.drawable.room_cover_36, R.drawable.room_cover_37, R.drawable.room_cover_49,
-            R.drawable.room_cover_50, R.drawable.room_cover_57, R.drawable.room_cover_58, R.drawable.room_cover_64,
-            R.drawable.room_cover_72};
-
-    private static Map<String, Integer> roomCoverMap = new HashMap<>();
-    private static int index = 0;
-
-    public static void init() {
-        ChatRoomMemberCache.getInstance().clear();
-        ChatRoomMemberCache.getInstance().registerObservers(true);
-    }
-
-    public static void logout() {
-        ChatRoomMemberCache.getInstance().registerObservers(false);
-        ChatRoomMemberCache.getInstance().clear();
-    }
-
-    public static void setCoverImage(String roomId, ImageView coverImage, boolean blur) {
-        if (roomCoverMap.containsKey(roomId)) {
-            blurCoverImage(blur, coverImage, roomCoverMap.get(roomId));
-        } else {
-            if (index > imageRes.length) {
-                index = 0;
-            }
-            roomCoverMap.put(roomId, imageRes[index]);
-            blurCoverImage(blur, coverImage, imageRes[index]);
-            index++;
-        }
-    }
-
-    private static void blurCoverImage(boolean blur, final ImageView imageView, final int resId) {
-        final Context context = SheishuoCache.getContext();
-
-        if (!blur) {
-            Glide.with(context).load(resId).into(imageView);
-        } else {
-            Glide.with(context).load(resId)
-                    .bitmapTransform(new BlurTransformation(context, 5))
-                    .into(imageView);
-        }
-    }
-}

+ 0 - 293
app/src/com/sheishuo/app/chatroom/helper/ChatRoomMemberCache.java

@@ -1,293 +0,0 @@
-package com.sheishuo.app.chatroom.helper;
-
-import android.text.TextUtils;
-
-import com.netease.nim.uikit.cache.SimpleCallback;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.RequestCallbackWrapper;
-import com.netease.nimlib.sdk.ResponseCode;
-import com.netease.nimlib.sdk.chatroom.ChatRoomService;
-import com.netease.nimlib.sdk.chatroom.ChatRoomServiceObserver;
-import com.netease.nimlib.sdk.chatroom.constant.MemberQueryType;
-import com.netease.nimlib.sdk.chatroom.constant.MemberType;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
-import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
-import com.netease.nimlib.sdk.msg.constant.NotificationType;
-import com.netease.nimlib.sdk.msg.model.IMMessage;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 聊天室成员资料缓存
- * Created by huangjun on 2016/1/18.
- */
-public class ChatRoomMemberCache {
-
-    private static final String TAG = "ChatRoomMemberCache";
-
-    public static ChatRoomMemberCache getInstance() {
-        return InstanceHolder.instance;
-    }
-
-    private Map<String, Map<String, ChatRoomMember>> cache = new HashMap<>();
-
-    private Map<String, List<SimpleCallback<ChatRoomMember>>> frequencyLimitCache = new HashMap<>(); // 重复请求处理
-
-    private List<RoomMemberChangedObserver> roomMemberChangedObservers = new ArrayList<>();
-
-    public void clear() {
-        cache.clear();
-        frequencyLimitCache.clear();
-        roomMemberChangedObservers.clear();
-    }
-
-    public void clearRoomCache(String roomId) {
-        if (cache.containsKey(roomId)) {
-            cache.remove(roomId);
-        }
-    }
-
-    public ChatRoomMember getChatRoomMember(String roomId, String account) {
-        if (cache.containsKey(roomId)) {
-            return cache.get(roomId).get(account);
-        }
-
-        return null;
-    }
-
-    public void saveMyMember(ChatRoomMember chatRoomMember) {
-        saveMember(chatRoomMember);
-    }
-
-    /**
-     * 从服务器获取聊天室成员资料(去重处理)(异步)
-     */
-    public void fetchMember(final String roomId, final String account, final SimpleCallback<ChatRoomMember> callback) {
-        if (TextUtils.isEmpty(roomId) || TextUtils.isEmpty(account)) {
-            callback.onResult(false, null);
-            return;
-        }
-
-        // 频率控制
-        if (frequencyLimitCache.containsKey(account)) {
-            if (callback != null) {
-                frequencyLimitCache.get(account).add(callback);
-            }
-            return; // 已经在请求中,不要重复请求
-        } else {
-            List<SimpleCallback<ChatRoomMember>> cbs = new ArrayList<>();
-            if (callback != null) {
-                cbs.add(callback);
-            }
-            frequencyLimitCache.put(account, cbs);
-        }
-
-        // fetch
-        List<String> accounts = new ArrayList<>(1);
-        accounts.add(account);
-        NIMClient.getService(ChatRoomService.class).fetchRoomMembersByIds(roomId, accounts).setCallback(new RequestCallbackWrapper<List<ChatRoomMember>>() {
-            @Override
-            public void onResult(int code, List<ChatRoomMember> members, Throwable exception) {
-                ChatRoomMember member = null;
-                boolean hasCallback = !frequencyLimitCache.get(account).isEmpty();
-                boolean success = code == ResponseCode.RES_SUCCESS && members != null && !members.isEmpty();
-
-                // cache
-                if (success) {
-                    saveMembers(members);
-                    member = members.get(0);
-                } else {
-                    LogUtil.e(TAG, "fetch chat room member failed, code=" + code);
-                }
-
-                // callback
-                if (hasCallback) {
-                    List<SimpleCallback<ChatRoomMember>> cbs = frequencyLimitCache.get(account);
-                    for (SimpleCallback<ChatRoomMember> cb : cbs) {
-                        cb.onResult(success, member);
-                    }
-                }
-
-                frequencyLimitCache.remove(account);
-            }
-        });
-    }
-
-    public void fetchRoomMembers(String roomId, MemberQueryType memberQueryType, long time, int limit,
-                                 final SimpleCallback<List<ChatRoomMember>> callback) {
-        if (TextUtils.isEmpty(roomId)) {
-            callback.onResult(false, null);
-            return;
-        }
-
-        NIMClient.getService(ChatRoomService.class).fetchRoomMembers(roomId, memberQueryType, time, limit).setCallback(new RequestCallbackWrapper<List<ChatRoomMember>>() {
-            @Override
-            public void onResult(int code, List<ChatRoomMember> result, Throwable exception) {
-                boolean success = code == ResponseCode.RES_SUCCESS;
-
-                if (success) {
-                    saveMembers(result);
-                } else {
-                    LogUtil.e(TAG, "fetch members by page failed, code:" + code);
-                }
-
-                if (callback != null) {
-                    callback.onResult(success, result);
-                }
-            }
-        });
-    }
-
-    private void saveMember(ChatRoomMember member) {
-        if (member != null && !TextUtils.isEmpty(member.getRoomId()) && !TextUtils.isEmpty(member.getAccount())) {
-            Map<String, ChatRoomMember> members = cache.get(member.getRoomId());
-
-            if (members == null) {
-                members = new HashMap<>();
-                cache.put(member.getRoomId(), members);
-            }
-
-            members.put(member.getAccount(), member);
-        }
-    }
-
-    private void saveMembers(List<ChatRoomMember> members) {
-        if (members == null || members.isEmpty()) {
-            return;
-        }
-
-        for (ChatRoomMember m : members) {
-            saveMember(m);
-        }
-    }
-
-    /**
-     * ************************************ 单例 ***************************************
-     */
-    static class InstanceHolder {
-        final static ChatRoomMemberCache instance = new ChatRoomMemberCache();
-    }
-
-    /**
-     * ********************************** 监听 ********************************
-     */
-
-    public void registerObservers(boolean register) {
-        NIMClient.getService(ChatRoomServiceObserver.class).observeReceiveMessage(incomingChatRoomMsg, register);
-    }
-
-    private Observer<List<ChatRoomMessage>> incomingChatRoomMsg = new Observer<List<ChatRoomMessage>>() {
-        @Override
-        public void onEvent(List<ChatRoomMessage> messages) {
-            if (messages == null || messages.isEmpty()) {
-                return;
-            }
-
-            for (IMMessage msg : messages) {
-                if (msg == null) {
-                    LogUtil.e(TAG, "receive chat room message null");
-                    continue;
-                }
-
-                if (msg.getMsgType() == MsgTypeEnum.notification) {
-                    handleNotification(msg);
-                }
-            }
-        }
-    };
-
-    private void handleNotification(IMMessage message) {
-        if (message.getAttachment() == null) {
-            return;
-        }
-
-        String roomId = message.getSessionId();
-        ChatRoomNotificationAttachment attachment = (ChatRoomNotificationAttachment) message.getAttachment();
-        List<String> targets = attachment.getTargets();
-        if (targets != null) {
-            for (String target : targets) {
-                ChatRoomMember member = getChatRoomMember(roomId, target);
-                handleMemberChanged(attachment.getType(), member);
-            }
-        }
-    }
-
-    private void handleMemberChanged(NotificationType type, ChatRoomMember member) {
-        if (member == null) {
-            return;
-        }
-
-        switch (type) {
-            case ChatRoomMemberIn:
-                for (RoomMemberChangedObserver o : roomMemberChangedObservers) {
-                    o.onRoomMemberIn(member);
-                }
-                break;
-            case ChatRoomMemberExit:
-                for (RoomMemberChangedObserver o : roomMemberChangedObservers) {
-                    o.onRoomMemberExit(member);
-                }
-                break;
-            case ChatRoomManagerAdd:
-                member.setMemberType(MemberType.ADMIN);
-                break;
-            case ChatRoomManagerRemove:
-                member.setMemberType(MemberType.NORMAL);
-                break;
-            case ChatRoomMemberBlackAdd:
-                member.setInBlackList(true);
-                break;
-            case ChatRoomMemberBlackRemove:
-                member.setInBlackList(false);
-                break;
-            case ChatRoomMemberMuteAdd:
-                member.setMuted(true);
-                break;
-            case ChatRoomMemberMuteRemove:
-                member.setMuted(false);
-                member.setMemberType(MemberType.GUEST);
-                break;
-            case ChatRoomCommonAdd:
-                member.setMemberType(MemberType.NORMAL);
-                break;
-            case ChatRoomCommonRemove:
-                member.setMemberType(MemberType.GUEST);
-                break;
-            default:
-                break;
-        }
-
-        saveMember(member);
-    }
-
-    /**
-     * ************************** 在线用户变化通知 ****************************
-     */
-
-    public interface RoomMemberChangedObserver {
-        void onRoomMemberIn(ChatRoomMember member);
-
-        void onRoomMemberExit(ChatRoomMember member);
-    }
-
-    public void registerRoomMemberChangedObserver(RoomMemberChangedObserver o, boolean register) {
-        if (o == null) {
-            return;
-        }
-
-        if (register) {
-            if (!roomMemberChangedObservers.contains(o)) {
-                roomMemberChangedObservers.add(o);
-            }
-        } else {
-            roomMemberChangedObservers.remove(o);
-        }
-    }
-}

+ 0 - 126
app/src/com/sheishuo/app/chatroom/helper/ChatRoomNotificationHelper.java

@@ -1,126 +0,0 @@
-package com.sheishuo.app.chatroom.helper;
-
-import android.text.TextUtils;
-
-import com.sheishuo.app.SheishuoCache;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
-
-import java.util.List;
-
-/**
- * Created by huangjun on 2016/1/13.
- */
-public class ChatRoomNotificationHelper {
-    public static String getNotificationText(ChatRoomNotificationAttachment attachment) {
-        if (attachment == null) {
-            return "";
-        }
-
-        String targets = getTargetNicks(attachment);
-        String text;
-        switch (attachment.getType()) {
-            case ChatRoomMemberIn:
-                text = buildText("欢迎", targets, "进入直播间");
-                break;
-            case ChatRoomMemberExit:
-                text = buildText(targets, "离开了直播间");
-                break;
-            case ChatRoomMemberBlackAdd:
-                text = buildText(targets, "被管理员拉入黑名单");
-                break;
-            case ChatRoomMemberBlackRemove:
-                text = buildText(targets, "被管理员解除拉黑");
-                break;
-            case ChatRoomMemberMuteAdd:
-                text = buildText(targets, "被管理员禁言");
-                break;
-            case ChatRoomMemberMuteRemove:
-                text = buildText(targets, "被管理员解除禁言");
-                break;
-            case ChatRoomManagerAdd:
-                text = buildText(targets, "被任命管理员身份");
-                break;
-            case ChatRoomManagerRemove:
-                text = buildText(targets, "被解除管理员身份");
-                break;
-            case ChatRoomCommonAdd:
-                text = buildText(targets, "被设为普通成员");
-                break;
-            case ChatRoomCommonRemove:
-                text = buildText(targets, "被取消普通成员");
-                break;
-            case ChatRoomClose:
-                text = buildText("直播间被关闭");
-                break;
-            case ChatRoomInfoUpdated:
-                text = buildText("直播间信息已更新");
-                break;
-            case ChatRoomMemberKicked:
-                text = buildText(targets, "被踢出直播间");
-                break;
-            case ChatRoomMemberTempMuteAdd:
-                text = buildText(targets, "被临时禁言");
-                break;
-            case ChatRoomMemberTempMuteRemove:
-                text = buildText(targets, "被解除临时禁言");
-                break;
-            case ChatRoomMyRoomRoleUpdated:
-                text = buildText(targets, "更新了自己的角色信息");
-                break;
-            case ChatRoomQueueChange:
-                text = buildText(targets, "麦序队列中有变更");
-                break;
-            case ChatRoomRoomMuted:
-                text = buildText("全体禁言,管理员可发言");
-                break;
-            case ChatRoomRoomDeMuted:
-                text = buildText("解除全体禁言");
-                break;
-            default:
-                text = attachment.toString();
-                break;
-        }
-
-        return text;
-    }
-
-    private static String getTargetNicks(final ChatRoomNotificationAttachment attachment) {
-        StringBuilder sb = new StringBuilder();
-        List<String> accounts = attachment.getTargets();
-        List<String> targets = attachment.getTargetNicks();
-        if (attachment.getTargetNicks() != null) {
-            for (int i = 0; i < targets.size(); i++) {
-                sb.append(SheishuoCache.getAccount().equals(accounts.get(i)) ? "你" : targets.get(i));
-                sb.append(",");
-            }
-            sb.deleteCharAt(sb.length() - 1);
-        }
-
-        return sb.toString();
-    }
-
-    private static String buildText(String pre, String targets, String operate) {
-        StringBuilder sb = new StringBuilder();
-        if (!TextUtils.isEmpty(pre)) {
-            sb.append(pre);
-        }
-
-        if (!TextUtils.isEmpty(targets)) {
-            sb.append(targets);
-        }
-
-        if (!TextUtils.isEmpty(operate)) {
-            sb.append(operate);
-        }
-
-        return sb.toString();
-    }
-
-    private static String buildText(String targets, String operate) {
-        return buildText(null, targets, operate);
-    }
-
-    private static String buildText(String operate) {
-        return buildText(null, operate);
-    }
-}

+ 0 - 95
app/src/com/sheishuo/app/chatroom/helper/ExtensionHelper.java

@@ -1,95 +0,0 @@
-package com.sheishuo.app.chatroom.helper;
-
-import android.text.TextUtils;
-
-import com.netease.nim.uikit.common.util.log.LogUtil;
-
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 扩展字段Map和String转换工具类
- */
-public class ExtensionHelper {
-
-    private static final String TAG = ExtensionHelper.class.getSimpleName();
-
-    public static String getJsonStringFromMap(final Map<String, Object> map) {
-        String result = null;
-        if (map != null && !map.isEmpty()) {
-            try {
-                JSONObject json = new JSONObject(map);
-                result = json.toString();
-            } catch (Exception e) {
-                LogUtil.e(TAG, "getJsonStringFromMap exception =" + e.getMessage());
-            }
-        }
-
-        return result;
-    }
-
-    public static Map<String, Object> getMapFromJsonString(final String jsonStr) {
-        if (TextUtils.isEmpty(jsonStr)) {
-            return null;
-        }
-
-        try {
-            org.json.JSONObject json = new org.json.JSONObject(jsonStr);
-            return recursiveParseJsonObject(json);
-        } catch (org.json.JSONException e) {
-            LogUtil.e(TAG, "getMapFromJsonString exception =" + e.getMessage());
-        }
-
-        return null;
-    }
-
-    private static Map<String, Object> recursiveParseJsonObject(org.json.JSONObject json) throws org.json.JSONException {
-        if (json == null) {
-            return null;
-        }
-
-        Map<String, Object> map = new HashMap<>(json.length());
-        String key;
-        Object value;
-        Iterator<String> i = json.keys();
-        while (i.hasNext()) {
-            key = i.next();
-            value = json.get(key);
-            if (value instanceof org.json.JSONArray) {
-                map.put(key, recursiveParseJsonArray((org.json.JSONArray) value));
-            } else if (value instanceof org.json.JSONObject) {
-                map.put(key, recursiveParseJsonObject((org.json.JSONObject) value));
-            } else {
-                map.put(key, value);
-            }
-        }
-
-        return map;
-    }
-
-    private static List recursiveParseJsonArray(org.json.JSONArray array) throws org.json.JSONException {
-        if (array == null) {
-            return null;
-        }
-
-        List list = new ArrayList(array.length());
-        Object value;
-        for (int m = 0; m < array.length(); m++) {
-            value = array.get(m);
-            if (value instanceof org.json.JSONArray) {
-                list.add(recursiveParseJsonArray((org.json.JSONArray) value));
-            } else if (value instanceof org.json.JSONObject) {
-                list.add(recursiveParseJsonObject((org.json.JSONObject) value));
-            } else {
-                list.add(value);
-            }
-        }
-
-        return list;
-    }
-}

+ 0 - 426
app/src/com/sheishuo/app/chatroom/module/ChatRoomMsgListPanel.java

@@ -1,426 +0,0 @@
-package com.sheishuo.app.chatroom.module;
-
-import android.os.Build;
-import android.os.Handler;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.view.View;
-
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.chatroom.adapter.ChatRoomMsgAdapter;
-import com.netease.nim.uikit.R;
-import com.netease.nim.uikit.UserPreferences;
-import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialog;
-import com.netease.nim.uikit.common.ui.dialog.EasyAlertDialogHelper;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseFetchLoadAdapter;
-import com.netease.nim.uikit.common.ui.recyclerview.loadmore.MsgListFetchLoadMoreView;
-import com.netease.nim.uikit.session.audio.MessageAudioControl;
-import com.netease.nim.uikit.session.module.Container;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.Observer;
-import com.netease.nimlib.sdk.RequestCallback;
-import com.netease.nimlib.sdk.RequestCallbackWrapper;
-import com.netease.nimlib.sdk.avchat.model.AVChatAttachment;
-import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
-import com.netease.nimlib.sdk.chatroom.ChatRoomService;
-import com.netease.nimlib.sdk.chatroom.ChatRoomServiceObserver;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
-import com.netease.nimlib.sdk.msg.attachment.AudioAttachment;
-import com.netease.nimlib.sdk.msg.attachment.FileAttachment;
-import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
-import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
-import com.netease.nimlib.sdk.msg.model.AttachmentProgress;
-import com.netease.nimlib.sdk.msg.model.IMMessage;
-import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * 聊天室消息收发模块
- * Created by huangjun on 2016/1/27.
- */
-public class ChatRoomMsgListPanel {
-    private static final int MESSAGE_CAPACITY = 500;
-
-    // container
-    private Container container;
-    private View rootView;
-    private Handler uiHandler;
-
-    // message list view
-    private RecyclerView messageListView;
-    private LinkedList<ChatRoomMessage> items;
-    private ChatRoomMsgAdapter adapter;
-
-    public ChatRoomMsgListPanel(Container container, View rootView) {
-        this.container = container;
-        this.rootView = rootView;
-
-        init();
-    }
-
-    public void onResume() {
-        setEarPhoneMode(UserPreferences.isEarPhoneModeEnable());
-    }
-
-    public void onPause() {
-        MessageAudioControl.getInstance(container.activity).stopAudio();
-    }
-
-    public void onDestroy() {
-        registerObservers(false);
-    }
-
-    public boolean onBackPressed() {
-        uiHandler.removeCallbacks(null);
-        MessageAudioControl.getInstance(container.activity).stopAudio(); // 界面返回,停止语音播放
-        return false;
-    }
-
-    public void reload(Container container) {
-        this.container = container;
-        if (adapter != null) {
-            adapter.clearData();
-        }
-    }
-
-    private void init() {
-        initListView();
-        this.uiHandler = new Handler(SheishuoCache.getContext().getMainLooper());
-        registerObservers(true);
-    }
-
-    private void initListView() {
-        // RecyclerView
-        messageListView = (RecyclerView) rootView.findViewById(R.id.messageListView);
-        messageListView.setLayoutManager(new LinearLayoutManager(container.activity));
-        messageListView.requestDisallowInterceptTouchEvent(true);
-        messageListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
-            @Override
-            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
-                super.onScrollStateChanged(recyclerView, newState);
-                if (newState != RecyclerView.SCROLL_STATE_IDLE) {
-                    container.proxy.shouldCollapseInputPanel();
-                }
-            }
-        });
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
-            messageListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
-        }
-
-        // adapter
-        items = new LinkedList<>();
-        adapter = new ChatRoomMsgAdapter(messageListView, items);
-        adapter.closeLoadAnimation();
-        adapter.setFetchMoreView(new MsgListFetchLoadMoreView());
-        adapter.setLoadMoreView(new MsgListFetchLoadMoreView());
-        adapter.setEventListener(new MsgItemEventListener());
-        adapter.setOnFetchMoreListener(new MessageLoader()); // load from start
-        messageListView.setAdapter(adapter);
-    }
-
-    public void onIncomingMessage(List<ChatRoomMessage> messages) {
-        boolean needScrollToBottom = isLastMessageVisible();
-        boolean needRefresh = false;
-        List<ChatRoomMessage> addedListItems = new ArrayList<>(messages.size());
-        for (ChatRoomMessage message : messages) {
-            // 保证显示到界面上的消息,来自同一个聊天室
-            if (isMyMessage(message)) {
-                saveMessage(message);
-                addedListItems.add(message);
-                needRefresh = true;
-            }
-        }
-        if (needRefresh) {
-            adapter.notifyDataSetChanged();
-        }
-
-        // incoming messages tip
-        ChatRoomMessage lastMsg = messages.get(messages.size() - 1);
-        if (isMyMessage(lastMsg) && needScrollToBottom) {
-            doScrollToBottom();
-        }
-    }
-
-    private boolean isLastMessageVisible() {
-        LinearLayoutManager layoutManager = (LinearLayoutManager) messageListView.getLayoutManager();
-        int lastVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition();
-        return lastVisiblePosition >= adapter.getBottomDataPosition();
-    }
-
-
-    // 发送消息后,更新本地消息列表
-    public void onMsgSend(ChatRoomMessage message) {
-        saveMessage(message);
-
-        adapter.notifyDataSetChanged();
-        doScrollToBottom();
-    }
-
-    public void saveMessage(final ChatRoomMessage message) {
-        if (message == null) {
-            return;
-        }
-
-        if (items.size() >= MESSAGE_CAPACITY) {
-            items.poll();
-        }
-
-        items.add(message);
-    }
-
-    /**
-     * *************** MessageLoader ***************
-     */
-    private class MessageLoader implements BaseFetchLoadAdapter.RequestLoadMoreListener, BaseFetchLoadAdapter.RequestFetchMoreListener {
-
-        private static final int LOAD_MESSAGE_COUNT = 10;
-
-        private IMMessage anchor;
-
-        private boolean firstLoad = true;
-
-        private boolean fetching = false;
-
-        public MessageLoader() {
-            anchor = null;
-            loadFromLocal();
-        }
-
-        private RequestCallback<List<ChatRoomMessage>> callback = new RequestCallbackWrapper<List<ChatRoomMessage>>() {
-            @Override
-            public void onResult(int code, List<ChatRoomMessage> messages, Throwable exception) {
-                onMessageLoaded(messages);
-
-                fetching = false;
-            }
-        };
-
-        private void loadFromLocal() {
-            if (fetching) {
-                return;
-            }
-
-            fetching = true;
-            NIMClient.getService(ChatRoomService.class).pullMessageHistoryEx(container.account, anchor().getTime(), LOAD_MESSAGE_COUNT, QueryDirectionEnum.QUERY_OLD)
-                    .setCallback(callback);
-        }
-
-        private IMMessage anchor() {
-            if (items.size() == 0) {
-                return (anchor == null ? ChatRoomMessageBuilder.createEmptyChatRoomMessage(container.account, 0) : anchor);
-            } else {
-                return items.get(0);
-            }
-        }
-
-        /**
-         * 历史消息加载处理
-         */
-        private void onMessageLoaded(List<ChatRoomMessage> messages) {
-            int count = messages.size();
-
-            // 逆序
-            Collections.reverse(messages);
-            // 加入到列表中
-            if (count < LOAD_MESSAGE_COUNT) {
-                adapter.fetchMoreEnd(messages, true);
-            } else {
-                adapter.fetchMoreComplete(messages);
-            }
-
-            // 如果是第一次加载,updateShowTimeItem返回的就是lastShowTimeItem
-            if (firstLoad) {
-                doScrollToBottom();
-            }
-
-            firstLoad = false;
-        }
-
-        @Override
-        public void onFetchMoreRequested() {
-            loadFromLocal();
-        }
-
-        @Override
-        public void onLoadMoreRequested() {
-
-        }
-    }
-
-    /**
-     * ************************* 观察者 ********************************
-     */
-
-    private void registerObservers(boolean register) {
-        ChatRoomServiceObserver service = NIMClient.getService(ChatRoomServiceObserver.class);
-        service.observeMsgStatus(messageStatusObserver, register);
-        service.observeAttachmentProgress(attachmentProgressObserver, register);
-    }
-
-    /**
-     * 消息状态变化观察者
-     */
-    Observer<ChatRoomMessage> messageStatusObserver = new Observer<ChatRoomMessage>() {
-        @Override
-        public void onEvent(ChatRoomMessage message) {
-            if (isMyMessage(message)) {
-                onMessageStatusChange(message);
-            }
-        }
-    };
-
-    /**
-     * 消息附件上传/下载进度观察者
-     */
-    Observer<AttachmentProgress> attachmentProgressObserver = new Observer<AttachmentProgress>() {
-        @Override
-        public void onEvent(AttachmentProgress progress) {
-            onAttachmentProgressChange(progress);
-        }
-    };
-
-    private void onMessageStatusChange(IMMessage message) {
-        int index = getItemIndex(message.getUuid());
-        if (index >= 0 && index < items.size()) {
-            IMMessage item = items.get(index);
-            item.setStatus(message.getStatus());
-            item.setAttachStatus(message.getAttachStatus());
-            if (item.getAttachment() instanceof AVChatAttachment
-                    || item.getAttachment() instanceof AudioAttachment) {
-                item.setAttachment(message.getAttachment());
-            }
-            refreshViewHolderByIndex(index);
-        }
-    }
-
-    private void onAttachmentProgressChange(AttachmentProgress progress) {
-        int index = getItemIndex(progress.getUuid());
-        if (index >= 0 && index < items.size()) {
-            IMMessage item = items.get(index);
-            float value = (float) progress.getTransferred() / (float) progress.getTotal();
-            adapter.putProgress(item, value);
-            refreshViewHolderByIndex(index);
-        }
-    }
-
-    public boolean isMyMessage(ChatRoomMessage message) {
-        return message.getSessionType() == container.sessionType
-                && message.getSessionId() != null
-                && message.getSessionId().equals(container.account);
-    }
-
-    /**
-     * 刷新单条消息
-     */
-    private void refreshViewHolderByIndex(final int index) {
-        container.activity.runOnUiThread(new Runnable() {
-
-            @Override
-            public void run() {
-                if (index < 0) {
-                    return;
-                }
-
-                adapter.notifyDataItemChanged(index);
-            }
-        });
-    }
-
-    private int getItemIndex(String uuid) {
-        for (int i = 0; i < items.size(); i++) {
-            IMMessage message = items.get(i);
-            if (TextUtils.equals(message.getUuid(), uuid)) {
-                return i;
-            }
-        }
-
-        return -1;
-    }
-
-    private class MsgItemEventListener implements ChatRoomMsgAdapter.ViewHolderEventListener {
-
-        @Override
-        public void onFailedBtnClick(IMMessage message) {
-            if (message.getDirect() == MsgDirectionEnum.Out) {
-                // 发出的消息,如果是发送失败,直接重发,否则有可能是漫游到的多媒体消息,但文件下载
-                if (message.getStatus() == MsgStatusEnum.fail) {
-                    resendMessage(message); // 重发
-                } else {
-                    if (message.getAttachment() instanceof FileAttachment) {
-                        FileAttachment attachment = (FileAttachment) message.getAttachment();
-                        if (TextUtils.isEmpty(attachment.getPath())
-                                && TextUtils.isEmpty(attachment.getThumbPath())) {
-                            showReDownloadConfirmDlg(message);
-                        }
-                    } else {
-                        resendMessage(message);
-                    }
-                }
-            } else {
-                showReDownloadConfirmDlg(message);
-            }
-        }
-
-        @Override
-        public boolean onViewHolderLongClick(View clickView, View viewHolderView, IMMessage item) {
-            return true;
-        }
-
-        // 重新下载(对话框提示)
-        private void showReDownloadConfirmDlg(final IMMessage message) {
-            EasyAlertDialogHelper.OnDialogActionListener listener = new EasyAlertDialogHelper.OnDialogActionListener() {
-
-                @Override
-                public void doCancelAction() {
-                }
-
-                @Override
-                public void doOkAction() {
-                    // 正常情况收到消息后附件会自动下载。如果下载失败,可调用该接口重新下载
-                    if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
-                        NIMClient.getService(ChatRoomService.class).downloadAttachment((ChatRoomMessage) message, true);
-                }
-            };
-
-            final EasyAlertDialog dialog = EasyAlertDialogHelper.createOkCancelDiolag(container.activity, null,
-                    container.activity.getString(R.string.repeat_download_message), true, listener);
-            dialog.show();
-        }
-
-        // 重发消息到服务器
-        private void resendMessage(IMMessage message) {
-            // 重置状态为unsent
-            int index = getItemIndex(message.getUuid());
-            if (index >= 0 && index < items.size()) {
-                IMMessage item = items.get(index);
-                item.setStatus(MsgStatusEnum.sending);
-                refreshViewHolderByIndex(index);
-            }
-
-            NIMClient.getService(ChatRoomService.class).sendMessage((ChatRoomMessage) message, true);
-        }
-    }
-
-    private void setEarPhoneMode(boolean earPhoneMode) {
-        UserPreferences.setEarPhoneModeEnable(earPhoneMode);
-        MessageAudioControl.getInstance(container.activity).setEarPhoneModeEnable(earPhoneMode);
-    }
-
-    public void scrollToBottom() {
-        uiHandler.postDelayed(new Runnable() {
-            @Override
-            public void run() {
-                doScrollToBottom();
-            }
-        }, 200);
-    }
-
-    private void doScrollToBottom() {
-        messageListView.scrollToPosition(adapter.getBottomDataPosition());
-    }
-}

+ 0 - 150
app/src/com/sheishuo/app/chatroom/thridparty/ChatRoomHttpClient.java

@@ -1,150 +0,0 @@
-package com.sheishuo.app.chatroom.thridparty;
-
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONException;
-import com.alibaba.fastjson.JSONObject;
-import com.sheishuo.app.SheishuoCache;
-import com.sheishuo.app.chatroom.helper.ExtensionHelper;
-import com.netease.nim.uikit.common.http.NimHttpClient;
-import com.sheishuo.app.config.DemoServers;
-import com.netease.nim.uikit.common.util.log.LogUtil;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomInfo;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 网易云信Demo聊天室Http客户端。第三方开发者请连接自己的应用服务器。
- * <p/>
- * Created by huangjun on 2016/1/18.
- */
-public class ChatRoomHttpClient {
-    private static final String TAG = ChatRoomHttpClient.class.getSimpleName();
-
-    // code
-    private static final int RESULT_CODE_SUCCESS = 200;
-
-    // api
-    private static final String API_NAME_CHAT_ROOM_LIST = "homeList";
-
-    // header
-    private static final String HEADER_KEY_APP_KEY = "appkey";
-
-    // result
-    private static final String RESULT_KEY_RES = "res";
-    private static final String RESULT_KEY_MSG = "msg";
-    private static final String RESULT_KEY_TOTAL = "total";
-    private static final String RESULT_KEY_LIST = "list";
-    private static final String RESULT_KEY_NAME = "name";
-    private static final String RESULT_KEY_CREATOR = "creator";
-    private static final String RESULT_KEY_STATUS = "status";
-    private static final String RESULT_KEY_ANNOUNCEMENT = "announcement";
-    private static final String RESULT_KEY_EXT = "ext";
-    private static final String RESULT_KEY_ROOM_ID = "roomid";
-    private static final String RESULT_KEY_BROADCAST_URL = "broadcasturl";
-    private static final String RESULT_KEY_ONLINE_USER_COUNT = "onlineusercount";
-
-    public interface ChatRoomHttpCallback<T> {
-        void onSuccess(T t);
-
-        void onFailed(int code, String errorMsg);
-    }
-
-    private static ChatRoomHttpClient instance;
-
-    public static synchronized ChatRoomHttpClient getInstance() {
-        if (instance == null) {
-            instance = new ChatRoomHttpClient();
-        }
-
-        return instance;
-    }
-
-    private ChatRoomHttpClient() {
-        NimHttpClient.getInstance().init(SheishuoCache.getContext());
-    }
-
-    /**
-     * 向网易云信Demo应用服务器请求聊天室列表
-     */
-    public void fetchChatRoomList(final ChatRoomHttpCallback<List<ChatRoomInfo>> callback) {
-        String url = DemoServers.chatRoomAPIServer() + API_NAME_CHAT_ROOM_LIST;
-
-        Map<String, String> headers = new HashMap<>(1);
-        String appKey = readAppKey();
-        headers.put(HEADER_KEY_APP_KEY, appKey);
-
-        NimHttpClient.getInstance().execute(url, headers, null, false, new NimHttpClient.NimHttpCallback() {
-            @Override
-            public void onResponse(String response, int code, Throwable exception) {
-                if (code != 200 || exception != null) {
-                    LogUtil.e(TAG, "fetchChatRoomList failed : code = " + code + ", errorMsg = "
-                            + (exception != null ? exception.getMessage() : "null"));
-                    if (callback != null) {
-                        callback.onFailed(code, exception != null ? exception.getMessage() : "null");
-                    }
-                    return;
-                }
-
-                try {
-                    // ret 0
-                    JSONObject res = JSONObject.parseObject(response);
-                    // res 1
-                    int resCode = res.getIntValue(RESULT_KEY_RES);
-                    if (resCode == RESULT_CODE_SUCCESS) {
-                        // msg 1
-                        JSONObject msg = res.getJSONObject(RESULT_KEY_MSG);
-                        List<ChatRoomInfo> roomInfoList = null;
-                        if (msg != null) {
-                            // total 2
-                            roomInfoList = new ArrayList<>(msg.getIntValue(RESULT_KEY_TOTAL));
-
-                            // list 2
-                            JSONArray rooms = msg.getJSONArray(RESULT_KEY_LIST);
-                            for (int i = 0; i < rooms.size(); i++) {
-                                // room 3
-                                JSONObject room = rooms.getJSONObject(i);
-                                ChatRoomInfo roomInfo = new ChatRoomInfo();
-                                roomInfo.setName(room.getString(RESULT_KEY_NAME));
-                                roomInfo.setCreator(room.getString(RESULT_KEY_CREATOR));
-                                roomInfo.setValidFlag(room.getIntValue(RESULT_KEY_STATUS));
-                                roomInfo.setAnnouncement(room.getString(RESULT_KEY_ANNOUNCEMENT));
-                                roomInfo.setExtension(ExtensionHelper.getMapFromJsonString(room.getString(RESULT_KEY_EXT)));
-                                roomInfo.setRoomId(room.getString(RESULT_KEY_ROOM_ID));
-                                roomInfo.setBroadcastUrl(room.getString(RESULT_KEY_BROADCAST_URL));
-                                roomInfo.setOnlineUserCount(room.getIntValue(RESULT_KEY_ONLINE_USER_COUNT));
-                                roomInfoList.add(roomInfo);
-                            }
-                        }
-                        // reply
-                        callback.onSuccess(roomInfoList);
-                    } else {
-                        callback.onFailed(resCode, null);
-                    }
-                } catch (JSONException e) {
-                    callback.onFailed(-1, e.getMessage());
-                } catch (Exception e) {
-                    callback.onFailed(-2, e.getMessage());
-                }
-            }
-        });
-    }
-
-    private String readAppKey() {
-        try {
-            ApplicationInfo appInfo = SheishuoCache.getContext().getPackageManager()
-                    .getApplicationInfo(SheishuoCache.getContext().getPackageName(), PackageManager.GET_META_DATA);
-            if (appInfo != null) {
-                return appInfo.metaData.getString("com.netease.nim.appKey");
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-}

+ 0 - 365
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderBase.java

@@ -1,365 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import android.content.Context;
-import android.text.TextUtils;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.sheishuo.app.chatroom.adapter.ChatRoomMsgAdapter;
-import com.netease.nim.uikit.NimUIKit;
-import com.netease.nim.uikit.R;
-import com.netease.nim.uikit.cache.TeamDataCache;
-import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
-import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder;
-import com.netease.nim.uikit.common.ui.recyclerview.holder.RecyclerViewHolder;
-import com.netease.nim.uikit.common.util.sys.TimeUtil;
-import com.netease.nimlib.sdk.NIMClient;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
-import com.netease.nimlib.sdk.msg.MsgService;
-import com.netease.nimlib.sdk.msg.attachment.FileAttachment;
-import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum;
-import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
-import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
-
-/**
- * 会话窗口消息列表项的ViewHolder基类,负责每个消息项的外层框架,包括头像,昵称,发送/接收进度条,重发按钮等。<br>
- * 具体的消息展示项可继承该基类,然后完成具体消息内容展示即可。
- */
-public abstract class ChatRoomMsgViewHolderBase extends RecyclerViewHolder<BaseMultiItemFetchLoadAdapter,
-        BaseViewHolder, ChatRoomMessage> {
-
-    public ChatRoomMsgViewHolderBase(BaseMultiItemFetchLoadAdapter adapter) {
-        super(adapter);
-        this.adapter = adapter;
-    }
-
-    // basic
-    protected View view;
-    protected Context context;
-    protected BaseMultiItemFetchLoadAdapter adapter;
-
-    // data
-    protected ChatRoomMessage message;
-
-    // view
-    protected View alertButton;
-    protected TextView timeTextView;
-    protected ProgressBar progressBar;
-    protected TextView nameTextView;
-    protected FrameLayout contentContainer;
-    protected LinearLayout nameContainer;
-    protected TextView readReceiptTextView;
-
-    private HeadImageView avatarLeft;
-    private HeadImageView avatarRight;
-
-    public ImageView nameIconView;
-
-    // contentContainerView的默认长按事件。如果子类需要不同的处理,可覆盖onItemLongClick方法
-    // 但如果某些子控件会拦截触摸消息,导致contentContainer收不到长按事件,子控件也可在inflate时重新设置
-    protected View.OnLongClickListener longClickListener;
-
-    /// -- 以下接口可由子类覆盖或实现
-    // 返回具体消息类型内容展示区域的layout res id
-    abstract protected int getContentResId();
-
-    // 在该接口中根据layout对各控件成员变量赋值
-    abstract protected void inflateContentView();
-
-    // 将消息数据项与内容的view进行绑定
-    abstract protected void bindContentView();
-
-    // 内容区域点击事件响应处理。
-    protected void onItemClick() {
-    }
-
-    // 内容区域长按事件响应处理。该接口的优先级比adapter中有长按事件的处理监听高,当该接口返回为true时,adapter的长按事件监听不会被调用到。
-    protected boolean onItemLongClick() {
-        return false;
-    }
-
-    // 当是接收到的消息时,内容区域背景的drawable id
-    protected int leftBackground() {
-        return R.drawable.nim_message_item_left_selector;
-    }
-
-    // 当是发送出去的消息时,内容区域背景的drawable id
-    protected int rightBackground() {
-        return R.drawable.nim_message_item_right_selector;
-    }
-
-    // 返回该消息是不是居中显示
-    protected boolean isMiddleItem() {
-        return false;
-    }
-
-    // 是否显示头像,默认为显示
-    protected boolean isShowHeadImage() {
-        return true;
-    }
-
-    // 是否显示气泡背景,默认为显示
-    protected boolean isShowBubble() {
-        return true;
-    }
-
-    /// -- 以下接口可由子类调用
-    protected final ChatRoomMsgAdapter getMsgAdapter() {
-        return (ChatRoomMsgAdapter) adapter;
-    }
-
-    /**
-     * 下载附件/缩略图
-     */
-    protected void downloadAttachment() {
-        if (message.getAttachment() != null && message.getAttachment() instanceof FileAttachment)
-            NIMClient.getService(MsgService.class).downloadAttachment(message, true);
-    }
-
-    // 设置FrameLayout子控件的gravity参数
-    protected final void setGravity(View view, int gravity) {
-        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams();
-        params.gravity = gravity;
-    }
-
-    // 设置控件的长宽
-    protected void setLayoutParams(int width, int height, View... views) {
-        for (View view : views) {
-            ViewGroup.LayoutParams maskParams = view.getLayoutParams();
-            maskParams.width = width;
-            maskParams.height = height;
-            view.setLayoutParams(maskParams);
-        }
-    }
-
-    // 根据layout id查找对应的控件
-    protected <T extends View> T findViewById(int id) {
-        return (T) view.findViewById(id);
-    }
-
-    // 判断消息方向,是否是接收到的消息
-    protected boolean isReceivedMessage() {
-        return message.getDirect() == MsgDirectionEnum.In;
-    }
-
-    /// -- 以下是基类实现代码
-    @Override
-    public void convert(BaseViewHolder holder, ChatRoomMessage data, int position, boolean isScrolling) {
-        view = holder.getConvertView();
-        context = holder.getContext();
-        message = data;
-
-        inflate();
-        refresh();
-    }
-
-    protected final void inflate() {
-        timeTextView = findViewById(R.id.message_item_time);
-        avatarLeft = findViewById(R.id.message_item_portrait_left);
-        avatarRight = findViewById(R.id.message_item_portrait_right);
-        alertButton = findViewById(R.id.message_item_alert);
-        progressBar = findViewById(R.id.message_item_progress);
-        nameTextView = findViewById(R.id.message_item_nickname);
-        contentContainer = findViewById(R.id.message_item_content);
-        nameIconView = findViewById(R.id.message_item_name_icon);
-        nameContainer = findViewById(R.id.message_item_name_layout);
-        readReceiptTextView = findViewById(R.id.textViewAlreadyRead);
-
-        // 这里只要inflate出来后加入一次即可
-        if (contentContainer.getChildCount() == 0) {
-            View.inflate(view.getContext(), getContentResId(), contentContainer);
-        }
-        inflateContentView();
-    }
-
-    protected final void refresh() {
-        setHeadImageView();
-        setNameTextView();
-        setTimeTextView();
-        setStatus();
-        setOnClickListener();
-        setLongClickListener();
-        setContent();
-        setReadReceipt();
-
-        bindContentView();
-    }
-
-    public void refreshCurrentItem() {
-        if (message != null) {
-            refresh();
-        }
-    }
-
-    /**
-     * 设置时间显示
-     */
-    private void setTimeTextView() {
-        if (getMsgAdapter().needShowTime(message)) {
-            timeTextView.setVisibility(View.VISIBLE);
-        } else {
-            timeTextView.setVisibility(View.GONE);
-            return;
-        }
-
-        String text = TimeUtil.getTimeShowString(message.getTime(), false);
-        timeTextView.setText(text);
-    }
-
-    /**
-     * 设置消息发送状态
-     */
-    private void setStatus() {
-        MsgStatusEnum status = message.getStatus();
-        switch (status) {
-            case fail:
-                progressBar.setVisibility(View.GONE);
-                alertButton.setVisibility(View.VISIBLE);
-                break;
-            case sending:
-                progressBar.setVisibility(View.VISIBLE);
-                alertButton.setVisibility(View.GONE);
-                break;
-            default:
-                progressBar.setVisibility(View.GONE);
-                alertButton.setVisibility(View.GONE);
-                break;
-        }
-    }
-
-    private void setHeadImageView() {
-        HeadImageView show = isReceivedMessage() ? avatarLeft : avatarRight;
-        HeadImageView hide = isReceivedMessage() ? avatarRight : avatarLeft;
-        hide.setVisibility(View.GONE);
-        if (!isShowHeadImage()) {
-            show.setVisibility(View.GONE);
-            return;
-        }
-        if (isMiddleItem()) {
-            show.setVisibility(View.GONE);
-        } else {
-            show.setVisibility(View.VISIBLE);
-            show.loadBuddyAvatar(message.getFromAccount());
-        }
-
-    }
-
-    private void setOnClickListener() {
-        // 重发/重收按钮响应事件
-        if (getMsgAdapter().getEventListener() != null) {
-            alertButton.setOnClickListener(new View.OnClickListener() {
-
-                @Override
-                public void onClick(View v) {
-                    getMsgAdapter().getEventListener().onFailedBtnClick(message);
-                }
-            });
-        }
-
-        // 内容区域点击事件响应, 相当于点击了整项
-        contentContainer.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                onItemClick();
-            }
-        });
-
-        // 头像点击事件响应
-        if (NimUIKit.getSessionListener() != null) {
-            View.OnClickListener portraitListener = new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    NimUIKit.getSessionListener().onAvatarClicked(context, message);
-                }
-            };
-            avatarLeft.setOnClickListener(portraitListener);
-            avatarRight.setOnClickListener(portraitListener);
-        }
-    }
-
-    /**
-     * item长按事件监听
-     */
-    private void setLongClickListener() {
-        longClickListener = new View.OnLongClickListener() {
-            @Override
-            public boolean onLongClick(View v) {
-                // 优先派发给自己处理,
-                if (!onItemLongClick()) {
-                    if (getMsgAdapter().getEventListener() != null) {
-                        getMsgAdapter().getEventListener().onViewHolderLongClick(contentContainer, view, message);
-                        return true;
-                    }
-                }
-                return false;
-            }
-        };
-        // 消息长按事件响应处理
-        contentContainer.setOnLongClickListener(longClickListener);
-
-        // 头像长按事件响应处理
-        if (NimUIKit.getSessionListener() != null) {
-            View.OnLongClickListener longClickListener = new View.OnLongClickListener() {
-                @Override
-                public boolean onLongClick(View v) {
-                    NimUIKit.getSessionListener().onAvatarLongClicked(context, message);
-                    return true;
-                }
-            };
-            avatarLeft.setOnLongClickListener(longClickListener);
-            avatarRight.setOnLongClickListener(longClickListener);
-        }
-    }
-
-    public void setNameTextView() {
-        if (message.getSessionType() == SessionTypeEnum.Team && isReceivedMessage() && !isMiddleItem()) {
-            nameTextView.setVisibility(View.VISIBLE);
-            nameTextView.setText(TeamDataCache.getInstance().getTeamMemberDisplayName(message.getSessionId(), message
-                    .getFromAccount()));
-        } else {
-            nameTextView.setVisibility(View.GONE);
-        }
-    }
-
-    private void setContent() {
-        if (!isShowBubble() && !isMiddleItem()) {
-            return;
-        }
-
-        LinearLayout bodyContainer = (LinearLayout) view.findViewById(R.id.message_item_body);
-
-        // 调整container的位置
-        int index = isReceivedMessage() ? 0 : 3;
-        if (bodyContainer.getChildAt(index) != contentContainer) {
-            bodyContainer.removeView(contentContainer);
-            bodyContainer.addView(contentContainer, index);
-        }
-
-        if (isMiddleItem()) {
-            setGravity(bodyContainer, Gravity.CENTER);
-        } else {
-            if (isReceivedMessage()) {
-                setGravity(bodyContainer, Gravity.LEFT);
-                contentContainer.setBackgroundResource(leftBackground());
-            } else {
-                setGravity(bodyContainer, Gravity.RIGHT);
-                contentContainer.setBackgroundResource(rightBackground());
-            }
-        }
-    }
-
-    private void setReadReceipt() {
-        if (!TextUtils.isEmpty(getMsgAdapter().getUuid()) && message.getUuid().equals(getMsgAdapter().getUuid())) {
-            readReceiptTextView.setVisibility(View.VISIBLE);
-        } else {
-            readReceiptTextView.setVisibility(View.GONE);
-        }
-    }
-}

+ 0 - 74
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderBaseText.java

@@ -1,74 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import android.graphics.Color;
-import android.text.method.LinkMovementMethod;
-import android.text.style.ImageSpan;
-import android.view.View;
-import android.widget.TextView;
-
-import com.netease.nim.uikit.NimUIKit;
-import com.netease.nim.uikit.R;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
-import com.netease.nim.uikit.common.util.sys.ScreenUtil;
-import com.netease.nim.uikit.session.emoji.MoonUtil;
-
-/**
- * Created by zhoujianghua on 2015/8/4.
- */
-public class ChatRoomMsgViewHolderBaseText extends ChatRoomMsgViewHolderBase {
-
-    public ChatRoomMsgViewHolderBaseText(BaseMultiItemFetchLoadAdapter adapter) {
-        super(adapter);
-    }
-
-    @Override
-    protected int getContentResId() {
-        return R.layout.nim_message_item_text;
-    }
-
-    @Override
-    protected void inflateContentView() {
-    }
-
-    @Override
-    protected void bindContentView() {
-        layoutDirection();
-
-        TextView bodyTextView = findViewById(R.id.nim_message_item_text_body);
-        bodyTextView.setTextColor(isReceivedMessage() ? Color.BLACK : Color.WHITE);
-        bodyTextView.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                onItemClick();
-            }
-        });
-        MoonUtil.identifyFaceExpression(NimUIKit.getContext(), bodyTextView, getDisplayText(), ImageSpan.ALIGN_BOTTOM);
-        bodyTextView.setMovementMethod(LinkMovementMethod.getInstance());
-        bodyTextView.setOnLongClickListener(longClickListener);
-    }
-
-    private void layoutDirection() {
-        TextView bodyTextView = findViewById(R.id.nim_message_item_text_body);
-        if (isReceivedMessage()) {
-            bodyTextView.setBackgroundResource(R.drawable.nim_message_item_left_selector);
-            bodyTextView.setPadding(ScreenUtil.dip2px(15), ScreenUtil.dip2px(8), ScreenUtil.dip2px(10), ScreenUtil.dip2px(8));
-        } else {
-            bodyTextView.setBackgroundResource(R.drawable.nim_message_item_right_selector);
-            bodyTextView.setPadding(ScreenUtil.dip2px(10), ScreenUtil.dip2px(8), ScreenUtil.dip2px(15), ScreenUtil.dip2px(8));
-        }
-    }
-
-    @Override
-    protected int leftBackground() {
-        return 0;
-    }
-
-    @Override
-    protected int rightBackground() {
-        return 0;
-    }
-
-    protected String getDisplayText() {
-        return message.getContent();
-    }
-}

+ 0 - 71
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderFactory.java

@@ -1,71 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import com.sheishuo.app.session.extension.GuessAttachment;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
-import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
-import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * 聊天室消息项展示ViewHolder工厂类。
- */
-public class ChatRoomMsgViewHolderFactory {
-
-    private static HashMap<Class<? extends MsgAttachment>, Class<? extends ChatRoomMsgViewHolderBase>> viewHolders =
-            new HashMap<>();
-
-    static {
-        // built in
-        register(ChatRoomNotificationAttachment.class, ChatRoomMsgViewHolderNotification.class);
-        register(GuessAttachment.class, ChatRoomMsgViewHolderGuess.class);
-    }
-
-    public static void register(Class<? extends MsgAttachment> attach, Class<? extends ChatRoomMsgViewHolderBase> viewHolder) {
-        viewHolders.put(attach, viewHolder);
-    }
-
-    public static Class<? extends ChatRoomMsgViewHolderBase> getViewHolderByType(ChatRoomMessage message) {
-        if (message.getMsgType() == MsgTypeEnum.text) {
-            return ChatRoomMsgViewHolderText.class;
-        } else {
-            Class<? extends ChatRoomMsgViewHolderBase> viewHolder = null;
-            if (message.getAttachment() != null) {
-                Class<? extends MsgAttachment> clazz = message.getAttachment().getClass();
-                while (viewHolder == null && clazz != null) {
-                    viewHolder = viewHolders.get(clazz);
-                    if (viewHolder == null) {
-                        clazz = getSuperClass(clazz);
-                    }
-                }
-            }
-            return viewHolder == null ? ChatRoomMsgViewHolderUnknown.class : viewHolder;
-        }
-    }
-
-    private static Class<? extends MsgAttachment> getSuperClass(Class<? extends MsgAttachment> derived) {
-        Class sup = derived.getSuperclass();
-        if (sup != null && MsgAttachment.class.isAssignableFrom(sup)) {
-            return sup;
-        } else {
-            for (Class itf : derived.getInterfaces()) {
-                if (MsgAttachment.class.isAssignableFrom(itf)) {
-                    return itf;
-                }
-            }
-        }
-        return null;
-    }
-
-    public static List<Class<? extends ChatRoomMsgViewHolderBase>> getAllViewHolders() {
-        List<Class<? extends ChatRoomMsgViewHolderBase>> list = new ArrayList<>();
-        list.addAll(viewHolders.values());
-        list.add(ChatRoomMsgViewHolderUnknown.class);
-        list.add(ChatRoomMsgViewHolderText.class);
-
-        return list;
-    }
-}

+ 0 - 21
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderGuess.java

@@ -1,21 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import com.sheishuo.app.session.extension.GuessAttachment;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
-
-/**
- * Created by hzxuwen on 2016/1/20.
- */
-public class ChatRoomMsgViewHolderGuess extends ChatRoomMsgViewHolderText {
-
-    public ChatRoomMsgViewHolderGuess(BaseMultiItemFetchLoadAdapter adapter) {
-        super(adapter);
-    }
-
-    @Override
-    protected String getDisplayText() {
-        GuessAttachment attachment = (GuessAttachment) message.getAttachment();
-
-        return attachment.getValue().getDesc() + "!";
-    }
-}

+ 0 - 38
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderNotification.java

@@ -1,38 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import android.widget.TextView;
-
-import com.sheishuo.app.chatroom.helper.ChatRoomNotificationHelper;
-import com.netease.nim.uikit.R;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
-
-public class ChatRoomMsgViewHolderNotification extends ChatRoomMsgViewHolderBase {
-
-    protected TextView notificationTextView;
-
-    public ChatRoomMsgViewHolderNotification(BaseMultiItemFetchLoadAdapter adapter) {
-        super(adapter);
-    }
-
-    @Override
-    protected int getContentResId() {
-        return R.layout.nim_message_item_notification;
-    }
-
-    @Override
-    protected void inflateContentView() {
-        notificationTextView = (TextView) view.findViewById(R.id.message_item_notification_label);
-    }
-
-    @Override
-    protected void bindContentView() {
-        notificationTextView.setText(ChatRoomNotificationHelper.getNotificationText((ChatRoomNotificationAttachment) message.getAttachment()));
-    }
-
-    @Override
-    protected boolean isMiddleItem() {
-        return true;
-    }
-}
-

+ 0 - 51
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderText.java

@@ -1,51 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import android.graphics.Color;
-import android.text.method.LinkMovementMethod;
-import android.text.style.ImageSpan;
-import android.widget.TextView;
-
-import com.netease.nim.uikit.NimUIKit;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
-import com.netease.nim.uikit.common.util.sys.ScreenUtil;
-import com.netease.nim.uikit.session.emoji.MoonUtil;
-
-/**
- * Created by hzxuwen on 2016/1/18.
- */
-public class ChatRoomMsgViewHolderText extends ChatRoomMsgViewHolderBaseText {
-    public ChatRoomMsgViewHolderText(BaseMultiItemFetchLoadAdapter adapter) {
-        super(adapter);
-    }
-
-    @Override
-    protected boolean isShowBubble() {
-        return false;
-    }
-
-    @Override
-    protected boolean isShowHeadImage() {
-        return false;
-    }
-
-    @Override
-    public void setNameTextView() {
-        nameContainer.setPadding(ScreenUtil.dip2px(6), 0, 0, 0);
-        ChatRoomViewHolderHelper.setNameTextView(message, nameTextView, nameIconView, context);
-    }
-
-    @Override
-    protected void bindContentView() {
-        TextView bodyTextView = findViewById(com.netease.nim.uikit.R.id.nim_message_item_text_body);
-        bodyTextView.setTextColor(Color.BLACK);
-        layoutDirection();
-        MoonUtil.identifyFaceExpression(NimUIKit.getContext(), bodyTextView, getDisplayText(), ImageSpan.ALIGN_BOTTOM);
-        bodyTextView.setMovementMethod(LinkMovementMethod.getInstance());
-        bodyTextView.setOnLongClickListener(longClickListener);
-    }
-
-    private void layoutDirection() {
-        TextView bodyTextView = findViewById(com.netease.nim.uikit.R.id.nim_message_item_text_body);
-        bodyTextView.setPadding(ScreenUtil.dip2px(6), 0, 0, 0);
-    }
-}

+ 0 - 36
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomMsgViewHolderUnknown.java

@@ -1,36 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import com.netease.nim.uikit.R;
-import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
-import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
-
-/**
- * Created by huangjun on 2016/12/27.
- */
-public class ChatRoomMsgViewHolderUnknown extends ChatRoomMsgViewHolderBase {
-
-    public ChatRoomMsgViewHolderUnknown(BaseMultiItemFetchLoadAdapter adapter) {
-        super(adapter);
-    }
-
-    @Override
-    protected int getContentResId() {
-        return R.layout.nim_message_item_unknown;
-    }
-
-    @Override
-    protected boolean isShowHeadImage() {
-        if (message.getSessionType() == SessionTypeEnum.ChatRoom) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    protected void inflateContentView() {
-    }
-
-    @Override
-    protected void bindContentView() {
-    }
-}

+ 0 - 56
app/src/com/sheishuo/app/chatroom/viewholder/ChatRoomViewHolderHelper.java

@@ -1,56 +0,0 @@
-package com.sheishuo.app.chatroom.viewholder;
-
-import android.content.Context;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.cache.NimUserInfoCache;
-import com.netease.nimlib.sdk.chatroom.constant.MemberType;
-import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
-import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
-
-import java.util.Map;
-
-/**
- * 聊天室成员姓名
- * Created by hzxuwen on 2016/1/20.
- */
-public class ChatRoomViewHolderHelper {
-
-    public static void setNameTextView(ChatRoomMessage message, TextView text, ImageView imageView, Context context) {
-        if (message.getMsgType() != MsgTypeEnum.notification) {
-            // 聊天室中显示姓名
-            if (message.getChatRoomMessageExtension() != null) {
-                text.setText(message.getChatRoomMessageExtension().getSenderNick());
-            } else {
-                text.setText(NimUserInfoCache.getInstance().getUserName(message.getFromAccount()));
-            }
-
-            text.setTextColor(context.getResources().getColor(R.color.color_black_ff999999));
-            text.setVisibility(View.VISIBLE);
-            setNameIconView(message, imageView);
-        }
-    }
-
-    private static void setNameIconView(ChatRoomMessage message, ImageView nameIconView) {
-        final String KEY = "type";
-        Map<String, Object> ext = message.getRemoteExtension();
-        if (ext == null || !ext.containsKey(KEY)) {
-            nameIconView.setVisibility(View.GONE);
-            return;
-        }
-
-        MemberType type = MemberType.typeOfValue((Integer) ext.get(KEY));
-        if (type == MemberType.ADMIN) {
-            nameIconView.setImageResource(R.drawable.admin_icon);
-            nameIconView.setVisibility(View.VISIBLE);
-        } else if (type == MemberType.CREATOR) {
-            nameIconView.setImageResource(R.drawable.master_icon);
-            nameIconView.setVisibility(View.VISIBLE);
-        } else {
-            nameIconView.setVisibility(View.GONE);
-        }
-    }
-}

+ 0 - 39
app/src/com/sheishuo/app/chatroom/widget/ChatRoomImageView.java

@@ -1,39 +0,0 @@
-package com.sheishuo.app.chatroom.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.bumptech.glide.Glide;
-import com.netease.nim.uikit.NimUIKit;
-import com.netease.nim.uikit.R;
-import com.netease.nim.uikit.common.ui.imageview.CircleImageView;
-
-public class ChatRoomImageView extends CircleImageView {
-
-    public static final int DEFAULT_THUMB_SIZE = (int) NimUIKit.getContext().getResources().getDimension(R.dimen.avatar_max_size);
-
-    public ChatRoomImageView(Context context) {
-        super(context);
-    }
-
-    public ChatRoomImageView(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public ChatRoomImageView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    public void loadAvatarByUrl(String url) {
-        loadAvatar(url, DEFAULT_THUMB_SIZE);
-    }
-
-    private void loadAvatar(final String url, final int thumbSize) {
-        Glide.with(getContext().getApplicationContext())
-                .load(url).asBitmap().centerCrop()
-                .placeholder(NimUIKit.getUserInfoProvider().getDefaultIconResId())
-                .error(NimUIKit.getUserInfoProvider().getDefaultIconResId())
-                .override(thumbSize, thumbSize)
-                .into(this);
-    }
-}

+ 0 - 31
app/src/com/sheishuo/app/common/beans/BeFollowedBean.java

@@ -1,31 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Created by KN on 2017/7/18.
- */
-
-public class BeFollowedBean implements Serializable{
-
-    private int c;
-    private List<String> d;
-
-    public int getC() {
-        return c;
-    }
-
-    public void setC(int c) {
-        this.c = c;
-    }
-
-    public List<String> getD() {
-        return d;
-    }
-
-    public void setD(List<String> d) {
-        this.d = d;
-    }
-
-}

File diff suppressed because it is too large
+ 0 - 14
app/src/com/sheishuo/app/common/beans/CircleBean.java


File diff suppressed because it is too large
+ 0 - 14
app/src/com/sheishuo/app/common/beans/CircleUnreadBean.java


+ 0 - 71
app/src/com/sheishuo/app/common/beans/CircleUserLikedBean.java

@@ -1,71 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-import java.util.List;
-
-/**
- * Created by KN on 2017/7/21.
- */
-
-public class CircleUserLikedBean {
-
-
-    /**
-     * c : 0
-     * d : {"likes":"2","social_id":"22","like_users":["200028","200030"]}
-     */
-
-    private int c;
-    private DBean d;
-
-    public int getC() {
-        return c;
-    }
-
-    public void setC(int c) {
-        this.c = c;
-    }
-
-    public DBean getD() {
-        return d;
-    }
-
-    public void setD(DBean d) {
-        this.d = d;
-    }
-
-    public static class DBean {
-        /**
-         * likes : 2
-         * social_id : 22
-         * like_users : ["200028","200030"]
-         */
-
-        private int likes;
-        private String social_id;
-        private List<String> like_users;
-
-        public int getLikes() {
-            return likes;
-        }
-
-        public void setLikes(int likes) {
-            this.likes = likes;
-        }
-
-        public String getSocial_id() {
-            return social_id;
-        }
-
-        public void setSocial_id(String social_id) {
-            this.social_id = social_id;
-        }
-
-        public List<String> getLike_users() {
-            return like_users;
-        }
-
-        public void setLike_users(List<String> like_users) {
-            this.like_users = like_users;
-        }
-    }
-}

+ 0 - 62
app/src/com/sheishuo/app/common/beans/CityDataBean.java

@@ -1,62 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by KN on 2017/8/14.
- */
-
-public class CityDataBean implements Serializable{
-
-    /**
-     * name : 北京
-     * city : [{"name":"北京","area":["东城区","西城区","崇文区","宣武区","朝阳区","丰台区","石景山区","海淀区","门头沟区","房山区","通州区","顺义区","昌平区","大兴区","平谷区","怀柔区","密云县","延庆县"]}]
-     */
-
-    private String name;
-    private List<CityBean> city;
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public List<CityBean> getCity() {
-        return city;
-    }
-
-    public void setCity(List<CityBean> city) {
-        this.city = city;
-    }
-
-    public static class CityBean {
-        /**
-         * name : 北京
-         * area : ["东城区","西城区","崇文区","宣武区","朝阳区","丰台区","石景山区","海淀区","门头沟区","房山区","通州区","顺义区","昌平区","大兴区","平谷区","怀柔区","密云县","延庆县"]
-         */
-
-        private String name;
-        private ArrayList<String> area;
-
-        public String getName() {
-            return name;
-        }
-
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        public ArrayList<String> getArea() {
-            return area;
-        }
-
-        public void setArea(ArrayList<String> area) {
-            this.area = area;
-        }
-    }
-}

+ 0 - 44
app/src/com/sheishuo/app/common/beans/ContactRelationshipBean.java

@@ -1,44 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-import java.io.Serializable;
-
-/**
- * Created by KN on 2017/8/27.
- */
-
-public class ContactRelationshipBean implements Serializable {
-
-    /**
-     * id : 200034
-     * mobile : 13175812396
-     * follow : 0
-     */
-
-    private String id;
-    private String mobile;
-    private int follow;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getMobile() {
-        return mobile;
-    }
-
-    public void setMobile(String mobile) {
-        this.mobile = mobile;
-    }
-
-    public int getFollow() {
-        return follow;
-    }
-
-    public void setFollow(int follow) {
-        this.follow = follow;
-    }
-}

File diff suppressed because it is too large
+ 0 - 12
app/src/com/sheishuo/app/common/beans/GiftBean.java


+ 0 - 83
app/src/com/sheishuo/app/common/beans/NearbyGroupsBean.java

@@ -1,83 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-import java.util.List;
-
-/**
- * Created by KN on 2017/7/18.
- */
-
-public class NearbyGroupsBean {
-
-
-    /**
-     * c : 0
-     * d : {"list":[{"id":"55005163","name":"哈哈哈哈哈","dist":"60122"},{"id":"68622903","name":"太谷","dist":"1087681"},{"id":"50824810","name":"has intro","dist":"11026705"},{"id":"64216569","name":"hahaha","dist":"11026705"},{"id":"50776617","name":"other avatar","dist":"11110365"}]}
-     */
-
-    private int c;
-    private DBean d;
-
-    public int getC() {
-        return c;
-    }
-
-    public void setC(int c) {
-        this.c = c;
-    }
-
-    public DBean getD() {
-        return d;
-    }
-
-    public void setD(DBean d) {
-        this.d = d;
-    }
-
-    public class DBean {
-        private List<ListBean> list;
-
-        public List<ListBean> getList() {
-            return list;
-        }
-
-        public void setList(List<ListBean> list) {
-            this.list = list;
-        }
-
-        public class ListBean {
-            /**
-             * id : 55005163
-             * name : 哈哈哈哈哈
-             * dist : 60122
-             */
-
-            private String id;
-            private String name;
-            private String dist;
-
-            public String getId() {
-                return id;
-            }
-
-            public void setId(String id) {
-                this.id = id;
-            }
-
-            public String getName() {
-                return name;
-            }
-
-            public void setName(String name) {
-                this.name = name;
-            }
-
-            public String getDist() {
-                return dist;
-            }
-
-            public void setDist(String dist) {
-                this.dist = dist;
-            }
-        }
-    }
-}

+ 0 - 106
app/src/com/sheishuo/app/common/beans/RequestBean.java

@@ -1,106 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Created by KN on 2017/7/18.
- */
-
-public class RequestBean implements Serializable{
-
-    private int c;
-    private List<ListBean> d;
-
-    public int getC() {
-        return c;
-    }
-
-    public void setC(int c) {
-        this.c = c;
-    }
-
-    public List<ListBean> getD() {
-        return d;
-    }
-
-    public void setD(List<ListBean> d) {
-        this.d = d;
-    }
-
-    public class ListBean implements Serializable{
-
-        private String id;
-        private String user_id;
-        private String target_id;
-        private String msg;
-        private String state;
-        private String type;
-        private String extra_id;
-        private String inputtime;
-
-        public String getId() {
-            return id;
-        }
-
-        public void setId(String id) {
-            this.id = id;
-        }
-
-        public String getUser_id() {
-            return user_id;
-        }
-
-        public void setUser_id(String user_id) {
-            this.user_id = user_id;
-        }
-
-        public String getTarget_id() {
-            return target_id;
-        }
-
-        public void setTarget_id(String target_id) {
-            this.target_id = target_id;
-        }
-
-        public String getMsg() {
-            return msg;
-        }
-
-        public void setMsg(String msg) {
-            this.msg = msg;
-        }
-
-        public String getState() {
-            return state;
-        }
-
-        public void setState(String state) {
-            this.state = state;
-        }
-
-        public String getInputtime() {
-            return inputtime;
-        }
-
-        public void setInputtime(String inputtime) {
-            this.inputtime = inputtime;
-        }
-
-        public String getType() {
-            return type;
-        }
-
-        public void setType(String type) {
-            this.type = type;
-        }
-
-        public String getExtra_id() {
-            return extra_id;
-        }
-
-        public void setExtra_id(String extra_id) {
-            this.extra_id = extra_id;
-        }
-    }
-}

+ 0 - 336
app/src/com/sheishuo/app/common/beans/SocialInfoBean.java

@@ -1,336 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-import java.util.List;
-
-/**
- * Created by KN on 2017/8/20.
- */
-
-public class SocialInfoBean {
-
-    /**
-     * id : 200030
-     * pwd : e10adc3949ba59abbe56e057f20f883e
-     * nick :
-     * mobile : 18523545395
-     * coin : 940
-     * room_id : 0
-     * latitude : 37.421998333333335
-     * longitude : -122.08400000000002
-     * province : 山东省
-     * city : 威海市
-     * district : 环翠区
-     * social_bg_aid : 0
-     * create_time : 2017-07-13 17:11:53
-     * user_id : 200030
-     * age : 0
-     * show_age : 1
-     * real_name :
-     * id_number :
-     * social_banner :
-     * add_verify : 0
-     * find_mobile : 0
-     * find_id : 0
-     * find_nick : 0
-     * see_social : 0
-     * effect : 0
-     * hobby :
-     * address :
-     * follow : 0
-     * photos : []
-     */
-
-    private String id;
-    private String ssid;
-    private String pwd;
-    private String nick;
-    private String alias;
-    private String mobile;
-    private String coin;
-    private String room_id;
-    private String latitude;
-    private String longitude;
-    private String province;
-    private String city;
-    private String district;
-    private String social_bg_aid;
-    private String create_time;
-    private String user_id;
-    private String age;
-    private String show_age;
-    private String real_name;
-    private String id_number;
-    private String social_banner;
-    private String social_last_like;
-    private String social_last_comment;
-    private String add_verify;
-    private String find_mobile;
-    private String find_id;
-    private String find_nick;
-    private String see_social;
-    private String effect;
-    private String hobby;
-    private String address;
-    private int follow;
-    private List<SocialPhoto> photos;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getSsid() {return  ssid;}
-
-    public void setSsid(String ssid) { this.ssid = ssid;}
-
-    public String getPwd() {
-        return pwd;
-    }
-
-    public void setPwd(String pwd) {
-        this.pwd = pwd;
-    }
-
-    public String getNick() {
-        return nick;
-    }
-
-    public void setNick(String nick) {
-        this.nick = nick;
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-
-    public String getMobile() {
-        return mobile;
-    }
-
-    public void setMobile(String mobile) {
-        this.mobile = mobile;
-    }
-
-    public String getCoin() {
-        return coin;
-    }
-
-    public void setCoin(String coin) {
-        this.coin = coin;
-    }
-
-    public String getRoom_id() {
-        return room_id;
-    }
-
-    public void setRoom_id(String room_id) {
-        this.room_id = room_id;
-    }
-
-    public String getLatitude() {
-        return latitude;
-    }
-
-    public void setLatitude(String latitude) {
-        this.latitude = latitude;
-    }
-
-    public String getLongitude() {
-        return longitude;
-    }
-
-    public void setLongitude(String longitude) {
-        this.longitude = longitude;
-    }
-
-    public String getProvince() {
-        return province;
-    }
-
-    public void setProvince(String province) {
-        this.province = province;
-    }
-
-    public String getCity() {
-        return city;
-    }
-
-    public void setCity(String city) {
-        this.city = city;
-    }
-
-    public String getDistrict() {
-        return district;
-    }
-
-    public void setDistrict(String district) {
-        this.district = district;
-    }
-
-    public String getSocial_bg_aid() {
-        return social_bg_aid;
-    }
-
-    public void setSocial_bg_aid(String social_bg_aid) {
-        this.social_bg_aid = social_bg_aid;
-    }
-
-    public String getCreate_time() {
-        return create_time;
-    }
-
-    public void setCreate_time(String create_time) {
-        this.create_time = create_time;
-    }
-
-    public String getUser_id() {
-        return user_id;
-    }
-
-    public void setUser_id(String user_id) {
-        this.user_id = user_id;
-    }
-
-    public String getAge() {
-        return age;
-    }
-
-    public void setAge(String age) {
-        this.age = age;
-    }
-
-    public String getShow_age() {
-        return show_age;
-    }
-
-    public void setShow_age(String show_age) {
-        this.show_age = show_age;
-    }
-
-    public String getReal_name() {
-        return real_name;
-    }
-
-    public void setReal_name(String real_name) {
-        this.real_name = real_name;
-    }
-
-    public String getId_number() {
-        return id_number;
-    }
-
-    public void setId_number(String id_number) {
-        this.id_number = id_number;
-    }
-
-    public String getSocial_banner() {
-        return social_banner;
-    }
-
-    public void setSocial_banner(String social_banner) {
-        this.social_banner = social_banner;
-    }
-
-    public String getSocial_last_like() {
-        return social_last_like;
-    }
-
-    public void setSocial_last_like(String social_last_like) {
-        this.social_last_like = social_last_like;
-    }
-
-    public String getSocial_last_comment() {
-        return social_last_comment;
-    }
-
-    public void setSocial_last_comment(String social_last_comment) {
-        this.social_last_comment = social_last_comment;
-    }
-
-    public String getAdd_verify() {
-        return add_verify;
-    }
-
-    public void setAdd_verify(String add_verify) {
-        this.add_verify = add_verify;
-    }
-
-    public String getFind_mobile() {
-        return find_mobile;
-    }
-
-    public void setFind_mobile(String find_mobile) {
-        this.find_mobile = find_mobile;
-    }
-
-    public String getFind_id() {
-        return find_id;
-    }
-
-    public void setFind_id(String find_id) {
-        this.find_id = find_id;
-    }
-
-    public String getFind_nick() {
-        return find_nick;
-    }
-
-    public void setFind_nick(String find_nick) {
-        this.find_nick = find_nick;
-    }
-
-    public String getSee_social() {
-        return see_social;
-    }
-
-    public void setSee_social(String see_social) {
-        this.see_social = see_social;
-    }
-
-    public String getEffect() {
-        return effect;
-    }
-
-    public void setEffect(String effect) {
-        this.effect = effect;
-    }
-
-    public String getHobby() {
-        return hobby;
-    }
-
-    public void setHobby(String hobby) {
-        this.hobby = hobby;
-    }
-
-    public String getAddress() {
-        return address;
-    }
-
-    public void setAddress(String address) {
-        this.address = address;
-    }
-
-    public int getFollow() {
-        return follow;
-    }
-
-    public void setFollow(int follow) {
-        this.follow = follow;
-    }
-
-    public List<SocialPhoto> getPhotos() {
-        return photos;
-    }
-
-    public void setPhotos(List<SocialPhoto> photos) {
-        this.photos = photos;
-    }
-}

+ 0 - 72
app/src/com/sheishuo/app/common/beans/SocialPhoto.java

@@ -1,72 +0,0 @@
-package com.sheishuo.app.common.beans;
-
-/**
- * Created by KN on 2017/8/21.
- */
-
-public class SocialPhoto {
-
-    /**
-     * id : 42
-     * user_id : 200031
-     * aid : 415
-     * inputtime : 2017-08-11 19:59:56
-     * pic : http://whosay.dashgame.com/uploadfile/2017/0811/20170811075956884.jpg
-     * thumb : http://whosay.dashgame.com/uploadfile/2017/0811/thumb_128_128_20170811075956884.jpg
-     */
-
-    private String id;
-    private String user_id;
-    private String aid;
-    private String inputtime;
-    private String pic;
-    private String thumb;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getUser_id() {
-        return user_id;
-    }
-
-    public void setUser_id(String user_id) {
-        this.user_id = user_id;
-    }
-
-    public String getAid() {
-        return aid;
-    }
-
-    public void setAid(String aid) {
-        this.aid = aid;
-    }
-
-    public String getInputtime() {
-        return inputtime;
-    }
-
-    public void setInputtime(String inputtime) {
-        this.inputtime = inputtime;
-    }
-
-    public String getPic() {
-        return pic;
-    }
-
-    public void setPic(String pic) {
-        this.pic = pic;
-    }
-
-    public String getThumb() {
-        return thumb;
-    }
-
-    public void setThumb(String thumb) {
-        this.thumb = thumb;
-    }
-}

File diff suppressed because it is too large
+ 0 - 13
app/src/com/sheishuo/app/common/beans/TradeBean.java


+ 0 - 180
app/src/com/sheishuo/app/common/imageView/GroupHeadImageView.java

@@ -1,180 +0,0 @@
-package com.sheishuo.app.common.imageView;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffXfermode;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-import android.widget.ImageView;
-
-import com.sheishuo.app.R;
-import com.netease.nim.uikit.common.util.media.BitmapDecoder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 聊天室头像合成控件
- * <p/>
- * Created by huangjun on 2015/6/17.
- */
-public class GroupHeadImageView extends ImageView {
-
-    public GroupHeadImageView(Context context) {
-        super(context);
-    }
-
-    public GroupHeadImageView(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public GroupHeadImageView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    private static final int[] headIconResources = new int[]{
-            R.drawable.head_icon_1, R.drawable.head_icon_2, R.drawable.head_icon_3
-    };
-
-    private static final Paint antiPaint = createAntiPaint();
-
-    private static final Paint createAntiPaint() {
-        Paint paint = new Paint();
-        paint.setAntiAlias(true);
-
-        return paint;
-    }
-
-    private static final Paint circlePaint = createCirclePaint();
-
-    private static final Paint createCirclePaint() {
-        Paint paint = new Paint();
-        paint.setAntiAlias(true);
-        paint.setStyle(Paint.Style.STROKE);
-        paint.setColor(Color.WHITE);
-
-        return paint;
-    }
-
-    private static final Paint destInPaint = createDestInPaint();
-
-    private static final Paint createDestInPaint() {
-        Paint paint = new Paint();
-
-        paint.setAntiAlias(true);
-        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
-
-        return paint;
-    }
-
-    private static final Paint maskPaint = createMaskPaint();
-
-    private static final Paint createMaskPaint() {
-        Paint paint = new Paint();
-        paint.setAntiAlias(true);
-
-        paint.setStyle(Paint.Style.FILL);
-        paint.setColor(Color.BLACK);
-
-        return paint;
-    }
-
-    private static final float o = 11f / 36f;
-    private static final float i = 10f / 36f;
-
-    private List<Bitmap> bitmaps;
-
-    /**
-     * 确定三个RECT(外圆,内圆),左上角的起点
-     */
-    private static final float[][][] p = new float[][][]{
-            new float[][]{
-                    new float[]{0.5f - o, 0},
-                    new float[]{0.5f - i, o - i},
-            },
-            new float[][]{
-                    new float[]{1.0f - o * 2, 1.0f - o * 2},
-                    new float[]{1.0f - o * 2 + o - i, 1.0f - o * 2 + o - i},
-            },
-            new float[][]{
-                    new float[]{0, 1.0f - o * 2},
-                    new float[]{o - i, 1.0f - o * 2 + o - i},
-            },
-
-    };
-
-    public void loadResourceImage() {
-        int width = getWidth();
-        int height = getHeight();
-
-        this.bitmaps = new ArrayList<>(3);
-        for (int i = 0; i < 3; i++) {
-            bitmaps.add(BitmapDecoder.decodeSampled(getResources(), headIconResources[i], width, height));
-        }
-
-        invalidate();
-    }
-
-    @Override
-    public void draw(Canvas canvas) {
-        // bounds
-        int width = getWidth();
-        int height = getHeight();
-
-        super.draw(canvas);
-
-        // to canvas
-        join3(canvas, width, height, this.bitmaps);
-    }
-
-    private final void join3(Canvas canvas, int destWidth, int destHeight, List<Bitmap> bitmaps) {
-        if (bitmaps == null) {
-            return;
-        }
-
-        int size = Math.min(p.length, bitmaps.size());
-        for (int index = size - 1; index >= 0; index--) {
-            Bitmap bitmap = bitmaps.get(index);
-
-            // 矩形区域
-            float[] posOut = new float[]{
-                    p[index][0][0] * destWidth, p[index][0][1] * destHeight
-            };
-
-            // 外圈内圈半径
-            float rdsOut = destWidth * o;
-            float rdsIn = destWidth * i;
-
-            // 头像层
-            RectF rect = new RectF(posOut[0], posOut[1], posOut[0] + 2 * rdsOut, posOut[1] + 2 * rdsOut);
-            canvas.saveLayer(rect, null, Canvas.ALL_SAVE_FLAG);
-            // 对头像位图进行缩放
-            Matrix matrix = new Matrix();
-            matrix.postScale((float) destWidth / bitmap.getWidth(), (float) destHeight / bitmap.getHeight());
-            matrix.postScale(2 * o, 2 * o);
-
-            canvas.translate(posOut[0], posOut[1]);
-            canvas.drawBitmap(bitmap, matrix, antiPaint);
-            canvas.translate(-posOut[0], -posOut[1]);
-
-            Paint paint = circlePaint;
-            paint.setStrokeWidth(rdsOut - rdsIn);
-            canvas.drawCircle(posOut[0] + rdsOut, posOut[1] + rdsOut, rdsOut, paint);
-
-            // MASK层
-            canvas.saveLayer(rect, destInPaint, Canvas.ALL_SAVE_FLAG);
-            canvas.drawCircle(posOut[0] + rdsOut, posOut[1] + rdsOut, rdsOut, maskPaint);
-
-            // MASK层与头像层合并->MERGE层
-            canvas.restore();
-
-            // MERGE层与DEFAULT层合并
-            canvas.restore();
-        }
-    }
-}

+ 0 - 59
app/src/com/sheishuo/app/common/infra/AbstractTaskWorker.java

@@ -1,59 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.concurrent.Executor;
-
-public abstract class AbstractTaskWorker {	
-	public interface ExecuteCallback {
-		public void onExecuted(Task task, boolean unschedule);
-	}
-
-	/**
-	 * execute callback
-	 */
-	private ExecuteCallback executeCallback;
-
-	/**
-	 * dispatch
-	 * @param task
-	 * @return Executor
-	 */
-	protected abstract Executor getTaskHost(Task task);
-
-	public AbstractTaskWorker() {
-
-	}
-
-	public void setExecuteCallback(ExecuteCallback executeCallback) {
-		this.executeCallback = executeCallback;
-	}
-
-	public void execute(Task task) {
-		getExecutor(task).execute(getRunnable(task));
-	}
-
-	private final Executor getExecutor(Task task) {
-		if (task.info.background) {
-			Executor executor = getTaskHost(task);
-			if (executor != null) {
-				return executor;
-			}
-		}
-
-		return TaskExecutor.IMMEDIATE_EXECUTOR;
-	}
-	
-	private final Runnable getRunnable(final Task task) {
-		return new Runnable() {
-			@Override
-			public void run() {
-				// schedule
-				boolean unschedule = task.schedule();
-				
-				// callback
-				if (executeCallback != null) {
-					executeCallback.onExecuted(task, unschedule);
-				}
-			}
-		};
-	}
-}

+ 0 - 15
app/src/com/sheishuo/app/common/infra/CallbackWrapper.java

@@ -1,15 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public class CallbackWrapper<T> implements TaskObserver {
-	protected T callback;
-	
-	public CallbackWrapper(T callback) {
-		this.callback = callback;
-	}
-
-	@Override
-	public void onTaskResult(Task task, Object[] results) {}
-
-	@Override
-	public void onTaskProgress(Task task, Object[] params) {}
-}

+ 0 - 26
app/src/com/sheishuo/app/common/infra/CompoundTaskWorker.java

@@ -1,26 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.concurrent.Executor;
-
-public class CompoundTaskWorker extends AbstractTaskWorker {
-	private AbstractTaskWorker[] workers;
-	
-	public CompoundTaskWorker(AbstractTaskWorker... workers) {
-		this.workers = workers;
-	}
-	
-	protected int dispatch(Task task) {
-		return 0;
-	}
-	
-	@Override
-	protected Executor getTaskHost(Task task) {
-		int index = dispatch(task);
-		
-		if (index >= 0 && index < workers.length) {
-			return workers[index].getTaskHost(task);
-		}
-		
-		return null;
-	}
-}

+ 0 - 22
app/src/com/sheishuo/app/common/infra/DefaultTask.java

@@ -1,22 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public abstract class DefaultTask extends ManagedTask {
-    private DefaultTaskCallback callback;
-
-    public DefaultTask(DefaultTaskCallback callback) {
-        this.callback = callback;
-    }
-
-    @Override
-    protected void onTaskResult(Object[] results) {
-        if (results != null) {
-            notifyResult((Integer) results[0], results[1]);
-        }
-    }
-
-    private void notifyResult(int result, Object attachment) {
-        if (callback != null) {
-            callback.onFinish(key(), result, attachment);
-        }
-    }
-}

+ 0 - 5
app/src/com/sheishuo/app/common/infra/DefaultTaskCallback.java

@@ -1,5 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public interface DefaultTaskCallback {
-    public void onFinish(String key, int result, Object attachment);
-}

+ 0 - 15
app/src/com/sheishuo/app/common/infra/DefaultTaskManager.java

@@ -1,15 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public class DefaultTaskManager extends TaskManager {
-    public DefaultTaskManager() {
-    	this(new DefaultTaskWorker());
-    }
-    
-    public DefaultTaskManager(String name) {
-    	this(new DefaultTaskWorker(name));
-    }
-    
-    public DefaultTaskManager(AbstractTaskWorker worker) {
-    	super(new DefaultTaskScheduler(worker));
-    }
-}

+ 0 - 69
app/src/com/sheishuo/app/common/infra/DefaultTaskRegistry.java

@@ -1,69 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-
-public class DefaultTaskRegistry implements TaskRegistry {
-	/** tasks */
-	public HashMap<String, Task> tasks = new HashMap<String, Task>();
-	
-	@Override
-	public Task register(Task task) {
-		// key
-		String key = task.key();
-		
-		synchronized (tasks) {
-			Task tsk = tasks.get(key);
-
-			if (tsk == null) {
-				tsk = task;
-				
-				tasks.put(key, task);
-			}
-			
-			return tsk;
-		}
-	}
-	
-    @Override
-	public Task unregister(Task task) {
-		// key
-		String key = task.key();
-		
-		synchronized (tasks) {
-			return tasks.remove(key);
-		}
-	}
-
-	@Override
-	public boolean registered(Task task) {
-		// key
-		String key = task.key();
-		
-		synchronized (tasks) {
-			return tasks.containsKey(key);
-		}
-	}
-	
-	@Override
-	public Task query(String key) {
-		synchronized (tasks) {
-			return tasks.get(key);
-		}
-	}
-
-    @Override
-    public Collection<Task> queryAll() {
-        synchronized (tasks) {
-            return new ArrayList<Task>(tasks.values());
-        }
-    }
-    
-    @Override
-    public int count() {
-        synchronized (tasks) {
-            return tasks.size();
-        }
-    }
-}

+ 0 - 94
app/src/com/sheishuo/app/common/infra/DefaultTaskScheduler.java

@@ -1,94 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import android.os.Handler;
-import android.os.Looper;
-
-public class DefaultTaskScheduler implements TaskScheduler {
-	/**
-	 * registry
-	 */
-	private final TaskRegistry registry = new DefaultTaskRegistry();
-	
-	/**
-	 * execute callback
-	 */
-	private final AbstractTaskWorker.ExecuteCallback executeCallback = new AbstractTaskWorker.ExecuteCallback() {
-		@Override
-		public void onExecuted(Task task, boolean unschedule) {
-			if (unschedule) {
-				unschedule(task);
-			}
-		}
-	};
-	
-	/**
-	 * worker
-	 */
-	private final AbstractTaskWorker worker;
-	
-	private final Handler handler;
-	
-    private static final Handler sharedHandler = new Handler(Looper.getMainLooper());
-
-	public DefaultTaskScheduler(AbstractTaskWorker worker) {
-		this(worker, sharedHandler);
-	}
-		
-	public DefaultTaskScheduler(AbstractTaskWorker worker, Handler handler) {
-		worker.setExecuteCallback(executeCallback);
-		
-		this.worker = worker;
-		this.handler = handler;
-	}
-	
-	@Override
-	public Task schedule(boolean background, String key, Task task, Object... params) {
-		// attach
-		task.info = new Task.Info(background, key, params);
-		task.state = new Task.State();
-		task.handler = handler;
-		
-		// register
-		Task tsk = registry.register(task);
-		
-		if (task == tsk) {
-			// execute
-			worker.execute(task);
-		}
-	
-		return tsk;
-	}
-	
-	@Override
-	public void reschedule(Task task) {
-		if (registry.registered(task)) {
-			// execute
-			worker.execute(task);
-		}
-	}
-
-    @Override
-	public void unschedule(Task task) {
-		registry.unregister(task);
-	}
-	
-	@Override
-	public Task scheduled(String key) {
-		return registry.query(key);
-	}
-	
-	@Override
-	public int count() {
-		return registry.count();
-	}
-	
-    @Override
-    public void cancelAll() {
-        for (Task task : registry.queryAll()) {
-            if (task.scheduled() > 0) {
-                registry.unregister(task);
-            }
-            task.cancel();
-        }
-    }
-}

+ 0 - 15
app/src/com/sheishuo/app/common/infra/DefaultTaskWorker.java

@@ -1,15 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public class DefaultTaskWorker extends TaskWorker {
-	public DefaultTaskWorker() {
-		this("Default");
-	}
-	
-	public DefaultTaskWorker(String name) {
-		this(name, TaskExecutor.defaultConfig);
-	}
-
-	public DefaultTaskWorker(String name, TaskExecutor.Config config) {
-		super(new TaskExecutor("TW#" + name, config));
-	}
-}

+ 0 - 95
app/src/com/sheishuo/app/common/infra/Handlers.java

@@ -1,95 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.HashMap;
-
-import android.content.Context;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.text.TextUtils;
-
-public final class Handlers {
-	public static final String DEFAULT_TAG = "Default";
-	
-	private static Handlers instance;
-	
-	public static synchronized Handlers sharedInstance() {
-		if (instance == null) {
-			instance = new Handlers();
-		}
-		
-		return instance;
-	}
-	
-	private static Handler sharedHandler;
-	
-	/**
-	 * get shared handler for main looper
-	 * @param context
-	 * @return
-	 */
-	public static final Handler sharedHandler(Context context) {
-		/**
-		 * duplicate handlers !!! i don't care
-		 */
-		
-		if (sharedHandler == null) {
-			sharedHandler = new Handler(context.getMainLooper());
-		}
-		
-		return sharedHandler;
-	}
-	
-	/**
-	 * get new handler for main looper
-	 * @param context
-	 * @return
-	 */
-	public static final Handler newHandler(Context context) {
-		return new Handler(context.getMainLooper());
-	}
-	
-	private Handlers() {
-		
-	}
-	
-	/**
-	 * get new handler for a background default looper
-	 * @return
-	 */
-	public final Handler newHandler() {
-		return newHandler(DEFAULT_TAG);
-	}
-	
-	/**
-	 * get new handler for a background stand alone looper identified by tag
-	 * @param tag
-	 * @return
-	 */
-	public final Handler newHandler(String tag) {
-		return new Handler(getHandlerThread(tag).getLooper());
-	}
-	
-	private final HashMap<String, HandlerThread> threads = new HashMap<String, HandlerThread>();
-	
-	private final HandlerThread getHandlerThread(String tag) {
-		HandlerThread handlerThread = null;
-		
-		synchronized (threads) {
-			handlerThread = threads.get(tag);
-			
-			if (handlerThread == null) {
-				handlerThread = new HandlerThread(nameOfTag(tag));
-				
-				handlerThread.start();
-				
-				threads.put(tag, handlerThread);
-			}
-		}
-		
-		return handlerThread;
-	}
-	
-	private final static String nameOfTag(String tag) {
-		return "HT-" + (TextUtils.isEmpty(tag) ? DEFAULT_TAG : tag);
-	}
-}

+ 0 - 244
app/src/com/sheishuo/app/common/infra/ManagedTask.java

@@ -1,244 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import android.text.TextUtils;
-
-import com.netease.nim.uikit.common.util.log.LogUtil;
-
-public abstract class ManagedTask extends ObservableTask {
-	private static final String TAG = "ManagedTask";
-	private static final String ENCLOSURE = "()";
-	
-	private static AtomicInteger serial = new AtomicInteger();
-	
-	private TaskManager taskManager;
-	
-	private TaskObserver taskObserver;
-	
-	private final TaskObserver getTaskObserver() {
-		if (taskObserver == null) {
-			taskObserver = new TaskObserver() {
-				@Override
-				public void onTaskResult(Task task, Object[] results) {
-					if (!cancelled()) {
-						onDepTaskResult(task, results);						
-					}
-				}
-				
-				@Override
-				public void onTaskProgress(Task task, Object[] params) {
-					if (!cancelled()) {
-						onDepTaskProgress(task, params);
-					}
-				}
-			};
-		}
-		
-		return taskObserver;
-	}
-	
-	private ArrayList<ManagedTask> links = new ArrayList<ManagedTask>();
-
-	/**
-	 * on task result
-	 * @param results
-	 */
-	protected void onTaskResult(Object[] results) {}
-
-	/**
-	 * on task progress
-	 * @param params
-	 */
-	protected void onTaskProgress(Object[] params) {}
-	
-	/**
-	 * on dependent task result
-	 * @param task
-	 * @param results
-	 */
-	protected void onDepTaskResult(Task task, Object[] results) {}
-
-	/**
-	 * on dependent task progress
-	 * @param task
-	 * @param params
-	 */
-	protected void onDepTaskProgress(Task task, Object[] params) {}
-	
-	/**
-	 * on task result
-	 * @param results
-	 */
-	@Override
-	protected final void onPublishResult(Object[] results) {
-		// self
-		if (!cancelled()) {
-			onTaskResult(results);
-		}			
-		notifyTaskResult(results);
-		
-		// links
-		synchronized (links) {
-			for (ManagedTask link : links) {
-				link.onPublishResult(results);
-			}
-		}
-	}
-	
-	/**
-	 * on task progress
-	 * @param params
-	 */
-	@Override
-	protected final void onPublishProgress(Object[] params) {
-		// self
-		if (!cancelled()) {
-			onTaskProgress(params);
-		}
-		notifyTaskProgress(params);
-		
-		// links
-		synchronized (links) {
-			for (ManagedTask link : links) {
-				link.onPublishProgress(params);
-			}
-		}
-	}
-	
-	/**
-	 * attach task manager
-	 * @param taskManager
-	 */
-	/*package*/ final void attachTaskManager(TaskManager taskManager) {
-		this.taskManager = taskManager;
-	}
-	
-	/**
-	 * an same task has been scheduled
-	 * 
-	 * @param task
-	 */
-	/*package*/ final void onSameTask(ManagedTask task) {
-		// link
-		task.link(this);
-	}
-	
-	/**
-	 * make task key
-	 * 
-	 * @param task
-	 * @param params
-	 * @return
-	 */
-	/*package*/ static final String makeTaskKey(ManagedTask task, Object... params) {
-		String tag = task.getTaskTag();
-		String id = task.getTaskId();
-		String extraId = task.getTaskExtraId(params);
-		
-		StringBuilder sb = new StringBuilder();
-
-		// tag
-		sb.append("T");
-		sb.append(ENCLOSURE.charAt(0));
-		sb.append(tag);
-		sb.append(ENCLOSURE.charAt(1));
-		
-		// id
-		sb.append("I");
-		sb.append(ENCLOSURE.charAt(0));
-		sb.append(id);
-		sb.append(ENCLOSURE.charAt(1));
-		
-		// extra id
-		if (!TextUtils.isEmpty(extraId)) {
-			sb.append("E");
-			sb.append(ENCLOSURE.charAt(0));
-			sb.append(extraId);
-			sb.append(ENCLOSURE.charAt(1));
-		}
-		
-		return sb.toString();
-	}
-		
-	/**
-	 * get task tag
-	 * 
-	 * @return task tag
-	 */
-	protected String getTaskTag() {
-		return getClass().getSimpleName();
-	}
-	
-	/**
-	 * get task id
-	 * 
-	 * @return task id
-	 */
-	protected String getTaskId() {
-		return Integer.toString(serial.getAndIncrement());
-	}
-	
-	/**
-	 * get task extra id
-	 * 
-	 * @param params
-	 * @return
-	 */
-	protected String getTaskExtraId(Object... params) {
-		return null;
-	}
-
-	/**
-	 * schedule task
-	 * 
-	 * @param background
-	 * @param task
-	 * @param params
-	 * @return task key
-	 */
-	protected String schedule(boolean background, ManagedTask task, Object... params) {
-		// register		
-		task.registerObserver(getTaskObserver());
-
-		// execute
-		return taskManager.schedule(background, task, params);
-	}
-	
-	/**
-	 * reschedule self
-	 */
-	protected void reschedule() {
-		taskManager.reschedule(this);
-	}
-
-    /**
-     * cancel linked tasks recursively
-     */
-    @Override
-    public void cancel() {
-        super.cancel();
-        synchronized (links) {
-            for (ManagedTask link : links) {
-                link.cancel();
-            }
-        }
-    }
-
-    /**
-	 * link task
-	 * @param task
-	 */
-	private final void link(ManagedTask task) {
-		trace("link " + dump(true));
-		
-		synchronized (links) {
-			links.add(task);
-		}
-	}
-	
-	private static final void trace(String msg) {
-		LogUtil.d(TAG, msg);
-	}
-}

+ 0 - 53
app/src/com/sheishuo/app/common/infra/Observable.java

@@ -1,53 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class Observable<T> {
-    protected final ArrayList<T> mObservers = new ArrayList<T>();
-
-    public void registerObserver(T observer) {
-        if (observer == null) {
-        	return;
-        }
-        synchronized(mObservers) {
-            if (mObservers.contains(observer)) {
-            	return;
-            }
-            mObservers.add(observer);
-        }
-    }
-
-    public void unregisterObserver(T observer) {
-        if (observer == null) {
-        	return;
-        }
-        synchronized(mObservers) {
-            int index = mObservers.indexOf(observer);
-            if (index == -1) {
-            	return;
-            }
-            mObservers.remove(index);
-        }
-    }
-
-    public void unregisterAll() {
-        synchronized(mObservers) {
-            mObservers.clear();
-        }        
-    }
-	
-	protected List<T> getObservers() {
-    	return getObservers(true);
-    }
-    
-    protected List<T> getObservers(boolean sync) {
-    	if (sync) {
-	        synchronized(mObservers) {
-	        	return new ArrayList<T>(mObservers);
-	        }
-    	} else {
-    		return mObservers;
-    	}
-    }
-}

+ 0 - 39
app/src/com/sheishuo/app/common/infra/ObservableTask.java

@@ -1,39 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public abstract class ObservableTask extends Task {
-	private TaskObservable observable = new TaskObservable();
-	
-	/**
-	 * register observer
-	 * @param observer
-	 */
-	public void registerObserver(TaskObserver observer) {
-		observable.registerObserver(observer);
-	}
-	
-	/**
-	 * unregister observer
-	 * @param observer
-	 */
-	public void unregisterObserver(TaskObserver observer) {
-		observable.unregisterObserver(observer);
-	}
-
-	/**
-	 * notify task result
-	 * @param results
-	 */
-	protected final void notifyTaskResult(Object[] results) {
-		// observable
-		observable.onTaskResult(this, results);
-	}
-	
-	/**
-	 * notify task progress
-	 * @param params
-	 */
-	protected final void notifyTaskProgress(Object[] params) {
-		// observable
-		observable.onTaskProgress(this, params);
-	}
-}

+ 0 - 46
app/src/com/sheishuo/app/common/infra/Params.java

@@ -1,46 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public final class Params {	
-	public static final int[] getDimension(Object[] params, int index, int[] def) {
-		if (params != null && params.length > index && params[index] != null) {
-			if (params[index] instanceof int[]) {
-				int[] param = (int[])params[index];
-				if (param.length > 1) {
-					return param;
-				}
-			}
-		}
-		
-		return def;
-	} 
-	
-	public static final String getString(Object[] params, int index, String def) {
-		if (params != null && params.length > index && params[index] != null) {
-			if (params[index] instanceof String) {
-				String param = (String)params[index];
-				return param;
-			}
-		}
-		
-		return def;
-	} 
-	
-	public static final boolean getBoolean(Object[] params, int index, boolean def) {
-		if (params != null && params.length > index && params[index] != null) {
-			if (params[index] instanceof Boolean) {
-				Boolean param = (Boolean)params[index];
-				return param;
-			}
-		}
-		
-		return def;
-	}
-	
-	public static final Object getObject(Object[] params, int index, Object def) {
-		if (params != null && params.length > index && params[index] != null) {
-			return params[index];
-		}
-		
-		return def;
-	}
-}

+ 0 - 258
app/src/com/sheishuo/app/common/infra/Task.java

@@ -1,258 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import android.os.Handler;
-
-public abstract class Task {
-	private static final String ENCLOSURE = "<>";
-	private static final int RETRY_COUNT = 1;
-	
-	/*package*/ static class Info {
-		/** background */
-		boolean background;
-
-		/** key */
-		String key;
-		
-		/** parameters */
-		Object[] params;
-		
-		Info(boolean background, String key, Object[] params) {
-			this.background = background;
-			this.key = key;
-			this.params = params;
-		}
-		
-		@Override
-		public String toString() {
-			StringBuilder sb = new StringBuilder();
-	
-			sb.append("B");
-			sb.append(ENCLOSURE.charAt(0));
-			sb.append(background ? "T" : "F");
-			sb.append(ENCLOSURE.charAt(1));
-			
-			sb.append(" ");
-
-			sb.append("K");
-			sb.append(ENCLOSURE.charAt(0));
-			sb.append(key);
-			sb.append(ENCLOSURE.charAt(1));
-
-			return sb.toString();
-		}
-	}
-	
-	/*package*/ static class State {
-		/** cancelled */
-		boolean cancelled;
-		
-		/** chances */
-		int chances;
-		
-		/** pending */
-		boolean pending;
-
-		/** fault */
-		boolean fault;
-
-		State() {
-			
-		}
-		
-		@Override
-		public String toString() {
-			StringBuilder sb = new StringBuilder();
-			
-			sb.append("C");
-			sb.append(ENCLOSURE.charAt(0));
-			sb.append(chances);
-			sb.append(ENCLOSURE.charAt(1));
-
-			sb.append(" ");
-			
-			sb.append("P");
-			sb.append(ENCLOSURE.charAt(0));
-			sb.append(pending ? "T" : "F");
-			sb.append(ENCLOSURE.charAt(1));
-
-			return sb.toString();
-		}
-	}
-		
-	/** handler for publish states */
-	/*package*/ Handler handler;
-	
-	/** task info */
-	/*package*/ Info info;
-	
-	/** task state */
-	/*package*/ State state;
-	
-	public void cancel() {
-		state.cancelled = true;
-	}
-	
-	public void setProperty(int prop, Object data) {
-		// NOP
-	}
-	
-	protected boolean background() {
-		return info.background;
-	}
-
-	protected String key() {
-		return info.key;
-	}
-	
-	protected Object[] params() {
-		return info.params;
-	}
-	
-	protected boolean cancelled() {
-		return state.cancelled;
-	}
-	
-	protected int scheduled() {
-		return state.chances;
-	}
-	
-	protected void pending() {
-		state.pending = true;
-	}
-	
-	protected boolean giveup() {
-		// give up
-		boolean giveup = scheduled() > RETRY_COUNT;
-		
-		// mark pending if proceed
-		if (!giveup) {
-			pending();
-		}
-		
-		return giveup;
-	}
-	
-	/*package*/ boolean schedule() {
-		// update chances
-		state.chances++;
-		// reset pending
-		state.pending = false;
-
-		// execute
-		Object[] results = null;
-		try {
-			results = execute(info.params);
-		} catch (Throwable tr) {
-			onException(tr);
-
-			// fault
-			state.fault = true;
-		}
-		
-		// no fault and pending
-		if (!state.fault && state.pending) {
-			// not proceed
-			return false;
-		}
-		
-		// publish result
-		publishResult(results);
-		
-		return true;
-	}
-	
-	/**
-	 * execute
-	 *
-	 * @param params
-	 * @return results
-	 */
-	protected abstract Object[] execute(Object[] params);
-	
-	/**
-	 * on exception
-	 * @param tr throwable
-	 */
-	protected void onException(Throwable tr) {
-		// save
-//		AppCrashHandler.getInstance(null).saveException(tr, false);
-	};
-	
-	/**
-	 * on handle result
-	 * @param results
-	 */
-	protected void onHandleResult(Object[] results) {};
-	
-	/**
-	 * on publish result
-	 * @param results
-	 */
-	protected void onPublishResult(Object[] results) {}
-
-	/**
-	 * on publish progress
-	 * @param params
-	 */
-	protected void onPublishProgress(Object[] params) {}
-			
-	/**
-	 * publish result
-	 * @param results
-	 */
-	protected final void publishResult(Object[] results) {
-		publish(true, results);
-	}
-
-	/**
-	 * publish progress
-	 * @param params
-	 */
-	protected final void publishProgress(Object[] params) {
-		publish(false, params);			
-	}
-	
-	private final void publish(final boolean result, final Object[] params) {
-		if (info.background && handler != null) {
-			// shift to looper thread of handler to publish
-			handler.post(new Runnable() {
-				@Override
-				public void run() {
-					// publish on current thread
-					onPublish(result, params);
-				}	
-			});
-		} else {
-			// publish on current thread
-			onPublish(result, params);
-		}
-	}
-	
-	private final void onPublish(boolean result, Object[] params) {
-		if (result) {		
-			onHandleResult(params);
-			onPublishResult(params);
-		} else {
-			onPublishProgress(params);
-		}
-	}
-	
-	public final String dump(boolean statefull) {
-		StringBuilder sb = new StringBuilder();
-
-		// info
-		sb.append(info);
-		// state
-		if (statefull) {
-			sb.append(" ");
-			sb.append(state);
-		}
-		
-		return sb.toString();
-	}
-	
-	@Override
-	public String toString() {
-		return dump(true);
-	}
-}

+ 0 - 233
app/src/com/sheishuo/app/common/infra/TaskExecutor.java

@@ -1,233 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.Comparator;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.PriorityBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import android.annotation.TargetApi;
-import android.os.Build;
-
-
-public class TaskExecutor implements Executor {
-	private final static int QUEUE_INIT_CAPACITY = 11;
-
-	private static final int CORE = 3;
-
-	private static final int MAX = 5;
-
-	private static final int TIMEOUT = 30 * 1000;
-	
-	public static final Executor IMMEDIATE_EXECUTOR = new Executor() {
-		@Override
-		public void execute(Runnable command) {
-			 command.run();			
-		}
-	};
-	
-	public static class Config {
-		public int core;
-
-		public int max;
-
-		public int timeout;
-
-		public boolean allowCoreTimeOut;
-
-		public Config(int core, int max, int timeout, boolean allowCoreTimeOut) {
-			this.core = core;
-			this.max = max;
-			this.timeout = timeout;
-			this.allowCoreTimeOut = allowCoreTimeOut;
-		}
-	}
-
-	public static Config defaultConfig = new Config(CORE, MAX, TIMEOUT, true);
-
-	private final String name;
-
-	private final Config config;
-
-	private ExecutorService service;
-
-	public TaskExecutor(String name) {
-		this(name, defaultConfig);
-	}
-
-	public TaskExecutor(String name, Config config) {
-		this(name, config, true);
-	}
-
-	public TaskExecutor(String name, Config config, boolean startup) {
-		this.name = name;
-		this.config = config;
-
-		if (startup) {
-			startup();
-		}
-	}
-
-	public void startup() {
-		synchronized (this) {
-			// has startup
-			if (service != null && !service.isShutdown()) {
-				return;
-			}
-
-			// create
-			service = createExecutor(config);
-		}
-	}
-
-	public void shutdown() {
-		ExecutorService executor = null;
-
-		synchronized (this) {
-			// swap
-			if (service != null) {
-				executor = service;
-				service = null;
-			}
-		}
-
-		if (executor != null) {
-			// shutdown
-			if (!executor.isShutdown()) {
-				executor.shutdown();
-			}
-
-			// recycle
-			executor = null;
-		}
-	}
-
-	@Override
-	public void execute(Runnable runnable) {
-		// executeRunnable runnable with default priority
-		executeRunnable(new PRunnable(runnable, 0));
-	}
-
-	public Future<?> submit(Runnable runnable) {
-		synchronized (this) {
-			if (service == null || service.isShutdown()) {
-				return null;
-			}
-			return service.submit(new PRunnable(runnable, 0));
-		}
-	}
-
-	public void execute(Runnable runnable, int priority) {
-		// executeRunnable runnable with priority
-		executeRunnable(new PRunnable(runnable, priority));
-	}
-
-	private void executeRunnable(Runnable runnable) {
-		synchronized (this) {
-			// has shutdown, reject
-			if (service == null || service.isShutdown()) {
-				return;
-			}
-
-			// execute
-			service.execute(runnable);
-		}
-	}
-
-	private ExecutorService createExecutor(Config config) {
-		ThreadPoolExecutor service = new ThreadPoolExecutor(config.core, config.max, config.timeout,
-				TimeUnit.MILLISECONDS, new PriorityBlockingQueue<Runnable>(QUEUE_INIT_CAPACITY, mQueueComparator),
-				new TaskThreadFactory(name), new ThreadPoolExecutor.DiscardPolicy());
-
-		allowCoreThreadTimeOut(service, config.allowCoreTimeOut);
-
-		return service;
-	}
-
-	private static class PRunnable implements Runnable {
-		private static int sSerial = 0;
-
-		private Runnable runnable;
-
-		private int priority;
-
-		private int serial;
-
-		public PRunnable(Runnable r, int p) {
-			serial = sSerial++;
-			runnable = r;
-			priority = p;
-		}
-
-		@Override
-		public void run() {
-			if (runnable != null) {
-				runnable.run();
-			}
-		}
-
-		public static final int compare(PRunnable r1, PRunnable r2) {
-			if (r1.priority != r2.priority) {
-				return r2.priority - r1.priority;
-			} else {
-				return r1.serial - r2.serial;
-			}
-		}
-	}
-
-	Comparator<Runnable> mQueueComparator = new Comparator<Runnable>() {
-
-		@Override
-		public int compare(Runnable lhs, Runnable rhs) {
-			PRunnable r1 = (PRunnable) lhs;
-			PRunnable r2 = (PRunnable) rhs;
-
-			return PRunnable.compare(r1, r2);
-		}
-	};
-
-	static class TaskThreadFactory implements ThreadFactory {
-		private final ThreadGroup mThreadGroup;
-
-		private final AtomicInteger mThreadNumber = new AtomicInteger(1);
-
-		private final String mNamePrefix;
-
-		TaskThreadFactory(String name) {
-			SecurityManager s = System.getSecurityManager();
-
-			mThreadGroup = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
-
-			mNamePrefix = name + "#";
-		}
-
-		public Thread newThread(Runnable r) {
-			Thread t = new Thread(mThreadGroup, r, mNamePrefix + mThreadNumber.getAndIncrement(), 0);
-
-			// no daemon
-			if (t.isDaemon())
-				t.setDaemon(false);
-
-			// normal priority
-			if (t.getPriority() != Thread.NORM_PRIORITY)
-				t.setPriority(Thread.NORM_PRIORITY);
-
-			return t;
-		}
-	}
-
-	private static final void allowCoreThreadTimeOut(ThreadPoolExecutor service, boolean value) {
-		if (Build.VERSION.SDK_INT >= 9) {
-			allowCoreThreadTimeOut9(service, value);
-		}
-	}
-
-	@TargetApi(9)
-	private static final void allowCoreThreadTimeOut9(ThreadPoolExecutor service, boolean value) {
-		service.allowCoreThreadTimeOut(value);
-	}
-}

+ 0 - 65
app/src/com/sheishuo/app/common/infra/TaskFrequencyController.java

@@ -1,65 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 控制任务执行频率,允许调用根据任务类型,设定最小的执行间隔。
- * 任务类型默认就是任务的类名,如果同一种任务需要再细分,由用户提供自定义的tag
- */
-public class TaskFrequencyController {
-
-    private static Map<String, Long> taskTime = new HashMap<String, Long>();
-
-    public static<T> T runTask(ControllableTask<T> task, int frequencyInS, T def) {
-        String key = makeKey(task);
-        Long lastTime = taskTime.get(key);
-        long current = new Date().getTime() / 1000;
-        if (lastTime != null && current - lastTime < frequencyInS) {
-            return def;
-        }
-
-        taskTime.put(key, current);
-        return task.run();
-    }
-
-    public static boolean runTask(VoidControllableTask task, int frequencyInS) {
-        String key = makeKey(task);
-        Long lastTime = taskTime.get(key);
-        long current = new Date().getTime() / 1000;
-        if (lastTime != null && current - lastTime < frequencyInS) {
-            return false;
-        }
-
-        taskTime.put(key, current);
-        task.run();
-        return true;
-    }
-
-    public static void reset() {
-        taskTime.clear();
-    }
-
-    private static interface IControllableTask {
-        public String tag();
-    }
-
-    public static abstract class ControllableTask<T> implements IControllableTask {
-        public String tag() {
-            return getClass().getSimpleName();
-        }
-        public abstract T run();
-    }
-
-    public static abstract class VoidControllableTask implements IControllableTask {
-        public String tag() {
-            return getClass().getSimpleName();
-        }
-        public abstract void run();
-    }
-
-    private static String makeKey(IControllableTask task) {
-        return task.getClass().getName() + "#" + task.tag();
-    }
-}

+ 0 - 82
app/src/com/sheishuo/app/common/infra/TaskManager.java

@@ -1,82 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public class TaskManager {
-	/** task scheduler */
-	private TaskScheduler ts;
-
-    private boolean shutdown = false;
-
-	public TaskManager(TaskScheduler ts) {
-		this.ts = ts;
-        TaskManagerRegistry.register(this);
-	}
-
-	public String schedule(ManagedTask task, Object... params) {
-		return schedule(true, task, params);
-	}
-
-	public String schedule(boolean background, ManagedTask task, Object... params) {
-        // check state
-        if (shutdown) {
-            return null;
-        }
-
-		// attach
-		task.attachTaskManager(this);
-
-		// as task key
-		String key = ManagedTask.makeTaskKey(task, params);
-
-		// execute
-		ManagedTask tsk = (ManagedTask) ts.schedule(background, key, task, params);
-
-		// same
-		if (tsk != task) {
-			task.onSameTask(tsk);
-		}
-
-		// result
-		return key;
-	}
-
-	public void reschedule(ManagedTask task) {
-        // check state
-        if (shutdown) {
-            return;
-        }
-
-		ts.reschedule(task);
-	}
-
-	public boolean scheduled(String key) {
-		return ts.scheduled(key) != null;
-	}
-
-    public int count() {
-    	return ts.count();
-    }
-
-	public void cancel(String key) {
-		Task task = ts.scheduled(key);
-		
-		if (task != null) {
-			task.cancel();
-		}
-	}
-
-    public void shutdown() {
-        shutdown = true;
-        cancelAll();
-    }
-    public void cancelAll() {
-        ts.cancelAll();
-    }
-    	
-	public void setProperty(String key, int prop, Object data) { 
-		Task task = ts.scheduled(key);
-		
-		if (task != null) {
-			task.setProperty(prop, data);
-		}
-	}
-}

+ 0 - 67
app/src/com/sheishuo/app/common/infra/TaskManagerRegistry.java

@@ -1,67 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.content.Context;
-
-public class TaskManagerRegistry {
-    private static List<WeakReference<TaskManager>> managers = new ArrayList<WeakReference<TaskManager>>();
-
-    public static void register(TaskManager manager) {
-        synchronized (managers) {
-            managers.add(new WeakReference<TaskManager>(manager));
-        }
-    }
-    
-    public static void waitAll(final Context context, final Runnable done, final int max, final int interval) {
-		cancelAll(true);
-
-		Handlers.sharedHandler(context).postDelayed(new Runnable() {
-			int count;
-
-			@Override
-			public void run() {
-				if (!idle() && count++ < max) {
-					Handlers.sharedHandler(context).postDelayed(this, interval);
-				} else {
-					done.run();
-				}
-			}
-		}, interval);
-	}
-
-    private static void cancelAll(boolean clear) {
-        synchronized (managers) {
-            for (int i = 0; i < managers.size(); ++i) {
-                TaskManager manager = managers.get(i).get();
-                if (manager != null) {
-                    manager.shutdown();
-                } else {
-                    managers.remove(i--);
-                }
-            }
-
-            if (clear) {
-                managers.clear();
-            }
-        }
-    }
-
-    private static boolean idle() {
-        synchronized (managers) {
-            for (int i = 0; i < managers.size(); ++i) {
-                TaskManager manager = managers.get(i).get();
-                if (manager != null) {
-                    if (manager.count() > 0) {
-                        return false;
-                    }
-                } else {
-                    managers.remove(i--);
-                }
-            }
-        }
-        return true;
-    }
-}

+ 0 - 17
app/src/com/sheishuo/app/common/infra/TaskObservable.java

@@ -1,17 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public class TaskObservable extends Observable<TaskObserver> implements TaskObserver {
-	@Override
-	public void onTaskResult(Task task, Object[] results) {
-		for (TaskObserver observer : getObservers()) {
-			observer.onTaskResult(task, results);
-		}
-	}
-
-	@Override
-	public void onTaskProgress(Task task, Object[] params) {
-		for (TaskObserver observer : getObservers()) {
-			observer.onTaskProgress(task, params);
-		}
-	}
-}

+ 0 - 17
app/src/com/sheishuo/app/common/infra/TaskObserver.java

@@ -1,17 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public interface TaskObserver {
-	/**
-	 * on task result
-	 * @param task
-	 * @param results
-	 */
-	public void onTaskResult(Task task, Object[] results);
-
-	/**
-	 * on task progress
-	 * @param task
-	 * @param params
-	 */
-	public void onTaskProgress(Task task, Object[] params);
-}

+ 0 - 47
app/src/com/sheishuo/app/common/infra/TaskRegistry.java

@@ -1,47 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.Collection;
-
-public interface TaskRegistry {
-	/**
-	 * register task
-	 * 
-	 * @param task
-	 * @return task registered
-	 */
-	public Task register(Task task);
-	
-	/**
-	 * unregister task
-	 * @param task
-	 * @return task unregistered
-	 */
-	public Task unregister(Task task);
-	
-	/**
-	 * task registered
-	 * 
-	 * @param task
-	 * @return registered
-	 */
-	public boolean registered(Task task);
-	
-	/**
-	 * query task
-	 * @param key
-	 * @return task
-	 */
-	public Task query(String key);
-
-    /**
-     * query all tasks registered
-     * @return
-     */
-    public Collection<Task> queryAll();
-    
-    /**
-     * count
-     * @return count
-     */
-    public int count();
-}

+ 0 - 44
app/src/com/sheishuo/app/common/infra/TaskScheduler.java

@@ -1,44 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public interface TaskScheduler {
-	/**
-	 * schedule
-	 * 
-	 * @param background
-	 * @param task
-	 * @param key
-	 * @param params
-	 * @return scheduled task
-	 */
-	public Task schedule(boolean background, String key, Task task, Object... params);
-
-	/**
-	 * reschedule
-	 * @param task
-	 */
-	public void reschedule(Task task);
-	
-	/**
-	 * unschedule
-	 * @param task
-	 */
-	public void unschedule(Task task);
-	
-	/**
-	 * scheduled
-	 * @param key
-	 * @return Task
-	 */
-	public Task scheduled(String key);
-	
-	/**
-	 * count
-	 * @return count
-	 */
-	public int count();
-
-    /**
-     * cancelAll
-     */
-    public void cancelAll();
-}

+ 0 - 19
app/src/com/sheishuo/app/common/infra/TaskWorker.java

@@ -1,19 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-import java.util.concurrent.Executor;
-
-public class TaskWorker extends AbstractTaskWorker {
-	/**
-	 * executor
-	 */
-	private Executor executor;
-	
-	public TaskWorker(Executor executor) {
-		this.executor = executor;
-	}
-	
-	@Override
-	protected Executor getTaskHost(Task task) {
-		return executor;
-	}
-}

+ 0 - 34
app/src/com/sheishuo/app/common/infra/TraceTaskRegistry.java

@@ -1,34 +0,0 @@
-package com.sheishuo.app.common.infra;
-
-public class TraceTaskRegistry extends WrapTaskRegistry {
-	public TraceTaskRegistry(TaskRegistry wrap) {
-		super(wrap);
-	}
-
-	@Override
-	public Task register(Task task) {
-		Task tsk = super.register(task);
-		
-		if (tsk == task) {
-			trace("register " + tsk.dump(false));					
-		}
-		
-		return tsk;
-	}
-	
-	@Override
-	public Task unregister(Task task) {
-		Task tsk = super.unregister(task);
-		
-		if (tsk != null) {
-			trace("unregister " + tsk.dump(false));
-		}
-		
-		return tsk;
-	}
-
-	private final void trace(String msg) {
-
-	}
-}
-

Some files were not shown because too many files changed in this diff