Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from ITVlab/colortv
Colortv
- Loading branch information
Showing
12 changed files
with
196 additions
and
159 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
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,3 @@ | ||
#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public. | ||
#Fri Oct 21 21:23:32 EDT 2016 | ||
apiSecret=e9a5cc1704503d82ba5e97ce66f40ba38972ff71c11134713e447a7ec8cc160f |
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
17 changes: 9 additions & 8 deletions
17
app/src/main/java/news/androidtv/tvapprepo/PrivateUtils.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package news.androidtv.tvapprepo; | ||
|
||
/** | ||
* Created by Nick on 10/21/2016. | ||
*/ | ||
|
||
public class PrivateUtils { | ||
} | ||
package news.androidtv.tvapprepo; | ||
|
||
/** | ||
* Created by Nick on 10/21/2016. | ||
*/ | ||
|
||
public class PrivateUtils { | ||
public static final String COLOR_TV_KEY = "6290e438-a188-4ae9-a8bc-4e23e1b97cbd"; | ||
} |
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
140 changes: 70 additions & 70 deletions
140
app/src/main/java/news/androidtv/tvapprepo/download/AbstractDownloadHelper.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 |
---|---|---|
@@ -1,70 +1,70 @@ | ||
package news.androidtv.tvapprepo.download; | ||
|
||
import android.app.Activity; | ||
|
||
import com.colortv.android.AdPlacement; | ||
import com.colortv.android.ColorTvAdListener; | ||
import com.colortv.android.ColorTvError; | ||
import com.colortv.android.ColorTvSdk; | ||
|
||
/** | ||
* Created by Nick on 9/23/2016. | ||
*/ | ||
public abstract class AbstractDownloadHelper { | ||
private static final double AD_RATE = 1/1; | ||
private static final boolean mDisableAds = false; | ||
|
||
private Activity mActivity; | ||
|
||
private ColorTvAdListener mListener = new ColorTvAdListener() { | ||
@Override | ||
public void onAdLoaded(String placement) { | ||
ColorTvSdk.showAd(placement); | ||
} | ||
|
||
@Override | ||
public void onAdError(String placement, ColorTvError colorTvError) { | ||
} | ||
|
||
@Override | ||
public void onAdClosed(String placement, boolean watched) { | ||
} | ||
|
||
@Override | ||
public void onAdExpired(String placement) { | ||
} | ||
}; | ||
|
||
protected AbstractDownloadHelper() { | ||
|
||
} | ||
|
||
public AbstractDownloadHelper initialize(Activity activity) { | ||
mActivity = activity; | ||
ColorTvSdk.init(activity, getAppId()); | ||
ColorTvSdk.setRecordAudioEnabled(false); | ||
ColorTvSdk.onCreate(); | ||
ColorTvSdk.registerAdListener(mListener); | ||
return this; | ||
} | ||
|
||
public void destroy() { | ||
ColorTvSdk.onDestroy(); | ||
} | ||
|
||
public AbstractDownloadHelper startDownload(String url) { | ||
startDownload(url, AdPlacement.BETWEEN_LEVELS); | ||
return this; | ||
} | ||
|
||
public AbstractDownloadHelper startDownload(String url, String adType) { | ||
// Starts download | ||
// Also loads ad | ||
if (!mDisableAds && Math.random() < AD_RATE) { | ||
ColorTvSdk.loadAd(adType); | ||
} | ||
return this; | ||
} | ||
|
||
public abstract String getAppId(); | ||
} | ||
package news.androidtv.tvapprepo.download; | ||
|
||
import android.app.Activity; | ||
|
||
import com.colortv.android.AdPlacement; | ||
import com.colortv.android.ColorTvAdListener; | ||
import com.colortv.android.ColorTvError; | ||
import com.colortv.android.ColorTvSdk; | ||
|
||
/** | ||
* Created by Nick on 9/23/2016. | ||
*/ | ||
public abstract class AbstractDownloadHelper { | ||
private static final double AD_RATE = 1/1; | ||
private static final boolean mDisableAds = false; | ||
|
||
private Activity mActivity; | ||
|
||
private ColorTvAdListener mListener = new ColorTvAdListener() { | ||
@Override | ||
public void onAdLoaded(String placement) { | ||
ColorTvSdk.showAd(placement); | ||
} | ||
|
||
@Override | ||
public void onAdError(String placement, ColorTvError colorTvError) { | ||
} | ||
|
||
@Override | ||
public void onAdClosed(String placement, boolean watched) { | ||
} | ||
|
||
@Override | ||
public void onAdExpired(String placement) { | ||
} | ||
}; | ||
|
||
protected AbstractDownloadHelper() { | ||
|
||
} | ||
|
||
public AbstractDownloadHelper initialize(Activity activity) { | ||
mActivity = activity; | ||
ColorTvSdk.init(activity, getAppId()); | ||
ColorTvSdk.setRecordAudioEnabled(false); | ||
ColorTvSdk.onCreate(); | ||
ColorTvSdk.registerAdListener(mListener); | ||
return this; | ||
} | ||
|
||
public void destroy() { | ||
ColorTvSdk.onDestroy(); | ||
} | ||
|
||
public AbstractDownloadHelper startDownload(String url) { | ||
startDownload(url, AdPlacement.BETWEEN_LEVELS); | ||
return this; | ||
} | ||
|
||
public AbstractDownloadHelper startDownload(String url, String adType) { | ||
// Starts download | ||
// Also loads ad | ||
if (!mDisableAds && Math.random() < AD_RATE) { | ||
ColorTvSdk.loadAd(adType); | ||
} | ||
return this; | ||
} | ||
|
||
public abstract String getAppId(); | ||
} |
136 changes: 68 additions & 68 deletions
136
app/src/main/java/news/androidtv/tvapprepo/download/ApkDownloadHelper.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 |
---|---|---|
@@ -1,68 +1,68 @@ | ||
package news.androidtv.tvapprepo.download; | ||
|
||
import android.app.Activity; | ||
|
||
import java.io.File; | ||
|
||
import news.androidtv.tvapprepo.PrivateUtils; | ||
import tv.puppetmaster.tinydl.PackageInstaller; | ||
|
||
/** | ||
* Created by Nick on 9/23/2016. | ||
*/ | ||
public class ApkDownloadHelper extends AbstractDownloadHelper { | ||
private PackageInstaller mPackageInstaller; | ||
|
||
public ApkDownloadHelper(Activity activity) { | ||
initialize(activity, null); | ||
} | ||
|
||
public ApkDownloadHelper initialize(Activity activity, PackageInstaller.DownloadListener listener) { | ||
super.initialize(activity); | ||
mPackageInstaller = PackageInstaller.initialize(activity); | ||
if (listener != null) { | ||
mPackageInstaller.addListener(listener); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
super.destroy(); | ||
mPackageInstaller.destroy(); | ||
} | ||
|
||
@Override | ||
public AbstractDownloadHelper startDownload(String url) { | ||
mPackageInstaller.wget(url); | ||
return super.startDownload(url); | ||
} | ||
|
||
@Override | ||
public AbstractDownloadHelper startDownload(String url, String adType) { | ||
mPackageInstaller.wget(url); | ||
return super.startDownload(url, adType); | ||
} | ||
|
||
public PackageInstaller getPackageInstaller() { | ||
return mPackageInstaller; | ||
} | ||
|
||
@Override | ||
public String getAppId() { | ||
return PrivateUtils.COLOR_TV_KEY; | ||
} | ||
|
||
// Wrapper methods | ||
public void install(File file) { | ||
mPackageInstaller.install(file); | ||
} | ||
|
||
public void addListener(PackageInstaller.DownloadListener listener) { | ||
mPackageInstaller.addListener(listener); | ||
} | ||
|
||
public void removeListener(PackageInstaller.DownloadListener listener) { | ||
mPackageInstaller.removeListener(listener); | ||
} | ||
} | ||
package news.androidtv.tvapprepo.download; | ||
|
||
import android.app.Activity; | ||
|
||
import java.io.File; | ||
|
||
import news.androidtv.tvapprepo.PrivateUtils; | ||
import tv.puppetmaster.tinydl.PackageInstaller; | ||
|
||
/** | ||
* Created by Nick on 9/23/2016. | ||
*/ | ||
public class ApkDownloadHelper extends AbstractDownloadHelper { | ||
private PackageInstaller mPackageInstaller; | ||
|
||
public ApkDownloadHelper(Activity activity) { | ||
initialize(activity, null); | ||
} | ||
|
||
public ApkDownloadHelper initialize(Activity activity, PackageInstaller.DownloadListener listener) { | ||
super.initialize(activity); | ||
mPackageInstaller = PackageInstaller.initialize(activity); | ||
if (listener != null) { | ||
mPackageInstaller.addListener(listener); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
super.destroy(); | ||
mPackageInstaller.destroy(); | ||
} | ||
|
||
@Override | ||
public AbstractDownloadHelper startDownload(String url) { | ||
mPackageInstaller.wget(url); | ||
return super.startDownload(url); | ||
} | ||
|
||
@Override | ||
public AbstractDownloadHelper startDownload(String url, String adType) { | ||
mPackageInstaller.wget(url); | ||
return super.startDownload(url, adType); | ||
} | ||
|
||
public PackageInstaller getPackageInstaller() { | ||
return mPackageInstaller; | ||
} | ||
|
||
@Override | ||
public String getAppId() { | ||
return PrivateUtils.COLOR_TV_KEY; | ||
} | ||
|
||
// Wrapper methods | ||
public void install(File file) { | ||
mPackageInstaller.install(file); | ||
} | ||
|
||
public void addListener(PackageInstaller.DownloadListener listener) { | ||
mPackageInstaller.addListener(listener); | ||
} | ||
|
||
public void removeListener(PackageInstaller.DownloadListener listener) { | ||
mPackageInstaller.removeListener(listener); | ||
} | ||
} |
Oops, something went wrong.