瀏覽代碼

图像和视频重新加载图标

liuzhenxing1118 2 年之前
父節點
當前提交
5d82c6c152

+ 32 - 7
app/src/main/java/com/xplora/xpchat/view/ChatItem.java

@@ -45,6 +45,7 @@ public class ChatItem {
     public ImageView mSendingImage = null;
     public ImageView mUnreadImage = null;
     public ImageView mUnsendImage = null;
+    public ImageView mReLoadingImage = null;
     public TextView mReadStatusText = null;
 
     public Animation sendingAnimation = null;
@@ -75,6 +76,7 @@ public class ChatItem {
         mSendingImage = (ImageView)convertView.findViewById(R.id.mSendingImage);
         mUnsendImage = (ImageView)convertView.findViewById(R.id.mUnsendImage);
         mUnreadImage = (ImageView)convertView.findViewById(R.id.mUnreadImage);
+        mReLoadingImage = (ImageView)convertView.findViewById(R.id.mReLoadingImage);
         mReadStatusText = (TextView)convertView.findViewById(R.id.mReadStatusText);
     }
 
@@ -88,7 +90,8 @@ public class ChatItem {
 
         //消息状态
         setLocalState(messageBean.localState);
-        setReadStatus(messageBean.owner, messageBean.state);
+        setReLoadingImage(messageBean);
+        setReadStatus(messageBean.owner, messageBean.localState);
 
         //setPosition(messageBean);
     }
@@ -227,18 +230,40 @@ public class ChatItem {
         }
     }
 
+    public void setReLoadingImage(MessageBean bean) {
+        if (mReLoadingImage == null)
+            return;
+        if (bean.owner == Constant.OWNER_ME)
+            return;
+        if (bean.type == Constant.MESSAGE_TYPE_PHOTO) {
+            int status = bean.filePath.length() > 1 ? View.GONE : View.VISIBLE;
+            mReLoadingImage.setVisibility(status);
+        } else if (bean.type == Constant.MESSAGE_TYPE_VIDEO) {
+            int status = bean.filePath.length() > 1 && bean.videoPath.length() > 1 ? View.GONE : View.VISIBLE;
+            mReLoadingImage.setVisibility(status);
+        } else {
+            mReLoadingImage.setVisibility(View.GONE);
+        }
+    }
+
     public void setReadStatus(int owner, int state) {
         if (mReadStatusText == null)
             return;
-        if (owner != Constant.OWNER_ME || state == 0) {
-            mReadStatusText.setVisibility(View.GONE);
-        } else {
-            if (state == 1)
+        if (owner == Constant.OWNER_ME) {
+            if (state == Constant.MESSAGE_STATE_SEND_SUCCESS || state == Constant.MESSAGE_STATE_UNREAD) {
+                mReadStatusText.setVisibility(View.VISIBLE);
                 mReadStatusText.setText(R.string.read_status_1);
-            else if (state == 2)
+            } else if (state == Constant.MESSAGE_STATE_READ) {
+                mReadStatusText.setVisibility(View.VISIBLE);
                 mReadStatusText.setText(R.string.read_status_2);
-            else if (state == 3)
+            } else if (state == Constant.MESSAGE_STATE_SEND_FAIL) {
+                mReadStatusText.setVisibility(View.VISIBLE);
                 mReadStatusText.setText(R.string.read_status_3);
+            } else {
+                mReadStatusText.setVisibility(View.GONE);
+            }
+        } else {
+            mReadStatusText.setVisibility(View.GONE);
         }
     }
 

+ 10 - 0
app/src/main/res/layout/item_other_photo.xml

@@ -61,6 +61,16 @@
             app:riv_corner_radius="24dp"
             android:scaleType="centerCrop"
             />
+
+        <ImageView
+            android:id="@+id/mReLoadingImage"
+            android:layout_width="14dp"
+            android:layout_height="14dp"
+            android:layout_centerVertical="true"
+            android:layout_toEndOf="@+id/mItemPhoto"
+            android:layout_marginStart="7.5dp"
+            android:src="@drawable/item_sending"
+            />
     </RelativeLayout>
 
 </LinearLayout>

+ 10 - 0
app/src/main/res/layout/item_other_video.xml

@@ -69,5 +69,15 @@
             android:layout_marginStart="30dp"
             android:src="@drawable/icon_video_mark"
             />
+
+        <ImageView
+            android:id="@+id/mReLoadingImage"
+            android:layout_width="14dp"
+            android:layout_height="14dp"
+            android:layout_centerVertical="true"
+            android:layout_toEndOf="@+id/mItemVideo"
+            android:layout_marginStart="7.5dp"
+            android:src="@drawable/item_sending"
+            />
     </RelativeLayout>
 </LinearLayout>