Skip to content

Instantly share code, notes, and snippets. laaptu

Block or report user

Report or block laaptu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
laaptu / StaticHandler
Last active Dec 22, 2015
Creating static handlers on Android
View StaticHandler
CustomHandler customHandler = new CustomHandler(this);
static class CustomHandler extends Handler{
private final WeakReference<FriendListFragment> fragmentHolder;
public CustomHandler(FriendListFragment friendListFragment){
fragmentHolder = new WeakReference<FriendListFragment>(friendListFragment);
View CustomScrollView
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;
public class VerticalScrollView extends ScrollView {
public VerticalScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
laaptu / AssetFileStringReader
Last active Mar 17, 2019
Android read file as string from asset
View AssetFileStringReader
public String ReadFromfile(String fileName, Context context) {
StringBuilder ReturnString = new StringBuilder();
InputStream fIn = null;
InputStreamReader isr = null;
BufferedReader input = null;
try {
fIn = context.getResources().getAssets()
isr = new InputStreamReader(fIn);
input = new BufferedReader(isr);
laaptu / bitmap_not_stretch
Created Sep 6, 2013
Android stop background from stretching with content,meaning making width of background fixed
View bitmap_not_stretch
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android=""
android:tileMode="disabled" android:gravity="top" >
laaptu / DisableChildViews
Created Sep 17, 2013
Method to disable or enable child view of a view group or view
View DisableChildViews
* Enables/Disables all child views in a view group.
* @param viewGroup the view group
* @param enabled <code>true</code> to enable, <code>false</code> to disable
* the views.
public static void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) {
int childCount = viewGroup.getChildCount();
laaptu / SmoothInterpolator
Created Sep 17, 2013
Android smooth interpolator as per Cyril Mottier
View SmoothInterpolator
//as per
public class SmoothInterpolator extends LinearInterpolator {
public float getInterpolation(float input) {
return (float) Math.pow(input - 1, 5) + 1;
laaptu / CollapseValueAnimator
Last active Mar 14, 2019
Android collapse animation by ValueAnimator
View CollapseValueAnimator
private void valueAnimateAndDelete(final View view,
final int deletePosition) {
final ViewGroup.LayoutParams lp = view.getLayoutParams();
final int originalHeight = view.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 0);
animator.addListener(new AnimatorListener() {
public void onAnimationStart(Animator arg0) {
laaptu / CollapseAnimation
Created Sep 17, 2013
Android Collapse Animation by decreasing height
View CollapseAnimation
private void animateAndDelete(final View view, final int deletePosition) {
final int height = view.getMeasuredHeight();
Animation animation = new Animation() {
protected void applyTransformation(float interpolatedTime,
Transformation t) {
view.getLayoutParams().height = height
- (int) (height * interpolatedTime);
laaptu / ListViewSmoothScrollToPosition
Created Sep 19, 2013
ListView smooth scroll to certain position
View ListViewSmoothScrollToPosition
//Keep in mind the position should be actual size of ArrayList not ArrayList size -1
listView.getListView().postDelayed(new Runnable() {
public void run() {
View WebViewAssetFileLoad
public class ViewWeb extends Activity {
public void onCreate(Bundle savedInstanceState) {
WebView wv;
wv = (WebView) findViewById(;
wv.loadUrl("file:///android_asset/aboutcertified.html"); // now it will not fail here
You can’t perform that action at this time.