Browse Source

图片上传

dxh 6 years ago
parent
commit
9cbc3aba72

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

@ -307,7 +307,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
307 307
        Map<String, String> map = new HashMap<>();
308 308
        map.put("fileNames", fileNames);
309 309
        Log.e("fileNameDir fileName", fileNames);
310
        map.put("expiration", (System.currentTimeMillis() + 1800) + "");
310
//        map.put("expiration", (System.currentTimeMillis() + 1800) + "");
311 311
        map.put("targetType", "24");//23视频/24图片
312 312
        OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
313 313
            @Override
@ -334,7 +334,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
334 334
                        String sign = signBeans.get(0).sign;
335 335
336 336
                        formUpload(Bimp.tempSelectBitmap.get(0).getImagePath(), sign,
337
                                signBeans.get(0).fname);
337
                                signBeans.get(0).fname, signBeans.get(0).policy);
338 338
                    }
339 339
                }
340 340
            }
@ -1018,7 +1018,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
1018 1018
     * @param sign
1019 1019
     * @param saveName
1020 1020
     */
1021
    private void formUpload(String SAMPLE_PIC_FILE, String sign, String saveName) {
1021
    private void formUpload(String SAMPLE_PIC_FILE, String sign, String saveName, String policyServer) {
1022 1022
        File temp = new File(SAMPLE_PIC_FILE);
1023 1023
//
1024 1024
//        final Map<String, Object> paramsMap = new HashMap<>();
@ -1054,7 +1054,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
1054 1054
            }
1055 1055
        };
1056 1056
        //表单上传(服务器签名方式)
1057
        UploadEngine.getInstance().formUpload(temp, policy, OPERATER, sign, completeListener, progressListener);
1057
        UploadEngine.getInstance().formUpload(temp, policyServer, OPERATER, sign, completeListener, progressListener);
1058 1058
1059 1059
    }
1060 1060

+ 12 - 7
app/src/main/java/com/electric/chargingpile/activity/TopicDetailsActivity.java

@ -4,13 +4,16 @@ import android.content.Intent;
4 4
import android.graphics.Color;
5 5
import android.os.Bundle;
6 6
import android.support.annotation.Nullable;
7
import android.support.v4.app.FragmentActivity;
7 8
import android.support.v7.app.AppCompatActivity;
9
import android.support.v7.widget.GridLayoutManager;
8 10
import android.support.v7.widget.LinearLayoutManager;
9 11
import android.support.v7.widget.StaggeredGridLayoutManager;
10 12
import android.text.TextUtils;
11 13
import android.util.Log;
12 14
import android.view.View;
13 15
import android.view.ViewTreeObserver;
16
import android.widget.FrameLayout;
14 17
import android.widget.ImageView;
15 18
import android.widget.LinearLayout;
16 19
import android.widget.RelativeLayout;
@ -54,14 +57,14 @@ import okhttp3.Call;
54 57
/**
55 58
 * @desc 话题详情
56 59
 */
57
public class TopicDetailsActivity extends AppCompatActivity implements View.OnClickListener, PullToZoomScrollView3.ScrollViewListener, OnLoadMoreListener {
60
public class TopicDetailsActivity extends FragmentActivity implements View.OnClickListener, PullToZoomScrollView3.ScrollViewListener, OnLoadMoreListener {
58 61
59 62
    private String topicId;
60 63
    private PullToZoomScrollView3 scrollview;
61 64
    private String topicTitleContent;
62 65
    private int screenWidth, bgHeight, screenHeight;
63 66
    private TextView textview, topic_title,topic_content, read_data, join_data, sort_text_info;
64
    private RelativeLayout top_view;
67
    private FrameLayout top_view;
65 68
    private LinearLayout content_view, ll_sort_view;
66 69
    private int page = 1;
67 70
    private int sort = 1;
@ -79,7 +82,7 @@ public class TopicDetailsActivity extends AppCompatActivity implements View.OnCl
79 82
        setContentView(R.layout.activity_topic_details_info);
80 83
        initView();
81 84
        initListeners();
82
        initListeners(content_view);
85
        initListeners(findViewById(R.id.make_header_lines));
83 86
84 87
        requestData();
85 88
    }
@ -95,9 +98,10 @@ public class TopicDetailsActivity extends AppCompatActivity implements View.OnCl
95 98
        sort_text_info = (TextView) findViewById(R.id.sort_text_info);
96 99
        user_avater = (ImageView) findViewById(R.id.user_avater);
97 100
        user_content_more = (ImageView) findViewById(R.id.user_content_more);
98
        top_view = (RelativeLayout) findViewById(R.id.top_view);
101
        top_view = (FrameLayout) findViewById(R.id.top_view);
99 102
        content_view = (LinearLayout) findViewById(R.id.content_view);
100 103
        ll_sort_view = (LinearLayout) findViewById(R.id.ll_sort_view);
104
        ll_sort_view.setOnClickListener(this);
101 105
        scrollview = (PullToZoomScrollView3) findViewById(R.id.scroll_view);
102 106
        scrollview.setVerticalScrollBarEnabled(false);
103 107
        screenHeight = ScreenUtils.getScreenHeight(this);
@ -114,8 +118,9 @@ public class TopicDetailsActivity extends AppCompatActivity implements View.OnCl
114 118
        loadMoreFooterView = (LoadMoreFooterView) comment_data.getLoadMoreFooterView();
115 119
        //设置布局管理器
116 120
        waterFallAdapter = new WaterFallAdapter(this);
117
        layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
118
        comment_data.setLayoutManager(layoutManager);
121
//        layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
122
//        comment_data.setLayoutManager(layoutManager);
123
        comment_data.setLayoutManager(new GridLayoutManager(this, 2));
119 124
        comment_data.setIAdapter(waterFallAdapter);
120 125
        comment_data.setOnLoadMoreListener(this);
121 126
        comment_data.setLoadMoreEnabled(true);
@ -146,7 +151,7 @@ public class TopicDetailsActivity extends AppCompatActivity implements View.OnCl
146 151
            case R.id.iv_back:
147 152
                finish();
148 153
                break;
149
            case R.id.ll_sort:
154
            case R.id.ll_sort_view:
150 155
151 156
                final SortTopicPopWindow sortPopWindow = new SortTopicPopWindow(TopicDetailsActivity.this);
152 157
                sortPopWindow.setUi(sort);

+ 2 - 0
app/src/main/java/com/electric/chargingpile/data/AuthSignBean.java

@ -4,4 +4,6 @@ public class AuthSignBean {
4 4
5 5
    public String fname;
6 6
    public String sign;
7
    public String policy;
8
    public String path;
7 9
}

+ 3 - 3
app/src/main/java/com/electric/chargingpile/view/PullToZoomScrollView3.java

@ -18,7 +18,7 @@ import android.widget.ScrollView;
18 18
 *
19 19
 * Created by dxh
20 20
 */
21
public class PullToZoomScrollView3 extends ScrollView {
21
public class PullToZoomScrollView3 extends ScrollView{
22 22
    private  boolean isonce;//加载该View的布局时是否是第一次加载,是第一次就让其实现OnMeasure里的代码
23 23
24 24
    private LinearLayout mParentView;//布局的父布局,ScrollView内部只能有一个根ViewGroup,就是此View
@ -59,7 +59,7 @@ public class PullToZoomScrollView3 extends ScrollView {
59 59
        DisplayMetrics metrics=new DisplayMetrics();
60 60
        wm.getDefaultDisplay().getMetrics(metrics);
61 61
        mScreenHeight=metrics.heightPixels;
62
        mTopViewHeight=mScreenHeight/3-(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 90, context.getResources().getDisplayMetrics());
62
        mTopViewHeight=mScreenHeight/2-(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 90, context.getResources().getDisplayMetrics());
63 63
64 64
    }
65 65
@ -110,7 +110,7 @@ public class PullToZoomScrollView3 extends ScrollView {
110 110
                    isBig=false;
111 111
                }
112 112
                isTouchOne=false;
113
            break;
113
                break;
114 114
        }
115 115
        return super.onTouchEvent(ev);
116 116
    }

+ 1 - 0
app/src/main/res/layout/activity_talkrecommend_header_item.xml

@ -11,6 +11,7 @@
11 11
        android:id="@+id/iv_header_bg"
12 12
        android:layout_width="match_parent"
13 13
        android:layout_height="match_parent"
14
        android:scaleType="centerCrop"
14 15
        android:minHeight="85dp"
15 16
        android:minWidth="94dp"
16 17
        android:background="#44000000"/>

+ 60 - 5
app/src/main/res/layout/activity_topic_details_info.xml

@ -1,10 +1,15 @@
1
<?xml version="1.0" encoding="utf-8"?>
1 2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
    xmlns:tools="http://schemas.android.com/tools"
3
    android:id="@+id/id_drawerlayout"
3 4
    android:layout_width="match_parent"
4
    android:layout_height="match_parent"
5
    android:id="@+id/whole_view"
6
    android:scrollbars="none"
7
    android:orientation="vertical">
5
    android:layout_height="match_parent">
6
7
    <RelativeLayout
8
        android:id="@+id/whole_view"
9
        android:layout_width="match_parent"
10
        android:layout_height="match_parent"
11
        android:orientation="vertical"
12
        android:scrollbars="none">
8 13
9 14
    <com.electric.chargingpile.view.PullToZoomScrollView3
10 15
        android:id="@+id/scroll_view"
@ -19,9 +24,59 @@
19 24
20 25
            <include layout="@layout/activity_topic_info_top" />
21 26
27
            <View
28
                android:id="@+id/make_header_lines"
29
                android:layout_width="match_parent"
30
                android:layout_height="49dp"
31
                android:visibility="gone" />
32
22 33
            <include layout="@layout/activity_topic_infos_content" />
23 34
        </LinearLayout>
24 35
    </com.electric.chargingpile.view.PullToZoomScrollView3>
25 36
37
    <RelativeLayout
38
        android:id="@+id/rl_title"
39
        android:layout_width="fill_parent"
40
        android:layout_height="44dp"
41
        android:background="@color/title_background" >
42
43
        <ImageView
44
            android:id="@+id/iv_back"
45
            android:layout_width="wrap_content"
46
            android:layout_height="match_parent"
47
            android:layout_alignParentLeft="true"
48
            android:layout_centerVertical="true"
49
            android:contentDescription="@null"
50
            android:paddingLeft="15dp"
51
            android:paddingRight="15dp"
52
            android:src="@drawable/icon_lvback1119" />
53
54
        <TextView
55
            android:id="@+id/textview"
56
            android:layout_width="match_parent"
57
            android:layout_height="match_parent"
58
            android:layout_centerInParent="true"
59
            android:layout_toRightOf="@+id/iv_back"
60
            android:layout_toLeftOf="@+id/textview_share"
61
            android:gravity="center"
62
            android:singleLine="true"
63
            android:ellipsize="end"
64
            android:text="@string/about_name"
65
            android:textColor="#222222"
66
            android:textSize="16sp" />
67
68
        <TextView
69
            android:id="@+id/textview_share"
70
            android:layout_width="wrap_content"
71
            android:layout_height="match_parent"
72
            android:layout_alignParentRight="true"
73
            android:gravity="center"
74
            android:paddingRight="15dp"
75
            android:paddingLeft="15dp"
76
            android:text="分享"
77
            android:textColor="#222222"
78
            android:textSize="15sp"/>
79
    </RelativeLayout>
26 80
27 81
</RelativeLayout>
82
</RelativeLayout>

+ 4 - 69
app/src/main/res/layout/activity_topic_info_top.xml

@ -1,51 +1,11 @@
1 1
<?xml version="1.0" encoding="utf-8"?>
2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    android:layout_width="match_parent"
4
    android:layout_height="wrap_content"
4
    android:layout_height="50dp"
5
    android:visibility="gone"
5 6
    android:id="@+id/top_view">
6 7
7
    <RelativeLayout
8
        android:id="@+id/rl_title"
9
        android:layout_width="fill_parent"
10
        android:layout_height="44dp"
11
        android:background="@color/title_background" >
12 8
13
        <ImageView
14
            android:id="@+id/iv_back"
15
            android:layout_width="wrap_content"
16
            android:layout_height="match_parent"
17
            android:layout_alignParentLeft="true"
18
            android:layout_centerVertical="true"
19
            android:contentDescription="@null"
20
            android:paddingLeft="15dp"
21
            android:paddingRight="15dp"
22
            android:src="@drawable/icon_lvback1119" />
23
24
        <TextView
25
            android:id="@+id/textview"
26
            android:layout_width="match_parent"
27
            android:layout_height="match_parent"
28
            android:layout_centerInParent="true"
29
            android:layout_toRightOf="@+id/iv_back"
30
            android:layout_toLeftOf="@+id/textview_share"
31
            android:gravity="center"
32
            android:singleLine="true"
33
            android:ellipsize="end"
34
            android:text="@string/about_name"
35
            android:textColor="#222222"
36
            android:textSize="16sp" />
37
38
        <TextView
39
            android:id="@+id/textview_share"
40
            android:layout_width="wrap_content"
41
            android:layout_height="match_parent"
42
            android:layout_alignParentRight="true"
43
            android:gravity="center"
44
            android:padding="15dp"
45
            android:text="分享"
46
            android:textColor="#222222"
47
            android:textSize="15sp"/>
48
    </RelativeLayout>
49 9
    <!--<View-->
50 10
        <!--android:id="@+id/view_title"-->
51 11
        <!--android:layout_width="match_parent"-->
@ -53,33 +13,8 @@
53 13
        <!---->
54 14
        <!--android:background="@color/ui_titleline" />-->
55 15
56
    <LinearLayout
57
        android:layout_width="match_parent"
58
        android:layout_height="101dp"
59
        android:layout_below="@+id/rl_title"
60
        android:orientation="horizontal"
61
        android:gravity="center_vertical">
62
        <ImageView
63
            android:id="@+id/user_avater"
64
            android:layout_width="71dp"
65
            android:layout_height="71dp"
66
            android:layout_marginLeft="15dp"
67
            />
68
        <TextView
69
            android:id="@+id/topic_title"
70
            android:layout_width="match_parent"
71
            android:layout_height="match_parent"
72
            android:layout_marginLeft="5dp"
73
            android:layout_marginRight="15dp"
74
            android:text="111111"
75
            android:gravity="center_vertical"
76
            android:maxLines="2"
77
            android:ellipsize="end"
78
            android:textSize="17sp"
79
            android:textColor="#222222"/>
80 16
81
    </LinearLayout>
82 17
83 18
    <!--</LinearLayout>-->
84 19
85
</RelativeLayout>
20
</FrameLayout>

+ 28 - 1
app/src/main/res/layout/activity_topic_infos_content.xml

@ -6,7 +6,33 @@
6 6
    xmlns:app="http://schemas.android.com/apk/res-auto"
7 7
    android:orientation="vertical">
8 8
9
    <LinearLayout
10
        android:layout_width="match_parent"
11
        android:layout_height="101dp"
12
        android:layout_below="@+id/rl_title"
13
        android:layout_marginTop="44dp"
14
        android:orientation="horizontal"
15
        android:gravity="center_vertical">
16
        <ImageView
17
            android:id="@+id/user_avater"
18
            android:layout_width="71dp"
19
            android:layout_height="71dp"
20
            android:layout_marginLeft="15dp"
21
            />
22
        <TextView
23
            android:id="@+id/topic_title"
24
            android:layout_width="match_parent"
25
            android:layout_height="match_parent"
26
            android:layout_marginLeft="5dp"
27
            android:layout_marginRight="15dp"
28
            android:text="111111"
29
            android:gravity="center_vertical"
30
            android:maxLines="2"
31
            android:ellipsize="end"
32
            android:textSize="17sp"
33
            android:textColor="#222222"/>
9 34
35
    </LinearLayout>
10 36
11 37
    <RelativeLayout
12 38
        android:layout_width="match_parent"
@ -90,7 +116,8 @@
90 116
91 117
    <LinearLayout
92 118
        android:id="@+id/ll_sort_view"
93
        android:layout_width="match_parent"
119
        android:layout_width="wrap_content"
120
        android:minWidth="100dp"
94 121
        android:layout_height="50dp"
95 122
        android:orientation="horizontal"
96 123
        android:gravity="center_vertical">