Skip to content

Instantly share code, notes, and snippets.

View XinyueZ's full-sized avatar
🙊
Make sense, don't touch

ChrisDEV XinyueZ

🙊
Make sense, don't touch
View GitHub Profile
public VideoFrameExtractor(Context context, String path, TextureView textureView) {
mVideoPath = path;
mTextureView = textureView;
textureView.setSurfaceTextureListener(this);
textureView.setTranslationX(-1920);
if (textureView.isAvailable()) {
initPlayer(textureView.getSurfaceTexture());
}
System.getProperty("line.separator");
@XinyueZ
XinyueZ / gist:fd30f58446b7ed2937ba
Created August 8, 2014 11:13
Open Group directly for ExpandableListView
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View v = super.getGroupView(groupPosition, isExpanded, convertView, parent);
ExpandableListView mExpandableListView = (ExpandableListView) parent;
mExpandableListView.expandGroup(groupPosition);
return v;
}
@XinyueZ
XinyueZ / gist:87ea8d5a5eb5510546ee
Created August 18, 2014 09:08
Get duration of a remote video.
/**
* Asyn-post to get duration of video.
*
* @param _context
* {@link android.content.Context}.
* @param _urlToVideo
* The url to video in {@link java.lang.String}.
*
* @return {@link java.lang.String}. The Duration of video in long format like {@code 03:45}.
* <p/>
@XinyueZ
XinyueZ / OneDirectionScrollView.java
Created August 19, 2014 09:22
OneDirectionScrollView.
public class OneDirectionScrollView extends ScrollView {
private GestureDetector mGestureDetector;
private boolean mAllowTouch = true;
public OneDirectionScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
if (!isInEditMode())
mGestureDetector = new GestureDetector(context, new YScrollDetector());
}
@XinyueZ
XinyueZ / gist:cc0be271686491dcf6e6
Created August 20, 2014 12:08
Avoid keyboard showing at starting activity that holds EditText.
<LinearLayout
android:layout_width="0dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_height="0dp">
<requestFocus />
</LinearLayout>
<!--Just a random EditText.-->
<EditText
@XinyueZ
XinyueZ / gist:63db20f537ed24673949
Created August 24, 2014 12:15
Get ActionBar's height.
/* Get ActionBar's height. */
int[] abSzAttr;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
abSzAttr = new int[]{android.R.attr.actionBarSize};
} else {
abSzAttr = new int[]{R.attr.actionBarSize};
}
TypedArray a = obtainStyledAttributes(abSzAttr);
mActionBarHeight = a.getDimensionPixelSize(0, -1);
@XinyueZ
XinyueZ / gist:2177736f6fbad80b2622
Last active August 29, 2015 14:05
Hyperlink on TextView, better solved.
//Inspired by http://stackoverflow.com/a/20647011/1835650
//Inspired by http://aichixihongshi.iteye.com/blog/1207503
SpannableStringBuilder spanBuilder = (SpannableStringBuilder) p.getSpannedText(); //Html.from(.....)
URLSpan[] spans = spanBuilder.getSpans(0, spanBuilder.length(), URLSpan.class);
for (URLSpan s: spans) {
int start = spanBuilder.getSpanStart(s);
int end = spanBuilder.getSpanEnd(s);
spanBuilder.removeSpan(s);
CustomClickableSpan sp = new CustomClickableSpan(s, false);
@XinyueZ
XinyueZ / webserver.c
Created October 11, 2014 13:42
A webserver in C
/*
* WebServer.c
*
* Created on: Nov 3, 2012
* Author: pavithra
*
* A web server in C language using only the standard libraries.
* The port number is passed as an argument.
*
*/
@XinyueZ
XinyueZ / resizeImage.go
Created October 11, 2014 13:44
GO: resize image.
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package resize
import (
"image"
"image/ycbcr"
)