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
// Copyright 2012 Square, Inc. | |
package com.squareup.widgets; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
/** Maintains an aspect ratio based on either width or height. Disabled by default. */ | |
public class AspectRatioImageView extends ImageView { |
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
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.util.Log; | |
import com.android.volley.NetworkResponse; | |
import com.android.volley.Request; | |
import com.android.volley.Response; | |
import com.android.volley.toolbox.JsonRequest; | |
import com.google.gson.Gson; | |
import com.google.gson.GsonBuilder; |
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
Glide.with(this) | |
.load(url) | |
.asBitmap().diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop() | |
.into(new BitmapImageViewTarget(mImageViewBackdrop) { | |
@Override | |
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) { | |
super.onResourceReady(bitmap, anim); | |
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { | |
@Override | |
public void onGenerated(Palette palette) { |
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
import android.app.Application; | |
import android.app.UiModeManager; | |
import android.content.res.Configuration; | |
/** | |
* Created by fung.lam on 27/07/2015. | |
*/ | |
public class DefaultApplication extends Application { | |
private boolean isRunningOnTv(){ |
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
//implement ViewPager.SimpleOnPageChangeListener(), override the following method | |
public void onPageScrollStateChanged(int state) { | |
if (state == ViewPager2.SCROLL_STATE_IDLE) { | |
int curr = mViewPager.getCurrentItem(); | |
int lastReal = mViewPager.getAdapter().getCount() - 2; | |
if (curr == 0) { | |
mViewPager.setCurrentItem(lastReal, false); | |
} else if (curr > lastReal) { | |
mViewPager.setCurrentItem(1, false); | |
} |
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
private double calcDist(double lat1, double lng1, double lat2, double lng2) { | |
double earthRadius = 3958.75; | |
double lat = Math.toRadians(lat2 - lat1); | |
double lng = Math.toRadians(lng2 - lng1); | |
double a = Math.sin(lat / 2) * Math.sin(lat / 2) | |
+ Math.cos(Math.toRadians(lat1)) | |
* Math.cos(Math.toRadians(lat2)) * Math.sin(lng / 2) | |
* Math.sin(lng / 2); | |
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); | |
double dist = earthRadius * c; |
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
public class TimeHelper{ | |
public static final SimpleDateFormat HMS_DATE_FORMAT = new SimpleDateFormat("hh:mm:ss"); | |
public static long toMillis(int hour, int minute, int second){ | |
return toSeconds(hour, minute, second) * 1000; | |
} | |
public static long toSeconds(int hour, int minute, int second){ | |
return (hour * 3600 + minute * 60 + second); | |
} |
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
import java.io.UnsupportedEncodingException; | |
import com.android.volley.NetworkResponse; | |
import com.android.volley.ParseError; | |
import com.android.volley.Response; | |
import com.android.volley.toolbox.HttpHeaderParser; | |
import com.android.volley.toolbox.JsonRequest; | |
import com.google.gson.Gson; | |
import com.google.gson.JsonSyntaxException; |
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
{ | |
campus : [ | |
{"id":"1", "campus_en":"Central Campus", "campus_xb5":"中央校園", "shortname":"", "color":"", "lat_lng":"(22.41938957865346, 114.20692563056946)", "contains_landmarks":"True"}, | |
{"id":"2", "campus_en":"Chung Chi College", "campus_xb5":"崇基學院", "shortname":"cc", "color":"", "lat_lng":"(22.415214072123707, 114.2094898223877)", "contains_landmarks":"True"}, | |
{"id":"3", "campus_en":"New Asia College", "campus_xb5":"新亞書院", "shortname":"na", "color":"", "lat_lng":"(22.42137810711142, 114.20880317687988)", "contains_landmarks":"True"}, | |
{"id":"4", "campus_en":"United College", "campus_xb5":"聯合書院", "shortname":"uc", "color":"", "lat_lng":"(22.421417778212405, 114.20525193214417)", "contains_landmarks":"True"}, | |
{"id":"5", "campus_en":"Shaw College", "campus_xb5":"逸夫書院", "shortname":"sc", "color":"", "lat_lng":"(22.42287320389422, 114.20157998800278)", "contains_landmarks":"True"}, | |
{"id":"6", "campus_en":"Residential Area", "campus_xb5":"宿舍", "shortname":"", "color":"", "lat_lng":"", "contains_landmarks":"False"}, |
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
import java.io.IOException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.util.Map; | |
public class Helper { | |
public enum Channel {HDJ, J2, INEWS}; | |
public enum Quality {QUALITY_720P, QUALITY_360P}; | |
private static String[] links720p = {"http://token.tvb.com/stream/live/hls/mobilehd_hdj.smil", | |
"http://token.tvb.com/stream/live/hls/mobilehd_jade.smil", |
NewerOlder