Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Added viewer count and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
markhaehnel committed Feb 24, 2016
1 parent d9ca2e3 commit 99a67ce
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 56 deletions.
Binary file modified app/app-release.apk
Binary file not shown.
25 changes: 16 additions & 9 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,44 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.devbrackets.android/exomedia/2.5.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.devbrackets.android/exomedia/2.5.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.exoplayer/exoplayer/r1.5.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="exomedia-2.5.4" level="project" />
<orderEntry type="library" exported="" name="exomedia-2.5.5" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="exoplayer-r1.5.5" level="project" />
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "de.markhaehnel.rbtv.rocketbeanstv"
minSdkVersion 17
targetSdkVersion 23
versionCode 11
versionName "2.7"
versionCode 12
versionName "2.8"
}
buildTypes {
release {
Expand All @@ -21,5 +21,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.devbrackets.android:exomedia:2.5.4'
compile 'com.devbrackets.android:exomedia:2.5.5'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.markhaehnel.rbtv.rocketbeanstv;

public class ChannelInfo {
ChannelInfo(String i_currentShow, String i_viewerCount) {
currentShow = i_currentShow;
viewerCount = i_viewerCount;
}

public String currentShow = "";
public String viewerCount = "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package de.markhaehnel.rbtv.rocketbeanstv;

import android.os.AsyncTask;
import org.json.JSONException;
import org.json.JSONObject;

public class GetChannelInfoTask extends AsyncTask<Void, ChannelInfo, String> {
protected String doInBackground(Void... voids) {
while (true) {
try {
try {
String response = HttpRequest.get("https://api.twitch.tv/kraken/streams/rocketbeanstv").body();
JSONObject json = new JSONObject(response).getJSONObject("stream");
JSONObject channel = json.getJSONObject("channel");
publishProgress(new ChannelInfo(channel.getString("status"), json.getString("viewers") + " Zuschauer"));
} catch (JSONException e) {
e.printStackTrace();
}
Thread.sleep(15000);
} catch (Exception e) {
e.printStackTrace();
}
}
}

protected void onProgressUpdate(ChannelInfo... infos) {
ChannelInfo info = infos[0];
if (info.currentShow.length() != 0) {
MainActivity.getInstance().setInfoOverlay(info);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.json.JSONObject;

import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;

Expand All @@ -36,7 +35,7 @@ public class MainActivity extends AppCompatActivity implements MediaPlayer.OnPre
private EMVideoView videoView;

boolean showGetterIsRunning = false;
String currentShow = "Keine Informationen";
ChannelInfo channelInfo = new ChannelInfo("Keine Informationen", "");

private static MainActivity ins;

Expand Down Expand Up @@ -87,7 +86,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
System.exit(0);
return true;
case KeyEvent.KEYCODE_MENU:
this.showCurrentShow();
this.showInfoOverlay();
return true;
}
return false;
Expand Down Expand Up @@ -125,7 +124,7 @@ public boolean onInfo(MediaPlayer mp, int what, int extra) {
pb.setVisibility(View.INVISIBLE);

if (!showGetterIsRunning) {
new GetCurrentShowTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new GetChannelInfoTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
showGetterIsRunning = true;
}
break;
Expand Down Expand Up @@ -156,10 +155,10 @@ protected static MainActivity getInstance() {
return ins;
}

protected void setCurrentShow(String showName) {
if (!showName.equals(currentShow)) {
currentShow = showName;
showCurrentShow();
protected void setInfoOverlay(ChannelInfo info) {
if (!info.currentShow.equals(channelInfo.currentShow)) {
channelInfo = info;
showInfoOverlay();
}
}

Expand Down Expand Up @@ -231,10 +230,12 @@ public void onClick(DialogInterface dialog, int which) {
ad.create().show();
}

private void showCurrentShow() {
private void showInfoOverlay() {
TableLayout containerCurrentShow = (TableLayout)findViewById(R.id.containerCurrentShow);
TextView textCurrentShow = (TextView)findViewById(R.id.textCurrentShow);
textCurrentShow.setText(currentShow);
textCurrentShow.setText(channelInfo.currentShow);
TextView textViewerCount = (TextView)findViewById(R.id.textViewerCount);
textViewerCount.setText(channelInfo.viewerCount);

AnimationSet animation = new AnimationSet(true);
animation.addAnimation(AnimationBuilder.getFadeInAnimation());
Expand Down
26 changes: 23 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/currentShow"
android:layout_column="2"
android:layout_column="1"
android:textAlignment="textEnd"
android:textColor="#b2ffffff"
android:textStyle="italic"
Expand All @@ -72,7 +72,7 @@
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
android:layout_gravity="right" >

<TextView
android:layout_width="wrap_content"
Expand All @@ -84,7 +84,27 @@
android:visibility="visible"
android:layout_gravity="right"
android:textAlignment="textEnd"
android:layout_column="2" />
android:layout_column="1" />
</TableRow>

<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="@+id/textViewerCount"
android:textColor="#b2ffffff"
android:visibility="visible"
android:layout_gravity="right"
android:textAlignment="textEnd"
android:layout_column="1" />


</TableRow>

</TableLayout>
Expand Down

0 comments on commit 99a67ce

Please sign in to comment.