This file contains 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
@Override | |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
int height = 0; | |
for(int i = 0; i < getChildCount(); i++) { | |
View child = getChildAt(i); | |
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); | |
int h = child.getMeasuredHeight(); | |
if(h > height) height = h; | |
} |
This file contains 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 printInsides(Object object) { | |
StringBuilder result = new StringBuilder(); | |
String newLine = "\n"; | |
result.append( object.getClass().getName() ); | |
result.append( " Object { " ); | |
result.append(newLine); | |
//determine fields declared in this class only (no fields of superclass) | |
Field[] fields = object.getClass().getDeclaredFields(); |
This file contains 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
import android.graphics.Rect; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
/** | |
* Created by markhetherington on 15-08-17. | |
*/ | |
public class SpacesItemDecoration extends RecyclerView.ItemDecoration { | |
private int halfSpace; |
This file contains 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 Bitmap addGradient(Bitmap src, @ColorInt int start, @ColorInt int end, int alpha) { | |
int w = src.getWidth(); | |
int h = src.getHeight(); | |
Bitmap overlay = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); | |
Canvas canvas = new Canvas(overlay); | |
canvas.drawBitmap(src, 0, 0, null); | |
Paint paint = new Paint(); | |
LinearGradient shader = new LinearGradient(0, 0, 0, h, start, end, Shader.TileMode.CLAMP); |
This file contains 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 final Log logger = LogFactory.getLog(getClass()); | |
public void given_i_need_a_github_name() { | |
List<String> names = getNamePerms(6); | |
for (String name : names) { | |
System.out.print('.'); | |
RestTemplate restTemplate = new RestTemplate(); | |
String url = "http://github.com/" + name; | |
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, null, String.class); | |
if (response.hasBody() && response.getBody().contains("This is not the web page you are looking for")) { |
This file contains 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
#import "UILabel+HTML.h" | |
@implementation UILabel (HTML) | |
- (void) setHtml: (NSString*) html | |
{ | |
// Add font from label | |
NSString* finalHtml = [html stringByAppendingString:[NSString stringWithFormat:@"<style>body{font-family: '%@'; font-size:%fpx;}</style>", | |
self.font.fontName, | |
self.font.pointSize]]; |
This file contains 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 class WindowUtils { | |
public static int getActionBarHeight(Context context) { | |
final TypedArray styledAttributes = context.getTheme().obtainStyledAttributes( | |
new int[]{R.attr.actionBarSize}); | |
int actionBarHeight = (int) styledAttributes.getDimension(0, 0); | |
styledAttributes.recycle(); | |
return actionBarHeight; | |
} |
This file contains 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
/** | |
* Implementation of {@link OnClickListener} that ignores subsequent clicks that happen too quickly after the first one.<br/> | |
* To use this class, implement {@link #onSingleClick(View)} instead of {@link OnClickListener#onClick(View)}. | |
*/ | |
public abstract class OnSingleClickListener implements OnClickListener { | |
private static final String TAG = OnSingleClickListener.class.getSimpleName(); | |
private static final long MIN_DELAY_MS = 500; | |
private long mLastClickTime; |
This file contains 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
import os, sys | |
if len(sys.argv) < 4: | |
print "Family you need 3 params, originalFolder, newResFolder, fileName" | |
else: | |
orginalResFolder = sys.argv[1] | |
newResFolder = sys.argv[2] | |
fileNames = sys.argv[3:] | |
print "files to move " + str(fileNames) |
This file contains 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
TwitterServiceBuilder.getTwitterService().search("test").enqueue(new Callback<ResponseBody>() { | |
@Override | |
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { | |
Toast.makeText(TwitterActivity.this, response.toString(), Toast.LENGTH_LONG).show(); | |
} | |
@Override | |
public void onFailure(Call<ResponseBody> call, Throwable t) { | |
Toast.makeText(TwitterActivity.this, t.toString(), Toast.LENGTH_LONG).show(); | |
} |
OlderNewer