forked from hitherejoe/Vineyard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreviewCardView.java
89 lines (69 loc) · 2.33 KB
/
PreviewCardView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.hitherejoe.vineyard.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import com.hitherejoe.vineyard.R;
import butterknife.Bind;
import butterknife.ButterKnife;
public class PreviewCardView extends FrameLayout {
@Bind(R.id.main_container)
FrameLayout mMainContainer;
@Bind(R.id.main_video)
LoopingVideoView mVideoView;
@Bind(R.id.main_image)
ImageView mImageView;
@Bind(R.id.view_overlay)
View mOverlayView;
@Bind(R.id.progress_card)
ProgressBar mProgressCard;
private String mVideoUrl;
public PreviewCardView(Context context) {
super(context);
init();
}
public PreviewCardView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public PreviewCardView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
public PreviewCardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
private void init() {
View view = inflate(getContext(), R.layout.widget_preview_card, this);
ButterKnife.bind(view);
}
public void setVideoUrl(String videoUrl) {
mVideoUrl = videoUrl;
}
public ImageView getImageView() {
return mImageView;
}
public void setLoading() {
mOverlayView.setVisibility(View.VISIBLE);
mProgressCard.setVisibility(View.VISIBLE);
mVideoView.setVisibility(View.VISIBLE);
mVideoView.setupMediaPlayer(mVideoUrl, new LoopingVideoView.OnVideoReadyListener() {
@Override
public void onVideoReady() {
mOverlayView.setVisibility(View.INVISIBLE);
mProgressCard.setVisibility(View.INVISIBLE);
mImageView.setVisibility(View.INVISIBLE);
}
});
}
public void setFinished() {
mVideoView.stopMediaPlayer();
mImageView.setVisibility(View.VISIBLE);
mVideoView.setVisibility(View.INVISIBLE);
mOverlayView.setVisibility(View.INVISIBLE);
mProgressCard.setVisibility(View.INVISIBLE);
}
}