Commit 05ffc32dc450b4fbaad44d0fb6fd198518fe42ba

Authored by 朱显松
2 parents 3f7e8d94 4fd76e52

Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/CNLiveApp

Showing 40 changed files with 979 additions and 65 deletions
app/src/main/java/com/cnlive/gundam/application/CNLiveApplication.java
... ... @@ -10,6 +10,8 @@ import com.cnlive.libs.util.Config;
10 10  
11 11 public class CNLiveApplication extends Application {
12 12  
  13 + public static final String secret = "c2faeb120f0ea2e2d47020d4b03cb8a93bed2585897a94";
  14 +
13 15 @Override
14 16 public void onCreate() {
15 17 super.onCreate();
... ...
app/src/main/java/com/cnlive/gundam/main/model/ActiveExInfo.java 0 → 100644
  1 +package com.cnlive.gundam.main.model;
  2 +
  3 +/**
  4 + * Created by gujun on 2017/6/29.
  5 + */
  6 +
  7 +public class ActiveExInfo {
  8 +
  9 + private String name ;
  10 + private String iconUrl;
  11 +
  12 + public ActiveExInfo(String name, String iconUrl) {
  13 + this.name = name;
  14 + this.iconUrl = iconUrl;
  15 + }
  16 +
  17 + public String getName() {
  18 + return name;
  19 + }
  20 +
  21 + public void setName(String name) {
  22 + this.name = name;
  23 + }
  24 +
  25 + public String getIconUrl() {
  26 + return iconUrl;
  27 + }
  28 +
  29 + public void setIconUrl(String iconUrl) {
  30 + this.iconUrl = iconUrl;
  31 + }
  32 +
  33 + @Override
  34 + public String toString() {
  35 + return "ActiveExInfo{" +
  36 + "name='" + name + '\'' +
  37 + ", iconUrl='" + iconUrl + '\'' +
  38 + '}';
  39 + }
  40 +}
... ...
app/src/main/java/com/cnlive/gundam/main/model/ActiveInfo.java
... ... @@ -21,13 +21,13 @@ public class ActiveInfo implements Serializable {
21 21 private String endTime;
22 22 private String coverImgUrl;
23 23 private String activityCategory;
24   - private Object extensions;
  24 + private ActiveExInfo extensions;
25 25 private String rates;
26 26  
27 27 public ActiveInfo() {
28 28 }
29 29  
30   - public ActiveInfo(int totalCount, int nextCursor, int preCursor, String activityId, String activityName, int activityStatus, int isHorizontalScreen, String channelId, String createTime, String startTime, String endTime, String coverImgUrl, String activityCategory, Object extensions, String rates) {
  30 + public ActiveInfo(int totalCount, int nextCursor, int preCursor, String activityId, String activityName, int activityStatus, int isHorizontalScreen, String channelId, String createTime, String startTime, String endTime, String coverImgUrl, String activityCategory, ActiveExInfo extensions, String rates) {
31 31 this.totalCount = totalCount;
32 32 this.nextCursor = nextCursor;
33 33 this.preCursor = preCursor;
... ... @@ -149,11 +149,11 @@ public class ActiveInfo implements Serializable {
149 149 this.activityCategory = activityCategory;
150 150 }
151 151  
152   - public Object getExtensions() {
  152 + public ActiveExInfo getExtensions() {
153 153 return extensions;
154 154 }
155 155  
156   - public void setExtensions(Object extensions) {
  156 + public void setExtensions(ActiveExInfo extensions) {
157 157 this.extensions = extensions;
158 158 }
159 159  
... ... @@ -185,4 +185,12 @@ public class ActiveInfo implements Serializable {
185 185 ", rates='" + rates + '\'' +
186 186 '}';
187 187 }
  188 +
  189 + public String getExUrl() {
  190 + return extensions != null ? extensions.getIconUrl() : "";
  191 + }
  192 +
  193 + public String getExNick() {
  194 + return extensions != null ? extensions.getName() : "";
  195 + }
188 196 }
... ...
app/src/main/java/com/cnlive/gundam/main/model/ActivePlayInfo.java
... ... @@ -37,6 +37,7 @@ public class ActivePlayInfo extends ErrorMessage {
37 37 private String activityCategory;
38 38 private String rates;
39 39 private String extViews;
  40 + private ActiveExInfo extensions;
40 41  
41 42 public ActiveModel() {
42 43 }
... ... @@ -137,6 +138,14 @@ public class ActivePlayInfo extends ErrorMessage {
137 138 this.extViews = extViews;
138 139 }
139 140  
  141 + public ActiveExInfo getExtensions() {
  142 + return extensions;
  143 + }
  144 +
  145 + public void setExtensions(ActiveExInfo extensions) {
  146 + this.extensions = extensions;
  147 + }
  148 +
140 149 @Override
141 150 public String toString() {
142 151 return "ActiveModel{" +
... ...
app/src/main/java/com/cnlive/gundam/main/model/VideoListProgram.java
... ... @@ -18,18 +18,20 @@ public class VideoListProgram implements Serializable {
18 18 private String rates;
19 19 private String type;
20 20 private String category;//点播用
  21 + private int isHorizontalScreen = 1;//屏幕方向,0:垂直即竖屏 /1:水平即横屏 ,默认为1 |
21 22  
22 23 public VideoListProgram() {
23 24 }
24 25  
25 26 //ugc点播使用
26   - public VideoListProgram(String vId, String title, String img, String subTitle, String rates, String type) {
  27 + public VideoListProgram(String vId, String title, String img, String subTitle, String rates, String type, int isHorizontalScreen) {
27 28 this.vId = vId;
28 29 this.title = title;
29 30 this.subTitle = subTitle;
30 31 this.img = img;
31 32 this.rates = rates;
32 33 this.type = type;
  34 + this.isHorizontalScreen = isHorizontalScreen;
33 35 }
34 36  
35 37 //直播使用
... ... @@ -41,6 +43,16 @@ public class VideoListProgram implements Serializable {
41 43 this.type = type;
42 44 }
43 45  
  46 + //ugc直播使用
  47 + public VideoListProgram(String channelId, String title, String img, String docID, String type, int isHorizontalScreen) {
  48 + this.channelId = channelId;
  49 + this.title = title;
  50 + this.img = img;
  51 + this.docID = docID;
  52 + this.type = type;
  53 + this.isHorizontalScreen = isHorizontalScreen;
  54 + }
  55 +
44 56 public String getvId() {
45 57 return vId;
46 58 }
... ... @@ -104,4 +116,20 @@ public class VideoListProgram implements Serializable {
104 116 public void setType(String type) {
105 117 this.type = type;
106 118 }
  119 +
  120 + public String getCategory() {
  121 + return category;
  122 + }
  123 +
  124 + public void setCategory(String category) {
  125 + this.category = category;
  126 + }
  127 +
  128 + public int getIsHorizontalScreen() {
  129 + return isHorizontalScreen;
  130 + }
  131 +
  132 + public void setIsHorizontalScreen(int isHorizontalScreen) {
  133 + this.isHorizontalScreen = isHorizontalScreen;
  134 + }
107 135 }
... ...
app/src/main/java/com/cnlive/gundam/main/ui/activity/BackBaseActivity.java
... ... @@ -22,7 +22,7 @@ public class BackBaseActivity extends AppCompatActivity {
22 22 TextView toolbarTitle = (TextView) findViewById(R.id.toolbarTitle);
23 23 toolbarTitle.setText(title);
24 24 toolbar.setVisibility(View.VISIBLE);
25   - toolbar.setNavigationIcon(R.drawable.btn_cancel);
  25 + toolbar.setNavigationIcon(R.drawable.page_back);
26 26 setSupportActionBar(toolbar);
27 27  
28 28 }
... ...
app/src/main/java/com/cnlive/gundam/main/ui/activity/MainActivity.java
... ... @@ -17,11 +17,13 @@ import com.cnlive.gundam.main.ui.fragment.HomeFragment;
17 17 import com.cnlive.gundam.main.ui.fragment.LiveFragment;
18 18 import com.cnlive.gundam.main.ui.fragment.UGCListFragment;
19 19 import com.cnlive.gundam.main.ui.widget.FragmentTabHost;
  20 +import com.cnlive.gundam.main.utils.SharedPreferencesHelper;
20 21 import com.cnlive.gundam.stream.model.ChannelInfoModel;
21 22 import com.cnlive.gundam.stream.ui.activity.StreamActivity;
22 23 import com.cnlive.gundam.user.activity.LoginActivity;
23 24 import com.cnlive.gundam.user.auth.UserService;
24 25 import com.cnlive.gundam.user.model.User;
  26 +import com.cnlive.gundam.video.view.VideoView;
25 27 import com.cnlive.libs.util.Config;
26 28  
27 29 import java.util.Arrays;
... ... @@ -139,4 +141,10 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O
139 141 }
140 142 }).show();
141 143 }
  144 +
  145 + @Override
  146 + protected void onDestroy() {
  147 + super.onDestroy();
  148 + SharedPreferencesHelper.getInstance(this).setValue(VideoView.CAN_MOBILE_NET_PLAY, false);
  149 + }
142 150 }
143 151 \ No newline at end of file
... ...
app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
... ... @@ -79,12 +79,17 @@ public class ConfigFragment extends Fragment implements View.OnClickListener {
79 79 @Override
80 80 public void onResume() {
81 81 super.onResume();
82   - if (UserService.getInstance(getActivity()).getActiveAccountInfo().getUid() != 0) notifyUI();
  82 + notifyUI(UserService.getInstance(getActivity()).getActiveAccountInfo().getUid() != 0);
83 83 }
84 84  
85   - private void notifyUI() {
86   - User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo();
87   - Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg);
88   - binding.tvNickname.setText(activeAccountInfo.getNickname());
  85 + private void notifyUI(boolean isLogin) {
  86 + if(isLogin){
  87 + User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo();
  88 + Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg);
  89 + binding.tvNickname.setText(activeAccountInfo.getNickname());
  90 + }else{
  91 + Glide.with(getActivity()).load(R.drawable.cnlive_user_header).into(binding.headImg);
  92 + binding.tvNickname.setText(getString(R.string.click_login));
  93 + }
89 94 }
90 95 }
... ...
app/src/main/java/com/cnlive/gundam/main/ui/fragment/UGCListFragment.java
... ... @@ -6,6 +6,7 @@ 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;
9 10 import android.view.LayoutInflater;
10 11 import android.view.View;
11 12 import android.view.ViewGroup;
... ... @@ -65,9 +66,8 @@ public class UGCListFragment extends Fragment implements SwipeRefreshLayout.OnRe
65 66  
66 67 private void loadData() {
67 68 Map<String, String> params = new HashMap<>();
68   - //TODO 传多个播放状态
69 69 params.put("appId", Config.getAppId());
70   - params.put("activityStatus", "2");
  70 + params.put("activityStatus", "1,2");
71 71 params.put("pageNo", "1");
72 72 params.put("pageSize", "15");
73 73 RetrofitUtil.getApiService().getSpActivityList(SignUtil.getSignParamM(getActivity(), params)).enqueue(this);
... ... @@ -92,6 +92,7 @@ public class UGCListFragment extends Fragment implements SwipeRefreshLayout.OnRe
92 92  
93 93 @Override
94 94 public void onResponse(Call<ActiveListModel> call, Response<ActiveListModel> response) {
  95 + Log.e("11111111111111", "onResponse: "+call.request().toString() );
95 96 binding.contentView.setRefreshing(false);
96 97 if (response.isSuccessful()) {
97 98 ActiveListModel model = response.body();
... ...
app/src/main/java/com/cnlive/gundam/main/utils/ActivityJumpUtil.java
... ... @@ -57,9 +57,9 @@ public class ActivityJumpUtil {
57 57 private static void jumpByStatus(Context context, ActivePlayInfo.ActiveModel model) {
58 58 if (model == null) return;
59 59 if (model.getActivityStatus() == 1) {//直播中
60   - jumpByProgramType(context, new VideoListProgram(model.getChannelId(), model.getActivityName(), model.getCoverImgUrl(), model.getRates(), VideoView.TYPE_UGC_LIVE));
61   - } else if (model.getActivityStatus() == 3) {//已结束
62   - jumpByProgramType(context, new VideoListProgram(model.getActivityId(), model.getActivityName(), model.getCoverImgUrl(), model.getActivityName(), model.getRates(), VideoView.TYPE_UGC_VOD));
  60 + jumpByProgramType(context, new VideoListProgram(model.getChannelId(), model.getActivityName(), model.getCoverImgUrl(), model.getRates(), VideoView.TYPE_UGC_LIVE, model.getIsHorizontalScreen()));
  61 + } else if (model.getActivityStatus() == 4) {//回放状态
  62 + jumpByProgramType(context, new VideoListProgram(model.getActivityId(), model.getActivityName(), model.getCoverImgUrl(), model.getActivityName(), model.getRates(), VideoView.TYPE_UGC_VOD, model.getIsHorizontalScreen()));
63 63 } else {
64 64 Toast.makeText(context, context.getString(R.string.request_state_play_error), Toast.LENGTH_LONG).show();
65 65 }
... ...
app/src/main/java/com/cnlive/gundam/user/adapter/PersonalAdapter.java
... ... @@ -30,6 +30,11 @@ public class PersonalAdapter extends DataBindingAdapter&lt;PersonalData&gt;{
30 30 DataBindingViewHolder viewHolder = new DataBindingViewHolder(binding.getRoot());
31 31 viewHolder.setBinding(binding);
32 32 return viewHolder;
  33 + }else if(viewType == PersonalData.TYPE_LOGOUT){
  34 + ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.layout_personal_logout_item, parent, false);
  35 + DataBindingViewHolder viewHolder = new DataBindingViewHolder(binding.getRoot());
  36 + viewHolder.setBinding(binding);
  37 + return viewHolder;
33 38 }else{
34 39 return super.onCreateViewHolder(parent, viewType);
35 40 }
... ... @@ -43,6 +48,12 @@ public class PersonalAdapter extends DataBindingAdapter&lt;PersonalData&gt;{
43 48 if (l != null)
44 49 videoListViewHolder.getBinding().setVariable(BR.viewClickListner, l);
45 50 videoListViewHolder.getBinding().executePendingBindings();
  51 + }else if(getItem(position).getItemType() == PersonalData.TYPE_LOGOUT){
  52 + DataBindingViewHolder videoListViewHolder = (DataBindingViewHolder) holder;
  53 + videoListViewHolder.getBinding().setVariable(itemBRId, getItem(position));
  54 + if (l != null)
  55 + videoListViewHolder.getBinding().setVariable(BR.viewClickListner, l);
  56 + videoListViewHolder.getBinding().executePendingBindings();
46 57 }else{
47 58 super.onBindViewHolder(holder, position);
48 59 }
... ...
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalEditFragment.java
... ... @@ -16,6 +16,7 @@ import com.cnlive.gundam.user.auth.UserService;
16 16 import com.cnlive.gundam.user.model.User;
17 17 import com.cnlive.libs.user.IUserService;
18 18 import com.cnlive.libs.user.UserUtil;
  19 +import com.cnlive.libs.user.model.UserData;
19 20 import com.cnlive.libs.util.data.network.Callback;
20 21  
21 22 /**
... ... @@ -88,7 +89,7 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View
88 89 title = "修改地址";
89 90 break;
90 91 }
91   - ((UserPersonalActivity)getActivity()).setTitle(title);
  92 + ((UserPersonalActivity) getActivity()).setTitle(title);
92 93 }
93 94  
94 95 @Override
... ... @@ -109,7 +110,6 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View
109 110 break;
110 111 }
111 112 } else if (v.getId() == R.id.get_verify) {
112   - //TODO 获取验证码
113 113 UserUtil.sendMessage(IUserService.REGISTER_OR_MODIFY_MOBILE, binding.includeMobileLayout.edtLoginNumber.getText().toString(), new Callback() {
114 114 @Override
115 115 public void onState(int i, String s, Object o) {
... ... @@ -127,11 +127,23 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View
127 127 @Override
128 128 public void onState(int i, String s, Object o) {
129 129 if (i == IUserService.SUCCESS) {
  130 + updateUserInfo();
130 131 Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show();
131 132 } else {
132 133 Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show();
133 134 }
  135 + }
134 136  
135   - //TODO 更新一下本地数据
  137 + private void updateUserInfo() {
  138 + UserUtil.queryUserInfo(String.valueOf(user.getUid()), String.valueOf(user.getUid()), new Callback() {
  139 + @Override
  140 + public void onState(int i, String s, Object obj) {
  141 + if (i == IUserService.SUCCESS) {
  142 + UserData userData = (UserData) obj;
  143 + UserService userService = UserService.getInstance(getActivity());
  144 + userService.setActiveAccountInfo(userData.getData());
  145 + }
  146 + }
  147 + });
136 148 }
137 149 }
... ...
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalFragment.java
1 1 package com.cnlive.gundam.user.fragment;
2 2  
  3 +import android.Manifest;
  4 +import android.app.Activity;
3 5 import android.content.Intent;
  6 +import android.content.pm.PackageManager;
4 7 import android.databinding.DataBindingUtil;
  8 +import android.net.Uri;
  9 +import android.os.Build;
5 10 import android.os.Bundle;
  11 +import android.provider.MediaStore;
6 12 import android.support.annotation.Nullable;
7 13 import android.support.v4.app.Fragment;
  14 +import android.support.v4.content.ContextCompat;
8 15 import android.support.v7.widget.LinearLayoutManager;
  16 +import android.text.TextUtils;
  17 +import android.view.Gravity;
9 18 import android.view.LayoutInflater;
10 19 import android.view.View;
11 20 import android.view.ViewGroup;
... ... @@ -14,13 +23,21 @@ import android.widget.Toast;
14 23 import com.cnlive.gundam.BR;
15 24 import com.cnlive.gundam.R;
16 25 import com.cnlive.gundam.databinding.FragmentUserPersonalBinding;
  26 +import com.cnlive.gundam.main.application.CNLiveApplication;
17 27 import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter;
18 28 import com.cnlive.gundam.user.activity.UserPersonalActivity;
19 29 import com.cnlive.gundam.user.adapter.PersonalAdapter;
20 30 import com.cnlive.gundam.user.auth.UserService;
21 31 import com.cnlive.gundam.user.model.PersonalData;
22 32 import com.cnlive.gundam.user.model.User;
  33 +import com.cnlive.gundam.user.util.PictureUtil;
  34 +import com.cnlive.gundam.user.view.SelectPopupWindow;
  35 +import com.cnlive.libs.user.IUserService;
  36 +import com.cnlive.libs.user.UserUtil;
  37 +import com.cnlive.libs.user.model.UserData;
  38 +import com.cnlive.libs.util.data.network.Callback;
23 39  
  40 +import java.io.File;
24 41 import java.util.ArrayList;
25 42 import java.util.List;
26 43  
... ... @@ -30,7 +47,15 @@ import java.util.List;
30 47 * @time 2017/6/28 13:06
31 48 * @desc ${TODD}
32 49 */
33   -public class UserPersonalFragment extends Fragment implements DataBindingAdapter.OnAdapterViewClickListener<PersonalData> {
  50 +public class UserPersonalFragment extends Fragment implements DataBindingAdapter.OnAdapterViewClickListener<PersonalData>, Callback {
  51 +
  52 + public static final int IMG_FROM_PICTURE = 0x1001;
  53 + public static final int IMG_FROM_CAMERA = 0x1002;
  54 + public static final int PICTURE_REQUEST_CODE = 0x1003;
  55 + public static final int CAMERA_REQUEST_CODE = 0x1004;
  56 +
  57 + //从相机获取的图片地址
  58 + private String cameraImagePath = "";
34 59  
35 60 private FragmentUserPersonalBinding binding;
36 61  
... ... @@ -38,6 +63,11 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter
38 63  
39 64 private List<PersonalData> personalData;
40 65  
  66 + //上传头像和修改性别的PopupWindow
  67 + private SelectPopupWindow menuWindow;
  68 +
  69 + private User user;
  70 +
41 71 public static UserPersonalFragment newInstance() {
42 72  
43 73 Bundle args = new Bundle();
... ... @@ -57,27 +87,34 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter
57 87 @Override
58 88 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
59 89 super.onViewCreated(view, savedInstanceState);
60   - initData();
61 90 init();
62 91 }
63 92  
  93 + @Override
  94 + public void onResume() {
  95 + super.onResume();
  96 + initData();
  97 + }
  98 +
64 99 private void initData() {
65 100 UserService userService = UserService.getInstance(getActivity());
66   - User user = userService.getActiveAccountInfo();
  101 + user = userService.getActiveAccountInfo();
  102 + String gender = user.getGender().equals("f") ? "女" : (user.getGender().equals("m") ? "男" : "未知");
67 103 personalData = new ArrayList<>();
68 104 personalData.add(new PersonalData("头像", user.getFaceurl(), PersonalData.TYPE_HEADER));
69 105 personalData.add(new PersonalData("昵称", user.getNickname(), PersonalData.TYPE_NICK));
70   - personalData.add(new PersonalData("性别", user.getGender(), PersonalData.TYPE_GENDER));
  106 + personalData.add(new PersonalData("性别", gender, PersonalData.TYPE_GENDER));
71 107 personalData.add(new PersonalData("手机号", user.getMobile(), PersonalData.TYPE_MOBILE));
72 108 personalData.add(new PersonalData("邮箱", user.getEmail(), PersonalData.TYPE_EMAIL));
73 109 personalData.add(new PersonalData("联系地址", user.getLocation(), PersonalData.TYPE_ADDRESS));
  110 + personalData.add(new PersonalData("", "退出", PersonalData.TYPE_LOGOUT));
  111 + adapter.updateItems(personalData);
74 112 }
75 113  
76 114 private void init() {
77   - ((UserPersonalActivity)getActivity()).setTitle("个人资料");
  115 + ((UserPersonalActivity) getActivity()).setTitle("个人资料");
78 116 binding.setListAdapter(adapter = new PersonalAdapter(getActivity(), R.layout.layout_personal_item, BR.data));
79 117 binding.setLayoutManager(new LinearLayoutManager(getActivity()));
80   - adapter.updateItems(personalData);
81 118 adapter.setOnViewClickListener(this);
82 119 }
83 120  
... ... @@ -87,36 +124,200 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter
87 124 Intent intent = null;
88 125 switch (program.getItemType()) {
89 126 case PersonalData.TYPE_HEADER:
90   - Toast.makeText(getActivity(), "头像点击", Toast.LENGTH_LONG).show();
  127 + showTakePhoto();
91 128 break;
92 129 case PersonalData.TYPE_NICK:
93 130 intent = new Intent(getActivity(), UserPersonalActivity.class);
94   - intent.putExtra("isEdit",true);
  131 + intent.putExtra("isEdit", true);
95 132 intent.putExtra("type", UserPersonalEditFragment.TYPE_NICK);
96 133 startActivity(intent);
97 134 break;
98 135 case PersonalData.TYPE_GENDER:
99   - Toast.makeText(getActivity(), "性别点击", Toast.LENGTH_LONG).show();
  136 + showSelectGender();
100 137 break;
101 138 case PersonalData.TYPE_MOBILE:
102 139 intent = new Intent(getActivity(), UserPersonalActivity.class);
103   - intent.putExtra("isEdit",true);
  140 + intent.putExtra("isEdit", true);
104 141 intent.putExtra("type", UserPersonalEditFragment.TYPE_MOBILE);
105 142 startActivity(intent);
106 143 break;
107 144 case PersonalData.TYPE_EMAIL:
108 145 intent = new Intent(getActivity(), UserPersonalActivity.class);
109   - intent.putExtra("isEdit",true);
  146 + intent.putExtra("isEdit", true);
110 147 intent.putExtra("type", UserPersonalEditFragment.TYPE_EMAIL);
111 148 startActivity(intent);
112 149 break;
113 150 case PersonalData.TYPE_ADDRESS:
114 151 intent = new Intent(getActivity(), UserPersonalActivity.class);
115   - intent.putExtra("isEdit",true);
  152 + intent.putExtra("isEdit", true);
116 153 intent.putExtra("type", UserPersonalEditFragment.TYPE_ADDRESS);
117 154 startActivity(intent);
118 155 break;
119 156 }
  157 + } else if (v.getId() == R.id.logout) {
  158 + UserService userService = UserService.getInstance(getActivity());
  159 + userService.clearUser();
  160 + getActivity().finish();
  161 + }
  162 + }
  163 +
  164 + /**
  165 + * 底部弹出上传头像的PopupWindow
  166 + */
  167 + public void showTakePhoto() {
  168 + menuWindow = new SelectPopupWindow(getActivity(), R.layout.pop_take_photo);
  169 + menuWindow.showAtLocation(getView().findViewById(R.id.layout), Gravity.BOTTOM, 0, 0);
  170 + menuWindow.getContentView().findViewById(R.id.ll_pick_photo).setOnClickListener(itemsOnClick);
  171 + menuWindow.getContentView().findViewById(R.id.ll_take_photo).setOnClickListener(itemsOnClick);
  172 + }
  173 +
  174 + /**
  175 + * 底部弹出修改性别的PopupWindow
  176 + */
  177 + public void showSelectGender() {
  178 + menuWindow = new SelectPopupWindow(getActivity(), R.layout.pop_modify_gender);
  179 + menuWindow.showAtLocation(getView().findViewById(R.id.layout), Gravity.BOTTOM, 0, 0);
  180 + menuWindow.getContentView().findViewById(R.id.boy).setOnClickListener(itemsOnClick);
  181 + menuWindow.getContentView().findViewById(R.id.girl).setOnClickListener(itemsOnClick);
  182 + }
  183 +
  184 + //为弹出窗口实现监听类
  185 + private View.OnClickListener itemsOnClick = new View.OnClickListener() {
  186 +
  187 + public void onClick(View v) {
  188 + if (menuWindow != null && menuWindow.isShowing()) {
  189 + menuWindow.dismiss();
  190 + }
  191 + switch (v.getId()) {
  192 + case R.id.ll_take_photo:
  193 + fromCamera();
  194 + break;
  195 + case R.id.ll_pick_photo:
  196 + fromPicture();
  197 + break;
  198 + case R.id.girl:
  199 + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "gender", "f", UserPersonalFragment.this);
  200 + break;
  201 + case R.id.boy:
  202 + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "gender", "m", UserPersonalFragment.this);
  203 + break;
  204 + default:
  205 + break;
  206 + }
  207 + }
  208 + };
  209 +
  210 + public void fromPicture() {
  211 + if (Build.VERSION.SDK_INT >= 23) {
  212 + int checkCallPhonePermission = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
  213 + if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) {
  214 + requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PICTURE_REQUEST_CODE);
  215 + return;
  216 + } else {
  217 + toIntentPicture();
  218 + }
  219 + } else {
  220 + toIntentPicture();
  221 + }
  222 + }
  223 +
  224 + private void toIntentPicture() {
  225 + Intent intent = new Intent();
  226 + intent.setType("image/*");
  227 + intent.setAction(Intent.ACTION_GET_CONTENT);
  228 + startActivityForResult(intent, IMG_FROM_PICTURE);
  229 + }
  230 +
  231 + public void fromCamera() {
  232 + if (Build.VERSION.SDK_INT >= 23) {
  233 + int checkCallPhonePermissionStorage = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA);
  234 + if (checkCallPhonePermissionStorage != PackageManager.PERMISSION_GRANTED) {
  235 + requestPermissions(new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CODE);
  236 + } else {
  237 + toIntentCamera();
  238 + }
  239 + } else {
  240 + toIntentCamera();
  241 + }
  242 + }
  243 +
  244 + private void toIntentCamera() {
  245 + cameraImagePath = PictureUtil.getImagePath(getActivity());
  246 + if (!TextUtils.isEmpty(cameraImagePath)) {
  247 + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  248 + File tmpFile = new File(cameraImagePath);
  249 + intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile));
  250 + startActivityForResult(intent, IMG_FROM_CAMERA);
  251 + }
  252 + }
  253 +
  254 +
  255 + @Override
  256 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
  257 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  258 + switch (requestCode) {
  259 + case PICTURE_REQUEST_CODE:
  260 + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  261 + toIntentPicture();
  262 + } else {
  263 + Toast.makeText(getActivity(), "权限已被禁止,请打开,再使用此功能", Toast.LENGTH_LONG).show();
  264 + }
  265 + break;
  266 + case CAMERA_REQUEST_CODE:
  267 + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  268 + toIntentCamera();
  269 + } else {
  270 + Toast.makeText(getActivity(), "权限已被禁止,请打开,再使用此功能", Toast.LENGTH_LONG).show();
  271 + }
  272 + break;
  273 + }
  274 + }
  275 +
  276 + @Override
  277 + public void onState(int i, String s, Object o) {
  278 + if (i == IUserService.SUCCESS) {
  279 + updateUserInfo();
  280 + Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show();
  281 + } else {
  282 + Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show();
  283 + }
  284 + }
  285 +
  286 + private void updateUserInfo() {
  287 + UserUtil.queryUserInfo(String.valueOf(user.getUid()), String.valueOf(user.getUid()), new Callback() {
  288 + @Override
  289 + public void onState(int i, String s, Object obj) {
  290 +
  291 + if (i == IUserService.SUCCESS) {
  292 + UserData userData = (UserData) obj;
  293 + UserService userService = UserService.getInstance(getActivity());
  294 + userService.setActiveAccountInfo(userData.getData());
  295 + initData();
  296 + } else {
  297 + Toast.makeText(getActivity(), "提交失败1111" + s, Toast.LENGTH_LONG).show();
  298 + }
  299 + }
  300 + });
  301 + }
  302 +
  303 + @Override
  304 + public void onActivityResult(int requestCode, int resultCode, Intent data) {
  305 + super.onActivityResult(requestCode, resultCode, data);
  306 + if (resultCode == Activity.RESULT_OK) {
  307 + File file = null;
  308 + switch (requestCode) {
  309 + case IMG_FROM_CAMERA:
  310 + file = new File(cameraImagePath);
  311 + UserUtil.uploadFace(String.valueOf(user.getUid()), CNLiveApplication.secret, file, this);
  312 + break;
  313 + case IMG_FROM_PICTURE:
  314 + Uri uri = data.getData();
  315 + file = new File(PictureUtil.getPath(getActivity(), uri));
  316 + UserUtil.uploadFace(String.valueOf(user.getUid()), CNLiveApplication.secret, file, this);
  317 + break;
  318 + default:
  319 + break;
  320 + }
120 321 }
121 322 }
122 323 }
... ...
app/src/main/java/com/cnlive/gundam/user/model/PersonalData.java
... ... @@ -17,6 +17,7 @@ public class PersonalData {
17 17 public static final int TYPE_MOBILE = 0x1004;
18 18 public static final int TYPE_EMAIL = 0x1005;
19 19 public static final int TYPE_ADDRESS = 0x1006;
  20 + public static final int TYPE_LOGOUT = 0x1007;
20 21  
21 22 public PersonalData(String itemName, String itemMessage, int itemType) {
22 23 this.itemName = itemName;
... ...
app/src/main/java/com/cnlive/gundam/user/util/PictureUtil.java 0 → 100644
  1 +package com.cnlive.gundam.user.util;
  2 +
  3 +import android.annotation.TargetApi;
  4 +import android.content.ContentUris;
  5 +import android.content.Context;
  6 +import android.database.Cursor;
  7 +import android.net.Uri;
  8 +import android.os.Build;
  9 +import android.os.Environment;
  10 +import android.provider.DocumentsContract;
  11 +import android.provider.MediaStore;
  12 +import android.widget.Toast;
  13 +
  14 +import java.io.File;
  15 +
  16 +/**
  17 + * Created by gujun on 2017/6/29.
  18 + */
  19 +
  20 +public class PictureUtil {
  21 + private static final String IMAGE_PATH = "/com.cnlive.gundam/image/";
  22 +
  23 + public static String getImagePath(Context context){
  24 + String status = Environment.getExternalStorageState();
  25 + String path = "";
  26 + if (status.equals(Environment.MEDIA_MOUNTED)) {
  27 + String rootPath = Environment.getExternalStorageDirectory().getAbsolutePath() + IMAGE_PATH;
  28 + File file = new File(rootPath);
  29 + if(!file.exists()){
  30 + file.mkdirs();
  31 + }
  32 + path = rootPath + System.currentTimeMillis() + ".png";
  33 + }else {
  34 + Toast.makeText(context,"未插入SD卡",Toast.LENGTH_LONG).show();
  35 + }
  36 + return path;
  37 +
  38 + }
  39 +
  40 + @TargetApi(Build.VERSION_CODES.KITKAT)
  41 + public static String getPath(final Context context, final Uri uri) {
  42 +
  43 + final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
  44 +
  45 + // DocumentProvider
  46 + if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
  47 + // ExternalStorageProvider
  48 + if (isExternalStorageDocument(uri)) {
  49 + final String docId = DocumentsContract.getDocumentId(uri);
  50 + final String[] split = docId.split(":");
  51 + final String type = split[0];
  52 +
  53 + if ("primary".equalsIgnoreCase(type)) {
  54 + return Environment.getExternalStorageDirectory() + "/" + split[1];
  55 + }
  56 +
  57 + // TODO handle non-primary volumes
  58 + }
  59 + // DownloadsProvider
  60 + else if (isDownloadsDocument(uri)) {
  61 +
  62 + final String id = DocumentsContract.getDocumentId(uri);
  63 + final Uri contentUri = ContentUris.withAppendedId(
  64 + Uri.parse("content://downloads/public_downloads"), Long.parseLong(id));
  65 +
  66 + return getDataColumn(context, contentUri, null, null);
  67 + }
  68 + // MediaProvider
  69 + else if (isMediaDocument(uri)) {
  70 + final String docId = DocumentsContract.getDocumentId(uri);
  71 + final String[] split = docId.split(":");
  72 + final String type = split[0];
  73 +
  74 + Uri contentUri = null;
  75 + if ("image".equals(type)) {
  76 + contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
  77 + } else if ("video".equals(type)) {
  78 + contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
  79 + } else if ("audio".equals(type)) {
  80 + contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
  81 + }
  82 +
  83 + final String selection = "_id=?";
  84 + final String[] selectionArgs = new String[]{
  85 + split[1]
  86 + };
  87 +
  88 + return getDataColumn(context, contentUri, selection, selectionArgs);
  89 + }
  90 + }
  91 + // MediaStore (and general)
  92 + else if ("content".equalsIgnoreCase(uri.getScheme())) {
  93 +
  94 + // Return the remote address
  95 + if (isGooglePhotosUri(uri))
  96 + return uri.getLastPathSegment();
  97 +
  98 + return getDataColumn(context, uri, null, null);
  99 + }
  100 + // File
  101 + else if ("file".equalsIgnoreCase(uri.getScheme())) {
  102 + return uri.getPath();
  103 + }
  104 +
  105 + return null;
  106 + }
  107 +
  108 + /**
  109 + * Get the value of the data column for this Uri. This is useful for
  110 + * MediaStore Uris, and other file-based ContentProviders.
  111 + *
  112 + * @param context The context.
  113 + * @param uri The Uri to query.
  114 + * @param selection (Optional) Filter used in the query.
  115 + * @param selectionArgs (Optional) Selection arguments used in the query.
  116 + * @return The value of the _data column, which is typically a file path.
  117 + */
  118 + public static String getDataColumn(Context context, Uri uri, String selection,
  119 + String[] selectionArgs) {
  120 +
  121 + Cursor cursor = null;
  122 + final String column = "_data";
  123 + final String[] projection = {
  124 + column
  125 + };
  126 +
  127 + try {
  128 + cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
  129 + null);
  130 + if (cursor != null && cursor.moveToFirst()) {
  131 + final int index = cursor.getColumnIndexOrThrow(column);
  132 + return cursor.getString(index);
  133 + }
  134 + } finally {
  135 + if (cursor != null)
  136 + cursor.close();
  137 + }
  138 + return null;
  139 + }
  140 +
  141 + /**
  142 + * @param uri The Uri to check.
  143 + * @return Whether the Uri authority is ExternalStorageProvider.
  144 + */
  145 + public static boolean isExternalStorageDocument(Uri uri) {
  146 + return "com.android.externalstorage.documents".equals(uri.getAuthority());
  147 + }
  148 +
  149 + /**
  150 + * @param uri The Uri to check.
  151 + * @return Whether the Uri authority is DownloadsProvider.
  152 + */
  153 + public static boolean isDownloadsDocument(Uri uri) {
  154 + return "com.android.providers.downloads.documents".equals(uri.getAuthority());
  155 + }
  156 +
  157 + /**
  158 + * @param uri The Uri to check.
  159 + * @return Whether the Uri authority is MediaProvider.
  160 + */
  161 + public static boolean isMediaDocument(Uri uri) {
  162 + return "com.android.providers.media.documents".equals(uri.getAuthority());
  163 + }
  164 +
  165 + /**
  166 + * @param uri The Uri to check.
  167 + * @return Whether the Uri authority is Google Photos.
  168 + */
  169 + public static boolean isGooglePhotosUri(Uri uri) {
  170 + return "com.google.android.apps.photos.content".equals(uri.getAuthority());
  171 + }
  172 +}
... ...
app/src/main/java/com/cnlive/gundam/user/view/SelectPopupWindow.java 0 → 100644
  1 +package com.cnlive.gundam.user.view;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.drawable.ColorDrawable;
  5 +import android.view.LayoutInflater;
  6 +import android.view.MotionEvent;
  7 +import android.view.View;
  8 +import android.widget.PopupWindow;
  9 +import android.widget.RelativeLayout;
  10 +
  11 +import com.cnlive.gundam.R;
  12 +
  13 +
  14 +public class SelectPopupWindow extends PopupWindow {
  15 +
  16 + private View view;
  17 + private View tv_cancel;
  18 +
  19 + public SelectPopupWindow(Context mContext, int layout) {
  20 +
  21 + this.view = LayoutInflater.from(mContext).inflate(layout, null);
  22 +
  23 + tv_cancel = view.findViewById(R.id.tv_cancel);
  24 +
  25 + tv_cancel.setOnClickListener(new View.OnClickListener() {
  26 +
  27 + public void onClick(View v) {
  28 + dismiss();
  29 + }
  30 + });
  31 +
  32 + this.setOutsideTouchable(true);
  33 + this.view.setOnTouchListener(new View.OnTouchListener() {
  34 +
  35 + public boolean onTouch(View v, MotionEvent event) {
  36 + int height = view.findViewById(R.id.pop_layout).getTop();
  37 + int y = (int) event.getY();
  38 + if (event.getAction() == MotionEvent.ACTION_UP) {
  39 + if (y < height) {
  40 + dismiss();
  41 + }
  42 + }
  43 + return true;
  44 + }
  45 + });
  46 +
  47 + /* 设置弹出窗口特征 */
  48 + // 设置视图
  49 + this.setContentView(this.view);
  50 + // 设置弹出窗体的宽和高
  51 + this.setHeight(RelativeLayout.LayoutParams.MATCH_PARENT);
  52 + this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
  53 + // 设置弹出窗体可点击
  54 + this.setFocusable(true);
  55 + // 实例化一个ColorDrawable颜色为透明
  56 + ColorDrawable dw = new ColorDrawable(0x30000000);
  57 + // 设置弹出窗体的背景
  58 + this.setBackgroundDrawable(dw);
  59 + // 设置弹出窗体显示时的动画,从底部向上弹出
  60 + this.setAnimationStyle(R.style.take_photo_anim);
  61 + }
  62 +}
... ...
app/src/main/java/com/cnlive/gundam/video/activity/PlayerActivity.java
... ... @@ -22,14 +22,11 @@ import com.cnlive.gundam.video.utils.PlayerUtils;
22 22 */
23 23  
24 24 public class PlayerActivity extends AppCompatActivity {
25   - private final String SCREEN_DIRECT_P = "0";
26   - private final String SCREEN_DIRECT_L = "1";
27 25  
28 26 private Fragment fragment;
29 27 private VideoListProgram program;
30 28 //默认横屏
31   - private String screenDirect = SCREEN_DIRECT_L;
32   - private String screenDirectName = "screenDirect";
  29 + private int screenDirect = 1;
33 30  
34 31 @Override
35 32 protected void onCreate(@Nullable Bundle savedInstanceState) {
... ... @@ -69,10 +66,9 @@ public class PlayerActivity extends AppCompatActivity {
69 66 }
70 67  
71 68 if (fragment instanceof PlayerUgcLiveFragment || fragment instanceof PlayerUgcVodFragment) {
72   - if (intent.hasExtra(screenDirectName)) {
73   - screenDirect = intent.getStringExtra(screenDirectName);
74   - }
75   - if (SCREEN_DIRECT_P.equals(screenDirect)) {
  69 + PlayerUtils.setStatusBarVisibility(this, false);
  70 + screenDirect = program.getIsHorizontalScreen();
  71 + if (screenDirect == 0) {
76 72 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
77 73 } else {
78 74 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
... ...
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerUgcLiveFragment.java
1 1 package com.cnlive.gundam.video.fragment;
2 2  
  3 +import android.Manifest;
  4 +import android.content.pm.PackageManager;
3 5 import android.content.res.Configuration;
4 6 import android.databinding.DataBindingUtil;
5 7 import android.os.Bundle;
  8 +import android.support.annotation.NonNull;
6 9 import android.support.annotation.Nullable;
7 10 import android.support.v4.app.Fragment;
8 11 import android.view.LayoutInflater;
9 12 import android.view.View;
10 13 import android.view.ViewGroup;
  14 +import android.widget.Toast;
11 15  
12 16 import com.cnlive.gundam.R;
13   -import com.cnlive.gundam.databinding.FragmentPlayerUgcVodBinding;
  17 +import com.cnlive.gundam.databinding.FragmentPlayerUgcLiveBinding;
14 18 import com.cnlive.gundam.main.model.VideoListProgram;
15 19 import com.cnlive.gundam.video.model.VideoModel;
16 20 import com.cnlive.gundam.video.utils.PlayerUtils;
  21 +import com.cnlive.gundam.video.view.BaseVideoView;
17 22 import com.cnlive.gundam.video.view.VideoView;
18 23  
19 24 /**
20 25 * Created by gujun on 2017/4/5.
21 26 */
22 27  
23   -public class PlayerUgcLiveFragment extends Fragment {
24   - private FragmentPlayerUgcVodBinding binding;
  28 +public class PlayerUgcLiveFragment extends Fragment implements BaseVideoView.OnUgcLiveStatusPermissionListener{
  29 + private final int PERMISSION_REQUEST_CODE = 0x1001;
  30 + private FragmentPlayerUgcLiveBinding binding;
25 31  
26 32 private VideoListProgram program;
27 33 private String title;
... ... @@ -57,6 +63,7 @@ public class PlayerUgcLiveFragment extends Fragment {
57 63 @Override
58 64 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
59 65 super.onViewCreated(view, savedInstanceState);
  66 + binding.videoView.setUgcLiveStatusPermissionListener(this);//必须在设置播放数据前调用
60 67 binding.videoView.setVideoInfo(new VideoModel(title, id, VideoView.TYPE_UGC_LIVE, rates));
61 68 }
62 69  
... ... @@ -85,4 +92,21 @@ public class PlayerUgcLiveFragment extends Fragment {
85 92 super.onDestroyView();
86 93 }
87 94  
  95 + @Override
  96 + public void onShouldRequestPermission() {
  97 + requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, PERMISSION_REQUEST_CODE);
  98 + }
  99 +
  100 + @Override
  101 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  102 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  103 + if(requestCode == PERMISSION_REQUEST_CODE){
  104 + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  105 + if(binding != null && binding.videoView != null)
  106 + binding.videoView.addUgcLiveStatus();
  107 + } else {
  108 + Toast.makeText(getActivity(), "权限已被禁止,您将接收不到直播状态", Toast.LENGTH_LONG).show();
  109 + }
  110 + }
  111 + }
88 112 }
... ...
app/src/main/java/com/cnlive/gundam/video/view/BaseVideoView.java
1 1 package com.cnlive.gundam.video.view;
2 2  
  3 +import android.Manifest;
3 4 import android.content.Context;
  5 +import android.content.pm.PackageManager;
4 6 import android.databinding.DataBindingUtil;
  7 +import android.os.Build;
  8 +import android.support.v4.content.ContextCompat;
5 9 import android.util.AttributeSet;
6 10 import android.util.Log;
7 11 import android.view.LayoutInflater;
... ... @@ -58,8 +62,12 @@ public abstract class BaseVideoView extends RelativeLayout implements
58 62  
59 63 private DataSource curDataSource;
60 64  
  65 + //播放器播放状态的监听
61 66 private OnVideoViewPlayStatusListener l;
62 67  
  68 + //ugclive需要权限监听
  69 + private OnUgcLiveStatusPermissionListener ugcLivePermissionListener;
  70 +
63 71 public BaseVideoView(Context context) {
64 72 this(context, null);
65 73 }
... ... @@ -97,8 +105,17 @@ public abstract class BaseVideoView extends RelativeLayout implements
97 105 public void setDataSource() {
98 106 //只有ugcLive视频才有状态监听
99 107 if (videoModel.getType().equals(VideoView.TYPE_UGC_LIVE)) {
100   - VideoStatusUtil.setOnVideoPlayStatusCallback(mOnVideoStatusCallback);
101   - VideoStatusUtil.init(videoModel.getId());
  108 + if (Build.VERSION.SDK_INT >= 23) {
  109 + int checkCallPhonePermission = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_PHONE_STATE);
  110 + if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) {
  111 + if(ugcLivePermissionListener != null)
  112 + ugcLivePermissionListener.onShouldRequestPermission();
  113 + } else {
  114 + addUgcLiveStatus();
  115 + }
  116 + } else {
  117 + addUgcLiveStatus();
  118 + }
102 119 }
103 120  
104 121 if (isLive) {
... ... @@ -111,7 +128,21 @@ public abstract class BaseVideoView extends RelativeLayout implements
111 128  
112 129 preRate = Config.TYPE_PLAY_RATE_2;
113 130  
  131 + }
114 132  
  133 + /**
  134 + * 设置UGC LIVE的直播状态监听
  135 + */
  136 + public void setUgcLiveStatusPermissionListener(OnUgcLiveStatusPermissionListener l){
  137 + ugcLivePermissionListener = l;
  138 + }
  139 +
  140 + /**
  141 + * 添加UGC LIVE的直播状态监听
  142 + */
  143 + public void addUgcLiveStatus(){
  144 + VideoStatusUtil.setOnVideoPlayStatusCallback(mOnVideoStatusCallback);
  145 + VideoStatusUtil.init(videoModel.getId());
115 146 }
116 147  
117 148 /**
... ... @@ -311,4 +342,9 @@ public abstract class BaseVideoView extends RelativeLayout implements
311 342 public interface OnVideoViewPlayStatusListener {
312 343 void onVideoViewPlayStatus(boolean isPlay);
313 344 }
  345 +
  346 + //ugc live 监听直播状态得需要android.permission.READ_PHONE_STATE
  347 + public interface OnUgcLiveStatusPermissionListener{
  348 + void onShouldRequestPermission();
  349 + }
314 350 }
... ...
app/src/main/res/drawable-hdpi/page_back.png 0 → 100644

489 Bytes

app/src/main/res/drawable-hdpi/user_list_arrows.png 0 → 100644

343 Bytes

app/src/main/res/drawable-mdpi/page_back.png 0 → 100644

364 Bytes

app/src/main/res/drawable-xhdpi/page_back.png 0 → 100644

832 Bytes

app/src/main/res/drawable-xhdpi/user_list_arrows.png 0 → 100644

509 Bytes

app/src/main/res/drawable-xxhdpi/page_back.png 0 → 100644

1.33 KB

app/src/main/res/drawable-xxhdpi/user_list_arrows.png 0 → 100644

1 KB

app/src/main/res/drawable-xxxhdpi/page_back.png 0 → 100644

2.26 KB

app/src/main/res/drawable-xxxhdpi/user_list_arrows.png 0 → 100644

1.62 KB

app/src/main/res/layout/fragment_personal_edit.xml
... ... @@ -13,25 +13,40 @@
13 13  
14 14 <RelativeLayout
15 15 android:layout_width="match_parent"
16   - android:layout_height="match_parent">
  16 + android:layout_height="match_parent"
  17 + android:background="@color/gray_bg"
  18 + android:paddingTop="10dp">
17 19  
18   - <EditText
19   - android:id="@+id/editText"
  20 + <LinearLayout
20 21 android:layout_width="match_parent"
21   - android:layout_height="50dp"
22   - android:visibility="gone"/>
  22 + android:layout_height="wrap_content"
  23 + android:orientation="vertical"
  24 + android:background="@android:color/white">
  25 +
  26 + <EditText
  27 + android:id="@+id/editText"
  28 + style="@style/LoginContentStyle"
  29 + android:layout_width="match_parent"
  30 + android:layout_height="50dp"
  31 + android:layout_marginLeft="11dp"
  32 + android:layout_marginRight="11dp"
  33 + android:visibility="gone" />
  34 +
  35 + <include
  36 + android:id="@+id/includeMobileLayout"
  37 + layout="@layout/mobile_keycode_layout" />
23 38  
24   - <include
25   - android:id="@+id/includeMobileLayout"
26   - layout="@layout/mobile_keycode_layout"/>
  39 + </LinearLayout>
27 40  
28 41 <Button
29 42 android:id="@+id/submit"
  43 + style="@style/LoginButtonStyle"
30 44 android:layout_width="match_parent"
31 45 android:layout_height="50dp"
32 46 android:layout_alignParentBottom="true"
33 47 android:layout_marginBottom="200dp"
34 48 android:onClick="@{userPersonalEditFragment.onClick}"
  49 + android:background="@drawable/user_btn_login"
35 50 android:text="提交" />
36 51  
37 52 </RelativeLayout>
... ...
app/src/main/res/layout/fragment_player_ugc_live.xml
... ... @@ -23,9 +23,8 @@
23 23  
24 24 <RelativeLayout
25 25 android:id="@+id/contentLayout"
26   - android:background="@android:color/black"
27 26 android:layout_width="match_parent"
28   - android:layout_height="400dp"
  27 + android:layout_height="match_parent"
29 28 android:layout_alignParentBottom="true">
30 29  
31 30 </RelativeLayout>
... ...
app/src/main/res/layout/fragment_user_personal.xml
... ... @@ -17,6 +17,7 @@
17 17 </data>
18 18  
19 19 <RelativeLayout
  20 + android:id="@+id/layout"
20 21 android:layout_width="match_parent"
21 22 android:layout_height="match_parent">
22 23  
... ... @@ -27,7 +28,7 @@
27 28 android:clipToPadding="true"
28 29 android:clipChildren="true"
29 30 android:paddingTop="5dp"
30   - android:background="@color/list_divider"
  31 + android:background="@color/gray_bg"
31 32 app:adapter="@{listAdapter}"
32 33 app:layoutManager="@{layoutManager}"/>
33 34  
... ...
app/src/main/res/layout/layout_actionbar_back.xml
... ... @@ -8,6 +8,7 @@
8 8 android:layout_height="?attr/actionBarSize"
9 9 android:theme="@style/ThemeOverlay.AppCompat.Light"
10 10 app:contentInsetEnd="?attr/actionBarSize"
  11 + android:background="@android:color/white"
11 12 android:visibility="gone"
12 13 tools:visibility="visible">
13 14  
... ...
app/src/main/res/layout/layout_item_active_video_list.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">
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools">
4 5  
5 6 <data>
6 7  
7 8 <import type="com.cnlive.gundam.main.model.ActiveInfo" />
8   - <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/>
  9 + <import type="android.view.View"/>
  10 + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener" />
9 11  
10 12 <variable
11 13 name="activeInfo"
... ... @@ -13,7 +15,7 @@
13 15  
14 16 <variable
15 17 name="viewClickListner"
16   - type="OnAdapterViewClickListener&lt;ActiveInfo>"/>
  18 + type="OnAdapterViewClickListener&lt;ActiveInfo>" />
17 19  
18 20 </data>
19 21  
... ... @@ -26,25 +28,61 @@
26 28 <ImageView
27 29 android:id="@+id/image"
28 30 android:layout_width="match_parent"
29   - android:layout_height="200dp"
  31 + android:layout_height="300dp"
30 32 android:scaleType="centerCrop"
31 33 app:error="@{@drawable/image_error}"
32 34 app:imageUrl="@{activeInfo.getCoverImgUrl()}" />
33 35  
34 36 <TextView
  37 + android:layout_width="wrap_content"
  38 + android:layout_height="wrap_content"
  39 + android:layout_alignParentRight="true"
  40 + android:background="#60494747"
  41 + android:padding="3dp"
  42 + android:text="@{activeInfo.getActivityStatus() == 1 ? @string/ugc_live : @string/ugc_vod}"
  43 + android:textColor="@{activeInfo.getActivityStatus() == 1 ? @android:color/holo_red_light : @android:color/white}"
  44 + tools:text="直播" />
  45 +
  46 + <TextView
35 47 android:id="@+id/title"
36 48 android:layout_width="match_parent"
37 49 android:layout_height="wrap_content"
38   - android:layout_below="@+id/image"
  50 + android:layout_alignBottom="@+id/image"
  51 + android:background="#60494747"
39 52 android:padding="10dp"
40 53 android:text="@{activeInfo.getActivityName()}"
41   - android:textColor="@android:color/black"
42   - android:textSize="16sp"/>
  54 + android:textColor="@android:color/white"
  55 + android:textSize="16sp"
  56 + tools:text="title" />
  57 +
  58 + <LinearLayout
  59 + android:id="@+id/exLayout"
  60 + android:layout_width="match_parent"
  61 + android:layout_height="wrap_content"
  62 + android:layout_below="@+id/image"
  63 + android:visibility="@{activeInfo.getExtensions() != null ? View.VISIBLE : View.GONE}">
  64 +
  65 + <ImageView
  66 + android:id="@+id/header"
  67 + android:layout_width="30dp"
  68 + android:layout_height="30dp"
  69 + android:layout_margin="5dp"
  70 + app:error="@{@drawable/image_error}"
  71 + app:imageUrl="@{activeInfo.getExUrl()}"/>
  72 +
  73 + <TextView
  74 + android:layout_width="wrap_content"
  75 + android:layout_height="wrap_content"
  76 + android:layout_gravity="center_vertical"
  77 + android:textColor="@android:color/black"
  78 + android:text="@{activeInfo.getExNick()}"
  79 + tools:text="nick" />
  80 + </LinearLayout>
43 81  
44 82 <View
45 83 android:layout_width="match_parent"
46 84 android:layout_height="8dp"
47   - android:layout_below="@+id/title"
  85 + android:layout_below="@+id/exLayout"
48 86 android:background="@color/list_divider" />
49 87  
50 88 </RelativeLayout>
... ...
app/src/main/res/layout/layout_personal_header_item.xml
... ... @@ -38,6 +38,7 @@
38 38 android:text="@{data.getItemName()}"
39 39 android:textColor="@color/black"
40 40 android:textSize="18sp"
  41 + android:layout_marginLeft="10dp"
41 42 tools:text="nick" />
42 43  
43 44 <ImageView
... ...
app/src/main/res/layout/layout_personal_item.xml
... ... @@ -37,6 +37,7 @@
37 37 android:text="@{data.getItemName()}"
38 38 android:textColor="@color/black"
39 39 android:textSize="18sp"
  40 + android:layout_marginLeft="10dp"
40 41 tools:text="nick" />
41 42  
42 43 <TextView
... ... @@ -48,7 +49,7 @@
48 49 android:layout_toRightOf="@+id/itemName"
49 50 android:gravity="center_vertical|right"
50 51 android:text="@{data.getItemMessage()}"
51   - android:textColor="@color/black"
  52 + android:textColor="@color/gray"
52 53 android:textSize="18sp"
53 54 tools:text="haha" />
54 55  
... ... @@ -56,7 +57,9 @@
56 57 android:layout_width="wrap_content"
57 58 android:layout_height="wrap_content"
58 59 android:layout_alignParentRight="true"
59   - android:layout_centerVertical="true"/>
  60 + android:layout_centerVertical="true"
  61 + android:src="@drawable/user_list_arrows"
  62 + android:layout_marginRight="10dp"/>
60 63  
61 64 </RelativeLayout>
62 65  
... ...
app/src/main/res/layout/layout_personal_logout_item.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <data>
  5 +
  6 + <import type="com.cnlive.gundam.user.model.PersonalData" />
  7 + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/>
  8 +
  9 + <variable
  10 + name="data"
  11 + type="PersonalData"/>
  12 +
  13 + <variable
  14 + name="viewClickListner"
  15 + type="OnAdapterViewClickListener&lt;PersonalData>"/>
  16 +
  17 + </data>
  18 +
  19 + <RelativeLayout
  20 + android:id="@+id/itemLayout"
  21 + android:layout_width="match_parent"
  22 + android:layout_height="wrap_content">
  23 +
  24 + <Button
  25 + android:id="@+id/logout"
  26 + style="@style/LoginButtonStyle"
  27 + android:layout_width="match_parent"
  28 + android:layout_height="50dp"
  29 + android:background="@drawable/user_btn_login"
  30 + android:layout_marginTop="50dp"
  31 + android:onClick="@{(view)->viewClickListner.onViewClick(view,data)}"
  32 + android:text="退出" />
  33 +
  34 + </RelativeLayout>
  35 +
  36 +</layout>
0 37 \ No newline at end of file
... ...
app/src/main/res/layout/pop_modify_gender.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="fill_parent"
  4 + android:layout_height="wrap_content"
  5 + android:gravity="center_horizontal"
  6 + android:orientation="vertical">
  7 +
  8 + <RelativeLayout
  9 + android:id="@+id/pop_layout"
  10 + android:layout_width="fill_parent"
  11 + android:layout_height="wrap_content">
  12 +
  13 + <TextView
  14 + android:id="@+id/tv_cancel"
  15 + android:layout_width="match_parent"
  16 + android:layout_height="58dp"
  17 + android:layout_alignParentBottom="true"
  18 + android:background="#ffffff"
  19 + android:gravity="center"
  20 + android:text="取消"
  21 + android:textColor="#FF6633"
  22 + android:textSize="16sp" />
  23 +
  24 + <LinearLayout
  25 + android:id="@+id/boy"
  26 + android:layout_width="match_parent"
  27 + android:layout_height="58dp"
  28 + android:layout_above="@id/tv_cancel"
  29 + android:background="#ffffff"
  30 + android:orientation="vertical">
  31 +
  32 + <TextView
  33 + android:layout_width="match_parent"
  34 + android:layout_height="50dp"
  35 + android:layout_alignParentBottom="true"
  36 + android:gravity="center"
  37 + android:text="男"
  38 + android:textColor="#333333"
  39 + android:textSize="16sp" />
  40 +
  41 + <View
  42 + android:layout_width="match_parent"
  43 + android:layout_height="10dp"
  44 + android:background="#D8D8D8" />
  45 + </LinearLayout>
  46 +
  47 +
  48 + <LinearLayout
  49 + android:id="@+id/girl"
  50 + android:layout_width="match_parent"
  51 + android:layout_height="58dp"
  52 + android:layout_above="@id/boy"
  53 + android:background="#ffffff"
  54 + android:orientation="vertical">
  55 +
  56 + <TextView
  57 + android:layout_width="match_parent"
  58 + android:layout_height="50dp"
  59 + android:layout_alignParentBottom="true"
  60 + android:gravity="center"
  61 + android:text="女"
  62 + android:textColor="#333333"
  63 + android:textSize="16sp" />
  64 +
  65 + <View
  66 + android:layout_width="match_parent"
  67 + android:layout_height="1dp"
  68 + android:background="#D8D8D8" />
  69 + </LinearLayout>
  70 +
  71 +
  72 + <LinearLayout
  73 + android:id="@+id/ll_changeHead"
  74 + android:layout_width="match_parent"
  75 + android:layout_height="51dp"
  76 + android:layout_above="@id/girl"
  77 + android:background="#ffffff"
  78 + android:orientation="vertical">
  79 +
  80 + <TextView
  81 + android:id="@+id/changeTitleTag"
  82 + android:layout_width="match_parent"
  83 + android:layout_height="50dp"
  84 + android:layout_alignParentBottom="true"
  85 + android:gravity="center"
  86 + android:text="性别修改"
  87 + android:textColor="@color/black"
  88 + android:textSize="18sp" />
  89 +
  90 + <View
  91 + android:layout_width="match_parent"
  92 + android:layout_height="1dp"
  93 + android:background="@color/color_list_bg" />
  94 +
  95 + </LinearLayout>
  96 +
  97 + </RelativeLayout>
  98 +
  99 +</RelativeLayout>
0 100 \ No newline at end of file
... ...
app/src/main/res/layout/pop_take_photo.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="fill_parent"
  4 + android:layout_height="wrap_content"
  5 + android:gravity="center_horizontal"
  6 + android:orientation="vertical">
  7 +
  8 + <RelativeLayout
  9 + android:id="@+id/pop_layout"
  10 + android:layout_width="fill_parent"
  11 + android:layout_height="wrap_content">
  12 +
  13 + <TextView
  14 + android:id="@+id/tv_cancel"
  15 + android:layout_width="match_parent"
  16 + android:layout_height="58dp"
  17 + android:layout_alignParentBottom="true"
  18 + android:background="#ffffff"
  19 + android:gravity="center"
  20 + android:text="取消"
  21 + android:textColor="#FF6633"
  22 + android:textSize="16sp" />
  23 +
  24 + <LinearLayout
  25 + android:id="@+id/ll_pick_photo"
  26 + android:layout_width="match_parent"
  27 + android:layout_height="58dp"
  28 + android:layout_above="@id/tv_cancel"
  29 + android:background="#ffffff"
  30 + android:orientation="vertical">
  31 +
  32 + <TextView
  33 + android:layout_width="match_parent"
  34 + android:layout_height="50dp"
  35 + android:layout_alignParentBottom="true"
  36 + android:gravity="center"
  37 + android:text="从手机相册中选取"
  38 + android:textColor="#333333"
  39 + android:textSize="16sp" />
  40 +
  41 + <View
  42 + android:layout_width="match_parent"
  43 + android:layout_height="10dp"
  44 + android:background="#D8D8D8" />
  45 + </LinearLayout>
  46 +
  47 +
  48 + <LinearLayout
  49 + android:id="@+id/ll_take_photo"
  50 + android:layout_width="match_parent"
  51 + android:layout_height="58dp"
  52 + android:layout_above="@id/ll_pick_photo"
  53 + android:background="#ffffff"
  54 + android:orientation="vertical">
  55 +
  56 + <TextView
  57 + android:layout_width="match_parent"
  58 + android:layout_height="50dp"
  59 + android:layout_alignParentBottom="true"
  60 + android:gravity="center"
  61 + android:text="拍照"
  62 + android:textColor="#333333"
  63 + android:textSize="16sp" />
  64 +
  65 + <View
  66 + android:layout_width="match_parent"
  67 + android:layout_height="1dp"
  68 + android:background="#D8D8D8" />
  69 + </LinearLayout>
  70 +
  71 +
  72 + <LinearLayout
  73 + android:id="@+id/ll_changeHead"
  74 + android:layout_width="match_parent"
  75 + android:layout_height="51dp"
  76 + android:layout_above="@id/ll_take_photo"
  77 + android:background="#ffffff"
  78 + android:orientation="vertical">
  79 +
  80 + <TextView
  81 + android:id="@+id/changeTitleTag"
  82 + android:layout_width="match_parent"
  83 + android:layout_height="50dp"
  84 + android:layout_alignParentBottom="true"
  85 + android:gravity="center"
  86 + android:text="头像修改"
  87 + android:textColor="@color/black"
  88 + android:textSize="18sp" />
  89 +
  90 + <View
  91 + android:layout_width="match_parent"
  92 + android:layout_height="1dp"
  93 + android:background="@color/color_list_bg" />
  94 +
  95 + </LinearLayout>
  96 +
  97 + </RelativeLayout>
  98 +
  99 +</RelativeLayout>
0 100 \ No newline at end of file
... ...
app/src/main/res/values/colors.xml
... ... @@ -8,4 +8,7 @@
8 8  
9 9 <color name="rate_sel">#ff0000</color>
10 10 <color name="rate_nor">#ffffff</color>
  11 +
  12 + <color name="gray">#9e9e9e</color>
  13 + <color name="gray_bg">#dedbdb</color>
11 14 </resources>
... ...
app/src/main/res/values/strings.xml
... ... @@ -37,6 +37,9 @@
37 37 <string name="request_state_error">获取活动状态失败</string>
38 38 <string name="request_state_play_error">此活动状态无法播放</string>
39 39  
  40 + <string name="ugc_live">直播</string>
  41 + <string name="ugc_vod">回放</string>
  42 +
40 43 <string name="verified_url" formatted="false">https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp?sid=%s&amp;plat=a&amp;appId=%s </string>
41 44 <string name="debug_verified_url" formatted="false">https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp?sid=%s&amp;plat=a&amp;appId=%s&amp;type=0 </string>
42 45 </resources>
... ...