Ver Código Fonte

add dialog tips and forward to other activity

dxh 6 anos atrás
pai
commit
491b0e7b27

+ 41 - 10
app/src/main/java/com/electric/chargingpile/fragment/SvVideoShowView.java

1
package com.electric.chargingpile.fragment;
1
package com.electric.chargingpile.fragment;
2
2
3
import android.app.Activity;
3
import android.app.Activity;
4
import android.content.Intent;
4
import android.support.v4.view.PagerAdapter;
5
import android.support.v4.view.PagerAdapter;
5
import android.support.v4.view.ViewPager;
6
import android.support.v4.view.ViewPager;
6
import android.text.TextUtils;
7
import android.text.TextUtils;
14
import android.widget.TextView;
15
import android.widget.TextView;
15
import android.widget.Toast;
16
import android.widget.Toast;
16
17
18
import com.blankj.utilcode.util.NetworkUtils;
17
import com.blankj.utilcode.util.ToastUtils;
19
import com.blankj.utilcode.util.ToastUtils;
18
import com.bumptech.glide.Glide;
20
import com.bumptech.glide.Glide;
19
import com.bumptech.glide.request.RequestOptions;
21
import com.bumptech.glide.request.RequestOptions;
20
import com.electric.chargingpile.R;
22
import com.electric.chargingpile.R;
23
import com.electric.chargingpile.activity.PersonalPageActivity;
21
import com.electric.chargingpile.application.MainApplication;
24
import com.electric.chargingpile.application.MainApplication;
22
import com.electric.chargingpile.data.TalkRecommendBean;
25
import com.electric.chargingpile.data.TalkRecommendBean;
23
import com.electric.chargingpile.util.CircleTransform;
26
import com.electric.chargingpile.util.CircleTransform;
24
import com.electric.chargingpile.util.JsonUtils;
27
import com.electric.chargingpile.util.JsonUtils;
25
import com.electric.chargingpile.util.ToastUtil;
28
import com.electric.chargingpile.util.ToastUtil;
29
import com.electric.chargingpile.view.AlertDialog;
26
import com.electric.chargingpile.view.UpVideoView2;
30
import com.electric.chargingpile.view.UpVideoView2;
27
import com.electric.chargingpile.view.VideoCommentDialog;
31
import com.electric.chargingpile.view.VideoCommentDialog;
28
import com.electric.chargingpile.view.VideoPubilshDialog;
32
import com.electric.chargingpile.view.VideoPubilshDialog;
37
import java.util.Map;
41
import java.util.Map;
38
42
39
import okhttp3.Call;
43
import okhttp3.Call;
44
import tv.danmaku.ijk.media.player.IMediaPlayer;
40
45
41
public class SvVideoShowView implements View.OnClickListener {
46
public class SvVideoShowView implements View.OnClickListener {
42
47
197
                    public void onResponse(String response) {
202
                    public void onResponse(String response) {
198
                        String rtnCode = JsonUtils.getKeyResult(response, "code");
203
                        String rtnCode = JsonUtils.getKeyResult(response, "code");
199
204
200
201
202
//                        sv_show_like_ll =view.findViewById(R.id.sv_show_like_ll);
205
//                        sv_show_like_ll =view.findViewById(R.id.sv_show_like_ll);
203
                        sv_show_like_img =view.findViewById(R.id.sv_show_like_img);
206
                        sv_show_like_img = view.findViewById(R.id.sv_show_like_img);
204
                        ToastUtils.showLong("like没有提供图片");
207
                        ToastUtils.showLong("like没有提供图片");
205
//                        sv_show_like_tv =view.findViewById(R.id.sv_show_like_tv);
208
//                        sv_show_like_tv =view.findViewById(R.id.sv_show_like_tv);
206
                        if ("1000".equals(rtnCode)) {
209
                        if ("1000".equals(rtnCode)) {
207
                            if (likeFlag == 1) {
210
                            if (likeFlag == 1) {
208
                                talkRecommendBean.likeNums+=1;
209
                                sv_show_like_tv.setText(""+talkRecommendBean.likeNums);
211
                                talkRecommendBean.likeNums += 1;
212
                                sv_show_like_tv.setText("" + talkRecommendBean.likeNums);
210
                                //点赞
213
                                //点赞
211
                            } else {
214
                            } else {
212
                                talkRecommendBean.likeNums-=1;
213
                                sv_show_like_tv.setText(""+talkRecommendBean.likeNums);
215
                                talkRecommendBean.likeNums -= 1;
216
                                sv_show_like_tv.setText("" + talkRecommendBean.likeNums);
214
                                //取消赞
217
                                //取消赞
215
                            }
218
                            }
216
                        }
219
                        }
239
        sv_show_comment_ll.setOnClickListener(this);
242
        sv_show_comment_ll.setOnClickListener(this);
240
        sv_show_forward.setOnClickListener(this);
243
        sv_show_forward.setOnClickListener(this);
241
        sv_show_like_ll.setOnClickListener(this);
244
        sv_show_like_ll.setOnClickListener(this);
245
        sv_show_like_img.setOnClickListener(this);
242
    }
246
    }
243
247
244
    private void initPlayer(View view) {
248
    private void initPlayer(View view) {
320
        } else {
324
        } else {
321
            if (upVideoView2 != null && !TextUtils.isEmpty(talkRecommendBean.videoUrl)) {
325
            if (upVideoView2 != null && !TextUtils.isEmpty(talkRecommendBean.videoUrl)) {
322
                String videoUrl = talkRecommendBean.videoUrl;
326
                String videoUrl = talkRecommendBean.videoUrl;
323
                Log.d("SvVideoShowView", "play");
324
                upVideoView2.setVideoPath(videoUrl);
325
                upVideoView2.start();
327
                playVideo(videoUrl);
326
            }
328
            }
327
        }
329
        }
328
    }
330
    }
329
331
332
    private void playVideo(String urlPath){
333
        upVideoView2.setVideoPath(urlPath);
334
        NetworkUtils.NetworkType networkType = NetworkUtils.getNetworkType();
335
        switch (networkType) {
336
            case NETWORK_2G:
337
            case NETWORK_3G:
338
            case NETWORK_4G:
339
                new AlertDialog(activity)
340
                        .builder()
341
                        .setMsg("您当前使用的是流量,是否播放视频?")
342
                        .setPositiveButton("确定", new View.OnClickListener() {
343
                            @Override
344
                            public void onClick(View view) {
345
                                upVideoView2.start();
346
                            }
347
                        })
348
                        .setNegativeButton("取消", null);
349
                break;
350
            default:
351
                upVideoView2.start();
352
                break;
353
        }
354
    }
355
330
    @Override
356
    @Override
331
    public void onClick(View view) {
357
    public void onClick(View view) {
332
        switch (view.getId()) {
358
        switch (view.getId()) {
352
                }
378
                }
353
                likeRequest(newLike);
379
                likeRequest(newLike);
354
                break;
380
                break;
381
            case R.id.sv_show_like_img:
382
                Intent intent = new Intent(activity, PersonalPageActivity.class);
383
                intent.putExtra("targetUserId", talkRecommendBean.addUserId);
384
                activity.startActivity(intent);
385
                break;
355
            default:
386
            default:
356
                break;
387
                break;
357
        }
388
        }

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

126
        btn_neg.setOnClickListener(new OnClickListener() {
126
        btn_neg.setOnClickListener(new OnClickListener() {
127
            @Override
127
            @Override
128
            public void onClick(View v) {
128
            public void onClick(View v) {
129
                listener.onClick(v);
129
                if (listener != null) {
130
                    listener.onClick(v);
131
                }
130
                dialog.dismiss();
132
                dialog.dismiss();
131
            }
133
            }
132
        });
134
        });