/
VideoTabActivity.java
301 lines (278 loc) · 11.8 KB
/
VideoTabActivity.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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
package com.fanchen.imovie.activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import com.fanchen.imovie.R;
import com.fanchen.imovie.adapter.pager.A4dyPagerAdapter;
import com.fanchen.imovie.adapter.pager.AismPagerAdapter;
import com.fanchen.imovie.adapter.pager.BabayuPagerAdapter;
import com.fanchen.imovie.adapter.pager.BobmaoPagerAdapter;
import com.fanchen.imovie.adapter.pager.BumimiPagerAdapter;
import com.fanchen.imovie.adapter.pager.CcyPagerAdapter;
import com.fanchen.imovie.adapter.pager.Dm5PagerAdapter;
import com.fanchen.imovie.adapter.pager.HaliHaliPagerAdapter;
import com.fanchen.imovie.adapter.pager.HaoQuPagerAdapter;
import com.fanchen.imovie.adapter.pager.ICanTvPagerAdapter;
import com.fanchen.imovie.adapter.pager.IKanFanPagerAdapter;
import com.fanchen.imovie.adapter.pager.JrenPagerAdapter;
import com.fanchen.imovie.adapter.pager.JugouPagerAdapter;
import com.fanchen.imovie.adapter.pager.K8dyPagerAdapter;
import com.fanchen.imovie.adapter.pager.KankanPagerAdapter;
import com.fanchen.imovie.adapter.pager.KmaoPagerAdapter;
import com.fanchen.imovie.adapter.pager.KupianPagerAdapter;
import com.fanchen.imovie.adapter.pager.LL520PagerAdapter;
import com.fanchen.imovie.adapter.pager.LaosijiPagerAdapter;
import com.fanchen.imovie.adapter.pager.MmyyPagerAdapter;
import com.fanchen.imovie.adapter.pager.S80PagerAdapter;
import com.fanchen.imovie.adapter.pager.SmdyPagerAdapter;
import com.fanchen.imovie.adapter.pager.TaihanPagerAdapter;
import com.fanchen.imovie.adapter.pager.TepianPagerAdapter;
import com.fanchen.imovie.adapter.pager.VipysPagerAdapter;
import com.fanchen.imovie.adapter.pager.WandouPagerAdapter;
import com.fanchen.imovie.adapter.pager.WeilaiPagerAdapter;
import com.fanchen.imovie.adapter.pager.XiaokabaPagerAdapter;
import com.fanchen.imovie.adapter.pager.DianxiumeiPagerAdapter;
import com.fanchen.imovie.adapter.pager.YdwPagerAdapter;
import com.fanchen.imovie.adapter.pager.ZhandiPagerAdapter;
import com.fanchen.imovie.adapter.pager.ZzyoPagerAdapter;
import com.fanchen.imovie.adapter.pager.ZzzvzPagerAdapter;
import com.fanchen.imovie.base.BaseFragmentAdapter;
import com.fanchen.imovie.base.BaseTabActivity;
import com.fanchen.imovie.dialog.BaseAlertDialog;
import com.fanchen.imovie.dialog.OnButtonClickListener;
import com.fanchen.imovie.dialog.fragment.SearchDialogFragment;
import com.fanchen.imovie.entity.face.ISearchWord;
import com.fanchen.imovie.util.DialogUtil;
/**
* [五弹幕][布米米]等其他视频站
* 的TabActivity
* Created by fanchen on 2017/9/23.
*/
public class VideoTabActivity extends BaseTabActivity implements SearchDialogFragment.OnSearchClickListener {
public static final int ICAN_LIVE = -3;
public static final int HQ_LIVE = -2;
// public static final int DYTT_LIVE = -1;
public static final int DM5 = 1;
public static final int WANDOU = 2;
public static final int SMDY = 3;
public static final int AISM = 4;
public static final int ZHANDI = 5;
public static final int XIU169 = 6;
public static final int BUMIMI = 7;
public static final int BABAYU = 8;
public static final int A4DY = 9;
public static final int K8DY = 10;
public static final int LL520 = 11;
public static final int S80 = 12;
public static final int HALIHALI = 13;
public static final int IKANFAN = 14;
public static final int MMYY = 15;
public static final int KANKANWU = 16;
public static final int XIAOKANBA = 17;
public static final int W4K = 18;
public static final int JREN = 19;
public static final int SANMAO = 20;
public static final int TAIHAN = 21;
public static final int KUPIAN = 22;
public static final int TEPIAN = 23;
public static final int JUGOU = 24;
public static final int LAOSIJI = 25;
public static final int ZZZVZ = 26;
public static final int VIPYS = 27;
public static final int FEIFAN = 28;
public static final int ZZYO = 29;
public static final int CCY = 30;
public static final int YDW = 31;
public static final String TYPE = "type";
public static final String TITLE = "title";
private SearchDialogFragment mSearchFragment = SearchDialogFragment.newInstance();
private SharedPreferences mSharedPreferences;
private BaseFragmentAdapter mPagerAdapter;
private int type;
private String title;
/**
* @param context
* @param title
* @param type
*/
public static void startActivity(Context context, String title, int type) {
try {
Intent intent = new Intent(context, VideoTabActivity.class);
intent.putExtra(TYPE, type);
intent.putExtra(TITLE, title);
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void startLiveActivity(Context context, String type) {
String string = context.getString(R.string.tv_live);
/*if ("dytt".equals(type)) {
VideoTabActivity.startActivity(context, string, VideoTabActivity.DYTT_LIVE);
} else */if ("ican".equals(type)) {
VideoTabActivity.startActivity(context, string, VideoTabActivity.ICAN_LIVE);
} else {
VideoTabActivity.startActivity(context, string, VideoTabActivity.HQ_LIVE);
}
}
/**
* @param context
* @param title
*/
public static void startActivity(Context context, String title) {
startActivity(context, title, S80);
}
@Override
protected void setListener() {
super.setListener();
mSearchFragment.setOnSearchClickListener(this);
}
// @Override
// protected int getTabMode(PagerAdapter adapter) {
// return type == DYTT_LIVE || type == DM5 || type == JREN || type == HALIHALI || type == IKANFAN || type == TEPIAN || type == KUPIAN
// || type == K8DY || type == JUGOU ? TabLayout.MODE_FIXED : TabLayout.MODE_SCROLLABLE;
// }
@Override
protected int getTabMode(PagerAdapter adapter) {
return adapter.getCount() < 5 ? TabLayout.MODE_FIXED : TabLayout.MODE_SCROLLABLE;
}
@Override
protected void initActivity(Bundle savedState, LayoutInflater inflater) {
type = getIntent().getIntExtra(TYPE, S80);
title = getIntent().getStringExtra(TITLE);
super.initActivity(savedState, inflater);
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
if (mSharedPreferences.getBoolean("video_thit", true)) {
String string = getString(R.string.video_thit);
DialogUtil.showCancelableDialog(this, string, "继续提醒", "不要再说了", buttonClickListener);
}
}
@Override
protected PagerAdapter getAdapter(FragmentManager fm) {
if (type == S80) {
mPagerAdapter = new S80PagerAdapter(fm);
} else if (type == BUMIMI) {
mPagerAdapter = new BumimiPagerAdapter(fm);
} else if (type == DM5) {
mPagerAdapter = new Dm5PagerAdapter(fm);
} else if (type == XIU169) {
mPagerAdapter = new DianxiumeiPagerAdapter(fm);
} else if (type == XIAOKANBA) {
mPagerAdapter = new XiaokabaPagerAdapter(fm);
} else if (type == W4K) {
mPagerAdapter = new KmaoPagerAdapter(fm);
} else if (type == A4DY) {
mPagerAdapter = new A4dyPagerAdapter(fm);
} else if (type == KANKANWU) {
mPagerAdapter = new KankanPagerAdapter(fm);
} else if (type == BABAYU) {
mPagerAdapter = new BabayuPagerAdapter(fm);
} else if (type == LL520) {
mPagerAdapter = new LL520PagerAdapter(fm);
} else if (type == K8DY) {
mPagerAdapter = new K8dyPagerAdapter(fm);
} else if (type == IKANFAN) {
mPagerAdapter = new IKanFanPagerAdapter(fm);
} else if (type == CCY) {
mPagerAdapter = new CcyPagerAdapter(fm);
} else if (type == HALIHALI) {
mPagerAdapter = new HaliHaliPagerAdapter(fm);
} else if (type == MMYY) {
mPagerAdapter = new MmyyPagerAdapter(fm);
} else if (type == SMDY) {
mPagerAdapter = new SmdyPagerAdapter(fm);
} else if (type == AISM) {
mPagerAdapter = new AismPagerAdapter(fm);
} else if (type == WANDOU) {
mPagerAdapter = new WandouPagerAdapter(fm);
} else if (type == ZHANDI) {
mPagerAdapter = new ZhandiPagerAdapter(fm);
} else if (type == SANMAO) {
mPagerAdapter = new BobmaoPagerAdapter(fm);
} else if (type == JREN) {
mPagerAdapter = new JrenPagerAdapter(fm);
} else if (type == KUPIAN) {
mPagerAdapter = new KupianPagerAdapter(fm);
} else if (type == TAIHAN) {
mPagerAdapter = new TaihanPagerAdapter(fm);
} else if (type == TEPIAN) {
mPagerAdapter = new TepianPagerAdapter(fm);
} else if (type == JUGOU) {
mPagerAdapter = new JugouPagerAdapter(fm);
} else if (type == LAOSIJI) {
mPagerAdapter = new LaosijiPagerAdapter(fm);
} else if (type == ZZZVZ) {
mPagerAdapter = new ZzzvzPagerAdapter(fm);
} else if (type == VIPYS) {
mPagerAdapter = new VipysPagerAdapter(fm);
} else if (type == FEIFAN) {
mPagerAdapter = new WeilaiPagerAdapter(fm);
}/* else if (type == DYTT_LIVE) {
mPagerAdapter = new TvLivePagerAdapter(fm);
} */else if (type == HQ_LIVE) {
mPagerAdapter = new HaoQuPagerAdapter(fm);
} else if (type == ICAN_LIVE) {
mPagerAdapter = new ICanTvPagerAdapter(fm);
} else if (type == ZZYO) {
mPagerAdapter = new ZzyoPagerAdapter(fm);
}else if (type == YDW) {
mPagerAdapter = new YdwPagerAdapter(fm);
}
return mPagerAdapter;
}
@Override
protected String getActivityTitle() {
return title;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if(type == ICAN_LIVE || type == HQ_LIVE){
getMenuInflater().inflate(R.menu.menu_down, menu);
}else{
getMenuInflater().inflate(R.menu.menu_search_down, menu);
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_search:
if (mSearchFragment != null) {
mSearchFragment.show(getSupportFragmentManager(), getClass().getSimpleName());
}
break;
case R.id.action_download:
DownloadTabActivity.startActivity(this);
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onSearchClick(ISearchWord word) {
Object info = mPagerAdapter.getExtendInfo();
if (info == null) return;
String classNmae = info.toString();
int multiple = mPagerAdapter.getMultiple();
int pageStart = mPagerAdapter.getPageStart();
String wordString = word.getWord();
SearchVideoActivity.startActivity(this, wordString, classNmae, pageStart, multiple);
}
private OnButtonClickListener buttonClickListener = new OnButtonClickListener() {
@Override
public void onButtonClick(BaseAlertDialog<?> dialog, int btn) {
dialog.dismiss();
if (mSharedPreferences == null) return;
if (btn == OnButtonClickListener.RIGHT) {
mSharedPreferences.edit().putBoolean("video_thit", false).commit();
}
}
};
}