Skip to content

Instantly share code, notes, and snippets.

Avatar

Fung Lam seventhmoon

View GitHub Profile
View AndroidViewModelKtx.kt
protected open fun AndroidViewModel.getString(@StringRes resId: Int) =
getApplication<Application>().resources.getString(resId)
protected open fun AndroidViewModel.getStringArray(@ArrayRes resId: Int): Array<String> =
getApplication<Application>().resources.getStringArray(resId)
View Streams.kt
val supportedHardwareAcceleratedDecodeType = MediaCodecList(MediaCodecList.REGULAR_CODECS).codecInfos
.filter { !it.isEncoder && it.isHardwareAccelerated }
.map { it.supportedTypes.toList() }
.flatten()
.toSortedSet()
View now331.json
//curl 'https://hkt-mobile-api.nowtv.now.com/09/1/getLiveURL' -H 'Accept: */*' -H 'Referer: https://news.now.com/home/live331a' -H 'Origin: https://news.now.com' -H 'User-Agent: Mozilla/5.0 (X11; CrOS x86_64 12105.75.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.102 Safari/537.36' -H 'Content-Type: application/json' --data-binary '{"channelno":"331","mode":"prod","audioCode":"","format":"HLS","callerReferenceNo":"20140702122500"}' --compressed
{"asset":{"hls":{"fix":{"2":["http://ewcdnsite06.nowe.com/session/09-66f7223b8ba659a79719d70a1aeee/Content/HLS/LIVE/Channel(HLS_CH331)/Stream(02)/index.m3u8?token=0425484f980b53d36d0293acc69c55b2_1562399934"],"1":["http://ewcdnsite06.nowe.com/session/09-66f7223b8ba659a79719d70a1aeee/Content/HLS/LIVE/Channel(HLS_CH331)/Stream(01)/index.m3u8?token=d3db0393451ab9b83b4d738376c7e979_1562399934"]},"adaptive":["http://ewcdnsite06.nowe.com/session/09-66f7223b8ba659a79719d70a1aeee/Content/HLS/LIVE/Channel(HLS_CH331)/index.m3u8?token=37c2269e3eff183d98c4c3084ac72060_
@seventhmoon
seventhmoon / Util.java
Created Feb 20, 2018
Helper Utility for Android
View Util.java
import android.content.Context;
import android.graphics.Point;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Toast;
/**
* A collection of utility methods, all static.
*/
public class Utils {
@seventhmoon
seventhmoon / Util.java
Created Feb 20, 2018
Helper Utility for Android
View Util.java
import android.content.Context;
import android.graphics.Point;
import android.view.Display;
import android.view.WindowManager;
import android.widget.Toast;
/**
* A collection of utility methods, all static.
*/
public class Utils {
@seventhmoon
seventhmoon / SensorActivity
Created Mar 20, 2017
Sample for Reading Sensor Value on Android
View SensorActivity
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorEventListener2;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
View layout.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:flexWrap="wrap"
android:layout_gravity="center"
app:alignItems="center"
tools:context="com.androidfung.layoutsample.MainActivity">
@seventhmoon
seventhmoon / okio_proguard.pro
Created Mar 14, 2017
ProGuard Configurations
View okio_proguard.pro
-dontwarn okio.**
@seventhmoon
seventhmoon / RecordSerializer.java
Last active Feb 21, 2017
Gson Serializer for Skygear Record
View RecordSerializer.java
package org.astri.isns.elderly;
import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.util.Map;
import io.skygear.skygear.Record;
@seventhmoon
seventhmoon / RecordHelper.java
Last active Feb 21, 2017
Helper function for casting / parsing Record when using Skygear
View RecordHelper.java
import com.google.gson.Gson;
import java.util.Map;
import io.skygear.skygear.Record;
public class RecordHelper {
public static <T> T toObject(Record record, Class<T> classOfT) {
You can’t perform that action at this time.