Browse Source

Merge branch 'master' of http://git.dashgame.com/fenix/sheishuoAPP

Fenix Wang 8 năm trước cách đây
mục cha
commit
a204dd7d8c
29 tập tin đã thay đổi với 892 bổ sung309 xóa
  1. 5 1
      app/AndroidManifest.xml
  2. 1 1
      app/proguard.cfg
  3. BIN
      app/res/drawable-hdpi/circle_new_tweet_img.png
  4. BIN
      app/res/drawable-mdpi/circle_new_tweet_img.png
  5. BIN
      app/res/drawable-xhdpi/circle_new_tweet_img.png
  6. BIN
      app/res/drawable-xxhdpi/circle_new_tweet_img.png
  7. BIN
      app/res/drawable-xxxhdpi/circle_new_tweet_img.png
  8. 8 1
      app/res/layout/base_toolbar.xml
  9. 28 2
      app/res/layout/circle_new_tweeting.xml
  10. 9 0
      app/res/layout/recent_contacts_list_activity.xml
  11. 0 116
      app/src/com/sheishuo/app/circle/activity/NewTweetingActivity.java
  12. 0 65
      app/src/com/sheishuo/app/circle/model/NewTweetModel.java
  13. 0 33
      app/src/com/sheishuo/app/circle/presenter/NewTweetPresenter.java
  14. 7 0
      app/src/com/sheishuo/app/common/util/net/INet.java
  15. 76 0
      app/src/com/sheishuo/app/common/util/net/NetImpl.java
  16. 1 0
      app/src/com/sheishuo/app/common/util/net/NetInfo.java
  17. 97 0
      app/src/com/sheishuo/app/common/views/BaseToolbar.java
  18. 266 0
      app/src/com/sheishuo/app/core_module/circle/activity/NewTweetingActivity.java
  19. 135 0
      app/src/com/sheishuo/app/core_module/circle/model/NewTweetModel.java
  20. 1 1
      app/src/com/sheishuo/app/core_module/circle/model/beans/NewTweetingBean.java
  21. 54 0
      app/src/com/sheishuo/app/core_module/circle/presenter/NewTweetPresenter.java
  22. 45 0
      app/src/com/sheishuo/app/core_module/recent_contacts/activity/ContactsListActivity.java
  23. 4 37
      app/src/com/sheishuo/app/main/activity/MainActivity.java
  24. 56 34
      app/src/com/sheishuo/app/main/adapter/CircleListAdapter.java
  25. 63 8
      app/src/com/sheishuo/app/main/fragment/CircleOfFriendsFragment.java
  26. 12 9
      app/src/com/sheishuo/app/main/fragment/HomeFragment.java
  27. 19 0
      app/src/com/sheishuo/app/main/fragment/SessionListFragment.java
  28. 5 0
      app/src/com/sheishuo/app/main/model/CircleModel.java
  29. 0 1
      app/src/com/sheishuo/app/main/presenter/CirclePresenter.java

+ 5 - 1
app/AndroidManifest.xml

@@ -115,10 +115,14 @@
             android:windowSoftInputMode="adjustResize|stateHidden"/>
 
         <!--朋友圈相关-->
-        <activity android:name=".circle.activity.NewTweetingActivity"
+        <activity android:name=".core_module.circle.activity.NewTweetingActivity"
             android:theme="@style/AppTheme.NoActionBar"/>
 
 
+        <!--联系人界面-->
+        <activity android:name=".core_module.recent_contacts.activity.ContactsListActivity"
+            android:theme="@style/AppTheme.NoActionBar"/>
+
         <!-- 关于 -->
         <activity
             android:name="com.sheishuo.app.main.activity.AboutActivity"

+ 1 - 1
app/proguard.cfg

@@ -153,7 +153,7 @@
 -keepattributes Signature
 -keepattributes *Annotation*
 
--keep class com.sheishuo.app.circle.model.beans.**{*;}
+-keep class com.sheishuo.app.core_module.circle.model.beans.**{*;}
 -keep class com.sheishuo.app.login.beans.**{*;}
 -keep class com.sheishuo.app.common.beans.**{*;}
 

BIN
app/res/drawable-hdpi/circle_new_tweet_img.png


BIN
app/res/drawable-mdpi/circle_new_tweet_img.png


BIN
app/res/drawable-xhdpi/circle_new_tweet_img.png


BIN
app/res/drawable-xxhdpi/circle_new_tweet_img.png


BIN
app/res/drawable-xxxhdpi/circle_new_tweet_img.png


+ 8 - 1
app/res/layout/base_toolbar.xml

@@ -38,6 +38,13 @@
                 android:gravity="center"
                 android:textColor="@color/white"
                 android:textSize="16sp" />
-
+            <LinearLayout
+                android:id="@+id/toolbar_ico_layout"
+                android:layout_weight="2"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:visibility="gone"
+                android:gravity="center"/>
         </LinearLayout>
 </android.support.v7.widget.Toolbar>

+ 28 - 2
app/res/layout/circle_new_tweeting.xml

@@ -34,15 +34,41 @@
         app:layout_constraintHorizontal_bias="0.0"
         android:layout_marginStart="8dp"
         android:layout_marginEnd="8dp" />
+    <HorizontalScrollView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:layout_marginTop="8dp"
+        app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
+        app:layout_constraintLeft_toLeftOf="@+id/new_tweet_content"
+        android:scrollbarAlwaysDrawHorizontalTrack="true">
+
+        <LinearLayout
+            android:id="@+id/new_tweet_img_layout"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal">
+
+            <ImageView
+                android:id="@+id/new_tweet_add_imgs"
+                android:layout_width="128dp"
+                android:layout_height="128dp"
+                android:src="@drawable/circle_new_tweet_img"/>
+        </LinearLayout>
+    </HorizontalScrollView>
+
 
     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@color/grey_light_light"
         android:padding="4dp"
+        android:layout_marginLeft="8dp"
         app:layout_constraintLeft_toLeftOf="@+id/new_tweet_content"
-        android:layout_marginTop="10dp"
-        app:layout_constraintTop_toBottomOf="@+id/new_tweet_content">
+        android:layout_marginTop="8dp"
+        app:layout_constraintTop_toBottomOf="@+id/new_tweet_content"
+        android:id="@+id/linearLayout2"
+        android:layout_marginStart="8dp">
         <ImageView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"

+ 9 - 0
app/res/layout/recent_contacts_list_activity.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical" android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <LinearLayout
+        android:id="@+id/recent_contacts_list_layout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+</LinearLayout>

+ 0 - 116
app/src/com/sheishuo/app/circle/activity/NewTweetingActivity.java

@@ -1,116 +0,0 @@
-package com.sheishuo.app.circle.activity;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.sheishuo.app.cache.AccountCache;
-import com.sheishuo.app.R;
-import com.sheishuo.app.circle.presenter.NewTweetPresenter;
-import com.sheishuo.app.common.util.location.LocationHelper;
-import com.sheishuo.app.common.views.BaseToolbar;
-import com.sheishuo.app.main.activity.MainActivity;
-import com.sheishuo.app.uikit_implements.SheishuoUI;
-
-/**
- * Created by KN on 2017/7/21.
- */
-
-public class NewTweetingActivity extends SheishuoUI {
-    private String TAG = this.getClass().getSimpleName();
-    private Context context = this;
-    private BaseToolbar toolbar;
-    private EditText tweetContent;
-    private TextView locationTV;
-    private NewTweetPresenter presenter;
-
-    public static void start(Context context) {
-        start(context, null);
-    }
-
-    public static void start(Context context, Intent extras) {
-        Intent intent = new Intent();
-        intent.setClass(context, MainActivity.class);
-        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
-        if (extras != null) {
-            intent.putExtras(extras);
-        }
-        context.startActivity(intent);
-    }
-
-
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.circle_new_tweeting);
-        findViews();
-        init();
-    }
-
-
-
-
-    private void findViews(){
-        toolbar = (BaseToolbar) findViewById(R.id.new_tweet_toolbar);
-        tweetContent = (EditText) findViewById(R.id.new_tweet_content);
-        locationTV = (TextView) findViewById(R.id.new_tweet_location_tv);
-    }
-
-    private void init(){
-
-        presenter = new NewTweetPresenter(this);
-
-        //初始化Toolbar
-        toolbar.getLeftTV().setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                finish();
-            }
-        });
-
-
-        toolbar.getRightTV().setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                presenter.publishNewTweeting(tweetContent.getText().toString());
-            }
-        });
-
-
-        //初始化定位
-        AccountCache.getAccount().setLatitude(LocationHelper.getLatitude());
-        AccountCache.getAccount().setLongitude(LocationHelper.getLongitude());
-
-        Log.e(TAG,"location ===> " + LocationHelper.getLatitude() + "   " + LocationHelper.getLongitude());
-        locationTV.setText(AccountCache.getAccount().getCity() + AccountCache.getAccount().getDistrict());
-
-
-    }
-
-
-    /**
-     * 以下为开放给Presenter的通用方法
-     */
-
-    public void showToast(final String toast){
-        getHandler().post(new Runnable() {
-            @Override
-            public void run() {
-                Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
-            }
-        });
-    }
-
-
-    public void onTweetSuccess(){
-        showToast("发布成功");
-        finish();
-    }
-
-}

+ 0 - 65
app/src/com/sheishuo/app/circle/model/NewTweetModel.java

@@ -1,65 +0,0 @@
-package com.sheishuo.app.circle.model;
-
-import com.google.gson.Gson;
-import com.sheishuo.app.cache.AccountCache;
-import com.sheishuo.app.circle.model.beans.NewTweetingBean;
-import com.sheishuo.app.circle.presenter.NewTweetPresenter;
-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.login.beans.LoginBean;
-
-import okhttp3.FormBody;
-
-/**
- * Created by KN on 2017/7/21.
- */
-
-public class NewTweetModel {
-    private NewTweetPresenter presenter;
-    private INet net;
-    private NewTweetingBean bean;
-
-    public NewTweetModel(NewTweetPresenter presenter){
-        this.presenter = presenter;
-        net = new NetImpl();
-        bean = new NewTweetingBean();
-    }
-
-
-
-    public void publishNewTweeting(final String content){
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                LoginBean.DBean accuont = AccountCache.getAccount();
-                FormBody body = new FormBody.Builder()
-                        .add("id",accuont.getId())
-                        .add("msg",content)
-                        .add("local",accuont.getCity() + accuont.getDistrict())
-                        .add("latitude",accuont.getLatitude())
-                        .add("longitude",accuont.getLongitude())
-                        .build();
-
-
-                net.post(NetInfo.NEW_TWEETING, body, new ResponseCallback() {
-                    @Override
-                    public void onSuccess(Object object) {
-                        bean = new Gson().fromJson((String)object,NewTweetingBean.class);
-                        if (0==bean.getC()){
-                            presenter.onPublishSuccess();
-                        }else {
-                            presenter.showToast("发布失败");
-                        }
-                    }
-
-                    @Override
-                    public void onFailed() {
-                        presenter.showToast("发布失败");
-                    }
-                });
-            }
-        }).start();
-    }
-}

+ 0 - 33
app/src/com/sheishuo/app/circle/presenter/NewTweetPresenter.java

@@ -1,33 +0,0 @@
-package com.sheishuo.app.circle.presenter;
-
-import com.sheishuo.app.circle.activity.NewTweetingActivity;
-import com.sheishuo.app.circle.model.NewTweetModel;
-import com.sheishuo.app.main.model.CircleModel;
-
-/**
- * Created by KN on 2017/7/21.
- */
-
-public class NewTweetPresenter {
-    NewTweetingActivity activity;
-    NewTweetModel model;
-
-    public NewTweetPresenter(NewTweetingActivity activity){
-        this.activity = activity;
-        model = new NewTweetModel(this);
-    }
-
-
-    public void publishNewTweeting(String content){
-        model.publishNewTweeting(content);
-    }
-
-    public void onPublishSuccess(){
-        activity.onTweetSuccess();
-    }
-
-    public void showToast(String toast){
-        activity.showToast(toast);
-    }
-
-}

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

@@ -1,14 +1,21 @@
 package com.sheishuo.app.common.util.net;
 
+import java.util.List;
+
 import okhttp3.FormBody;
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
 
 /**
  * Created by KN on 2017/7/14.
  */
 
 public interface INet {
+    MediaType JSON = MediaType.parse("application/json; charset=utf-8");
     void baseQuery();
     void post(String url,FormBody body,ResponseCallback callback);
+    void post(String url, RequestBody body,ResponseCallback callback);
     void loginQuery(String mobile,String pwd,ResponseCallback callback);
     void getGiftList(ResponseCallback callback);
+    void uploadImgs(String filePath,ResponseCallback callback);
 }

+ 76 - 0
app/src/com/sheishuo/app/common/util/net/NetImpl.java

@@ -4,15 +4,26 @@ import android.util.Log;
 
 import com.google.gson.Gson;
 import com.google.gson.JsonObject;
+import com.sheishuo.app.cache.AccountCache;
 import com.sheishuo.app.cache.GiftCache;
 import com.sheishuo.app.common.beans.GiftBean;
 import com.sheishuo.app.login.beans.LoginBean;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.File;
 import java.io.IOException;
+import java.util.List;
 
+import okhttp3.Call;
+import okhttp3.Callback;
 import okhttp3.FormBody;
+import okhttp3.MediaType;
+import okhttp3.MultipartBody;
 import okhttp3.OkHttpClient;
 import okhttp3.Request;
+import okhttp3.RequestBody;
 import okhttp3.Response;
 
 /**
@@ -21,6 +32,7 @@ import okhttp3.Response;
 
 public class  NetImpl implements INet {
 
+
     private static OkHttpClient client = new OkHttpClient.Builder().build();
     private Gson gson = new Gson();
 
@@ -52,6 +64,28 @@ public class  NetImpl implements INet {
     }
 
     @Override
+    public void post(String url, RequestBody body, ResponseCallback callback) {
+        Request request = new Request.Builder()
+                .url(url)
+                .post(body)
+                .build();
+
+        try {
+            Response response = client.newCall(request).execute();
+
+            if (200 == response.code()){
+                callback.onSuccess(response.body().string());
+            }else {
+                callback.onFailed();
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+            callback.onFailed();
+        }
+    }
+
+    @Override
     public void loginQuery(String mobile, String pwd, final ResponseCallback callback) {
         final FormBody body = new FormBody.Builder()
                 .add("mobile",mobile)
@@ -129,5 +163,47 @@ public class  NetImpl implements INet {
 
     }
 
+    @Override
+    public void uploadImgs(String filePath, final ResponseCallback callback) {
+        File file = new File(filePath);
+        MultipartBody.Builder builder = new MultipartBody.Builder();
+        builder.setType(MultipartBody.FORM);
+
+        builder.addFormDataPart("user_id", AccountCache.getAccount().getId());
+        builder.addFormDataPart("upload",file.getName(), RequestBody.create(null,file));
+
+
+        RequestBody body = builder.build();
+        Request request = new Request.Builder()
+                .url(NetInfo.UPLOAD_IMG)
+                .post(body)
+                .build();
+
+        Call call = client.newCall(request);
+        call.enqueue(new Callback() {
+            @Override
+            public void onFailure(Call call, IOException e) {
+                callback.onFailed();
+                e.printStackTrace();
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                try {
+                    JSONObject jsonObject = new JSONObject(response.body().string());
+                    if (jsonObject.getInt("c") == 0){
+                        int imgCode = jsonObject.getJSONObject("d").getInt("aid");
+                        callback.onSuccess(imgCode);
+                    }else {
+                        callback.onFailed();
+                    }
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                    callback.onFailed();
+                }
+            }
+        });
+    }
+
 
 }

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

@@ -14,4 +14,5 @@ public class NetInfo {
     public final static String NEW_TWEETING = INDEX + "?m=who&c=social&a=publish";
     public final static String GIFT_LIST = INDEX + "?m=who&c=index&a=gift_list";
     public final static String GET_CODE = INDEX + "?m=who&c=index&a=send_code";
+    public final static String UPLOAD_IMG = INDEX + "?m=who&c=social&a=upload";
 }

+ 97 - 0
app/src/com/sheishuo/app/common/views/BaseToolbar.java

@@ -7,10 +7,18 @@ import android.support.v7.widget.Toolbar;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
+import com.bumptech.glide.Glide;
 import com.sheishuo.app.R;
+import com.sheishuo.app.common.util.img.ImgUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import okhttp3.FormBody;
 
 /**
  * Created by KN on 2017/7/20.
@@ -19,12 +27,19 @@ import com.sheishuo.app.R;
 public class BaseToolbar extends Toolbar {
 
     private final String TITLE = "title",LEFT_TEXT = "left_text",RIGHT_TEXT = "right_text";
+    private static Context context;
     private String titleStr = "",leftStr = "",rightStr = "";
     private TextView titleTV,leftTV,rightTV;
+    private LinearLayout icoLayout;
+
+    public interface IcoBtnClickListener{
+        void onClick(View view);
+    }
 
 
     public BaseToolbar(Context context, @Nullable AttributeSet attrs) {
         super(context, attrs);
+        this.context = context;
         View view = LayoutInflater.from(context).inflate(R.layout.base_toolbar,this,true);
         findViews(view);
         assert attrs != null;
@@ -56,6 +71,7 @@ public class BaseToolbar extends Toolbar {
         titleTV = (TextView) view.findViewById(R.id.toolbar_title);
         leftTV = (TextView) view.findViewById(R.id.toolbar_left);
         rightTV = (TextView) view.findViewById(R.id.toolbar_right);
+        icoLayout = (LinearLayout) view.findViewById(R.id.toolbar_ico_layout);
     }
 
 
@@ -76,6 +92,8 @@ public class BaseToolbar extends Toolbar {
         titleTV.setVisibility(INVISIBLE);
         leftTV.setVisibility(INVISIBLE);
         rightTV.setVisibility(INVISIBLE);
+        icoLayout.removeAllViews();
+        icoLayout.setVisibility(GONE);
         titleTV.setOnClickListener(null);
         leftTV.setOnClickListener(null);
         rightTV.setOnClickListener(null);
@@ -84,6 +102,10 @@ public class BaseToolbar extends Toolbar {
 
 
 
+
+
+
+
     public void setTitle(String title){
         getTitleTV().setText(title);
         titleTV.setVisibility(VISIBLE);
@@ -101,6 +123,81 @@ public class BaseToolbar extends Toolbar {
 
     }
 
+    public LinearLayout getIcoLayout() {
+        return icoLayout;
+    }
+
+    public void setIcoLayout(LinearLayout icoLayout) {
+        this.icoLayout = icoLayout;
+    }
+
+
+
+
+    /**************用于为BaseToolbar增加额外功能***************/
+
+
+    public static class Builder implements OnClickListener{
+
+        BaseToolbar toolbar;
+        private List<Integer> icoIds = new ArrayList<>();
+        IcoBtnClickListener listener;
+        Context context;
+
+        public Builder create(Context context,@Nullable BaseToolbar toolbar){
+            if (toolbar == null){
+                this.toolbar = new BaseToolbar(context,null);
+            }else {
+                this.toolbar = toolbar;
+            }
+
+            this.context = context;
+
+            return this;
+        }
+
+
+
+        /**
+         * 为Toolbar添加一个图标按钮
+         *
+         * 为了保证布局显示正常,若添加ico按钮则自动隐藏Right_Text
+         * @param resId
+         */
+        public BaseToolbar.Builder addIcoButton(int resId){
+                toolbar.rightTV.setVisibility(GONE);
+                toolbar.icoLayout.setVisibility(VISIBLE);
+                ImageView icoView = new ImageView(context);
+                icoView.setAdjustViewBounds(true);
+                int dpToPixel = (int) ImgUtil.convertDpToPixel(24,context);
+                Glide.with(context)
+                        .load(resId)
+                        .override(dpToPixel,dpToPixel)
+                        .into(icoView);
+                toolbar.icoLayout.addView(icoView);
+                icoIds.add(resId);
+                return this;
+        }
+
+
+        public BaseToolbar.Builder addIcoButtonClickListener(int index,IcoBtnClickListener listener){
+                this.listener = listener;
+                toolbar.getIcoLayout().getChildAt(0).setOnClickListener(this);
+                return this;
+        }
+
+        public BaseToolbar build(){
+                return toolbar;
+        }
+
+
+
+        @Override
+        public void onClick(View v) {
+            if (listener != null) listener.onClick(v);
+        }
+    }
+
 
 
 

+ 266 - 0
app/src/com/sheishuo/app/core_module/circle/activity/NewTweetingActivity.java

@@ -0,0 +1,266 @@
+package com.sheishuo.app.core_module.circle.activity;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+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.sheishuo.app.R;
+import com.sheishuo.app.cache.AccountCache;
+import com.sheishuo.app.core_module.circle.presenter.NewTweetPresenter;
+import com.sheishuo.app.common.util.img.ImgUtil;
+import com.sheishuo.app.common.util.location.LocationHelper;
+import com.sheishuo.app.common.util.net.NetStatus;
+import com.sheishuo.app.common.views.BaseToolbar;
+import com.sheishuo.app.main.activity.MainActivity;
+import com.sheishuo.app.main.fragment.CircleOfFriendsFragment;
+import com.sheishuo.app.uikit_implements.SheishuoUI;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import jp.wasabeef.glide.transformations.ColorFilterTransformation;
+
+/**
+ * Created by KN on 2017/7/21.
+ */
+
+public class NewTweetingActivity extends SheishuoUI {
+    private String TAG = this.getClass().getSimpleName();
+    private Context context = this;
+    private BaseToolbar toolbar;
+    private EditText tweetContent;
+    private TextView locationTV;
+    private LinearLayout imgsLayout;
+    private ImageView addImg;
+    private NewTweetPresenter presenter;
+    private List<String> selectedPhotoPathList;
+    private List<Integer> photoIds;
+    private Toast toast = null;
+//    private static MainActivity activity;
+
+    public static void start(Context context) {
+        start(context, null);
+    }
+
+    public static void start(Context context, Intent extras) {
+        Intent intent = new Intent();
+        intent.setClass(context, NewTweetingActivity.class);
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+        if (extras != null) {
+            intent.putExtras(extras);
+        }
+        context.startActivity(intent);
+    }
+
+    public static void startActivityForResult(Context context, Intent extras){
+        Intent intent = new Intent();
+        intent.setClass(context, NewTweetingActivity.class);
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+        if (extras != null) {
+            intent.putExtras(extras);
+        }
+        if (context instanceof MainActivity){
+            ((MainActivity)context).startActivityForResult(intent,0);
+        }
+
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.circle_new_tweeting);
+        findViews();
+        init();
+        setResult(CircleOfFriendsFragment.REFRESH_CIRCLE);
+    }
+
+
+    private void findViews() {
+        toolbar = (BaseToolbar) findViewById(R.id.new_tweet_toolbar);
+        tweetContent = (EditText) findViewById(R.id.new_tweet_content);
+        locationTV = (TextView) findViewById(R.id.new_tweet_location_tv);
+        imgsLayout = (LinearLayout) findViewById(R.id.new_tweet_img_layout);
+        addImg = (ImageView) findViewById(R.id.new_tweet_add_imgs);
+    }
+
+    private void init() {
+
+        presenter = new NewTweetPresenter(this);
+
+        //初始化Toolbar
+        toolbar.getLeftTV().setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                finish();
+            }
+        });
+
+
+
+        //发布按钮监听事件
+        toolbar.getRightTV().setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (NetStatus.IS_BUSY){
+                    showToast("内容发布中,请稍后...");
+                }else {
+                    showToast("内容发布中...");
+                    toolbar.getRightTV().setEnabled(false);
+                    getHandler().postDelayed(new Runnable() {
+                        @Override
+                        public void run() {
+                            presenter.publishNewTweeting(tweetContent.getText().toString(),photoIds);
+                        }
+                    },1000);
+                }
+            }
+        });
+
+
+        //初始化定位
+        AccountCache.getAccount().setLatitude(LocationHelper.getLatitude());
+        AccountCache.getAccount().setLongitude(LocationHelper.getLongitude());
+
+        Log.e(TAG, "location ===> " + LocationHelper.getLatitude() + "   " + LocationHelper.getLongitude());
+        locationTV.setText(AccountCache.getAccount().getCity() + AccountCache.getAccount().getDistrict());
+
+
+        //初始化照片添加监听事件
+        selectedPhotoPathList = new ArrayList<>();
+        photoIds = new ArrayList<>();
+        addImg.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                PickImageHelper.PickImageOption option = new PickImageHelper.PickImageOption();
+                PickImageHelper.pickImage(context, 0, option);
+
+            }
+        });
+
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (resultCode == Activity.RESULT_OK) {
+            for (String key : data.getExtras().keySet()) {
+                Log.e("key", key);
+            }
+
+            Bundle result = data.getExtras();
+            if (!result.getBoolean("from_local")) {
+                //照相机
+                String filePath = result.getString("file_path");
+                imgsLayout.removeAllViews();
+                ImageView imageView = new ImageView(this);
+                imageView.setAdjustViewBounds(true);
+                int toDp = (int) ImgUtil.convertDpToPixel(128, context);
+                imageView.setLayoutParams(new LinearLayout.LayoutParams(toDp, toDp));
+                Glide.with(context).load(filePath)
+                        .centerCrop()
+                        .bitmapTransform(new ColorFilterTransformation(context, 0x7900CCCC))
+                        .into(imageView);
+                presenter.uploadPhoto(filePath);
+            } else {
+                //相册
+                imgsLayout.removeAllViews();
+                List<PhotoInfo> photoInfoList = (List<PhotoInfo>) result.getSerializable("photo_list");
+                for (PhotoInfo info : photoInfoList) {
+                    ImageView imageView = new ImageView(this);
+                    imageView.setAdjustViewBounds(true);
+                    int toDp = (int) ImgUtil.convertDpToPixel(128, context);
+                    imageView.setLayoutParams(new LinearLayout.LayoutParams(toDp, toDp));
+                    Glide.with(context).load(info.getFilePath())
+                            .centerCrop()
+                            .bitmapTransform(new ColorFilterTransformation(context, 0x7900CCCC))
+                            .into(imageView);
+                    imgsLayout.addView(imageView);
+                    selectedPhotoPathList.add(info.getAbsolutePath());
+                }
+
+                presenter.uploadPhoto(selectedPhotoPathList);
+            }
+
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+//        activity.onActivityResult(0,CircleOfFriendsFragment.REFRESH_CIRCLE,null);
+    }
+
+    /**
+     * 以下为开放给Presenter的通用方法
+     */
+
+    public void showToast(final String str){
+        getHandler().post(new Runnable() {
+            @Override
+            public void run() {
+                if (toast == null){
+                    toast = Toast.makeText(context,str,Toast.LENGTH_SHORT);
+                }else {
+                    toast.setText(str);
+                }
+                toast.show();
+
+            }
+        });
+    }
+
+
+
+    public void onTweetSuccess() {
+        showToast("发布成功");
+        finish();
+    }
+
+
+
+    //当一张照片上传完成后回调
+    public void onOnePhotoUploaded(final int index, final int photoId){
+        getHandler().post(new Runnable() {
+            @Override
+            public void run() {
+                ImageView imageView = (ImageView) imgsLayout.getChildAt(index);
+                String filePath = selectedPhotoPathList.get(index);
+                Glide.with(context).load(filePath).into(imageView);
+                Collections.synchronizedList(photoIds);
+                photoIds.add(photoId);
+
+            }
+        });
+
+    }
+
+
+    //全部照片上传完成
+    public void onAllPhotosUploaded(){
+        getHandler().post(new Runnable() {
+            @Override
+            public void run() {
+                toolbar.getRightTV().setEnabled(true);
+            }
+        });
+    }
+
+
+
+
+
+
+}

+ 135 - 0
app/src/com/sheishuo/app/core_module/circle/model/NewTweetModel.java

@@ -0,0 +1,135 @@
+package com.sheishuo.app.core_module.circle.model;
+
+import com.google.gson.Gson;
+import com.sheishuo.app.cache.AccountCache;
+import com.sheishuo.app.core_module.circle.model.beans.NewTweetingBean;
+import com.sheishuo.app.core_module.circle.presenter.NewTweetPresenter;
+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.NetStatus;
+import com.sheishuo.app.common.util.net.ResponseCallback;
+import com.sheishuo.app.login.beans.LoginBean;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import okhttp3.FormBody;
+
+/**
+ * Created by KN on 2017/7/21.
+ */
+
+public class NewTweetModel {
+    private NewTweetPresenter presenter;
+    private INet net;
+    private NewTweetingBean bean;
+
+    public NewTweetModel(NewTweetPresenter presenter){
+        this.presenter = presenter;
+        net = new NetImpl();
+        bean = new NewTweetingBean();
+    }
+
+
+
+    public void uploadPhoto(final List<String> filesPath){
+        NetStatus.IS_BUSY = true;
+        final int allPhotoNum = filesPath.size();
+        final List<Integer> uploadedNum = new ArrayList<>();
+        uploadedNum.add(0);
+        uploadedNum.set(0,0);
+
+        for (int i = 0;i < filesPath.size();i++){
+            final int finalI = i;
+            new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    final int index = finalI;
+                    net.uploadImgs(filesPath.get(finalI), new ResponseCallback() {
+                        @Override
+                        public void onSuccess(Object object) {
+                            //Log.e("object", (String) object);
+                            presenter.onOnePhotoUploaded(index,(int)object);
+                            presenter.showToast("第" + (finalI + 1) + "张照片上传完毕");
+                        }
+
+                        @Override
+                        public void onFailed() {
+                            presenter.showToast("第" + (finalI + 1) + "张照片上传失败");
+                        }
+                    });
+
+
+                    //同步List
+                    Collections.synchronizedList(uploadedNum);
+                    int temp = uploadedNum.get(0) + 1;
+                    uploadedNum.set(0,temp);
+                    if(uploadedNum.get(0) == allPhotoNum) {
+                        presenter.onAllPhotoUploaded();
+                        NetStatus.IS_BUSY = false;
+                    }
+                }
+
+
+            }).start();
+
+        }
+
+    }
+
+    public void publishNewTweeting(final String content,final List<Integer> photoIds){
+        NetStatus.IS_BUSY = true;
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                LoginBean.DBean accuont = AccountCache.getAccount();
+                String pics = "";
+                if (photoIds.size() > 0){
+                    int[] temp = new int[photoIds.size()];
+                    for (int i = 0;i < photoIds.size();i++){
+                        temp[i] = photoIds.get(i);
+                    }
+                    pics = Arrays.toString(temp);
+
+                    pics = pics.replace("[","");
+                    pics = pics.replace("]","");
+                }
+
+
+                FormBody body = new FormBody.Builder()
+                        .add("id",accuont.getId())
+                        .add("msg",content)
+                        .add("local",accuont.getCity() + accuont.getDistrict())
+                        .add("latitude",accuont.getLatitude())
+                        .add("longitude",accuont.getLongitude())
+                        .add("pic",pics)
+                        .build();
+
+
+
+
+                net.post(NetInfo.NEW_TWEETING, body, new ResponseCallback() {
+                    @Override
+                    public void onSuccess(Object object) {
+                        NetStatus.IS_BUSY = false;
+                        bean = new Gson().fromJson((String)object,NewTweetingBean.class);
+                        if (0==bean.getC()){
+                            presenter.onPublishSuccess();
+                        }else {
+                            presenter.showToast("发布失败");
+                        }
+                    }
+
+                    @Override
+                    public void onFailed() {
+                        NetStatus.IS_BUSY = false;
+                        presenter.showToast("发布失败");
+                    }
+                });
+            }
+        }).start();
+    }
+}

+ 1 - 1
app/src/com/sheishuo/app/circle/model/beans/NewTweetingBean.java → app/src/com/sheishuo/app/core_module/circle/model/beans/NewTweetingBean.java

@@ -1,4 +1,4 @@
-package com.sheishuo.app.circle.model.beans;
+package com.sheishuo.app.core_module.circle.model.beans;
 
 /**
  * Created by KN on 2017/7/21.

+ 54 - 0
app/src/com/sheishuo/app/core_module/circle/presenter/NewTweetPresenter.java

@@ -0,0 +1,54 @@
+package com.sheishuo.app.core_module.circle.presenter;
+
+import com.sheishuo.app.core_module.circle.activity.NewTweetingActivity;
+import com.sheishuo.app.core_module.circle.model.NewTweetModel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by KN on 2017/7/21.
+ */
+
+public class NewTweetPresenter {
+    NewTweetingActivity activity;
+    NewTweetModel model;
+
+    public NewTweetPresenter(NewTweetingActivity activity){
+        this.activity = activity;
+        model = new NewTweetModel(this);
+    }
+
+
+    public void uploadPhoto(String filePath){
+        List<String> list = new ArrayList<>();
+        list.add(filePath);
+        uploadPhoto(list);
+    }
+
+    public void uploadPhoto(List<String> filesPath){
+        model.uploadPhoto(filesPath);
+    }
+
+    public void onOnePhotoUploaded(int index,int photoId){
+        activity.onOnePhotoUploaded(index,photoId);
+    }
+
+    public void onAllPhotoUploaded(){
+        activity.onAllPhotosUploaded();
+    }
+
+    public void publishNewTweeting(String content,List<Integer> ids){
+        model.publishNewTweeting(content,ids);
+    }
+
+    public void onPublishSuccess(){
+        activity.onTweetSuccess();
+    }
+
+    public void showToast(String toast){
+        activity.showToast(toast);
+    }
+
+
+}

+ 45 - 0
app/src/com/sheishuo/app/core_module/recent_contacts/activity/ContactsListActivity.java

@@ -0,0 +1,45 @@
+package com.sheishuo.app.core_module.recent_contacts.activity;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import com.netease.nim.uikit.contact.ContactsFragment;
+import com.sheishuo.app.R;
+import com.sheishuo.app.main.fragment.ContactListFragment;
+import com.sheishuo.app.main.fragment.SessionListFragment;
+import com.sheishuo.app.uikit_implements.SheishuoUI;
+
+/**
+ * Created by KN on 2017/7/28.
+ */
+
+public class ContactsListActivity extends SheishuoUI {
+
+    private LinearLayout layout;
+    private FragmentManager manager = getSupportFragmentManager();
+    private FragmentTransaction transaction;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.recent_contacts_list_activity);
+        findViews();
+        init();
+    }
+
+    void findViews(){
+        layout = findView(R.id.recent_contacts_list_layout);
+    }
+
+    void init(){
+        if (manager != null){
+            ContactsFragment fragment  = new ContactsFragment();
+            transaction = manager.beginTransaction();
+            transaction.add(R.id.recent_contacts_list_layout,fragment);
+            transaction.commit();
+        }
+
+    }
+}

+ 4 - 37
app/src/com/sheishuo/app/main/activity/MainActivity.java

@@ -46,6 +46,8 @@ import com.sheishuo.app.uikit_implements.SheishuoUI;
 
 import java.util.ArrayList;
 
+import static com.sheishuo.app.main.fragment.CircleOfFriendsFragment.REFRESH_CIRCLE;
+
 /**
  * 主界面
  * <p/>
@@ -210,42 +212,6 @@ public class MainActivity extends SheishuoUI {
         outState.clear();
     }
 
-//    @Override
-//    public boolean onCreateOptionsMenu(Menu menu) {
-//        MenuInflater inflater = getMenuInflater();
-//        inflater.inflate(R.menu.main_activity_menu, menu);
-//        super.onCreateOptionsMenu(menu);
-//        return true;
-//    }
-//
-//    @Override
-//    public boolean onOptionsItemSelected(MenuItem item) {
-//        switch (item.getItemId()) {
-//            case R.id.about:
-//                startActivity(new Intent(MainActivity.this, SettingsActivity.class));
-//                break;
-//            case R.id.create_normal_team:
-//                ContactSelectActivity.Option option = TeamHelper.getCreateContactSelectOption(null, 50);
-//                NimUIKit.startContactSelect(MainActivity.this, option, REQUEST_CODE_NORMAL);
-//                break;
-//            case R.id.create_regular_team:
-//                ContactSelectActivity.Option advancedOption = TeamHelper.getCreateContactSelectOption(null, 50);
-//                NimUIKit.startContactSelect(MainActivity.this, advancedOption, REQUEST_CODE_ADVANCED);
-//                break;
-//            case R.id.search_advanced_team:
-//                AdvancedTeamSearchActivity.start(MainActivity.this);
-//                break;
-//            case R.id.add_buddy:
-//                AddFriendActivity.start(MainActivity.this);
-//                break;
-//            case R.id.search_btn:
-//                GlobalSearchActivity.start(MainActivity.this);
-//                break;
-//            default:
-//                break;
-//        }
-//        return super.onOptionsItemSelected(item);
-//    }
 
     private void onParseIntent() {
         Intent intent = getIntent();
@@ -288,7 +254,6 @@ public class MainActivity extends SheishuoUI {
 
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
         Log.e(TAG,"onActivityResult " + requestCode + "    " + resultCode);
         if (resultCode == Activity.RESULT_OK) {
             if (requestCode == REQUEST_CODE_NORMAL) {
@@ -302,6 +267,8 @@ public class MainActivity extends SheishuoUI {
                 final ArrayList<String> selected = data.getStringArrayListExtra(ContactSelectActivity.RESULT_DATA);
                 TeamCreateHelper.createAdvancedTeam(MainActivity.this, selected);
             }
+        }else if(resultCode == REFRESH_CIRCLE){
+            mainFragment.onActivityResult(requestCode,resultCode,data);
         }
 
     }

+ 56 - 34
app/src/com/sheishuo/app/main/adapter/CircleListAdapter.java

@@ -51,6 +51,7 @@ public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.C
         this.addAll(bean);
         this.context = fragment.getActivity();
         this.circleFragment = fragment;
+
     }
 
     @Override
@@ -71,39 +72,8 @@ public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.C
         holder.likesNumTV.setText(bean.getLikes());
         holder.visitNumTv.setText(bean.getViews());
 
-        //获取此朋友圈中的所有用户id
-        List<String> userList = new ArrayList<>();
-        //添加此朋友圈发布者id
-        userList.add(bean.getUser_id());
-        //添加此朋友圈喜欢用户的id
-        for (String likedUser : bean.getLike_users()){
-            if (!userList.contains(likedUser))
-                userList.add(likedUser);
-        }
-        //添加次朋友圈评论用户的id
-        for (CircleBean.DBean.ListBean.Comment comment : bean.getComments_list()){
-            if (!userList.contains(comment.getUser_id()))
-                userList.add(comment.getUser_id());
-        }
 
-        //使用NIM SDK更新用户信息并将用户信息显示出来
-        NIMClient.getService(UserService.class).fetchUserInfo(userList).setCallback(new RequestCallback<List<NimUserInfo>>() {
-            @Override
-            public void onSuccess(List<NimUserInfo> user) {
-                holder.usernameTV.setText(getUserName(bean.getUser_id()));
-
-            }
-
-            @Override
-            public void onFailed(int i) {
-
-            }
-
-            @Override
-            public void onException(Throwable throwable) {
-
-            }
-        });
+        holder.usernameTV.setText(getUserName(bean.getUser_id()));
 
 
         //加载thumbs
@@ -207,12 +177,16 @@ public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.C
         if (position > data.size() - 2 && !data.get(data.size() - 1).getId().equals("1")) {
             Log.e("CircleListAdapter",data.get(data.size() - 1).getId());
             circleFragment.loadCircleListMore(data.get(data.size() - 1).getId());
+        }else if(data.get(data.size() - 1).getId().equals("1")){
+            circleFragment.showToast("已无更多内容");
         }
 
 
 
     }
 
+
+    //onViewRecycled重置item
     @Override
     public void onViewRecycled(CircleListViewHolder holder) {
         super.onViewRecycled(holder);
@@ -253,12 +227,57 @@ public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.C
 
 
 
+    //添加数据
+    public void addAll(CircleBean bean){
+        final List<CircleBean.DBean.ListBean> datas = bean.getD().getList();
 
 
-    public void addAll(CircleBean bean){
-        this.data.addAll(bean.getD().getList());
+        //将数据中的所有用户ID存入List
+        List<String> userIds = new ArrayList<>();
+        //遍历发布者ID
+        for (CircleBean.DBean.ListBean data : datas){
+            if (!userIds.contains(data.getUser_id()))
+                userIds.add(data.getUser_id());
+
+            //遍历喜欢者ID
+            for (String likedUser : data.getLike_users()){
+                if (!userIds.contains(likedUser))
+                    userIds.add(likedUser);
+            }
+            //遍历评论者ID
+            for (CircleBean.DBean.ListBean.Comment comment : data.getComments_list()){
+                if (!userIds.contains(comment.getUser_id()))
+                    userIds.add(comment.getUser_id());
+            }
+        }
+
+        NIMClient.getService(UserService.class).fetchUserInfo(userIds).setCallback(new RequestCallback<List<NimUserInfo>>() {
+            @Override
+            public void onSuccess(List<NimUserInfo> nimUserInfos) {
+                //添加数据
+                data.addAll(datas);
+                notifyDataSetChanged();
+                Log.e("添加数据成功","Success");
+            }
+
+            @Override
+            public void onFailed(int i) {
+                Log.e("Failed",i+"");
+            }
+
+            @Override
+            public void onException(Throwable throwable) {
+
+            }
+        });
+
     }
 
+    //清空数据
+    public void clearAll(){
+        data.clear();
+    }
+    //点击事件
     @Override
     public void onClick(View v) {
         if (listener != null){
@@ -273,6 +292,9 @@ public class CircleListAdapter  extends RecyclerView.Adapter<CircleListAdapter.C
 
     }
 
+
+
+    //ViewHolder
     class CircleListViewHolder extends RecyclerView.ViewHolder{
         private CardView layout;
         private LinearLayout commentsLayout;

+ 63 - 8
app/src/com/sheishuo/app/main/fragment/CircleOfFriendsFragment.java

@@ -18,7 +18,7 @@ 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.circle.activity.NewTweetingActivity;
+import com.sheishuo.app.core_module.circle.activity.NewTweetingActivity;
 import com.sheishuo.app.common.beans.CircleBean;
 import com.sheishuo.app.common.views.BaseToolbar;
 import com.sheishuo.app.main.activity.MainActivity;
@@ -34,6 +34,8 @@ import com.sheishuo.app.main.presenter.CirclePresenter;
 
 public class CircleOfFriendsFragment extends MainTabFragment{
     private String TAG = this.getClass().getSimpleName();
+    public final static int REFRESH_CIRCLE = 10000;
+    private boolean isLoaded = false;
 
     private Context context = getActivity();
     private CirclePresenter presenter = new CirclePresenter(this);
@@ -51,6 +53,8 @@ public class CircleOfFriendsFragment extends MainTabFragment{
 
     private Handler handler = getHandler();
 
+    private Toast toast = null;
+    private long lastTime = System.currentTimeMillis();
 
 
     public CircleOfFriendsFragment(){
@@ -77,7 +81,7 @@ public class CircleOfFriendsFragment extends MainTabFragment{
         username.setText(user.getName());
 
 
-
+        isLoaded = true;
 
     }
 
@@ -97,13 +101,31 @@ public class CircleOfFriendsFragment extends MainTabFragment{
         toolbar.init();
         toolbar.setTitle("朋友圈");
         toolbar.setRightText("发表");
+
+        //打开发布Activity
         toolbar.getRightTV().setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Log.e(TAG,"start NewTweetActivity");
-                //NewTweetingActivity.start(getActivity());
+                NewTweetingActivity.startActivityForResult(getActivity(),null);
+            }
+        });
+
+
+        //双击标题返回顶部
+        toolbar.getTitleTV().setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                long nowTime = System.currentTimeMillis();
+                long interval = lastTime - nowTime;
+                if (interval < 1000){
+                    lastTime = nowTime;
+                    if (recyclerView!=null){
+                        recyclerView.smoothScrollToPosition(0);
+                    }
+                }
 
-                startActivity(new Intent(getActivity(),NewTweetingActivity.class));
+                lastTime = nowTime;
             }
         });
 
@@ -114,18 +136,23 @@ public class CircleOfFriendsFragment extends MainTabFragment{
     public void setUserVisibleHint(boolean isVisibleToUser) {
         super.setUserVisibleHint(isVisibleToUser);
         if (isVisibleToUser && toolbar != null) initToolbar();
+
+        if (isVisibleToUser && isLoaded) refreshCircle();
     }
 
-    /**
-     *  以下为开放调用的方法
-     */
+    /**********************以下为开放调用的方法*********************/
 
 
     public void showToast(final String str){
         handler.post(new Runnable() {
             @Override
             public void run() {
-                Toast.makeText(getActivity(),str,Toast.LENGTH_SHORT).show();
+                if (toast == null){
+                    toast = Toast.makeText(getActivity(),str,Toast.LENGTH_SHORT);
+                }else {
+                    toast.setText(str);
+                }
+                toast.show();
 
             }
         });
@@ -166,12 +193,40 @@ public class CircleOfFriendsFragment extends MainTabFragment{
         });
     }
 
+    /**
+     * 加载更多朋友圈
+     * @param lastId
+     */
     public void loadCircleListMore(String lastId){
+        showToast("正在加载更多内容...");
         presenter.loadCircleList(AccountCache.getAccount().getId(),lastId);
     }
 
 
+    /**
+     * 刷新朋友圈
+     */
+    public void refreshCircle(){
+        if (adapter != null){
+            //防止Inconsistency detected
+            recyclerView.getRecycledViewPool().clear();
+            recyclerView.scrollToPosition(0);
+
+            adapter.clearAll();
+            loadCircleListMore("");
+        }
+    }
+
 
 
 
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        switch (resultCode){
+            case REFRESH_CIRCLE:
+                refreshCircle();
+                break;
+        }
+    }
 }

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

@@ -6,6 +6,7 @@ import android.content.Intent;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.design.widget.BottomNavigationView;
+import android.support.v4.app.Fragment;
 import android.support.v4.view.ViewPager;
 import android.support.v4.view.ViewPager.OnPageChangeListener;
 import android.support.v7.widget.Toolbar;
@@ -80,8 +81,6 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
-        //setToolBar(R.id.toolbar, R.string.app_name, R.drawable.actionbar_dark_logo);
-        //setTitle(R.string.app_name);
 
 
         findViews();
@@ -103,7 +102,7 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
                 pager.setCurrentItem(1);
                 pager.setCurrentItem(0);
             }
-        },1000);
+        },300);
 
 
     }
@@ -377,21 +376,25 @@ public class HomeFragment extends TFragment implements OnPageChangeListener, Rem
     }
 
 
+    @SuppressWarnings("RestrictedApi")
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         //super.onActivityResult(requestCode, resultCode, data);
-        List<String> test = data.getStringArrayListExtra(ContactSelectActivity.RESULT_DATA);
-        Log.e("返回的用户为",test.get(0));
-
-        Log.e("resultCode",resultCode+"");
-        Log.e("requestCode",requestCode+"");
         switch (resultCode){
             //创建群回调
             case Activity.RESULT_OK:
                 List<String> memberList = data.getStringArrayListExtra(ContactSelectActivity.RESULT_DATA);
-                Log.e("返回的用户为",memberList.get(0));
                 TeamCreateHelper.createAdvancedTeam(context,memberList);
                 break;
+
+            //朋友圈自动刷新回调
+            case CircleOfFriendsFragment.REFRESH_CIRCLE:
+                for (Fragment fragment : getFragmentManager().getFragments()){
+                    if (fragment instanceof CircleOfFriendsFragment)
+                        fragment.onActivityResult(requestCode,resultCode,data);
+
+                }
+                break;
         }
     }
 

+ 19 - 0
app/src/com/sheishuo/app/main/fragment/SessionListFragment.java

@@ -1,14 +1,18 @@
 package com.sheishuo.app.main.fragment;
 
+import android.content.Intent;
 import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
 import android.util.Log;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
+import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.bumptech.glide.Glide;
 import com.netease.nim.uikit.common.activity.UI;
 import com.netease.nim.uikit.common.util.log.LogUtil;
 import com.netease.nim.uikit.recent.RecentContactsCallback;
@@ -26,6 +30,7 @@ import com.netease.nimlib.sdk.msg.model.RecentContact;
 import com.sheishuo.app.R;
 import com.sheishuo.app.common.views.BaseToolbar;
 import com.sheishuo.app.config.preference.Preferences;
+import com.sheishuo.app.core_module.recent_contacts.activity.ContactsListActivity;
 import com.sheishuo.app.login.LoginActivity;
 import com.sheishuo.app.login.LogoutHelperBak;
 import com.sheishuo.app.main.activity.MainActivity;
@@ -117,8 +122,22 @@ public class SessionListFragment extends MainTabFragment {
 
     //初始化toolbar
     public void initToolbar(){
+        Log.e(TAG,"init toolbar");
         toolbar.init();
         toolbar.setTitle("朋友");
+        if (toolbar != null){
+            toolbar = new BaseToolbar.Builder()
+                    .create(getActivity(),toolbar)
+                    .addIcoButton(R.drawable.friends_contacts)
+                    .addIcoButtonClickListener(0, new BaseToolbar.IcoBtnClickListener() {
+                        @Override
+                        public void onClick(View view) {
+                            startActivity(new Intent(getActivity(), ContactsListActivity.class));
+                        }
+                    })
+                    .build();
+        }
+
     }
 
     @Override

+ 5 - 0
app/src/com/sheishuo/app/main/model/CircleModel.java

@@ -7,6 +7,7 @@ import com.sheishuo.app.common.beans.CircleUserLikedBean;
 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.NetStatus;
 import com.sheishuo.app.common.util.net.ResponseCallback;
 import com.sheishuo.app.main.presenter.CirclePresenter;
 
@@ -30,6 +31,7 @@ public class CircleModel implements ICircle {
     //获取朋友圈列表
     @Override
     public void getCircleList(final String user_id, final String last_id) {
+        NetStatus.IS_BUSY = true;
         new Thread(new Runnable() {
             @Override
             public void run() {
@@ -49,11 +51,14 @@ public class CircleModel implements ICircle {
                         }else {
                             onFailed();
                         }
+
+                        NetStatus.IS_BUSY = false;
                     }
 
                     @Override
                     public void onFailed() {
                         presenter.showToast("加载失败,请检查网络");
+                        NetStatus.IS_BUSY = false;
                     }
                 });
 

+ 0 - 1
app/src/com/sheishuo/app/main/presenter/CirclePresenter.java

@@ -34,7 +34,6 @@ public class CirclePresenter {
         if (NetStatus.IS_BUSY){
             fragment.showToast("正在加载中...");
         }else {
-            NetStatus.IS_BUSY = true;
             model.getCircleList(user_id,last_id);
         }
     }