Browse Source

Merge branch 'draft' of https://gitlab.com/Arisono/SkWeiChat-Baidu into draft

# Conflicts:
#	app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/activity/DetailTaskActivity.java
Bitliker 8 years ago
parent
commit
bb2c72790c
32 changed files with 235 additions and 266 deletions
  1. 1 4
      WeiChat/src/main/AndroidManifest.xml
  2. BIN
      WeiChat/src/main/jniLibs/armeabi-v7a/libpl_droidsonroids_gif.so
  3. BIN
      WeiChat/src/main/jniLibs/armeabi-v7a/libpl_droidsonroids_gif_surface.so
  4. BIN
      WeiChat/src/main/jniLibs/armeabi/libpl_droidsonroids_gif.so
  5. BIN
      WeiChat/src/main/jniLibs/armeabi/libpl_droidsonroids_gif_surface.so
  6. BIN
      WeiChat/src/main/jniLibs/mips/libpl_droidsonroids_gif.so
  7. BIN
      WeiChat/src/main/jniLibs/mips/libpl_droidsonroids_gif_surface.so
  8. BIN
      WeiChat/src/main/jniLibs/mips64/libpl_droidsonroids_gif.so
  9. BIN
      WeiChat/src/main/jniLibs/mips64/libpl_droidsonroids_gif_surface.so
  10. BIN
      WeiChat/src/main/jniLibs/x86/libpl_droidsonroids_gif.so
  11. BIN
      WeiChat/src/main/jniLibs/x86/libpl_droidsonroids_gif_surface.so
  12. BIN
      WeiChat/src/main/jniLibs/x86_64/libpl_droidsonroids_gif.so
  13. BIN
      WeiChat/src/main/jniLibs/x86_64/libpl_droidsonroids_gif_surface.so
  14. 1 1
      WeiChat/src/main/res/layout/chat_from_item_gif.xml
  15. 1 1
      WeiChat/src/main/res/layout/chat_to_item_gif.xml
  16. 1 0
      app_core/common/build.gradle
  17. 5 2
      app_core/common/src/main/java/com/common/ui/ViewUtils.java
  18. 13 13
      app_core/common/src/main/java/com/core/dao/UUHelperDao.java
  19. 74 92
      app_core/common/src/main/java/com/core/model/UUHelperModel.java
  20. 1 1
      app_core/common/src/main/java/com/core/widget/gif/GifTextureView.java
  21. 2 2
      app_core/common/src/main/java/com/core/xmpp/XChatManager.java
  22. 2 1
      app_core/common/src/main/java/com/core/xmpp/widget/ChatContentView.java
  23. 1 1
      app_core/common/src/main/res/layout/activity_add_contacts.xml
  24. 2 4
      app_modular/appme/src/main/java/com/uas/appme/other/activity/RoomInfoActivity.java
  25. 16 19
      app_modular/appmessages/src/main/java/com/modular/appmessages/activity/UUHelperActivity.java
  26. 72 108
      app_modular/appmessages/src/main/java/com/modular/appmessages/adapter/UUHelperAdapter.java
  27. 11 11
      app_modular/appmessages/src/main/java/com/modular/appmessages/presenter/MessagePresenter.java
  28. 4 2
      app_modular/appmessages/src/main/res/layout/activity_uuhelper.xml
  29. 4 1
      app_modular/appmessages/src/main/res/layout/item_uuhelper_item.xml
  30. 17 0
      app_modular/appmessages/src/main/res/layout/item_uuhelper_time.xml
  31. 2 0
      build.gradle
  32. 5 3
      version.gradle

+ 1 - 4
WeiChat/src/main/AndroidManifest.xml

@@ -304,8 +304,6 @@
 
             <intent-filter>
                 <action android:name="com.modular.main.AddContactsActivity" />
-
-                <category android:name="com.modular.main.AddContactsActivity" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
@@ -479,7 +477,7 @@
             android:launchMode="singleTask"
             android:screenOrientation="portrait">
             <intent-filter>
-                <action android:name="com.modular.main.MainActivity" />
+                <action android:name="com.modular.message.InstantMessageActivity" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
@@ -964,7 +962,6 @@
         <activity
             android:name=".ui.erp.activity.oa.AddContactsActivity"
             android:label="@string/add_contact">
-
         </activity>
         <activity
             android:name=".ui.erp.activity.oa.AddVisitReportActivity"

BIN
WeiChat/src/main/jniLibs/armeabi-v7a/libpl_droidsonroids_gif.so


BIN
WeiChat/src/main/jniLibs/armeabi-v7a/libpl_droidsonroids_gif_surface.so


BIN
WeiChat/src/main/jniLibs/armeabi/libpl_droidsonroids_gif.so


BIN
WeiChat/src/main/jniLibs/armeabi/libpl_droidsonroids_gif_surface.so


BIN
WeiChat/src/main/jniLibs/mips/libpl_droidsonroids_gif.so


BIN
WeiChat/src/main/jniLibs/mips/libpl_droidsonroids_gif_surface.so


BIN
WeiChat/src/main/jniLibs/mips64/libpl_droidsonroids_gif.so


BIN
WeiChat/src/main/jniLibs/mips64/libpl_droidsonroids_gif_surface.so


BIN
WeiChat/src/main/jniLibs/x86/libpl_droidsonroids_gif.so


BIN
WeiChat/src/main/jniLibs/x86/libpl_droidsonroids_gif_surface.so


BIN
WeiChat/src/main/jniLibs/x86_64/libpl_droidsonroids_gif.so


BIN
WeiChat/src/main/jniLibs/x86_64/libpl_droidsonroids_gif_surface.so


+ 1 - 1
WeiChat/src/main/res/layout/chat_from_item_gif.xml

@@ -53,7 +53,7 @@
             android:layout_below="@+id/nick_name"
             android:layout_toLeftOf="@+id/chat_head_iv">
 
-            <com.core.widget.gif.GifImageView
+            <pl.droidsonroids.gif.GifImageView
                 android:layout_marginTop="10dp"
                 android:id="@+id/chat_from_gif_view"
                 android:layout_width="wrap_content"

+ 1 - 1
WeiChat/src/main/res/layout/chat_to_item_gif.xml

@@ -44,7 +44,7 @@
             android:layout_toRightOf="@+id/chat_head_iv"
             android:textSize="@dimen/SmallerTextSize" />
 
-        <com.core.widget.gif.GifImageView
+        <pl.droidsonroids.gif.GifImageView
             android:id="@+id/chat_to_gif_view"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"

+ 1 - 0
app_core/common/build.gradle

@@ -31,6 +31,7 @@ dependencies {
     compile(deps.stetho) {
         force = true
     }
+    compile deps.gif
     compile deps.circleimageview
     compile deps.activityOnCrash
     compile 'com.umeng.analytics:analytics:6.1.2'

+ 5 - 2
app_core/common/src/main/java/com/common/ui/ViewUtils.java

@@ -54,8 +54,11 @@ public class ViewUtils {
 
     public static void moveRecyclerView2Postion(RecyclerView recyclerView, int postion) {
         if (recyclerView != null && recyclerView.getLayoutManager() != null && recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
-            ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(postion, 0);
-            ((LinearLayoutManager) recyclerView.getLayoutManager()).setStackFromEnd(true);
+            int lastVisible=((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
+            if ( lastVisible< postion) {
+                ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(postion, 0);
+                ((LinearLayoutManager) recyclerView.getLayoutManager()).setStackFromEnd(true);
+            }
         }
     }
 }

+ 13 - 13
app_core/common/src/main/java/com/core/dao/UUHelperDao.java

@@ -16,7 +16,7 @@ import java.util.List;
  * Created by Bitliker on 2017/9/8.
  */
 
-public class UUHelperDao extends Dao<UUHelperModel.UUHelperItem> {
+public class UUHelperDao extends Dao<UUHelperModel> {
     private static UUHelperDao instance;
 
     public static UUHelperDao getInstance() {
@@ -43,21 +43,21 @@ public class UUHelperDao extends Dao<UUHelperModel.UUHelperItem> {
     }
 
     @Override
-    protected ContentValues getValues(UUHelperModel.UUHelperItem uuHelperItem) throws Exception {
+    protected ContentValues getValues(UUHelperModel model) throws Exception {
         ContentValues values = new ContentValues();
-        values.put(DatabaseTables.UUHelperTable.Cols.TIME_SEND, uuHelperItem.getTimeSend());
+        values.put(DatabaseTables.UUHelperTable.Cols.TIME_SEND, model.getTimeSend());
         values.put(DatabaseTables.UUHelperTable.Cols.USER_ID, MyApplication.getInstance().getLoginUserId());
-        values.put(DatabaseTables.UUHelperTable.Cols.IMAGE_URL, uuHelperItem.getImageUrl());
-        values.put(DatabaseTables.UUHelperTable.Cols.ICON_URL, uuHelperItem.getIconUrl());
-        values.put(DatabaseTables.UUHelperTable.Cols.LINK_URL, uuHelperItem.getLinkUrl());
-        values.put(DatabaseTables.UUHelperTable.Cols.CONTENT, uuHelperItem.getContent());
-        values.put(DatabaseTables.UUHelperTable.Cols.READED, uuHelperItem.isReaded());
-        values.put(DatabaseTables.UUHelperTable.Cols.DATE, uuHelperItem.getDate());
+        values.put(DatabaseTables.UUHelperTable.Cols.IMAGE_URL, model.getImageUrl());
+        values.put(DatabaseTables.UUHelperTable.Cols.ICON_URL, model.getIconUrl());
+        values.put(DatabaseTables.UUHelperTable.Cols.LINK_URL, model.getLinkUrl());
+        values.put(DatabaseTables.UUHelperTable.Cols.CONTENT, model.getContent());
+        values.put(DatabaseTables.UUHelperTable.Cols.READED, model.isReaded());
+        values.put(DatabaseTables.UUHelperTable.Cols.DATE, model.getDate());
         return values;
     }
 
     @Override
-    protected UUHelperModel.UUHelperItem getData(Cursor c) throws Exception {
+    protected UUHelperModel getData(Cursor c) throws Exception {
         int _id = c.getInt(c.getColumnIndex(DatabaseTables.UUHelperTable.Cols.ID));
         long timeSend = c.getLong(c.getColumnIndex(DatabaseTables.UUHelperTable.Cols.TIME_SEND));
         String imageUrl = c.getString(c.getColumnIndex(DatabaseTables.UUHelperTable.Cols.IMAGE_URL));
@@ -66,15 +66,15 @@ public class UUHelperDao extends Dao<UUHelperModel.UUHelperItem> {
         String content = c.getString(c.getColumnIndex(DatabaseTables.UUHelperTable.Cols.CONTENT));
         String date = c.getString(c.getColumnIndex(DatabaseTables.UUHelperTable.Cols.DATE));
         boolean readed = c.getInt(c.getColumnIndex(DatabaseTables.UUHelperTable.Cols.READED)) > 0;
-        return new UUHelperModel.UUHelperItem(readed, _id, timeSend, imageUrl, iconUrl, linkUrl, content, date);
+        return new UUHelperModel(readed, _id, timeSend, imageUrl, iconUrl, linkUrl, content, date);
     }
 
 
-    public boolean saveData(UUHelperModel.UUHelperItem uuHelperItem) {
+    public boolean saveData(UUHelperModel uuHelperItem) {
         return insert(uuHelperItem, null, null);
     }
 
-    public List<UUHelperModel.UUHelperItem> getAllModels() {
+    public List<UUHelperModel> getAllModels() {
         String orderBy = DatabaseTables.UUHelperTable.Cols.DATE + " asc";
         String where = DatabaseTables.UUHelperTable.Cols.USER_ID + " =?";
         String[] whereArgs = {MyApplication.getInstance().getLoginUserId()};

+ 74 - 92
app_core/common/src/main/java/com/core/model/UUHelperModel.java

@@ -4,9 +4,7 @@ import com.common.data.DateFormatUtil;
 import com.common.data.JSONUtil;
 import com.common.data.StringUtil;
 
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -14,114 +12,98 @@ import java.util.Map;
  */
 
 public class UUHelperModel {
-    private String date;
-    private List<UUHelperItem> items;
-
-    public static class UUHelperItem {
-        private int id;
-        private long timeSend;//发送时间
-        private String date;//发送日期(通过timeSend)
-        private String imageUrl;//图片网址
-        private String linkUrl;//链接网址
-        private String iconUrl;//小图片网址
-        private String content;//显示内容
-        private boolean readed;
-
-        @Override
-        public String toString() {
-            Map<String, Object> map = new HashMap<>();
-            map.put("_id", id);
-            map.put("timeSend", timeSend);
-            map.put("date", date);
-            map.put("imageUrl", imageUrl);
-            map.put("linkUrl", linkUrl);
-            map.put("iconUrl", iconUrl);
-            map.put("content", content);
-            return JSONUtil.map2JSON(map);
-        }
-
-        public UUHelperItem(long timeSend,
-                            String imageUrl,
-                            String iconUrl,
-                            String linkUrl,
-                            String content) {
-            this(false, 0, timeSend, imageUrl, iconUrl,linkUrl, content, null);
-        }
-
-        public UUHelperItem(boolean readed, int _id, long timeSend,
-                            String imageUrl,
-                            String iconUrl,
-                            String linkUrl,
-                            String content
-                , String date) {
-            this.readed = readed;
-            this.id = _id;
-            this.timeSend = timeSend;
-            this.imageUrl = imageUrl;
-            this.iconUrl = iconUrl;
-            this.linkUrl = linkUrl;
-            this.content = content;
-            //TODO 使用DateFormatUtil
-            if (StringUtil.isEmpty(date)) {
-                this.date = DateFormatUtil.long2Str(this.timeSend, DateFormatUtil.YMD);
-            } else {
-                this.date = date;
-            }
-        }
-
-        public long getTimeSend() {
-            return timeSend;
-        }
-
-        public String getDate() {
-            return date;
-        }
-
-        public String getImageUrl() {
-            return imageUrl;
-        }
-
-        public String getIconUrl() {
-            return iconUrl;
-        }
 
-        public String getLinkUrl() {
-            return linkUrl;
-        }
+    private boolean isTag;
+    private int id;
+    private long timeSend;//发送时间
+    private String date;//发送日期(通过timeSend)
+    private String imageUrl;//图片网址
+    private String linkUrl;//链接网址
+    private String iconUrl;//小图片网址
+    private String content;//显示内容
+    private boolean readed;
+
+
+
+    @Override
+    public String toString() {
+        Map<String, Object> map = new HashMap<>();
+        map.put("isTag", isTag);
+        map.put("_id", id);
+        map.put("timeSend", timeSend);
+        map.put("date", date);
+        map.put("imageUrl", imageUrl);
+        map.put("linkUrl", linkUrl);
+        map.put("iconUrl", iconUrl);
+        map.put("content", content);
+        return JSONUtil.map2JSON(map);
+    }
 
-        public String getContent() {
-            return content;
-        }
+    public UUHelperModel(String date) {
+        this.isTag = true;
+        this.date = date;
+    }
 
-        public boolean isReaded() {
-            return readed;
-        }
+    public UUHelperModel(long timeSend,
+                         String imageUrl,
+                         String iconUrl,
+                         String linkUrl,
+                         String content) {
+        this(false, 0, timeSend, imageUrl, iconUrl, linkUrl, content, null);
+    }
 
-        public int getId() {
-            return id;
+    public UUHelperModel(boolean readed, int _id, long timeSend,
+                         String imageUrl,
+                         String iconUrl,
+                         String linkUrl,
+                         String content
+            , String date) {
+        this.readed = readed;
+        this.id = _id;
+        this.timeSend = timeSend;
+        this.imageUrl = imageUrl;
+        this.iconUrl = iconUrl;
+        this.linkUrl = linkUrl;
+        this.content = content;
+        if (StringUtil.isEmpty(date)) {
+            this.date = DateFormatUtil.long2Str(this.timeSend, DateFormatUtil.YMD);
+        } else {
+            this.date = date;
         }
-
     }
 
-    public UUHelperModel(String date) {
-        this.date = date;
+    public long getTimeSend() {
+        return timeSend;
     }
 
     public String getDate() {
         return date;
     }
 
-
-    public List<UUHelperItem> getItems() {
-        return items == null ? items = new ArrayList<UUHelperItem>() : items;
+    public String getImageUrl() {
+        return imageUrl;
     }
 
+    public String getIconUrl() {
+        return iconUrl;
+    }
 
+    public String getLinkUrl() {
+        return linkUrl;
+    }
 
-
-    public void addItem(UUHelperItem item) {
-        getItems().add(item);
+    public String getContent() {
+        return content;
     }
 
+    public boolean isReaded() {
+        return readed;
+    }
 
+    public int getId() {
+        return id;
+    }
+    public boolean isTag() {
+        return isTag;
+    }
 }

+ 1 - 1
app_core/common/src/main/java/com/core/widget/gif/GifTextureView.java

@@ -395,7 +395,7 @@ public class GifTextureView extends TextureView {
 
     /**
      * Wrapper of {@link #setTransform(Matrix)}. Introduced to preserve the same API as in
-     * {@link GifImageView}.
+     * {@link }.
      *
      * @param matrix The transform to apply to the content of this view.
      */

+ 2 - 2
app_core/common/src/main/java/com/core/xmpp/XChatManager.java

@@ -296,8 +296,8 @@ public class XChatManager {
         if (!StringUtils.isEmpty(linkUrl) && user != null) {
             linkUrl += "?userid=" + user.getUserId() + "&username=" + user.getNickName() + "&iconurl=" + AvatarHelper.getInstance().getAvatarUrl(user.getUserId(), true);
         }
-        UUHelperModel.UUHelperItem item = new UUHelperModel.UUHelperItem(timeSend, imageUrl,iconUrl, linkUrl, content);
-        UUHelperDao.getInstance().saveData(item);
+        UUHelperModel model = new UUHelperModel(timeSend, imageUrl,iconUrl, linkUrl, content);
+        UUHelperDao.getInstance().saveData(model);
         NotificationManage.sendUUHelperNotif(content);
     }
 

+ 2 - 1
app_core/common/src/main/java/com/core/xmpp/widget/ChatContentView.java

@@ -56,7 +56,6 @@ import com.core.net.volley.Result;
 import com.core.net.volley.StringJsonObjectRequest;
 import com.core.utils.ToastUtil;
 import com.core.utils.helper.AvatarHelper;
-import com.core.widget.gif.GifImageView;
 import com.core.xmpp.dao.ChatMessageDao;
 import com.core.xmpp.dao.FriendDao;
 import com.core.xmpp.downloader.DownloadListener;
@@ -78,6 +77,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import pl.droidsonroids.gif.GifImageView;
+
 
 @SuppressWarnings("unused")
 public class ChatContentView extends PullDownListView implements VoicePlayer.OnMediaStateChange {

+ 1 - 1
app_core/common/src/main/res/layout/activity_add_contacts.xml

@@ -6,7 +6,7 @@
     android:layout_height="match_parent"
     android:background="@color/hine_bg"
     android:orientation="vertical"
-    tools:context="com.xzjmyk.pm.activity.ui.erp.activity.oa.AddContactsActivity">
+    >
 
     <RelativeLayout
         android:id="@+id/name_rl"

+ 2 - 4
app_modular/appme/src/main/java/com/uas/appme/other/activity/RoomInfoActivity.java

@@ -197,8 +197,7 @@ public class RoomInfoActivity extends BaseActivity {
                             existIds.add(mMembers.get(i).getUserId());
                         }
                         // 去添加人
-                        Intent intent = new Intent("com.xzjmyk.pm.activity.ui.erp.activity.oa.AddContactsActivity");
-                        intent.addCategory("com.xzjmyk.pm.activity.ui.erp.activity.oa.AddContactsActivity");
+                        Intent intent = new Intent("com.modular.main.AddContactsActivity");
                         intent.putExtra("id", mRoom.get_id());
                         intent.putExtra("roomId", mRoom.getRoomId());
                         intent.putExtra("roomJid", mRoomJid);
@@ -223,8 +222,7 @@ public class RoomInfoActivity extends BaseActivity {
                             existIds.add(mMembers.get(i).getUserId());
                         }
                         // 去添加人
-                        Intent intent = new Intent("com.xzjmyk.pm.activity.ui.erp.activity.oa.AddContactsActivity");
-                        intent.addCategory("com.xzjmyk.pm.activity.ui.erp.activity.oa.AddContactsActivity");
+                        Intent intent = new Intent("com.modular.main.AddContactsActivity");
                         intent.putExtra("id", mRoom.get_id());
                         intent.putExtra("roomId", mRoom.getRoomId());
                         intent.putExtra("roomJid", mRoomJid);

+ 16 - 19
app_modular/appmessages/src/main/java/com/modular/appmessages/activity/UUHelperActivity.java

@@ -13,6 +13,7 @@ import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 
+import com.common.data.ListUtils;
 import com.common.ui.ViewUtils;
 import com.core.app.AppConstant;
 import com.core.app.Constants;
@@ -81,30 +82,24 @@ public class UUHelperActivity extends BaseActivity implements View.OnClickListen
     }
 
     private void initData() {
-        List<UUHelperModel.UUHelperItem> items = UUHelperDao.getInstance().getAllModels();
-        List<UUHelperModel> models = new ArrayList<>();
-        if (items != null) {
+        List<UUHelperModel> models = UUHelperDao.getInstance().getAllModels();
+        List<UUHelperModel> showModels = new ArrayList<>();
+        if (!ListUtils.isEmpty(models)) {
             String dateChche = null;
-            UUHelperModel model = null;
-            for (UUHelperModel.UUHelperItem item : items) {
-                //第一次进来
+            for (int i = 0; i < models.size(); i++) {
+                UUHelperModel model = models.get(i);
                 if (dateChche == null) {
-                    dateChche = item.getDate();
-                }
-                if (model == null) {
-                    model = new UUHelperModel(item.getDate());
+                    dateChche = model.getDate();
+                    showModels.add(new UUHelperModel(dateChche));
+
                 }
-                if (!dateChche.equals(item.getDate())) {
-                    //已经变了另一天
-                    models.add(model);
-                    model = new UUHelperModel(item.getDate());
-                    dateChche = item.getDate();
+                if (!dateChche.equals(model.getDate())) {
+                    showModels.add(new UUHelperModel(dateChche));
                 }
-                model.addItem(item);
+                showModels.add(model);
             }
-            models.add(model);
         }
-        showModel(models);
+        showModel(showModels);
     }
 
     private void showModel(List<UUHelperModel> models) {
@@ -115,7 +110,9 @@ public class UUHelperActivity extends BaseActivity implements View.OnClickListen
             mAdapter.setModels(models);
             mAdapter.notifyDataSetChanged();
         }
-        ViewUtils.moveRecyclerView2Postion(contentRV, models.size());
+        if (ListUtils.getSize(models)>=5){
+            ViewUtils.moveRecyclerView2Postion(contentRV, models.size());
+        }
     }
 
 

+ 72 - 108
app_modular/appmessages/src/main/java/com/modular/appmessages/adapter/UUHelperAdapter.java

@@ -1,8 +1,8 @@
 package com.modular.appmessages.adapter;
 
 import android.content.Context;
-import android.support.v7.widget.DefaultItemAnimator;
-import android.support.v7.widget.LinearLayoutManager;
+import android.content.DialogInterface;
+import android.support.v7.app.AlertDialog;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -11,7 +11,6 @@ import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
-import com.common.LogUtil;
 import com.common.data.ListUtils;
 import com.core.dao.UUHelperDao;
 import com.core.model.UUHelperModel;
@@ -26,7 +25,7 @@ import java.util.List;
  * Created by Bitliker on 2017/9/7.
  */
 
-public class UUHelperAdapter extends RecyclerView.Adapter<UUHelperAdapter.ViewHolder> {
+public class UUHelperAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
     private Context ct;
     private List<UUHelperModel> models;
     private LayoutInflater inflater;
@@ -69,130 +68,98 @@ public class UUHelperAdapter extends RecyclerView.Adapter<UUHelperAdapter.ViewHo
 
 
     @Override
-    public UUHelperAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
-        return new ViewHolder(parent);
+    public int getItemViewType(int position) {
+        return position;
     }
 
     @Override
-    public void onBindViewHolder(ViewHolder holder, int position) {
-        UUHelperModel model = models.get(position);
-        holder.timeTV.setText(model.getDate());
-        ItemAdapter itemAdapter = null;
-        if (holder.itemRV.getAdapter() != null && holder.itemRV.getAdapter() instanceof ItemAdapter) {
-            itemAdapter = (ItemAdapter) holder.itemRV.getAdapter();
-            itemAdapter.setItems(model.getItems());
-            itemAdapter.notifyDataSetChanged();
+    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        boolean isTag = models.get(viewType).isTag();
+        if (isTag) {
+            return new TimeHolder(parent);
         } else {
-            itemAdapter = new ItemAdapter(model.getItems());
-            holder.itemRV.setAdapter(itemAdapter);
+            return new ViewHolder(parent);
         }
-//        if (position == getItemCount() - 1) {
-//            ViewUtils.moveRecyclerView2Postion(holder.itemRV, ListUtils.getSize(model.getItems()));
-//        }
     }
 
     @Override
-    public int getItemCount() {
-        return ListUtils.getSize(models);
-    }
-
-    class ViewHolder extends RecyclerView.ViewHolder {
-        TextView timeTV;
-        RecyclerView itemRV;
-
-        public ViewHolder(ViewGroup parent) {
-            this(getViewByLayout(R.layout.item_uuhelper, parent));
-        }
-
-        public ViewHolder(View itemView) {
-            super(itemView);
-            timeTV = (TextView) itemView.findViewById(R.id.timeTV);
-            itemRV = (RecyclerView) itemView.findViewById(R.id.itemRV);
-            itemRV.setLayoutManager(new LinearLayoutManager(ct));
-            itemRV.setItemAnimator(new DefaultItemAnimator());
+    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+        UUHelperModel model = models.get(position);
+        if (holder instanceof TimeHolder) {
+            ((TimeHolder) holder).timeTV.setText(model.getDate());
+        } else if (holder instanceof ViewHolder) {
+            bindViewHolder((ViewHolder) holder, model, position);
         }
     }
 
-
-    private class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.ItemViewHolder> {
-        private List<UUHelperModel.UUHelperItem> items;
-
-        public ItemAdapter(List<UUHelperModel.UUHelperItem> items) {
-            this.items = items;
-        }
-
-        public void setItems(List<UUHelperModel.UUHelperItem> items) {
-            this.items = items;
-        }
-
-        @Override
-        public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
-            return new ItemViewHolder(parent);
-        }
-
-        @Override
-        public int getItemCount() {
-            return this.items == null ? 0 : this.items.size();
-        }
-
-        class ItemViewHolder extends RecyclerView.ViewHolder {
-            RelativeLayout fristRL, normalRL;
-            ImageView fristIV, normalIV;
-            TextView fristTV, normalTV;
-            View line;
-
-            public ItemViewHolder(ViewGroup parent) {
-                this(getViewByLayout(R.layout.item_uuhelper_item, parent));
-            }
-
-            public ItemViewHolder(View itemView) {
-                super(itemView);
-                fristRL = (RelativeLayout) itemView.findViewById(R.id.fristRL);
-                normalRL = (RelativeLayout) itemView.findViewById(R.id.normalRL);
-                fristIV = (ImageView) itemView.findViewById(R.id.fristIV);
-                normalIV = (ImageView) itemView.findViewById(R.id.normalIV);
-                fristTV = (TextView) itemView.findViewById(R.id.fristTV);
-                normalTV = (TextView) itemView.findViewById(R.id.normalTV);
-                line = itemView.findViewById(R.id.line);
-            }
-        }
-
-        @Override
-        public void onBindViewHolder(ItemViewHolder holder, int position) {
-            final UUHelperModel.UUHelperItem model = this.items.get(position);
-            if (position == 0) {
+    private void bindViewHolder(ViewHolder holder, final UUHelperModel model, final int position) {
+        if (position > 0) {
+            if (models.get(position - 1).isTag()) {//上一个是时间
                 holder.fristRL.setVisibility(View.VISIBLE);
                 holder.normalRL.setVisibility(View.GONE);
                 ImageLoader.getInstance().displayImage(model.getImageUrl(), holder.fristIV);
                 holder.fristTV.setText(model.getContent());
-            } else {
+            } else {//上一个不是时间
                 holder.fristRL.setVisibility(View.GONE);
                 holder.normalRL.setVisibility(View.VISIBLE);
                 ImageLoader.getInstance().displayImage(model.getImageUrl(), holder.normalIV);
                 holder.normalTV.setText(model.getContent());
             }
-//            if (position == (items.size() - 1)) {
-//                holder.line.setVisibility(View.GONE);
-//            } else {
-//                holder.line.setVisibility(View.VISIBLE);
-//            }
             holder.itemView.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
-                    LogUtil.i(model.toString());
                     onItemClick(model);
                 }
             });
             holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
                 @Override
                 public boolean onLongClick(View v) {
-                    onLongItemClick(model);
+                    onLongItemClick(model, position);
                     return false;
                 }
             });
         }
     }
 
+    @Override
+    public int getItemCount() {
+        return ListUtils.getSize(models);
+    }
+
+    class ViewHolder extends RecyclerView.ViewHolder {
+        RelativeLayout fristRL, normalRL;
+        ImageView fristIV, normalIV;
+        TextView fristTV, normalTV;
+        View line;
+
+        public ViewHolder(ViewGroup parent) {
+            this(getViewByLayout(R.layout.item_uuhelper_item, parent));
+        }
+
+        public ViewHolder(View itemView) {
+            super(itemView);
+            fristRL = (RelativeLayout) itemView.findViewById(R.id.fristRL);
+            normalRL = (RelativeLayout) itemView.findViewById(R.id.normalRL);
+            fristIV = (ImageView) itemView.findViewById(R.id.fristIV);
+            normalIV = (ImageView) itemView.findViewById(R.id.normalIV);
+            fristTV = (TextView) itemView.findViewById(R.id.fristTV);
+            normalTV = (TextView) itemView.findViewById(R.id.normalTV);
+            line = itemView.findViewById(R.id.line);
+        }
+    }
+
+    class TimeHolder extends RecyclerView.ViewHolder {
+        TextView timeTV;
+
+        public TimeHolder(ViewGroup parent) {
+            this(getViewByLayout(R.layout.item_uuhelper_time, parent));
+        }
+
+        public TimeHolder(View itemView) {
+            super(itemView);
+            timeTV = (TextView) itemView.findViewById(R.id.timeTV);
+        }
+    }
 
     private View getViewByLayout(int layout, ViewGroup parent) {
         if (inflater == null) {
@@ -201,26 +168,23 @@ public class UUHelperAdapter extends RecyclerView.Adapter<UUHelperAdapter.ViewHo
         return inflater.inflate(layout, parent, false);
     }
 
-    private void onItemClick(UUHelperModel.UUHelperItem item) {
+    private void onItemClick(UUHelperModel item) {
         String title = item.getContent();
         UUHelperDao.getInstance().updateRead(item.getId());
         String url = item.getLinkUrl();
         IntentUtils.webLinks(ct, url, title);
-//        Intent intent = new Intent(ct, AppWebViewActivity.class);
-//        intent.putExtra("url", url);
-//        intent.putExtra("p", title);
-//        intent.putExtra("title", title);
-//        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-//        ct.startActivity(intent);
     }
 
-    private void onLongItemClick(final UUHelperModel.UUHelperItem item) {
-//        AlertDialog.Builder builder = new AlertDialog.Builder(ct);
-//        builder.setTitle(R.string.prompt_title).setMessage("确定删除该消息吗?").setPositiveButton(R.string.sure, new DialogInterface.OnClickListener() {
-//            @Override
-//            public void onClick(DialogInterface dialogInterface, int i) {
-//                UUHelperDao.getInstance().deleteData(item.getId());
-//            }
-//        }).setNegativeButton(R.string.cancel, null).show();
+    private void onLongItemClick(final UUHelperModel model, final int position) {
+        AlertDialog.Builder builder = new AlertDialog.Builder(ct);
+        builder.setTitle(R.string.prompt_title).setMessage("确定删除" + model.getContent() + "吗?").setPositiveButton(R.string.sure, new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialogInterface, int i) {
+                UUHelperDao.getInstance().deleteData(model.getId());
+                models.remove(position);
+                notifyItemRemoved(position);
+                notifyItemRangeChanged(position, models.size());
+            }
+        }).setNegativeButton(R.string.cancel, null).show();
     }
 }

+ 11 - 11
app_modular/appmessages/src/main/java/com/modular/appmessages/presenter/MessagePresenter.java

@@ -631,9 +631,9 @@ public class MessagePresenter implements OnHttpResultListener {
             String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
             List<Friend> friends = FriendDao.getInstance().getNearlyFriendMsg(mLoginUserId);
             List<MessageModel> model = MessageDao.getInstance().queryFirstFloor();
-            List<UUHelperModel.UUHelperItem> uuHelperItems = UUHelperDao.getInstance().getAllModels();
+            List<UUHelperModel> uuHelperModels = UUHelperDao.getInstance().getAllModels();
             setFriendName(friends, mLoginUserId);
-            return handlerErpAndIm(friends, model, uuHelperItems);
+            return handlerErpAndIm(friends, model, uuHelperModels);
         } catch (Exception e) {
             e.printStackTrace();
             return null;
@@ -652,7 +652,7 @@ public class MessagePresenter implements OnHttpResultListener {
      * @param friends
      * @param models
      */
-    private List<BaseSortModel<Friend>> handlerErpAndIm(List<Friend> friends, List<MessageModel> models, List<UUHelperModel.UUHelperItem> uuHelperItems) throws Exception {
+    private List<BaseSortModel<Friend>> handlerErpAndIm(List<Friend> friends, List<MessageModel> models, List<UUHelperModel> uuHelperItems) throws Exception {
         if (friends == null) friends = new ArrayList<>();
         List<BaseSortModel<Friend>> chche = new ArrayList<>();
         emnewsNum = 0;
@@ -678,21 +678,21 @@ public class MessagePresenter implements OnHttpResultListener {
             Friend friend = new Friend();
             friend.setNickName("UU 消息助手");
             friend.setType(XmppMessage.TYPE_UUHELPER);
-            UUHelperModel.UUHelperItem lastItem = null;
+            UUHelperModel lastModel= null;
             int unReadUnm = 0;
-            for (UUHelperModel.UUHelperItem item : uuHelperItems) {
-                if (!item.isReaded()) {
-                    lastItem = item;
+            for (UUHelperModel model : uuHelperItems) {
+                if (!model.isReaded()) {
+                    lastModel = model;
                     unReadUnm++;
                 }
             }
             friend.setClickNum(unReadUnm);
             uuHelperNum = unReadUnm;
             friend.setUnReadNum(unReadUnm);
-            if (lastItem != null) {
-                friend.set_id(lastItem.getId());
-                friend.setTimeSend((int) (lastItem.getTimeSend() / 1000));
-                friend.setContent(lastItem.getContent());
+            if (lastModel != null) {
+                friend.set_id(lastModel.getId());
+                friend.setTimeSend((int) (lastModel.getTimeSend() / 1000));
+                friend.setContent(lastModel.getContent());
             } else {
                 friend.setContent("");
             }

+ 4 - 2
app_modular/appmessages/src/main/res/layout/activity_uuhelper.xml

@@ -69,7 +69,9 @@
     <android.support.v7.widget.RecyclerView
         android:id="@+id/contentRV"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_above="@id/operationLL" />
+        android:layout_height="wrap_content"
+        android:layout_above="@id/operationLL"
+        android:layout_marginBottom="15dp"
+        android:layout_alignParentTop="true" />
 
 </RelativeLayout>

+ 4 - 1
app_modular/appmessages/src/main/res/layout/item_uuhelper_item.xml

@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
+             android:layout_marginLeft="20dp"
+             android:layout_marginRight="20dp"
+             android:background="@color/white"
              android:layout_height="wrap_content">
 
     <RelativeLayout
@@ -19,7 +22,7 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true"
-            android:background="#A0A0A0"
+            android:background="#afaeaeae"
             android:ellipsize="end"
             android:gravity="center_vertical"
             android:lines="2"

+ 17 - 0
app_modular/appmessages/src/main/res/layout/item_uuhelper_time.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <TextView
+        android:id="@+id/timeTV"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="10dp"
+        android:layout_marginBottom="8dp"
+        android:background="@drawable/text_hint_bg"
+        android:text="2017-11-11 10:11:11"
+        android:textColor="@color/white"
+        android:textSize="@dimen/text_main" />
+</RelativeLayout>

+ 2 - 0
build.gradle

@@ -5,6 +5,7 @@ buildscript {
         jcenter()
         maven { url "https://jcenter.bintray.com" }
         maven { url "https://jitpack.io" }
+        mavenCentral()
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:2.3.2'
@@ -17,6 +18,7 @@ buildscript {
 allprojects {
     repositories {
         jcenter()
+        mavenCentral()
         maven { url "https://jitpack.io" }
         maven {
             url 'https://maven.google.com'

+ 5 - 3
version.gradle

@@ -8,7 +8,7 @@ ext {
     android = [
             compileSdkVersion: 24,
             buildToolsVersion: '25.0.0',
-            minSdkVersion    :9,
+            minSdkVersion    : 9,
             targetSdkVersion : 24,
             javaVersion      : JavaVersion.VERSION_1_8,
             versionCode      : 113,
@@ -40,7 +40,8 @@ ext {
             activityOnCrashVersion  : '1.5.0',
             analyticsVersion        : 'latest.integration',
             tagGroupVersion         : '1.4@aar',
-            jodatimeVersion         : '2.9.4'
+            jodatimeVersion         : '2.9.4',
+            gifVersion              : '1.2.8',
     ]
 
     deps = [
@@ -84,7 +85,8 @@ ext {
             materialDialogs    : 'com.afollestad.material-dialogs:core:' + depsVersion.materialDialogsVersion,
             leakcanary         : 'com.squareup.leakcanary:leakcanary-android:' + depsVersion.leakcanaryVersion,
             leakcanaryNp       : 'com.squareup.leakcanary:leakcanary-android-no-op:' + depsVersion.leakcanaryVersion,
-            jodatime           : 'joda-time:joda-time:' + depsVersion.jodatimeVersion
+            jodatime           : 'joda-time:joda-time:' + depsVersion.jodatimeVersion,
+            gif                : 'pl.droidsonroids.gif:android-gif-drawable:' + depsVersion.gifVersion
 
 
     ]