-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
2,434 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "guru.ioio.alpha" | ||
minSdkVersion 21 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
dataBinding { | ||
enabled true | ||
} | ||
compileOptions { | ||
targetCompatibility 1.8 | ||
sourceCompatibility 1.8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
implementation 'com.android.support:appcompat-v7:28+' | ||
implementation 'com.android.support.constraint:constraint-layout:1.0.2' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | ||
implementation 'io.reactivex.rxjava2:rxjava:2.2.0' | ||
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' | ||
implementation 'com.squareup.retrofit2:retrofit:2.4.0' | ||
implementation 'com.github.k0shk0sh:PermissionHelper:1.1.0' | ||
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8' | ||
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8' | ||
implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8' | ||
implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8' | ||
implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8' | ||
implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8' | ||
implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8' | ||
implementation project(':base') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/guru/ioio/alpha/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package guru.ioio.alpha; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("guru.ioio.alpha", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="guru.ioio.alpha"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".player.PlayerActivity" | ||
android:theme="@style/PlayerTheme" /> | ||
<activity | ||
android:name=".ChannelListActivity" | ||
android:screenOrientation="portrait" /> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"list": [ | ||
{ | ||
"name": "中央1", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv1.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央2", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv2.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央3", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv3.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央4", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv4.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央5", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv5.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央6", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv6.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央7", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv7.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央8", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv8.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央9", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv9.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央10", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv10.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央11", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv11.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央12", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv12.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央13", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv13.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央14", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv14.m3u8" | ||
] | ||
}, | ||
{ | ||
"name": "中央15", | ||
"uri": [ | ||
"http://ivi.bupt.edu.cn/hls/cctv15.m3u8" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package guru.ioio.alpha; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.Toast; | ||
|
||
public class BaseActivity extends AppCompatActivity { | ||
protected void show(String message) { | ||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
app/src/main/java/guru/ioio/alpha/ChannelListActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package guru.ioio.alpha; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.databinding.DataBindingUtil; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.widget.GridLayoutManager; | ||
|
||
import com.google.gson.Gson; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
|
||
import java.io.InputStream; | ||
import java.util.List; | ||
|
||
import guru.ioio.alpha.databinding.ActivityChannelListBinding; | ||
import guru.ioio.alpha.model.ChannelBean; | ||
import guru.ioio.alpha.model.ChannelRoot; | ||
import guru.ioio.alpha.player.PlayerActivity; | ||
import guru.ioio.base.adapter.RVBindingBaseAdapter; | ||
import io.reactivex.Observable; | ||
import io.reactivex.android.schedulers.AndroidSchedulers; | ||
import io.reactivex.schedulers.Schedulers; | ||
|
||
public class ChannelListActivity extends BaseActivity { | ||
private ActivityChannelListBinding mBinding; | ||
private RVBindingBaseAdapter<ChannelBean> mAdapter; | ||
|
||
public static void launch(Context context) { | ||
context.startActivity(new Intent(context, ChannelListActivity.class)); | ||
} | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_channel_list); | ||
mBinding.setPresenter(this); | ||
mAdapter = new RVBindingBaseAdapter<>(R.layout.item_channel, guru.ioio.alpha.BR.data); | ||
mAdapter.addPresenter(guru.ioio.alpha.BR.presenter, this); | ||
mBinding.recycler.setLayoutManager(new GridLayoutManager(this, 1, GridLayoutManager.VERTICAL, false)); | ||
mBinding.recycler.setAdapter(mAdapter); | ||
|
||
loadChannels(); | ||
} | ||
|
||
@SuppressLint("CheckResult") | ||
private void loadChannels() { | ||
Observable.create(s -> { | ||
try (InputStream in = getAssets().open("channels.json")) { | ||
String data = IOUtils.toString(in, "utf-8"); | ||
Gson gson = new Gson(); | ||
ChannelRoot root = gson.fromJson(data, ChannelRoot.class); | ||
if (root != null && root.list != null) { | ||
s.onNext(root.list); | ||
} else { | ||
s.onError(new Exception("no data")); | ||
} | ||
s.onComplete(); | ||
} | ||
}).subscribeOn(Schedulers.io()) | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribe(list -> mAdapter.add((List<ChannelBean>) list), e -> { | ||
}); | ||
} | ||
|
||
public boolean onItemClick(ChannelBean bean) { | ||
PlayerActivity.launch(this, bean.uri.get(0)); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package guru.ioio.alpha; | ||
|
||
import android.databinding.DataBindingUtil; | ||
import android.os.Bundle; | ||
|
||
import guru.ioio.alpha.databinding.ActivityMainBinding; | ||
|
||
public class MainActivity extends BaseActivity { | ||
private ActivityMainBinding mBinding; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main); | ||
mBinding.setPresenter(this); | ||
ChannelListActivity.launch(this); | ||
finish(); | ||
} | ||
|
||
public boolean onPlayClick() { | ||
ChannelListActivity.launch(this); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package guru.ioio.alpha.model; | ||
|
||
import java.util.List; | ||
|
||
public class ChannelBean { | ||
public String name; | ||
public List<String> uri; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package guru.ioio.alpha.model; | ||
|
||
import java.util.List; | ||
|
||
public class ChannelRoot { | ||
public List<ChannelBean> list; | ||
} |
Oops, something went wrong.