dxh 6 ans auparavant
Parent
commit
c6922e5de9

+ 1 - 0
app/build.gradle

@ -279,4 +279,5 @@ dependencies {
279 279
    compile project(':XRefreshView')
280 280
    compile 'com.github.Aspsine:IRecyclerView:0.0.7'
281 281
    compile project(':ijkplayer-java')
282
    compile 'com.upyun:upyun-android-sdk:+'
282 283
}

+ 3 - 0
app/src/main/AndroidManifest.xml

@ -1007,6 +1007,9 @@
1007 1007
        <activity
1008 1008
            android:name=".activity.PersonalPageActivity"
1009 1009
            android:screenOrientation="portrait" />
1010
        <activity
1011
            android:name=".activity.TopicDetailsActivity"
1012
            android:screenOrientation="portrait" />
1010 1013
    </application>
1011 1014
1012 1015
</manifest>

+ 99 - 47
app/src/main/java/com/electric/chargingpile/activity/PublishPicTopicActivity.java

@ -24,6 +24,7 @@ import android.provider.MediaStore;
24 24
import android.support.v4.app.ActivityCompat;
25 25
import android.telephony.TelephonyManager;
26 26
import android.text.Editable;
27
import android.text.TextUtils;
27 28
import android.text.TextWatcher;
28 29
import android.util.Base64;
29 30
import android.util.Log;
@ -47,6 +48,8 @@ import android.widget.Toast;
47 48
48 49
import com.electric.chargingpile.R;
49 50
import com.electric.chargingpile.application.MainApplication;
51
import com.electric.chargingpile.data.AuthSignBean;
52
import com.electric.chargingpile.data.HomePageBean;
50 53
import com.electric.chargingpile.data.TalkRecommendBean;
51 54
import com.electric.chargingpile.data.UploadPic;
52 55
import com.electric.chargingpile.util.BarColorUtil;
@ -59,6 +62,7 @@ import com.electric.chargingpile.util.Res;
59 62
import com.electric.chargingpile.util.ScreenUtils;
60 63
import com.electric.chargingpile.util.ToastUtil;
61 64
import com.electric.chargingpile.util.UploadUtil;
65
import com.electric.chargingpile.view.footer.LoadMoreFooterView;
62 66
import com.umeng.analytics.MobclickAgent;
63 67
import com.zhy.http.okhttp.OkHttpUtils;
64 68
import com.zhy.http.okhttp.callback.StringCallback;
@ -84,11 +88,9 @@ import rx.android.schedulers.AndroidSchedulers;
84 88
import rx.schedulers.Schedulers;
85 89
86 90
/**
87
 *
88 91
 * @desc : 发布话题
89
 *
90
 * */
91
public class PublishPicTopicActivity extends Activity implements OnClickListener ,EasyPermissions.PermissionCallbacks{
92
 */
93
public class PublishPicTopicActivity extends Activity implements OnClickListener, EasyPermissions.PermissionCallbacks {
92 94
    private static final String TAG = "PublishPicTopicActivity";
93 95
    private static final int PIC_NUM = 9;
94 96
    private ImageView ivBack;
@ -161,7 +163,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
161 163
        mPublishTopicDe = (ImageView) findViewById(R.id.publishtopic_choose_topic_de);
162 164
        mPublishTopicDe.setOnClickListener(this);
163 165
        mPublishtopicChooseTopic = (TextView) findViewById(R.id.publishtopic_choose_topic);
164
        publishtopic_choose_topic = (TextView)findViewById(R.id.publishtopic_choose_topic);
166
        publishtopic_choose_topic = (TextView) findViewById(R.id.publishtopic_choose_topic);
165 167
        publishtopic_choose_topic.setOnClickListener(this);
166 168
        insertDialog = new ProgressDialog(this);
167 169
        insertDialog.setMessage("正在插入图片...");
@ -176,21 +178,25 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
176 178
                        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
177 179
                    }
178 180
                }
179
                new Thread(new Runnable() {
180
                    @Override
181
                    public void run() {
182
                        if (Bimp.tempSelectBitmap.size() > 0) {
183
                            uploadFeedbackPic();
184
185
                        } else {
186 181
187
                            uploadFeedbackInfo();
182
                //获取又拍云数据
183
                getYouPaiData();
188 184
189
190
                        }
191
192
                    }
193
                }).start();
185
//                new Thread(new Runnable() {
186
//                    @Override
187
//                    public void run() {
188
//                        if (Bimp.tempSelectBitmap.size() > 0) {
189
                uploadFeedbackPic();
190
//
191
//                        } else {
192
//
193
//                            uploadFeedbackInfo();
194
//
195
//
196
//                        }
197
//
198
//                    }
199
//                }).start();
194 200
195 201
            }
196 202
        });
@ -233,7 +239,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
233 239
                    tv_right.setEnabled(true);
234 240
//					tv_right.setTextColor(getResources().getColor(R.color.lvse));
235 241
                    tv_right.setBackgroundColor(Color.parseColor("#02b637"));
236
                }else {
242
                } else {
237 243
                    tv_right.setEnabled(false);
238 244
                    tv_right.setBackgroundColor(Color.parseColor("color_9ed3ae"));
239 245
                }
@ -245,7 +251,54 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
245 251
246 252
    }
247 253
254
    private void getYouPaiData() {
255
256
        if (null == Bimp.tempSelectBitmap)
257
            return;
258
        String fileNames = "";
259
        for (int i = 0; i < Bimp.tempSelectBitmap.size(); i++) {
260
            File tempFile = new File(Bimp.tempSelectBitmap.get(i).imagePath.trim());
261
            String fileName = tempFile.getName();
262
            if (TextUtils.isEmpty(fileNames))
263
                fileNames = fileName;
264
            else
265
                fileNames = "," + fileName;
266
        }
267
        String url = MainApplication.urlNew + "/topic/sign.do";
268
        Map<String, String> map = new HashMap<>();
269
        map.put("fileNames", fileNames);
270
        map.put("expiration", (System.currentTimeMillis() + 1800) + "");
271
        map.put("targetType", "23");
272
        OkHttpUtils.get().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
273
            @Override
274
            public void onError(Call call, Exception e) {
275
            }
276
277
            @Override
278
            public void onResponse(String response) {
279
                Log.i(TAG, response);
280
                String rtnCode = JsonUtils.getKeyResult(response, "code");
281
                if ("1000".equals(rtnCode)) {
282
                    String rtnMsg = JsonUtils.getKeyResult(response, "data");
283
                    ArrayList<AuthSignBean> signBeans = (ArrayList<AuthSignBean>) JsonUtils.parseToObjectList(rtnMsg, AuthSignBean.class);
284
                }
285
            }
286
        });
287
//
288
//        //图文路径
289
//        p = "/d/file/liaoliao/img/"+y+"/"+m+"/"+d;
290
//        //视频路径
291
//        p = "/d/file/liaoliao/video/"+y+"/"+m+"/"+d;
292
//        //生产policy传的参数
293
//        Map<String, Object> map = new HashMap<>();
294
//        map.put("bucket","d1evcom01-fs");
295
//        map.put("expiration",expiration);
296
//        map.put("save-key",p+"/"+fname);
297
//        policy =  UpYunUtils.getPolicy(map);
298
    }
299
248 300
    final int reqTopic = -100;
301
249 302
    @Override
250 303
    public void onClick(View v) {
251 304
        switch (v.getId()) {
@ -447,6 +500,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
447 500
448 501
    /**
449 502
     * 异步方式插入图片
503
     *
450 504
     * @param data
451 505
     */
452 506
    private void insertImagesSync(final Intent data) {
@ -691,8 +745,8 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
691 745
692 746
        }
693 747
        try {
694
            String u = UploadUtil.post(
695
                    MainApplication.url + "/zhannew/basic/web/index.php/fileupload/multi-upload",
748
            String u = UploadUtil.postTopicPicture(
749
                    MainApplication.urlNew + "/topic/sign.do",
696 750
//                    "http://123.57.6.131/zhannew/basic/web/index.php/zhanlist/add",
697 751
//					"http://59.110.68.162"+"/zhannew/fileupload/multi-upload",
698 752
                    par, null);
@ -788,37 +842,37 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
788 842
            // to handle the case where the user grants the permission. See the documentation
789 843
            // for ActivityCompat#requestPermissions for more details.
790 844
            imem = "";
791
        }else {
845
        } else {
792 846
            imem = telephonyManager.getDeviceId();
793 847
        }
794 848
        String url;
795
        if (null != json){
796
            url = MainApplication.url+"/zhannew/basic/web/index.php/advice/add?user_id="+MainApplication.userId+
797
                    "&msg="+et_context.getText().toString()+"&telephone="+MainApplication.userPhone+"&imem="+imem+
798
                    "&main_id=0&url="+json;
799
        }else {
800
            url = MainApplication.url+"/zhannew/basic/web/index.php/advice/add?user_id="+MainApplication.userId+
801
                    "&msg="+et_context.getText().toString()+"&telephone="+MainApplication.userPhone+"&imem="+imem+
849
        if (null != json) {
850
            url = MainApplication.url + "/zhannew/basic/web/index.php/advice/add?user_id=" + MainApplication.userId +
851
                    "&msg=" + et_context.getText().toString() + "&telephone=" + MainApplication.userPhone + "&imem=" + imem +
852
                    "&main_id=0&url=" + json;
853
        } else {
854
            url = MainApplication.url + "/zhannew/basic/web/index.php/advice/add?user_id=" + MainApplication.userId +
855
                    "&msg=" + et_context.getText().toString() + "&telephone=" + MainApplication.userPhone + "&imem=" + imem +
802 856
                    "&main_id=0&url=";
803 857
        }
804 858
805
        Log.e(TAG, "uploadFeedbackInfo: url="+url );
859
        Log.e(TAG, "uploadFeedbackInfo: url=" + url);
806 860
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
807 861
            @Override
808 862
            public void onError(Call call, Exception e) {
809 863
//				dialog.cancel();
810
                ToastUtil.showToast(getApplicationContext(),"请检查当前网络",Toast.LENGTH_SHORT);
864
                ToastUtil.showToast(getApplicationContext(), "请检查当前网络", Toast.LENGTH_SHORT);
811 865
            }
812 866
813 867
            @Override
814 868
            public void onResponse(String response) {
815
                Log.e(TAG, "onResponse: response="+response );
869
                Log.e(TAG, "onResponse: response=" + response);
816 870
//				dialog.cancel();
817
                String rtnCode = JsonUtils.getKeyResult(response,"rtnCode");
818
                if (rtnCode.equals("01")){
871
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
872
                if (rtnCode.equals("01")) {
819 873
//					ToastUtil.showToast(getApplicationContext(),"感谢您的反馈",Toast.LENGTH_SHORT);
820
                    String plusScore = JsonUtils.getKeyResult(response,"plusScore");
821
                    if (!plusScore.equals("")){
874
                    String plusScore = JsonUtils.getKeyResult(response, "plusScore");
875
                    if (!plusScore.equals("")) {
822 876
                        tv_point.setText(plusScore);
823 877
                        rl_point.setVisibility(View.VISIBLE);
824 878
                        rl_point.startAnimation(animation);
@ -832,17 +886,17 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
832 886
                                finish();
833 887
                            }
834 888
                        }, 1500);
835
                    }else {
836
                        ToastUtil.showToast(getApplicationContext(),"感谢您的反馈",Toast.LENGTH_SHORT);
889
                    } else {
890
                        ToastUtil.showToast(getApplicationContext(), "感谢您的反馈", Toast.LENGTH_SHORT);
837 891
                        finish();
838 892
                    }
839 893
//					finish();
840
                }else if (rtnCode.equals("03")){
841
                    String rtnMsg = JsonUtils.getKeyResult(response,"rtnMsg");
842
                    ToastUtil.showToast(getApplicationContext(),rtnMsg,Toast.LENGTH_SHORT);
843
                }else {
844
                    String rtnMsg = JsonUtils.getKeyResult(response,"rtnMsg");
845
                    ToastUtil.showToast(getApplicationContext(),rtnMsg,Toast.LENGTH_SHORT);
894
                } else if (rtnCode.equals("03")) {
895
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
896
                    ToastUtil.showToast(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT);
897
                } else {
898
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
899
                    ToastUtil.showToast(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT);
846 900
                }
847 901
            }
848 902
        });
@ -898,7 +952,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
898 952
        } else {
899 953
            // Ask for one permission
900 954
            EasyPermissions.requestPermissions(
901
                    this,"充电桩想要获取您的图片读取权限,是否允许?",
955
                    this, "充电桩想要获取您的图片读取权限,是否允许?",
902 956
                    RC_ALBUM_PERM,
903 957
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
904 958
                    Manifest.permission.READ_EXTERNAL_STORAGE);
@ -913,6 +967,4 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
913 967
    }
914 968
915 969
916
917
918 970
}

+ 10 - 0
app/src/main/java/com/electric/chargingpile/adapter/LayoutAdapter.java

@ -1,6 +1,7 @@
1 1
package com.electric.chargingpile.adapter;
2 2
3 3
import android.content.Context;
4
import android.content.Intent;
4 5
import android.support.v7.widget.LinearLayoutManager;
5 6
import android.support.v7.widget.RecyclerView;
6 7
import android.support.v7.widget.StaggeredGridLayoutManager;
@ -15,6 +16,7 @@ import android.widget.TextView;
15 16
16 17
import com.aspsine.irecyclerview.IViewHolder;
17 18
import com.electric.chargingpile.R;
19
import com.electric.chargingpile.activity.TopicDetailsActivity;
18 20
import com.electric.chargingpile.data.TalkRecommendBean;
19 21
import com.electric.chargingpile.iview.RecyclerItemTypeClickListener;
20 22
import com.electric.chargingpile.util.CircleTransform;
@ -192,6 +194,14 @@ public class LayoutAdapter extends RecyclerView.Adapter<IViewHolder> {
192 194
        TalkRecommendHeaderAdapter talkRecommendHeaderAdapter = new TalkRecommendHeaderAdapter(context);
193 195
        simpleHeaderViewHolder.header_recy.setAdapter(talkRecommendHeaderAdapter);
194 196
        talkRecommendHeaderAdapter.setData(talkHeaderRecommendBeans);
197
198
        talkRecommendHeaderAdapter.setOnRecyclerItemClickListener(new RecyclerItemTypeClickListener() {
199
            @Override
200
            public void onItemClickListener(int position, int index) {
201
                String topicId = talkHeaderRecommendBeans.get(position).topicId+"";
202
                context.startActivity(new Intent(context, TopicDetailsActivity.class).putExtra("topicId", topicId));
203
            }
204
        });
195 205
    }
196 206
197 207
    class SimpleViewHolder extends IViewHolder {

+ 1 - 1
app/src/main/java/com/electric/chargingpile/adapter/WaterFallAdapter.java

@ -94,7 +94,7 @@ public class WaterFallAdapter extends RecyclerView.Adapter<IViewHolder> {
94 94
            simpleViewHolder.info_bg_icon.setLayoutParams(lpImg);
95 95
        }
96 96
97
        TalkRecommendBean talkRecommendBean = talkRecommendBeans.get(position - 1);
97
        TalkRecommendBean talkRecommendBean = talkRecommendBeans.get(position);
98 98
        simpleViewHolder.recycler_view_title.setText(talkRecommendBean.title);
99 99
        simpleViewHolder.recycler_view_zan.setText(talkRecommendBean.likeNums + "");
100 100
        simpleViewHolder.user_avater_name.setText(talkRecommendBean.nickName);

+ 14 - 0
app/src/main/java/com/electric/chargingpile/data/HomePageBean.java

@ -13,5 +13,19 @@ public class HomePageBean {
13 13
        public String headImgUrl;
14 14
        public String carName;
15 15
        public int topicNums;
16
17
        public long targetId;
18
        public long addUserId;
19
        public int targetType;
20
        public String title;
21
        public String topicName;
22
        public String coverImgUrl;
23
        public String[] imgUrls;
24
        public int topicId;
25
        public int likeNums;
26
        public int commentNums;
27
        public int isTop;
28
        public int likeFlg;
29
        public int source;
16 30
    }
17 31
}

+ 1 - 0
app/src/main/java/com/electric/chargingpile/data/TalkRecommendBean.java

@ -25,6 +25,7 @@ public class TalkRecommendBean implements Serializable {
25 25
    public long addTime;
26 26
    public int topicId;
27 27
    public int joinNums;
28
    public int visitNums;
28 29
    public String coverImgUrl;
29 30
    public String headImgUrl;
30 31
    public String nickName;

+ 79 - 0
app/src/main/java/com/electric/chargingpile/util/UploadUtil.java

@ -157,4 +157,83 @@ public class UploadUtil {
157 157
        return sb2.toString();
158 158
    }
159 159

160
    public static String postTopicPicture(String url, Map<String, String> params,
161
                              Map<String, File> files) throws IOException {
162

163
        String expiration = System.currentTimeMillis()+"30";
164
        String BOUNDARY = java.util.UUID.randomUUID().toString();
165
        String PREFIX = "--", LINEND = "\r\n";
166
        String MULTIPART_FROM_DATA = "multipart/form-data";
167
        String CHARSET = "UTF-8";
168

169
        URL uri = new URL(url);
170
        HttpURLConnection conn = (HttpURLConnection) uri.openConnection();
171
        conn.setReadTimeout(10 * 1000);
172
        conn.setDoInput(true);
173
        conn.setDoOutput(true);
174
        conn.setUseCaches(false);
175
        conn.setRequestMethod("POST");
176
        conn.setRequestProperty("connection", "keep-alive");
177
        conn.setRequestProperty("Charsert", "UTF-8");
178
        conn.setRequestProperty("Content-Type", MULTIPART_FROM_DATA
179
                + ";boundary=" + BOUNDARY);
180

181
        StringBuilder sb = new StringBuilder();
182
        for (Map.Entry<String, String> entry : params.entrySet()) {
183
            sb.append(PREFIX);
184
            sb.append(BOUNDARY);
185
            sb.append(LINEND);
186
            sb.append("Content-Disposition: form-data; name=\""
187
                    + entry.getKey() + "\"" + LINEND);
188
            sb.append("Content-Type: text/plain; charset=" + CHARSET + LINEND);
189
            sb.append("Content-Transfer-Encoding: 8bit" + LINEND);
190
            sb.append(LINEND);
191
            sb.append(entry.getValue());
192
            sb.append(LINEND);
193
        }
194

195
        DataOutputStream outStream = new DataOutputStream(
196
                conn.getOutputStream());
197
        outStream.write(sb.toString().getBytes());
198
        if (files != null)
199
            for (Map.Entry<String, File> file : files.entrySet()) {
200
                StringBuilder sb1 = new StringBuilder();
201
                sb1.append(PREFIX);
202
                sb1.append(BOUNDARY);
203
                sb1.append(LINEND);
204
                sb1.append("Content-Disposition: form-data; name=\"uploadfile\"; targetType=24;fileNames=\""
205
                        + file.getValue().getName() + "\"" + LINEND);
206
                sb1.append("Content-Type: application/octet-stream; charset="
207
                        + CHARSET + LINEND);
208
                sb1.append(LINEND);
209
                outStream.write(sb1.toString().getBytes());
210

211
                InputStream is = new FileInputStream(file.getValue());
212
                byte[] buffer = new byte[1024];
213
                int len = 0;
214
                while ((len = is.read(buffer)) != -1) {
215
                    outStream.write(buffer, 0, len);
216
                }
217

218
                is.close();
219
                outStream.write(LINEND.getBytes());
220
            }
221

222
        byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINEND).getBytes();
223
        outStream.write(end_data);
224
        outStream.flush();
225
        int res = conn.getResponseCode();
226
        InputStream in = conn.getInputStream();
227
        StringBuilder sb2 = new StringBuilder();
228
        if (res == 200) {
229
            int ch;
230
            while ((ch = in.read()) != -1) {
231
                sb2.append((char) ch);
232
            }
233
        }
234
        outStream.close();
235
        conn.disconnect();
236
        return sb2.toString();
237
    }
238

160 239
}