PushHelper.java
5.02 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package com.cnlive.goldenline.util;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;
import com.cnlive.goldenline.model.response.bean.LiveShowBean;
import com.cnlive.goldenline.model.response.bean.VideoDemandBean;
import com.cnlive.goldenline.ui.activity.DianBoPlayerActivity;
import com.cnlive.goldenline.ui.activity.LiveShowActivity;
import com.cnlive.goldenline.ui.activity.MyTicketActivity;
import com.cnlive.goldenline.ui.activity.TheatreInfoActivity;
import com.cnlive.goldenline.ui.activity.WalletActivity;
import com.cnlive.goldenline.ui.activity.WebViewActivity;
import com.cnlive.goldenline.ui.activity.act.ActActivity;
/**
* Created by Sivin on 2017/3/23.
*/
public class PushHelper {
/**
* 充值成功----->
*/
public static final String PUSH_TYPE_AUTO_RECHARGE_SUCCESS = "101";
/**
* 预约成功---->
*/
public static final String PUSH_TYPE_AUTO_RESERVATION_SUCCESS = "102";
/**
* 即将直播---->
*/
public static final String PUSH_TYPE_AUTO_ABOUT_TO_START = "103";
/**
* 直播详情页--->
*/
public static final String PUSH_TYPE_MANUAL_LIVE_DETAILS = "201";
/**
* 点播详情页
*/
public static final String PUSH_TYPE_MANUAL_DEMAND_DETAILS = "202";
/**
* 活动详情页
*/
public static final String PUSH_TYPE_MANUAL_EVENT_DETAILS = "203";
/**
* 剧场详情页
*/
public static final String PUSH_TYPE_MANUAL_THEATER_DETAILS = "204";
/**
* url
*/
public static final String PUSH_TYPE_MANUAL_URL = "205";
public static Intent getIntent(@NonNull Context ctx, @NonNull String type, String jsonStr) {
Log.e("push", "getIntent: ");
Intent intent = null;
switch (type) {
case PUSH_TYPE_AUTO_RECHARGE_SUCCESS:// 支付成功推送
if (isLogin(ctx)) {
intent = new Intent(ctx, WalletActivity.class);
}
break;
case PUSH_TYPE_AUTO_RESERVATION_SUCCESS: //预约成功推送
if (isLogin(ctx))
intent = new Intent(ctx, MyTicketActivity.class);
break;
case PUSH_TYPE_AUTO_ABOUT_TO_START: // 即将开始直播
if (isLogin(ctx)){
intent = new Intent(ctx, MyTicketActivity.class);
}
break;
case PUSH_TYPE_MANUAL_LIVE_DETAILS: //直播详情推送
if (jsonStr != null && isLogin(ctx)) {
Log.e("push", "live: ");
LiveShowBean liveShowBean = JsonParser.getParseBean(jsonStr, LiveShowBean.class);
if (liveShowBean != null) {
Log.e("push", "live: 2");
Bundle bundle = new Bundle();
bundle.putParcelable("data", liveShowBean);
intent = new Intent(ctx, LiveShowActivity.class);
intent.putExtras(bundle);
}
}
break;
case PUSH_TYPE_MANUAL_DEMAND_DETAILS: //点播详情推送
if (jsonStr != null) {
VideoDemandBean dianboBean = JsonParser.getParseBean(jsonStr, VideoDemandBean.class);
if (dianboBean != null) {
intent = new Intent(ctx, DianBoPlayerActivity.class);
intent.putExtra("data", dianboBean);
}
}
break;
case PUSH_TYPE_MANUAL_EVENT_DETAILS: //活动详情推送
if(jsonStr !=null && isLogin(ctx)){
intent = new Intent(ctx, ActActivity.class);
intent.putExtra("actionId", jsonStr);
}
break;
case PUSH_TYPE_MANUAL_URL: //Url推送
if(jsonStr != null){
Log.e("url", "getIntent: "+jsonStr);
Bundle bundle = new Bundle();
bundle.putString("url",jsonStr);
intent = new Intent(ctx, WebViewActivity.class);
intent.putExtra("url",bundle);
}
break;
case PUSH_TYPE_MANUAL_THEATER_DETAILS: //剧院推送
if (jsonStr != null) {
intent = new Intent(ctx, TheatreInfoActivity.class);
intent.putExtra("id",jsonStr);
}
break;
}
return intent;
}
private static boolean isLogin(Context context) {
boolean isLogin = new UserService(context).isAutoLogin();
if (!isLogin) {
Log.e("test", "isLogin : " );
Toast toast = Toast.makeText(context, "请先登录",Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
return isLogin;
}
}