This file contains hidden or 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 void hideStatusBar() { | |
if (Build.VERSION.SDK_INT < 16) { | |
hideStatusBarLowVersion(); | |
} else { | |
hideStatusBarHighVersion(); | |
} | |
} | |
private void showStatusBar() { | |
if (Build.VERSION.SDK_INT < 16) { |
This file contains hidden or 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
/// Converts 14 dip into its equivalent px | |
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, getResources().getDisplayMetrics()); |
This file contains hidden or 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 OnClickListener popupClickListener = new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
switch (v.getId()) { | |
case R.id.share_google: | |
System.out.println("===== share_google"); | |
break; | |
case R.id.share_facebook: | |
System.out.println("===== share_facebook"); |
This file contains hidden or 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
Gson gson = new Gson(); | |
String videosJson = gson.toJson(playingVideos, | |
new TypeToken<ArrayList<PlayingVideo>>() { | |
}.getType()); |
This file contains hidden or 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 static boolean isAvailable(Context ctx, Intent intent) { | |
final PackageManager mgr = ctx.getPackageManager(); | |
List<ResolveInfo> list = | |
mgr.queryIntentActivities(intent, | |
PackageManager.MATCH_DEFAULT_ONLY); |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<inset xmlns:android="http://schemas.android.com/apk/res/android" | |
android:insetLeft="60dp" | |
android:insetRight="8dp" > | |
<shape> | |
<solid android:color="#c0c0c0" /> | |
</shape> | |
</inset> |
This file contains hidden or 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
InputMethodManager imm = (InputMethodManager) mActivity | |
.getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0); |
This file contains hidden or 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 static String extractJsUrl(String originHtml) { | |
// <script src="//s.ytimg.com/yts/jsbin/html5player-zh_CN-vflHa9pzi.js" | |
// name="html5player"></script> | |
final String REGEX = "//s[.]ytimg[.]com/.*html5player.*[.]js"; | |
Pattern p = Pattern.compile(REGEX); | |
Matcher m = p.matcher(originHtml); | |
String jsUrl = null; | |
if (m.find()) { | |
jsUrl = originHtml.substring(m.start(), m.end()); |
This file contains hidden or 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
static boolean isMain() { | |
return Looper.getMainLooper().getThread() == Thread.currentThread(); | |
} |
This file contains hidden or 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 seems to be a bug in the newly added support for nested fragments. | |
* Basically, the child FragmentManager ends up with a broken internal state | |
* when it is detached from the activity. A short-term workaround that fixed | |
* it for me is to add the following to onDetach() of every Fragment which | |
* you call getChildFragmentManager() on: | |
*/ | |
@Override | |
public void onDetach() { | |
super.onDetach(); |
OlderNewer