Commit 6704304580fb8ea01bd68d784f0655e16ebf6a1c
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/CNLiveApp
Showing
13 changed files
with
87 additions
and
60 deletions
app/src/main/java/com/cnlive/gundam/main/ui/fragment/UGCListFragment.java
| ... | ... | @@ -6,7 +6,6 @@ import android.support.annotation.Nullable; |
| 6 | 6 | import android.support.v4.app.Fragment; |
| 7 | 7 | import android.support.v4.widget.SwipeRefreshLayout; |
| 8 | 8 | import android.support.v7.widget.LinearLayoutManager; |
| 9 | -import android.util.Log; | |
| 10 | 9 | import android.view.LayoutInflater; |
| 11 | 10 | import android.view.View; |
| 12 | 11 | import android.view.ViewGroup; |
| ... | ... | @@ -14,11 +13,11 @@ import android.widget.Toast; |
| 14 | 13 | |
| 15 | 14 | import com.cnlive.gundam.BR; |
| 16 | 15 | import com.cnlive.gundam.R; |
| 16 | +import com.cnlive.gundam.data.network.RetrofitUtil; | |
| 17 | +import com.cnlive.gundam.data.network.util.SignUtil; | |
| 17 | 18 | import com.cnlive.gundam.databinding.FragmentActiveListBinding; |
| 18 | 19 | import com.cnlive.gundam.main.model.ActiveInfo; |
| 19 | 20 | import com.cnlive.gundam.main.model.ActiveListModel; |
| 20 | -import com.cnlive.gundam.data.network.RetrofitUtil; | |
| 21 | -import com.cnlive.gundam.data.network.util.SignUtil; | |
| 22 | 21 | import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter; |
| 23 | 22 | import com.cnlive.gundam.main.utils.ActivityJumpUtil; |
| 24 | 23 | import com.cnlive.libs.util.Config; |
| ... | ... | @@ -92,7 +91,6 @@ public class UGCListFragment extends Fragment implements SwipeRefreshLayout.OnRe |
| 92 | 91 | |
| 93 | 92 | @Override |
| 94 | 93 | public void onResponse(Call<ActiveListModel> call, Response<ActiveListModel> response) { |
| 95 | - Log.e("11111111111111", "onResponse: "+call.request().toString() ); | |
| 96 | 94 | binding.contentView.setRefreshing(false); |
| 97 | 95 | if (response.isSuccessful()) { |
| 98 | 96 | ActiveListModel model = response.body(); | ... | ... |
app/src/main/java/com/cnlive/gundam/video/view/BaseVideoView.java
| ... | ... | @@ -49,6 +49,8 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 49 | 49 | protected static boolean isLive; |
| 50 | 50 | //记录当前视频是否能播 |
| 51 | 51 | protected boolean canPlay = true; |
| 52 | + //记录当前视频状态是否结束 | |
| 53 | + protected boolean isStatusEnd = false; | |
| 52 | 54 | //本地缓存数据工具类 |
| 53 | 55 | private SharedPreferencesHelper sharedPreferencesHelper; |
| 54 | 56 | //播放进度保存至本地缓存的标识前缀 |
| ... | ... | @@ -108,7 +110,7 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 108 | 110 | if (Build.VERSION.SDK_INT >= 23) { |
| 109 | 111 | int checkCallPhonePermission = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_PHONE_STATE); |
| 110 | 112 | if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) { |
| 111 | - if(ugcLivePermissionListener != null) | |
| 113 | + if (ugcLivePermissionListener != null) | |
| 112 | 114 | ugcLivePermissionListener.onShouldRequestPermission(); |
| 113 | 115 | } else { |
| 114 | 116 | addUgcLiveStatus(); |
| ... | ... | @@ -133,14 +135,14 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 133 | 135 | /** |
| 134 | 136 | * 设置UGC LIVE的直播状态监听 |
| 135 | 137 | */ |
| 136 | - public void setUgcLiveStatusPermissionListener(OnUgcLiveStatusPermissionListener l){ | |
| 138 | + public void setUgcLiveStatusPermissionListener(OnUgcLiveStatusPermissionListener l) { | |
| 137 | 139 | ugcLivePermissionListener = l; |
| 138 | 140 | } |
| 139 | 141 | |
| 140 | 142 | /** |
| 141 | 143 | * 添加UGC LIVE的直播状态监听 |
| 142 | 144 | */ |
| 143 | - public void addUgcLiveStatus(){ | |
| 145 | + public void addUgcLiveStatus() { | |
| 144 | 146 | VideoStatusUtil.setOnVideoPlayStatusCallback(mOnVideoStatusCallback); |
| 145 | 147 | VideoStatusUtil.init(videoModel.getId()); |
| 146 | 148 | } |
| ... | ... | @@ -213,7 +215,6 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 213 | 215 | * @param rate |
| 214 | 216 | */ |
| 215 | 217 | public void switchVideoRate(String rate) { |
| 216 | - //TODO 换成无缝切换 | |
| 217 | 218 | curRate = rate; |
| 218 | 219 | if (binding.controllerView != null) |
| 219 | 220 | binding.controllerView.setSwitchRateType(PlayerControllerView.SWITCH_RATE_START, curRate); |
| ... | ... | @@ -252,7 +253,7 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 252 | 253 | isPrepareSeek = true; |
| 253 | 254 | iMediaPlayer.seekTo(curPlayPosition); |
| 254 | 255 | } else { |
| 255 | - if (canPlay && !iMediaPlayer.getPlayState()) { | |
| 256 | + if (!iMediaPlayer.getPlayState()) { | |
| 256 | 257 | setPlayState(true); |
| 257 | 258 | isPlay = true; |
| 258 | 259 | } |
| ... | ... | @@ -310,22 +311,27 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 310 | 311 | switch (status) { |
| 311 | 312 | case IVideoStatus.MEDIA_STATUS_LIVING: |
| 312 | 313 | //直播中' |
| 313 | - canPlay = true; | |
| 314 | - if (!binding.videoView.getPlayState()) { | |
| 315 | - binding.videoView.reload(); | |
| 316 | - binding.infoView.show(PlayerInfoView.SHOW_BUFFERING); | |
| 314 | + if (!isStatusEnd) { | |
| 315 | + canPlay = true; | |
| 316 | + isPlay = true; | |
| 317 | + setPlayState(true); | |
| 317 | 318 | } |
| 318 | 319 | break; |
| 319 | 320 | case IVideoStatus.MEDIA_STATUS_LEAVE: |
| 320 | 321 | //主播暂时离开 |
| 321 | - canPlay = false; | |
| 322 | - binding.videoView.stop(); | |
| 323 | - binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, getContext().getString(R.string.player_status_leave)); | |
| 322 | + if (!isStatusEnd) { | |
| 323 | + canPlay = false; | |
| 324 | + isPlay = false; | |
| 325 | + setPlayState(false); | |
| 326 | + binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, getContext().getString(R.string.player_status_leave)); | |
| 327 | + } | |
| 324 | 328 | break; |
| 325 | 329 | case IVideoStatus.MEDIA_STATUS_END: |
| 326 | 330 | //直播结束 |
| 327 | 331 | canPlay = false; |
| 328 | - binding.videoView.stop(); | |
| 332 | + isPlay = false; | |
| 333 | + isStatusEnd = true; | |
| 334 | + binding.videoView.release(); | |
| 329 | 335 | binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, getContext().getString(R.string.player_status_end)); |
| 330 | 336 | break; |
| 331 | 337 | } |
| ... | ... | @@ -344,7 +350,7 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 344 | 350 | } |
| 345 | 351 | |
| 346 | 352 | //ugc live 监听直播状态得需要android.permission.READ_PHONE_STATE |
| 347 | - public interface OnUgcLiveStatusPermissionListener{ | |
| 353 | + public interface OnUgcLiveStatusPermissionListener { | |
| 348 | 354 | void onShouldRequestPermission(); |
| 349 | 355 | } |
| 350 | 356 | } | ... | ... |
app/src/main/res/layout/fragment_player_ugc_live.xml
app/src/main/res/layout/layout_player_controller_live_l.xml
| ... | ... | @@ -144,7 +144,7 @@ |
| 144 | 144 | <RelativeLayout |
| 145 | 145 | android:id="@+id/bottomLayout" |
| 146 | 146 | android:layout_width="match_parent" |
| 147 | - android:layout_height="wrap_content" | |
| 147 | + android:layout_height="40dp" | |
| 148 | 148 | android:background="#44000000" |
| 149 | 149 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| 150 | 150 | |
| ... | ... | @@ -152,33 +152,43 @@ |
| 152 | 152 | android:id="@+id/playBtn" |
| 153 | 153 | android:layout_width="30dp" |
| 154 | 154 | android:layout_height="30dp" |
| 155 | + android:layout_centerVertical="true" | |
| 155 | 156 | android:layout_marginRight="5dp" |
| 157 | + android:layout_marginLeft="10dp" | |
| 156 | 158 | android:onClick="@{playerControllerView.onClick}" |
| 157 | 159 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> |
| 158 | 160 | |
| 159 | - <TextView | |
| 160 | - android:id="@+id/rate" | |
| 161 | + <RelativeLayout | |
| 161 | 162 | android:layout_width="wrap_content" |
| 162 | - android:layout_height="wrap_content" | |
| 163 | - android:layout_alignParentRight="true" | |
| 164 | - android:layout_centerVertical="true" | |
| 165 | - android:layout_marginRight="10dp" | |
| 166 | - android:onClick="@{playerControllerView.onClick}" | |
| 167 | - android:text="@{VideoRateUtil.getRateText(rateType.get())}" | |
| 168 | - android:textColor="@android:color/white" | |
| 169 | - android:visibility="@{hasRate.get() ? View.VISIBLE : View.GONE}" /> | |
| 163 | + android:layout_height="match_parent" | |
| 164 | + android:layout_alignParentRight="true"> | |
| 170 | 165 | |
| 171 | - <android.support.v7.widget.SwitchCompat | |
| 172 | - android:id="@+id/barrage_top" | |
| 173 | - android:layout_width="wrap_content" | |
| 174 | - android:layout_height="wrap_content" | |
| 175 | - android:layout_centerVertical="true" | |
| 176 | - android:background="@null" | |
| 177 | - android:textIsSelectable="false" | |
| 178 | - android:layout_alignParentRight="true" | |
| 179 | - android:thumb="@drawable/switch_thumb" | |
| 180 | - app:switchMinWidth="30dp" | |
| 181 | - app:track="@drawable/switch_track" /> | |
| 166 | + <TextView | |
| 167 | + android:id="@+id/rate" | |
| 168 | + android:layout_width="wrap_content" | |
| 169 | + android:layout_height="wrap_content" | |
| 170 | + android:layout_alignParentRight="true" | |
| 171 | + android:layout_centerVertical="true" | |
| 172 | + android:layout_marginRight="10dp" | |
| 173 | + android:onClick="@{playerControllerView.onClick}" | |
| 174 | + android:text="@{VideoRateUtil.getRateText(rateType.get())}" | |
| 175 | + android:textColor="@android:color/white" | |
| 176 | + android:visibility="@{hasRate.get() ? View.VISIBLE : View.GONE}" /> | |
| 177 | + | |
| 178 | + <android.support.v7.widget.SwitchCompat | |
| 179 | + android:id="@+id/barrage_top" | |
| 180 | + android:layout_width="wrap_content" | |
| 181 | + android:layout_height="wrap_content" | |
| 182 | + android:layout_centerVertical="true" | |
| 183 | + android:background="@null" | |
| 184 | + android:textIsSelectable="false" | |
| 185 | + android:layout_marginRight="10dp" | |
| 186 | + android:layout_toLeftOf="@+id/rate" | |
| 187 | + android:thumb="@drawable/switch_thumb" | |
| 188 | + app:switchMinWidth="15dp" | |
| 189 | + app:track="@drawable/switch_track" /> | |
| 190 | + | |
| 191 | + </RelativeLayout> | |
| 182 | 192 | |
| 183 | 193 | </RelativeLayout> |
| 184 | 194 | ... | ... |
app/src/main/res/layout/layout_player_controller_live_p.xml
| ... | ... | @@ -52,7 +52,7 @@ |
| 52 | 52 | <RelativeLayout |
| 53 | 53 | android:id="@+id/bottomLayout" |
| 54 | 54 | android:layout_width="match_parent" |
| 55 | - android:layout_height="wrap_content" | |
| 55 | + android:layout_height="40dp" | |
| 56 | 56 | android:background="#44000000" |
| 57 | 57 | android:layout_alignParentBottom="true" |
| 58 | 58 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| ... | ... | @@ -62,15 +62,17 @@ |
| 62 | 62 | android:layout_width="30dp" |
| 63 | 63 | android:layout_height="30dp" |
| 64 | 64 | android:layout_marginRight="5dp" |
| 65 | + android:layout_marginLeft="10dp" | |
| 66 | + android:layout_centerVertical="true" | |
| 65 | 67 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" |
| 66 | 68 | android:onClick="@{playerControllerView.onClick}"/> |
| 67 | 69 | |
| 68 | - | |
| 69 | - | |
| 70 | 70 | <ImageView |
| 71 | 71 | android:id="@+id/fullScreen" |
| 72 | - android:layout_width="30dp" | |
| 73 | - android:layout_height="30dp" | |
| 72 | + android:layout_width="25dp" | |
| 73 | + android:layout_height="25dp" | |
| 74 | + android:layout_centerVertical="true" | |
| 75 | + android:layout_marginRight="10dp" | |
| 74 | 76 | android:src="@drawable/player_full_screen" |
| 75 | 77 | android:layout_alignParentRight="true" |
| 76 | 78 | android:onClick="@{playerControllerView.onClick}"/> | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_live_l.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <layout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | - xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 4 | - > | |
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | |
| 5 | 4 | |
| 6 | 5 | <data> |
| 7 | 6 | |
| ... | ... | @@ -9,7 +8,7 @@ |
| 9 | 8 | |
| 10 | 9 | <import type="android.databinding.ObservableBoolean" /> |
| 11 | 10 | |
| 12 | - <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | |
| 11 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView" /> | |
| 13 | 12 | |
| 14 | 13 | <import type="android.view.View" /> |
| 15 | 14 | |
| ... | ... | @@ -27,7 +26,7 @@ |
| 27 | 26 | |
| 28 | 27 | <variable |
| 29 | 28 | name="playerControllerView" |
| 30 | - type="PlayerControllerView"/> | |
| 29 | + type="PlayerControllerView" /> | |
| 31 | 30 | |
| 32 | 31 | </data> |
| 33 | 32 | |
| ... | ... | @@ -47,8 +46,8 @@ |
| 47 | 46 | android:layout_width="30dp" |
| 48 | 47 | android:layout_height="30dp" |
| 49 | 48 | android:layout_marginLeft="10dp" |
| 50 | - android:src="@drawable/player_back" | |
| 51 | - android:onClick="@{playerControllerView.onClick}"/> | |
| 49 | + android:onClick="@{playerControllerView.onClick}" | |
| 50 | + android:src="@drawable/player_back" /> | |
| 52 | 51 | |
| 53 | 52 | <TextView |
| 54 | 53 | android:id="@+id/title" |
| ... | ... | @@ -75,9 +74,8 @@ |
| 75 | 74 | android:layout_height="30dp" |
| 76 | 75 | android:layout_marginRight="5dp" |
| 77 | 76 | android:onClick="@{playerControllerView.onClick}" |
| 78 | - android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> | |
| 79 | - | |
| 80 | - | |
| 77 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" | |
| 78 | + android:visibility="gone" /> | |
| 81 | 79 | |
| 82 | 80 | </RelativeLayout> |
| 83 | 81 | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_live_p.xml
| ... | ... | @@ -63,6 +63,7 @@ |
| 63 | 63 | android:layout_width="30dp" |
| 64 | 64 | android:layout_height="30dp" |
| 65 | 65 | android:layout_marginRight="5dp" |
| 66 | + android:visibility="gone" | |
| 66 | 67 | android:onClick="@{playerControllerView.onClick}" |
| 67 | 68 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}"/> |
| 68 | 69 | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_vod_l.xml
| ... | ... | @@ -92,6 +92,7 @@ |
| 92 | 92 | android:layout_width="30dp" |
| 93 | 93 | android:layout_height="30dp" |
| 94 | 94 | android:layout_marginRight="5dp" |
| 95 | + android:layout_marginLeft="10dp" | |
| 95 | 96 | android:onClick="@{playerControllerView.onClick}" |
| 96 | 97 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> |
| 97 | 98 | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_vod_p.xml
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | <RelativeLayout |
| 61 | 61 | android:id="@+id/bottomLayout" |
| 62 | 62 | android:layout_width="match_parent" |
| 63 | - android:layout_height="wrap_content" | |
| 63 | + android:layout_height="40dp" | |
| 64 | 64 | android:background="#44000000" |
| 65 | 65 | android:layout_alignParentBottom="true" |
| 66 | 66 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| ... | ... | @@ -70,6 +70,8 @@ |
| 70 | 70 | android:layout_width="30dp" |
| 71 | 71 | android:layout_height="30dp" |
| 72 | 72 | android:layout_marginRight="5dp" |
| 73 | + android:layout_marginLeft="10dp" | |
| 74 | + android:layout_centerVertical="true" | |
| 73 | 75 | android:onClick="@{playerControllerView.onClick}" |
| 74 | 76 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}"/> |
| 75 | 77 | ... | ... |
app/src/main/res/layout/layout_player_controller_vod_l.xml
| ... | ... | @@ -179,6 +179,7 @@ |
| 179 | 179 | android:layout_width="30dp" |
| 180 | 180 | android:layout_height="30dp" |
| 181 | 181 | android:layout_marginRight="5dp" |
| 182 | + android:layout_marginLeft="10dp" | |
| 182 | 183 | android:onClick="@{playerControllerView.onClick}" |
| 183 | 184 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> |
| 184 | 185 | ... | ... |
app/src/main/res/layout/layout_player_controller_vod_p.xml
| ... | ... | @@ -61,7 +61,7 @@ |
| 61 | 61 | <RelativeLayout |
| 62 | 62 | android:id="@+id/bottomLayout" |
| 63 | 63 | android:layout_width="match_parent" |
| 64 | - android:layout_height="wrap_content" | |
| 64 | + android:layout_height="40dp" | |
| 65 | 65 | android:background="#44000000" |
| 66 | 66 | android:layout_alignParentBottom="true" |
| 67 | 67 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| ... | ... | @@ -71,8 +71,10 @@ |
| 71 | 71 | android:layout_width="30dp" |
| 72 | 72 | android:layout_height="30dp" |
| 73 | 73 | android:layout_marginRight="5dp" |
| 74 | + android:layout_marginLeft="10dp" | |
| 74 | 75 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" |
| 75 | - android:onClick="@{playerControllerView.onClick}"/> | |
| 76 | + android:onClick="@{playerControllerView.onClick}" | |
| 77 | + android:layout_centerVertical="true"/> | |
| 76 | 78 | |
| 77 | 79 | <TextView |
| 78 | 80 | android:id="@+id/curTime" |
| ... | ... | @@ -106,10 +108,12 @@ |
| 106 | 108 | |
| 107 | 109 | <ImageView |
| 108 | 110 | android:id="@+id/fullScreen" |
| 109 | - android:layout_width="30dp" | |
| 110 | - android:layout_height="30dp" | |
| 111 | + android:layout_width="25dp" | |
| 112 | + android:layout_height="25dp" | |
| 111 | 113 | android:src="@drawable/player_full_screen" |
| 112 | 114 | android:layout_alignParentRight="true" |
| 115 | + android:layout_centerVertical="true" | |
| 116 | + android:layout_marginRight="10dp" | |
| 113 | 117 | android:onClick="@{playerControllerView.onClick}"/> |
| 114 | 118 | |
| 115 | 119 | </RelativeLayout> | ... | ... |
app/src/main/res/layout/layout_player_ugc_info.xml
| ... | ... | @@ -168,13 +168,14 @@ |
| 168 | 168 | android:layout_height="match_parent" |
| 169 | 169 | android:visibility="@{showType.get() == PlayerInfoView.SHOW_UGC_LIVE_STATUS ? View.VISIBLE : View.GONE}" |
| 170 | 170 | tools:visibility="gone" |
| 171 | - android:background="#000000"> | |
| 171 | + android:background="@color/play_status_bg"> | |
| 172 | 172 | |
| 173 | 173 | <TextView |
| 174 | 174 | android:layout_width="wrap_content" |
| 175 | 175 | android:layout_height="wrap_content" |
| 176 | 176 | android:text="@{statusMsg.get()}" |
| 177 | 177 | android:gravity="center" |
| 178 | + android:background="@drawable/player_btn_bg" | |
| 178 | 179 | android:textColor="@android:color/white" |
| 179 | 180 | android:layout_centerInParent="true"/> |
| 180 | 181 | ... | ... |