Skip to content

Instantly share code, notes, and snippets.

sanimap@gmail.com 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
laaptu / StaticHandler
Last active Dec 22, 2015
Creating static handlers on Android
View StaticHandler
CustomHandler customHandler = new CustomHandler(this);
customHandler.sendEmptyMessage(0);
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
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()
.open(fileName);
isr = new InputStreamReader(fIn);
input = new BufferedReader(isr);
@laaptu
laaptu / bitmap_not_stretch
Created Sep 6, 2013
Android stop background from stretching with content,meaning making width of background fixed http://stackoverflow.com/questions/5902230/how-to-implement-an-androidbackground-that-doesnt-stretch
View bitmap_not_stretch
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/dvdr"
android:tileMode="disabled" android:gravity="top" >
</bitmap>
@laaptu
laaptu / DisableChildViews
Created Sep 17, 2013
Method to disable or enable child view of a view group or view
View DisableChildViews
/**
*http://stackoverflow.com/questions/5418510/disable-the-touch-events-for-all-the-views
* 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
laaptu / SmoothInterpolator
Created Sep 17, 2013
Android smooth interpolator as per Cyril Mottier
View SmoothInterpolator
//as per cyrilmottier.com/2012/05/22/the-making-of-prixing-fly-in-app-menu-part-1/
public class SmoothInterpolator extends LinearInterpolator {
@Override
public float getInterpolation(float input) {
return (float) Math.pow(input - 1, 5) + 1;
}
}
@laaptu
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() {
@Override
public void onAnimationStart(Animator arg0) {
@laaptu
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() {
@Override
protected void applyTransformation(float interpolatedTime,
Transformation t) {
view.getLayoutParams().height = height
- (int) (height * interpolatedTime);
view.requestLayout();
@laaptu
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
chatListAdapter.notifyDataSetChanged();
listView.getListView().postDelayed(new Runnable() {
@Override
public void run() {
listView.getListView().smoothScrollToPosition(
messageItemList.size());
View WebViewAssetFileLoad
public class ViewWeb extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
WebView wv;
wv = (WebView) findViewById(R.id.webView1);
wv.loadUrl("file:///android_asset/aboutcertified.html"); // now it will not fail here
}
}
You can’t perform that action at this time.