Skip to content

Instantly share code, notes, and snippets.

@billynyh
billynyh / ApiModule.java
Last active May 29, 2020 07:25
Android integration of retrofit, signpost, twitter api
public class ApiModule {
private TwitterApi mApi;
public void init(String token, String tokenSecret) {
OAuthConsumer consumer = new DefaultOAuthConsumer(
Config.TWEET_API_KEY,
Config.TWEET_API_SECRET);
consumer.setTokenWithSecret(token, tokenSecret);
@billynyh
billynyh / VerticalScrollView.js
Created August 25, 2012 03:16
Using horizontal viewpager inside vertical scrollview
//http://stackoverflow.com/questions/2646028/android-horizontalscrollview-within-scrollview-touch-handling
public class VerticalScrollView extends ScrollView {
private float xDistance, yDistance, lastX, lastY;
public VerticalScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
/*
* Copyright 2013 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@billynyh
billynyh / ParallaxImageView.java
Created November 24, 2013 09:31
ParallaxImageView copy from notboringactionbar
package com.flavienlaurent.notboringactionbar;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* Created by f.laurent on 21/11/13.
* antoine-merle.com inspiration
@billynyh
billynyh / bootstrap-cdn.html
Created November 8, 2013 01:07
html template with bootstrap 3.0.2 cdn + jquery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Starter Template for Bootstrap</title>
@billynyh
billynyh / AutoViewPager.java
Created October 30, 2013 08:31
#android AutoViewPager, simply take the children defined in xml as viewpager item [NOT well tested]
public class AutoViewPager extends ViewPager {
public AutoViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public AutoViewPager(Context context) {
super(context);
init();
@billynyh
billynyh / gist:6788951
Created October 2, 2013 03:56
#android CharSequence String SpannableString relation
// CharSequence
String implements CharSequence
SpannableString implements Spannable, CharSequence
SpannableStringBuilder implements Spannable, CharSequence
@billynyh
billynyh / gist:6191512
Created August 9, 2013 06:18
#css textarea 100% width
textarea {
width:100%;
box-sizing: border-box;
}
@billynyh
billynyh / gist:6060003
Created July 23, 2013 05:12
#android screen on without extra permission
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@billynyh
billynyh / gist:5755405
Created June 11, 2013 08:48
not auto focus edit text when launch view
add this in parent view xml
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
or in code
layout.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
layout.setFocusableInTouchMode(true);