Fenix Wang 8 سال پیش
والد
کامیت
a6f6c67dc0

+ 1 - 0
app/res/layout/circle_details.xml

@@ -123,6 +123,7 @@
                         android:textColor="@color/grey_light" />
 
                     <ImageView
+                        android:id="@+id/circle_details_like_icon"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:src="@drawable/circle_likes" />

+ 29 - 68
app/res/layout/circle_details_comment_layout.xml

@@ -5,87 +5,48 @@
     android:orientation="vertical" android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-    <android.support.constraint.ConstraintLayout
+    <RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:padding="16dp"
-        android:background="@color/white">
+        android:padding="10dp">
+
         <com.netease.nim.uikit.common.ui.imageview.HeadImageView
             android:id="@+id/circle_details_comment_layout_avatar"
             android:layout_width="48dp"
             android:layout_height="48dp"
-            app:layout_constraintTop_toTopOf="parent"
-            android:layout_marginTop="8dp"
-            android:layout_marginLeft="8dp"
+            android:src="@drawable/nim_avatar_default"
             app:layout_constraintLeft_toLeftOf="parent"
-            android:layout_marginStart="8dp"
-            android:src="@drawable/nim_avatar_default"/>
-
-        <TextView
-            android:id="@+id/circle_details_comment_layout_name"
-            android:layout_width="44dp"
-            android:layout_height="16dp"
-            android:text="用户名"
-            app:layout_constraintLeft_toRightOf="@+id/circle_details_comment_layout_avatar"
-            android:layout_marginLeft="21dp"
-            app:layout_constraintTop_toTopOf="@+id/circle_details_comment_layout_avatar"
-            android:layout_marginStart="21dp" />
-
-        <TextView
-            android:id="@+id/circle_details_comment_layout_date"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="发布时间"
-            app:layout_constraintLeft_toLeftOf="@+id/circle_details_comment_layout_name"
-            android:layout_marginTop="15dp"
-            app:layout_constraintTop_toBottomOf="@+id/circle_details_comment_layout_name" />
-
-        <ImageView
-            android:id="@+id/circle_details_comment_layout_like"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:src="@drawable/ico_like_grey"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintRight_toRightOf="parent" />
-
-
-        <TextView
-            android:id="@+id/circle_details_comment_layout_content"
-            android:layout_width="268dp"
-            android:layout_height="48dp"
-            android:padding="16dp"
-            app:layout_constraintLeft_toLeftOf="@+id/circle_details_comment_layout_date"
-            android:layout_marginTop="8dp"
-            app:layout_constraintTop_toBottomOf="@+id/circle_details_comment_layout_date"
-            android:layout_marginRight="8dp"
-            app:layout_constraintRight_toRightOf="parent"
-            android:layout_marginEnd="8dp" />
-
+            app:layout_constraintTop_toTopOf="parent" />
 
         <LinearLayout
-            android:id="@+id/circle_details_comment_layout_comment_to_layout"
-            android:layout_width="268dp"
-            android:layout_height="150dp"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="60dp"
             android:orientation="vertical"
-            android:background="@color/grey_light_light"
-            android:layout_marginRight="8dp"
-            app:layout_constraintRight_toRightOf="@+id/circle_details_comment_layout_content"
-            android:layout_marginLeft="8dp"
-            app:layout_constraintLeft_toLeftOf="@+id/circle_details_comment_layout_content"
-            android:layout_marginTop="16dp"
-            app:layout_constraintTop_toBottomOf="@+id/circle_details_comment_layout_content"
-            app:layout_constraintHorizontal_bias="0.491"
-            tools:layout_editor_absoluteX="113dp"
-            android:visibility="gone">
-
+            android:paddingTop="5dp">
+
+            <TextView
+                android:id="@+id/circle_details_comment_layout_name"
+                android:layout_width="match_parent"
+                android:layout_height="16dp"
+                android:text="用户名"
+                android:textColor="@color/blue"/>
+
+            <TextView
+                android:id="@+id/circle_details_comment_layout_date"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="发布时间"/>
+
+            <TextView
+                android:id="@+id/circle_details_comment_layout_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textColor="@color/black"/>
 
         </LinearLayout>
-    </android.support.constraint.ConstraintLayout>
-
-
 
+    </RelativeLayout>
 
-    
-    
 
 </LinearLayout>

+ 3 - 6
app/res/layout/circle_item.xml

@@ -28,7 +28,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content">
 
-                <ImageView
+                <com.netease.nim.uikit.common.ui.imageview.HeadImageView
                     android:id="@+id/avatar_img"
                     android:layout_width="48dp"
                     android:layout_height="48dp"
@@ -57,9 +57,8 @@
                         android:id="@+id/user_content_tv"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:textColor="@android:color/black"
-                        android:minHeight="50dp"
-                        android:gravity="center_vertical"/>
+                        android:gravity="center_vertical"
+                        android:textColor="@android:color/black" />
                 </LinearLayout>
 
                 <com.sheishuo.app.common.views.ImgGridView
@@ -192,6 +191,4 @@
         </LinearLayout>
     </LinearLayout>
 
-    <View style="@style/horizontal_light_thin_divider" />
-
 </LinearLayout>

+ 21 - 1
app/res/layout/circle_of_friends_fragment.xml

@@ -36,7 +36,27 @@
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
                     android:scaleType="centerCrop"
-                    android:src="@drawable/temp_circle_background"/>
+                    android:src="@drawable/temp_circle_background" />
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:gravity="center"
+                    android:orientation="horizontal">
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="1"
+                        android:enabled="false"
+                        android:shadowColor="@color/black"
+                        android:shadowDx="1"
+                        android:shadowDy="1"
+                        android:shadowRadius="1"
+                        android:text="轻触换背景"
+                        android:textAlignment="center"
+                        android:textColor="@color/GreyWhite" />
+                </LinearLayout>
 
                 <LinearLayout
                     android:layout_width="wrap_content"

+ 1 - 0
app/src/com/sheishuo/app/common/util/net/INet.java

@@ -29,6 +29,7 @@ public interface INet {
     void deleteSocialPhoto(String id, ResponseCallback callback);
     void getSocialInfo(String targetID,ResponseCallback callback);
     void getSocialComment(String id, int page, ResponseCallback callback);
+    void socialLike(String id, ResponseCallback callback);
     void deleteSocial(String id, ResponseCallback callback);
     void getCityDataList(ResponseCallback callback);
     void getNearbyPeople(String userId,String page,ResponseCallback callback);

+ 30 - 1
app/src/com/sheishuo/app/common/util/net/NetImpl.java

@@ -10,6 +10,7 @@ import com.sheishuo.app.cache.AccountCache;
 import com.sheishuo.app.cache.HobbyCache;
 import com.sheishuo.app.cache.SocialInfoCache;
 import com.sheishuo.app.common.beans.CircleBean;
+import com.sheishuo.app.common.beans.CircleUserLikedBean;
 import com.sheishuo.app.common.beans.ContactRelationshipBean;
 import com.sheishuo.app.common.beans.GiftBean;
 import com.sheishuo.app.common.beans.SocialInfoBean;
@@ -436,7 +437,7 @@ public class NetImpl implements INet {
                     {
                         JSONObject data = jsonObject.getJSONObject("d");
                         SocialPhoto photo = new SocialPhoto();
-                        photo.setAid(data.getString("id"));
+                        photo.setId(data.getString("id"));
                         photo.setUser_id(AccountCache.getAccount().getId());
                         photo.setThumb(data.getString("thumb"));
                         photo.setPic(data.getString("pic"));
@@ -527,6 +528,34 @@ public class NetImpl implements INet {
 
 
     @Override
+    public void socialLike(final String id, final ResponseCallback callback) {
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                FormBody body = new FormBody.Builder()
+                        .add("user_id", AccountCache.getAccount().getId())
+                        .add("social_id", id)
+                        .build();
+
+                Request request = new Request.Builder()
+                        .post(body)
+                        .url(CIRCLE_USER_LIKED)
+                        .build();
+
+                try{
+                    Response response = client.newCall(request).execute();
+                    String resultStr = response.body().string();
+                    CircleUserLikedBean likedBean = new Gson().fromJson(resultStr, CircleUserLikedBean.class);
+                    callback.onSuccess(likedBean);
+                }catch (Exception e){
+                    e.printStackTrace();
+                    callback.onFailed();
+                }
+            }
+        }).start();
+    }
+
+    @Override
     public void getSocialComment(final String id, final int lastId, final ResponseCallback callback) {
         new Thread(new Runnable() {
             @Override

+ 92 - 25
app/src/com/sheishuo/app/core_module/circle/activity/CircleDetailsActivity.java

@@ -13,15 +13,18 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.bumptech.glide.Glide;
+import com.google.gson.Gson;
 import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
 import com.netease.nim.uikit.session.activity.WatchPictureActivity;
 import com.sheishuo.app.R;
 import com.sheishuo.app.cache.AccountCache;
 import com.sheishuo.app.common.beans.CircleBean;
+import com.sheishuo.app.common.beans.CircleUserLikedBean;
 import com.sheishuo.app.common.beans.TradeBean;
 import com.sheishuo.app.common.util.img.ImgUtil;
 import com.sheishuo.app.common.util.net.INet;
 import com.sheishuo.app.common.util.net.NetImpl;
+import com.sheishuo.app.common.util.net.NetInfo;
 import com.sheishuo.app.common.util.net.ResponseCallback;
 import com.sheishuo.app.common.views.BaseToolbar;
 import com.sheishuo.app.common.views.ImgGridView;
@@ -34,6 +37,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import jp.wasabeef.glide.transformations.CropCircleTransformation;
+import okhttp3.FormBody;
 
 /**
  * Created by KN on 2017/8/25.
@@ -56,6 +60,8 @@ public class CircleDetailsActivity extends SheishuoUI {
 
     private TextView nameTV,dateTV,readNumTV,likedNumTV,commentTV, likedNum2TV, deleteTV;
 
+    private ImageView likedIcon;
+
     private PartlyHighLightTextView contentTV;
 
     private LinearLayout likedUserAvatarLayout;
@@ -67,6 +73,8 @@ public class CircleDetailsActivity extends SheishuoUI {
     private LinearLayout commentsLayout;
     private HeadImageView comment;
 
+    private boolean liked;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -85,6 +93,7 @@ public class CircleDetailsActivity extends SheishuoUI {
         dateTV = findView(R.id.circle_details_date);
         readNumTV = findView(R.id.circle_details_read_num);
         deleteTV = findView(R.id.circle_details_delete);
+        likedIcon = findView(R.id.circle_details_like_icon);
         likedNumTV = findView(R.id.circle_details_like_num);
         likedNum2TV = findView(R.id.circle_details_like_num2);
         commentTV = findView(R.id.circle_details_comment_num);
@@ -150,10 +159,6 @@ public class CircleDetailsActivity extends SheishuoUI {
             deleteTV.setVisibility(View.GONE);
         }
 
-        //显示点赞数
-        likedNumTV.setText(bean.getLikes());
-        likedNum2TV.setText(bean.getLikes()+"人已赞");
-
         //显示朋友圈内容
         contentTV.setText(bean.getMsg());
 
@@ -168,27 +173,7 @@ public class CircleDetailsActivity extends SheishuoUI {
         });
 
 
-        //显示点赞用户头像
-        for (String userId : bean.getLike_users()){
-            ImageView avatarView = new ImageView(context);
-            avatarView.setAdjustViewBounds(true);
-            avatarView.setMaxHeight((int) ImgUtil.convertDpToPixel(48,context));
-            avatarView.setMaxWidth((int) ImgUtil.convertDpToPixel(48,context));
-
-            if (getUserInfo(userId).getAvatar() != null){
-                Glide.with(context)
-                        .load(getUserInfo(userId).getAvatar())
-                        .bitmapTransform(new CropCircleTransformation(context))
-                        .into(avatarView);
-            }else {
-                Glide.with(context)
-                        .load(R.drawable.nim_avatar_default)
-                        .bitmapTransform(new CropCircleTransformation(context))
-                        .into(avatarView);
-            }
-
-            likedUserAvatarLayout.addView(avatarView);
-        }
+        showLikedUsers();
 
 
         //显示朋友圈图片
@@ -235,6 +220,19 @@ public class CircleDetailsActivity extends SheishuoUI {
             imgGridView.addView(imageView);
         }
 
+        likedNumTV.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                like();
+            }
+        });
+
+        likedIcon.setOnClickListener(new View.OnClickListener(){
+            @Override
+            public void onClick(View v) {
+                like();
+            }
+        });
 
         //显示评论
         if (bean.getComments_list().size() > 0){
@@ -244,6 +242,41 @@ public class CircleDetailsActivity extends SheishuoUI {
         }
     }
 
+    private void showLikedUsers()
+    {
+        likedUserAvatarLayout.removeAllViewsInLayout();
+        liked = false;
+
+        //显示点赞用户头像
+        for (String userId : bean.getLike_users()){
+            ImageView avatarView = new ImageView(context);
+            avatarView.setAdjustViewBounds(true);
+            avatarView.setMaxHeight((int) ImgUtil.convertDpToPixel(48,context));
+            avatarView.setMaxWidth((int) ImgUtil.convertDpToPixel(48,context));
+
+            if (getUserInfo(userId).getAvatar() != null){
+                Glide.with(context)
+                        .load(getUserInfo(userId).getAvatar())
+                        .bitmapTransform(new CropCircleTransformation(context))
+                        .into(avatarView);
+            }else {
+                Glide.with(context)
+                        .load(R.drawable.nim_avatar_default)
+                        .bitmapTransform(new CropCircleTransformation(context))
+                        .into(avatarView);
+            }
+
+            likedUserAvatarLayout.addView(avatarView);
+
+            if(userId.equals(AccountCache.getAccount().getId())) {
+                liked = true;
+            }
+        }
+
+        //显示点赞数
+        likedNumTV.setText(bean.getLikes());
+        likedNum2TV.setText(bean.getLikes()+"人已赞");
+    }
 
     private void showUserInfo()
     {
@@ -353,4 +386,38 @@ public class CircleDetailsActivity extends SheishuoUI {
         normalDialog.show();
 
     }
+
+
+
+
+    public void like(){
+
+        if(liked)
+        {
+            showToast(context, "已赞过了");
+            return;
+        }
+
+        final String social_id = bean.getId();
+
+        net.socialLike(social_id, new ResponseCallback() {
+            @Override
+            public void onSuccess(Object object) {
+                CircleUserLikedBean likedBean = (CircleUserLikedBean) object;
+                bean.setLike_users(likedBean.getD().getLike_users());
+                bean.setLikes(likedBean.getD().getLikes());
+                getHandler().post(new Runnable() {
+                    @Override
+                    public void run() {
+                        showLikedUsers();
+                    }
+                });
+            }
+
+            @Override
+            public void onFailed() {
+                showToast(context, "点赞失败");
+            }
+        });
+    }
 }

+ 19 - 0
app/src/com/sheishuo/app/core_module/friends/activity/PhoneContactsActivity.java

@@ -8,6 +8,8 @@ import android.os.Bundle;
 import android.provider.ContactsContract;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.TextWatcher;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
@@ -110,6 +112,23 @@ public class PhoneContactsActivity extends SheishuoUI {
 
             }
         });
+
+        searchET.addTextChangedListener(new TextWatcher() {
+            @Override
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+            }
+
+            @Override
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
+                adapter.setSearchKey(searchET.getText().toString().trim());
+            }
+
+            @Override
+            public void afterTextChanged(Editable s) {
+
+            }
+        });
     }
 
 

+ 44 - 2
app/src/com/sheishuo/app/core_module/friends/adapter/PhoneContactItemAdapter.java

@@ -33,6 +33,7 @@ public class PhoneContactItemAdapter extends RecyclerView.Adapter<PhoneContactIt
 
 
     private List<ContactRelationshipBean> data = new ArrayList<>();
+    private List<ContactRelationshipBean> searchData = new ArrayList<>();
 
     private AddFriendButtonClickListener listener = null;
 
@@ -47,7 +48,16 @@ public class PhoneContactItemAdapter extends RecyclerView.Adapter<PhoneContactIt
 
     @Override
     public void onBindViewHolder(PhoneContactItemViewHolder holder, int position) {
-        ContactRelationshipBean bean = data.get(position);
+
+        ContactRelationshipBean bean = null;
+
+        if(searchData.size() > 0)
+            bean = searchData.get(position);
+        else
+            bean = data.get(position);
+
+        if(bean == null)
+            return;
 
         if (getAvatar(bean.getId()) != null){
             Glide.with(context)
@@ -84,6 +94,8 @@ public class PhoneContactItemAdapter extends RecyclerView.Adapter<PhoneContactIt
 
     @Override
     public int getItemCount() {
+        if(searchData.size() > 0)
+            return searchData.size();
         return data.size();
     }
 
@@ -92,7 +104,6 @@ public class PhoneContactItemAdapter extends RecyclerView.Adapter<PhoneContactIt
         if (NIMClient.getService(UserService.class).getUserInfo(userId).getName() != null){
             return NIMClient.getService(UserService.class).getUserInfo(userId).getName();
         }
-
         return userId;
     }
 
@@ -175,4 +186,35 @@ public class PhoneContactItemAdapter extends RecyclerView.Adapter<PhoneContactIt
     public interface AddFriendButtonClickListener{
         void onClick(View view);
     }
+
+
+
+    public void setSearchKey(String key)
+    {
+        searchData.clear();
+        if(key.length() > 0)
+        {
+            String lowerKey = key.toLowerCase();
+            for (ContactRelationshipBean bean : data) {
+                String mobile = bean.getMobile().toLowerCase();
+                String name = "";
+                if (bean.getId().equals("-1")){
+                    name = getContactName(context, bean.getMobile()).toLowerCase();
+                }else {
+                    name = getName(bean.getId()).toLowerCase();
+                }
+                if(mobile.indexOf(lowerKey) >= 0)
+                {
+                    searchData.add(bean);
+                }
+                else if(name.indexOf(lowerKey) >= 0)
+                {
+                    searchData.add(bean);
+                }
+            }
+        }
+        notifyDataSetChanged();
+    }
+
+
 }

+ 1 - 8
app/src/com/sheishuo/app/core_module/mine/view/ui/activity/MineUploadPhotoActivity.java

@@ -53,7 +53,6 @@ public class MineUploadPhotoActivity extends SheishuoUI {
     private Context context = this;
 
     private BaseToolbar toolbar;
-    private TextView toolbarRightTxt;
 
     private GridLayout gridLayout;
 
@@ -108,7 +107,7 @@ public class MineUploadPhotoActivity extends SheishuoUI {
             }
         });
 
-        toolbarRightTxt = new TextView(getBaseContext());
+        TextView toolbarRightTxt = new TextView(getBaseContext());
         toolbarRightTxt.setText("");
         toolbar.setRightItems(new View[]{toolbarRightTxt});
     }
@@ -191,9 +190,6 @@ public class MineUploadPhotoActivity extends SheishuoUI {
         super.onActivityResult(requestCode, resultCode, data);
         if (Activity.RESULT_OK == resultCode){
             if (ADD_PHOTOS_CODE == requestCode){
-                toolbarRightTxt.setEnabled(false);
-                toolbarRightTxt.setText("上传中...");
-
                 Bundle result = data.getExtras();
                 List<PhotoInfo> photoInfoList = (List<PhotoInfo>) result.getSerializable("photo_list");
                 uploadPhotos(photoInfoList);
@@ -227,9 +223,6 @@ public class MineUploadPhotoActivity extends SheishuoUI {
                         @Override
                         public void run() {
                             initPhotosWall(AccountCache.getAccount().getId());
-
-                            //解锁完成按钮
-                            toolbarRightTxt.setText("完成");
                         }
                     });
 

+ 85 - 39
app/src/com/sheishuo/app/core_module/mine/view/ui/activity/PersonalSettingsActivity.java

@@ -5,20 +5,30 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.Handler;
 import android.support.v7.app.AlertDialog;
+import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
 import android.widget.CompoundButton;
 import android.widget.LinearLayout;
 import android.widget.Switch;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import com.bumptech.glide.Glide;
 import com.netease.nim.uikit.common.media.picker.PickImageHelper;
 import com.netease.nim.uikit.common.media.picker.model.PhotoInfo;
+import com.netease.nim.uikit.common.ui.dialog.DialogMaker;
 import com.netease.nim.uikit.common.ui.imageview.HeadImageView;
+import com.netease.nim.uikit.common.util.log.LogUtil;
+import com.netease.nim.uikit.session.actions.PickImageAction;
+import com.netease.nimlib.sdk.AbortableFuture;
 import com.netease.nimlib.sdk.NIMClient;
 import com.netease.nimlib.sdk.RequestCallback;
+import com.netease.nimlib.sdk.RequestCallbackWrapper;
+import com.netease.nimlib.sdk.ResponseCode;
+import com.netease.nimlib.sdk.nos.NosService;
 import com.netease.nimlib.sdk.uinfo.UserInfoProvider;
 import com.netease.nimlib.sdk.uinfo.UserService;
 import com.netease.nimlib.sdk.uinfo.constant.UserInfoFieldEnum;
@@ -31,11 +41,13 @@ import com.sheishuo.app.common.util.net.INet;
 import com.sheishuo.app.common.util.net.NetImpl;
 import com.sheishuo.app.common.util.net.ResponseCallback;
 import com.sheishuo.app.common.views.BaseToolbar;
+import com.sheishuo.app.contact.helper.UserUpdateHelper;
 import com.sheishuo.app.core_module.location.LocationSelectActivity;
 import com.sheishuo.app.core_module.sheishuo.view.ui.SettingTextEditActivity;
 import com.sheishuo.app.impl.SheishuoUI;
 import com.sheishuo.app.main.fragment.MineFragment;
 
+import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -58,6 +70,7 @@ public class PersonalSettingsActivity extends SheishuoUI {
     public static final int REQUEST_REALNAME = 5402;
     public static final int REQUEST_IDNUM = 5403;
 
+    public static final int AVATAR_TIME_OUT = 30000;
 
     private String TAG = this.getClass().getSimpleName();
     private Context context = this;
@@ -79,6 +92,7 @@ public class PersonalSettingsActivity extends SheishuoUI {
     private INet net = new NetImpl();
     private ResponseCallback callback;
 
+    AbortableFuture<String> uploadAvatarFuture;
 
     public static void start(Context context) {
         start(context, null);
@@ -421,27 +435,33 @@ public class PersonalSettingsActivity extends SheishuoUI {
                 //照相机
                 String filePath = result.getString("file_path");
                 if (requestCode == MineFragment.AVATAR_SELECTED){
-                    Glide.with(this).load(filePath)
-                            .centerCrop()
-                            .into(avatarImg);
-                    Map<UserInfoFieldEnum,Object> filedMap = new HashMap<>();
-                    filedMap.put(UserInfoFieldEnum.AVATAR,filePath);
-                    NIMClient.getService(UserService.class).updateUserInfo(filedMap).setCallback(new RequestCallback<Void>() {
-                        @Override
-                        public void onSuccess(Void aVoid) {
-                            showToast(getBaseContext(), "更新头像成功");
-                        }
 
+                    new Handler().postDelayed(outimeTask, AVATAR_TIME_OUT);
+                    uploadAvatarFuture = NIMClient.getService(NosService.class).upload(new File(filePath), PickImageAction.MIME_JPEG);
+                    uploadAvatarFuture.setCallback(new RequestCallbackWrapper<String>() {
                         @Override
-                        public void onFailed(int i) {
-                            showToast(getBaseContext(), "更新头像失败");
-
-                        }
-
-                        @Override
-                        public void onException(Throwable throwable) {
-                            showToast(getBaseContext(), "更新头像失败");
-
+                        public void onResult(int code, String url, Throwable exception) {
+                            if (code == ResponseCode.RES_SUCCESS && !TextUtils.isEmpty(url)) {
+                                LogUtil.i(TAG, "upload avatar success, url =" + url);
+                                Glide.with(PersonalSettingsActivity.this).load(url)
+                                        .centerCrop()
+                                        .into(avatarImg);
+                                UserUpdateHelper.update(UserInfoFieldEnum.AVATAR, url, new RequestCallbackWrapper<Void>() {
+                                    @Override
+                                    public void onResult(int code, Void result, Throwable exception) {
+                                        if (code == ResponseCode.RES_SUCCESS) {
+                                            Toast.makeText(PersonalSettingsActivity.this, R.string.head_update_success, Toast.LENGTH_SHORT).show();
+                                            onUpdateDone();
+                                        } else {
+                                            Toast.makeText(PersonalSettingsActivity.this, R.string.head_update_failed, Toast.LENGTH_SHORT).show();
+                                        }
+                                    }
+                                }); // 更新资料
+                            } else {
+                                Toast.makeText(PersonalSettingsActivity.this, R.string.user_info_update_failed, Toast
+                                        .LENGTH_SHORT).show();
+                                onUpdateDone();
+                            }
                         }
                     });
                 }
@@ -452,28 +472,33 @@ public class PersonalSettingsActivity extends SheishuoUI {
                 //相册
                 List<PhotoInfo> photoInfoList = (List<PhotoInfo>) result.getSerializable("photo_list");
                 if (requestCode == MineFragment.AVATAR_SELECTED){
-                    Glide.with(this)
-                            .load(photoInfoList.get(0).getFilePath())
-                            .centerCrop()
-                            .into(avatarImg);
-                    Map<UserInfoFieldEnum,Object> filedMap = new HashMap<>();
-                    filedMap.put(UserInfoFieldEnum.AVATAR,photoInfoList.get(0).getAbsolutePath());
-                    NIMClient.getService(UserService.class).updateUserInfo(filedMap).setCallback(new RequestCallback<Void>() {
-                        @Override
-                        public void onSuccess(Void aVoid) {
-                            showToast(getBaseContext(), "更新头像成功");
-                        }
-
-                        @Override
-                        public void onFailed(int i) {
-                            showToast(getBaseContext(), "更新头像失败");
-
-                        }
 
+                    new Handler().postDelayed(outimeTask, AVATAR_TIME_OUT);
+                    uploadAvatarFuture = NIMClient.getService(NosService.class).upload(new File(photoInfoList.get(0).getAbsolutePath()), PickImageAction.MIME_JPEG);
+                    uploadAvatarFuture.setCallback(new RequestCallbackWrapper<String>() {
                         @Override
-                        public void onException(Throwable throwable) {
-                            showToast(getBaseContext(), "更新头像失败");
-
+                        public void onResult(int code, String url, Throwable exception) {
+                            if (code == ResponseCode.RES_SUCCESS && !TextUtils.isEmpty(url)) {
+                                LogUtil.i(TAG, "upload avatar success, url =" + url);
+                                Glide.with(PersonalSettingsActivity.this).load(url)
+                                        .centerCrop()
+                                        .into(avatarImg);
+                                UserUpdateHelper.update(UserInfoFieldEnum.AVATAR, url, new RequestCallbackWrapper<Void>() {
+                                    @Override
+                                    public void onResult(int code, Void result, Throwable exception) {
+                                        if (code == ResponseCode.RES_SUCCESS) {
+                                            Toast.makeText(PersonalSettingsActivity.this, R.string.head_update_success, Toast.LENGTH_SHORT).show();
+                                            onUpdateDone();
+                                        } else {
+                                            Toast.makeText(PersonalSettingsActivity.this, R.string.head_update_failed, Toast.LENGTH_SHORT).show();
+                                        }
+                                    }
+                                }); // 更新资料
+                            } else {
+                                Toast.makeText(PersonalSettingsActivity.this, R.string.user_info_update_failed, Toast
+                                        .LENGTH_SHORT).show();
+                                onUpdateDone();
+                            }
                         }
                     });
 
@@ -483,6 +508,27 @@ public class PersonalSettingsActivity extends SheishuoUI {
     }
 
 
+    private void cancelUpload(int resId) {
+        if (uploadAvatarFuture != null) {
+            uploadAvatarFuture.abort();
+            Toast.makeText(PersonalSettingsActivity.this, resId, Toast.LENGTH_SHORT).show();
+            onUpdateDone();
+        }
+    }
+
+    private Runnable outimeTask = new Runnable() {
+        @Override
+        public void run() {
+            cancelUpload(R.string.user_info_update_failed);
+        }
+    };
+
+    private void onUpdateDone() {
+        uploadAvatarFuture = null;
+        DialogMaker.dismissProgressDialog();
+    }
+
+
     private void selectGender(final UserService userService) {
         final int[] yourChoice = new int[1];
         final String[] items = {"保密", "男", "女"};

+ 2 - 0
app/src/com/sheishuo/app/main/adapter/CircleListAdapter.java

@@ -92,6 +92,7 @@ public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.C
         holder.layout.setTag(bean);
         holder.layout.setOnClickListener(this);
         holder.contentTV.setText(bean.getMsg());
+        holder.contentTV.setVisibility(bean.getMsg().length() > 0 ? View.VISIBLE : View.GONE);
         holder.locationTV.setText(bean.getLocal());
         holder.dateTV.setText(bean.getInputtime());
         holder.likesNumTV.setText(bean.getLikes());
@@ -126,6 +127,7 @@ public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.C
         }
         GridViewAdapter gridViewAdapter = new GridViewAdapter(context,bean.getThumbs(),bean.getPics());
         holder.gridView.setAdapter(gridViewAdapter);
+        holder.gridView.setVisibility(bean.getThumbs().size() > 0 ? View.VISIBLE : View.GONE);
 
 
         holder.avatarContainer.setOnClickListener(this);

+ 91 - 0
app/src/com/sheishuo/app/main/fragment/CircleOfFriendsFragment.java

@@ -1,5 +1,6 @@
 package com.sheishuo.app.main.fragment;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Color;
@@ -18,16 +19,24 @@ import android.widget.TextView;
 import android.widget.Toast;
 
 import com.bumptech.glide.Glide;
+import com.netease.nim.uikit.common.media.picker.PickImageHelper;
+import com.netease.nim.uikit.common.media.picker.activity.PickImageActivity;
+import com.netease.nim.uikit.common.media.picker.model.PhotoInfo;
 import com.netease.nimlib.sdk.NIMClient;
+import com.netease.nimlib.sdk.RequestCallback;
 import com.netease.nimlib.sdk.uinfo.UserService;
 import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
+import com.netease.nimlib.sdk.uinfo.constant.UserInfoFieldEnum;
 import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
 import com.sheishuo.app.cache.AccountCache;
 import com.sheishuo.app.R;
 import com.sheishuo.app.SheishuoApplication;
 import com.sheishuo.app.cache.SocialInfoCache;
 import com.sheishuo.app.common.beans.SocialInfoBean;
+import com.sheishuo.app.common.util.net.INet;
+import com.sheishuo.app.common.util.net.NetImpl;
 import com.sheishuo.app.common.util.net.NetStatus;
+import com.sheishuo.app.common.util.net.ResponseCallback;
 import com.sheishuo.app.common.views.ImgGridView;
 import com.sheishuo.app.core_module.circle.activity.CircleDetailsActivity;
 import com.sheishuo.app.core_module.circle.activity.NewTweetingActivity;
@@ -40,6 +49,12 @@ import com.sheishuo.app.main.adapter.OnCircleItemClickListener;
 import com.sheishuo.app.main.model.MainTab;
 import com.sheishuo.app.main.presenter.CirclePresenter;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.netease.nim.uikit.ContextCache.context;
+
 
 /**
  * Created by KN on 2017/7/17.
@@ -62,6 +77,7 @@ public class CircleOfFriendsFragment extends MainTabFragment{
     private TextView username;
     private BaseToolbar toolbar;
     private MainActivity parent;
+    private INet net = new NetImpl();
 
     private CircleListAdapter adapter;
 
@@ -94,6 +110,12 @@ public class CircleOfFriendsFragment extends MainTabFragment{
                 .load(SocialInfoCache.get(AccountCache.getAccount().getId()).getSocial_banner())
                 .centerCrop()
                 .into(backgroundImg);
+        backgroundImg.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                pickImage(MineFragment.BANNER_SELECTED);
+            }
+        });
 
         username.setText(SocialInfoCache.getNick(user.getAccount()));
         isLoaded = true;
@@ -101,6 +123,22 @@ public class CircleOfFriendsFragment extends MainTabFragment{
     }
 
 
+    private void pickImage(int requestCode){
+        PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption();
+        option.multiSelectMaxCount = 1;
+        PickImageHelper.pickImage(getContext(),requestCode,option);
+    }
+
+    private void pickImageFromLocal(int requestCode){
+        PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption();
+        option.multiSelectMaxCount = 1;
+        PickImageActivity.start((Activity) context, requestCode, PickImageActivity.FROM_LOCAL, option.outputPath, option.multiSelect,
+                option.multiSelectMaxCount, true, false, 0, 0);
+    }
+
+
+
+
     void findViews(){
         parent = (MainActivity) getActivity();
         toolbar = (BaseToolbar) parent.getToolBar();
@@ -267,6 +305,59 @@ public class CircleOfFriendsFragment extends MainTabFragment{
                 String id = bundle.getString(DELETE_ID);
                 adapter.onDelete(id);
                 break;
+            case Activity.RESULT_OK:
+                UpdateBanner(requestCode, data);
+                break;
+        }
+    }
+
+    private void UpdateBanner(int requestCode, Intent data)
+    {
+        Bundle result = data.getExtras();
+        if(result == null)
+            return;
+
+        if (!result.getBoolean("from_local")) {
+            //照相机
+            String filePath = result.getString("file_path");
+            if (requestCode == MineFragment.BANNER_SELECTED){
+                Glide.with(getActivity()).load(filePath)
+                        .centerCrop()
+                        .into(backgroundImg);
+
+                net.updateBanner(filePath, new ResponseCallback() {
+                    @Override
+                    public void onSuccess(Object object) {
+                        showToast("更新背景图成功");
+                    }
+
+                    @Override
+                    public void onFailed() {
+                        showToast("更新背景图失败");
+                    }
+                });
+
+            }
+        } else {
+            //相册
+            List<PhotoInfo> photoInfoList = (List<PhotoInfo>) result.getSerializable("photo_list");
+            if (requestCode == MineFragment.BANNER_SELECTED){
+                Glide.with(getActivity())
+                        .load(photoInfoList.get(0).getFilePath())
+                        .centerCrop()
+                        .into(backgroundImg);
+                net.updateBanner(photoInfoList.get(0).getAbsolutePath(), new ResponseCallback() {
+                    @Override
+                    public void onSuccess(Object object) {
+                        showToast("更新背景图成功");
+                    }
+
+                    @Override
+                    public void onFailed() {
+                        showToast("更新背景图失败");
+                    }
+                });
+            }
         }
     }
 

+ 1 - 1
app/src/com/sheishuo/app/main/fragment/HomeFragment.java

@@ -447,7 +447,7 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
         //我的 选择照片回调
         if (resultCode == MineUploadPhotoActivity.ADD_PHOTOS_CODE || (resultCode == Activity.RESULT_OK && (requestCode == MineFragment.AVATAR_SELECTED || requestCode == MineFragment.BANNER_SELECTED))) {
             for (Fragment fragment : getFragmentManager().getFragments()) {
-                if (fragment instanceof MineFragment)
+                if (fragment instanceof MineFragment || fragment instanceof CircleOfFriendsFragment)
                     fragment.onActivityResult(requestCode, resultCode, data);
             }
             //防止往下传递,为什么不会消耗掉这个事件?

+ 79 - 41
app/src/com/sheishuo/app/main/fragment/MineFragment.java

@@ -3,6 +3,8 @@ package com.sheishuo.app.main.fragment;
 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.Handler;
+import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -19,9 +21,16 @@ import com.google.gson.Gson;
 import com.netease.nim.uikit.common.media.picker.PickImageHelper;
 import com.netease.nim.uikit.common.media.picker.activity.PickImageActivity;
 import com.netease.nim.uikit.common.media.picker.model.PhotoInfo;
+import com.netease.nim.uikit.common.ui.dialog.DialogMaker;
+import com.netease.nim.uikit.common.util.log.LogUtil;
 import com.netease.nim.uikit.common.util.media.ImageUtil;
+import com.netease.nim.uikit.session.actions.PickImageAction;
+import com.netease.nimlib.sdk.AbortableFuture;
 import com.netease.nimlib.sdk.NIMClient;
 import com.netease.nimlib.sdk.RequestCallback;
+import com.netease.nimlib.sdk.RequestCallbackWrapper;
+import com.netease.nimlib.sdk.ResponseCode;
+import com.netease.nimlib.sdk.nos.NosService;
 import com.netease.nimlib.sdk.uinfo.UserInfoProvider;
 import com.netease.nimlib.sdk.uinfo.UserService;
 import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
@@ -38,6 +47,7 @@ import com.sheishuo.app.common.util.net.INet;
 import com.sheishuo.app.common.util.net.NetImpl;
 import com.sheishuo.app.common.util.net.ResponseCallback;
 import com.sheishuo.app.common.views.BaseToolbar;
+import com.sheishuo.app.contact.helper.UserUpdateHelper;
 import com.sheishuo.app.core_module.mine.view.ui.activity.MineTradeActivity;
 import com.sheishuo.app.core_module.mine.view.ui.activity.MineUploadPhotoActivity;
 import com.sheishuo.app.core_module.mine.view.ui.activity.NearbyPeopleActivity;
@@ -46,6 +56,7 @@ import com.sheishuo.app.core_module.mine.view.ui.activity.SettingsActivity;
 import com.sheishuo.app.core_module.mine.view.ui.activity.UserInfoDetailActivity;
 import com.sheishuo.app.main.activity.MainActivity;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -72,6 +83,8 @@ public class MineFragment extends MainTabFragment implements View.OnClickListene
 
     private String mineId;
 
+    AbortableFuture<String> uploadAvatarFuture;
+
     //FLAGS
     public final static int AVATAR_SELECTED = 5000;
     public final static int BANNER_SELECTED = 5001;
@@ -199,27 +212,31 @@ public class MineFragment extends MainTabFragment implements View.OnClickListene
                 //照相机
                 String filePath = result.getString("file_path");
                 if (requestCode == AVATAR_SELECTED){
-                    Glide.with(getActivity()).load(filePath)
-                            .centerCrop()
-                            .into(avatarImg);
-                    Map<UserInfoFieldEnum,Object> filedMap = new HashMap<>();
-                    filedMap.put(UserInfoFieldEnum.AVATAR,filePath);
-                    NIMClient.getService(UserService.class).updateUserInfo(filedMap).setCallback(new RequestCallback<Void>() {
-                        @Override
-                        public void onSuccess(Void aVoid) {
-                            showToast("更新头像成功");
-                        }
-
-                        @Override
-                        public void onFailed(int i) {
-                            showToast("更新头像失败");
-
-                        }
-
+                    new Handler().postDelayed(outimeTask, PersonalSettingsActivity.AVATAR_TIME_OUT);
+                    uploadAvatarFuture = NIMClient.getService(NosService.class).upload(new File(filePath), PickImageAction.MIME_JPEG);
+                    uploadAvatarFuture.setCallback(new RequestCallbackWrapper<String>() {
                         @Override
-                        public void onException(Throwable throwable) {
-                            showToast("更新头像失败");
-
+                        public void onResult(int code, String url, Throwable exception) {
+                            if (code == ResponseCode.RES_SUCCESS && !TextUtils.isEmpty(url)) {
+                                LogUtil.i(TAG, "upload avatar success, url =" + url);
+                                Glide.with(MineFragment.this).load(url)
+                                        .centerCrop()
+                                        .into(avatarImg);
+                                UserUpdateHelper.update(UserInfoFieldEnum.AVATAR, url, new RequestCallbackWrapper<Void>() {
+                                    @Override
+                                    public void onResult(int code, Void result, Throwable exception) {
+                                        if (code == ResponseCode.RES_SUCCESS) {
+                                            showToast(getResources().getString(R.string.head_update_success));
+                                            onUpdateDone();
+                                        } else {
+                                            showToast(getResources().getString(R.string.head_update_failed));
+                                        }
+                                    }
+                                }); // 更新资料
+                            } else {
+                                showToast(getResources().getString(R.string.user_info_update_failed));
+                                onUpdateDone();
+                            }
                         }
                     });
                 } else if (requestCode == BANNER_SELECTED){
@@ -244,28 +261,31 @@ public class MineFragment extends MainTabFragment implements View.OnClickListene
                 //相册
                 List<PhotoInfo> photoInfoList = (List<PhotoInfo>) result.getSerializable("photo_list");
                 if (requestCode == AVATAR_SELECTED){
-                    Glide.with(getActivity())
-                            .load(photoInfoList.get(0).getFilePath())
-                            .centerCrop()
-                            .into(avatarImg);
-                    Map<UserInfoFieldEnum,Object> filedMap = new HashMap<>();
-                    filedMap.put(UserInfoFieldEnum.AVATAR,photoInfoList.get(0).getAbsolutePath());
-                    NIMClient.getService(UserService.class).updateUserInfo(filedMap).setCallback(new RequestCallback<Void>() {
+                    new Handler().postDelayed(outimeTask, PersonalSettingsActivity.AVATAR_TIME_OUT);
+                    uploadAvatarFuture = NIMClient.getService(NosService.class).upload(new File(photoInfoList.get(0).getAbsolutePath()), PickImageAction.MIME_JPEG);
+                    uploadAvatarFuture.setCallback(new RequestCallbackWrapper<String>() {
                         @Override
-                        public void onSuccess(Void aVoid) {
-                            showToast("更新头像成功");
-                        }
-
-                        @Override
-                        public void onFailed(int i) {
-                            showToast("更新头像失败");
-
-                        }
-
-                        @Override
-                        public void onException(Throwable throwable) {
-                            showToast("更新头像失败");
-
+                        public void onResult(int code, String url, Throwable exception) {
+                            if (code == ResponseCode.RES_SUCCESS && !TextUtils.isEmpty(url)) {
+                                LogUtil.i(TAG, "upload avatar success, url =" + url);
+                                Glide.with(MineFragment.this).load(url)
+                                        .centerCrop()
+                                        .into(avatarImg);
+                                UserUpdateHelper.update(UserInfoFieldEnum.AVATAR, url, new RequestCallbackWrapper<Void>() {
+                                    @Override
+                                    public void onResult(int code, Void result, Throwable exception) {
+                                        if (code == ResponseCode.RES_SUCCESS) {
+                                            showToast(getResources().getString(R.string.head_update_success));
+                                            onUpdateDone();
+                                        } else {
+                                            showToast(getResources().getString(R.string.head_update_failed));
+                                        }
+                                    }
+                                }); // 更新资料
+                            } else {
+                                showToast(getResources().getString(R.string.user_info_update_failed));
+                                onUpdateDone();
+                            }
                         }
                     });
 
@@ -439,6 +459,24 @@ public class MineFragment extends MainTabFragment implements View.OnClickListene
     }
 
 
+    private void cancelUpload(int resId) {
+        if (uploadAvatarFuture != null) {
+            uploadAvatarFuture.abort();
+            showToast(getResources().getString(resId));
+            onUpdateDone();
+        }
+    }
+
+    private Runnable outimeTask = new Runnable() {
+        @Override
+        public void run() {
+            cancelUpload(R.string.user_info_update_failed);
+        }
+    };
 
+    private void onUpdateDone() {
+        uploadAvatarFuture = null;
+        DialogMaker.dismissProgressDialog();
+    }
 
 }

+ 4 - 0
uikit/src/com/netease/nim/uikit/session/viewholder/MsgViewHolderFactory.java

@@ -1,5 +1,7 @@
 package com.netease.nim.uikit.session.viewholder;
 
+import android.util.Log;
+
 import com.netease.nimlib.sdk.msg.attachment.AudioAttachment;
 import com.netease.nimlib.sdk.msg.attachment.ImageAttachment;
 import com.netease.nimlib.sdk.msg.attachment.LocationAttachment;
@@ -50,6 +52,8 @@ public class MsgViewHolderFactory {
             Class<? extends MsgViewHolderBase> viewHolder = null;
             if (message.getAttachment() != null) {
                 Class<? extends MsgAttachment> clazz = message.getAttachment().getClass();
+                MsgAttachment attachment = message.getAttachment();
+                Log.e("Message Holder", attachment.toString());
                 while (viewHolder == null && clazz != null) {
                     viewHolder = viewHolders.get(clazz);
                     if (viewHolder == null) {