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 int dpToPx(Context context, int dp) { | |
Resources r = context.getResources(); | |
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); | |
return (int) px; | |
} | |
public static int pxToDp(Context context, int px) { | |
final float scale = context.getResources().getDisplayMetrics().density; | |
int dp = (int) (px * scale + 0.5f); | |
return dp; |
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 Drawable resize(Resources r, Drawable image, int newSize) { | |
Bitmap b = ((BitmapDrawable)image).getBitmap(); | |
Bitmap bitmapResized = Bitmap.createScaledBitmap(b, newSize, newSize, false); | |
BitmapDrawable drawableBmp = new BitmapDrawable(r, bitmapResized); | |
return drawableBmp; | |
} |
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.annotation.TargetApi; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.os.Build; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.ViewGroup; |
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
package com.alimuzaffar.android.handlertest; | |
import java.lang.ref.WeakReference; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.Message; | |
import android.view.Menu; | |
import android.view.View; |
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.content.Context; | |
import android.content.res.TypedArray; | |
import android.text.TextUtils; | |
import android.util.AttributeSet; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewTreeObserver; | |
import android.view.ViewTreeObserver.OnGlobalLayoutListener; | |
import android.widget.FrameLayout; | |
import android.widget.TextView; |
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 CameraMicPermissionHelper extends Fragment { | |
private static final int REQUEST_CAMERA_MIC_PERMISSIONS = 10; | |
public static final String TAG = "CamMicPerm"; | |
private CameraMicPermissionCallback mCallback; | |
private static boolean sCameraMicPermissionDenied; | |
public static CameraMicPermissionHelper newInstance() { | |
return new CameraMicPermissionHelper(); | |
} |
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
/* | |
* Copyright 2012 Roman Nurik | |
* | |
* 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 |
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 ArrayList<View> getViewsByTag(ViewGroup root, String tag) { | |
ArrayList<View> views = new ArrayList<View>(); | |
final int childCount = root.getChildCount(); | |
for (int i = 0; i < childCount; i++) { | |
final View child = root.getChildAt(i); | |
if (child instanceof ViewGroup) { | |
views.addAll(getViewsByTag((ViewGroup) child, tag)); | |
} | |
final Object tagObj = child.getTag(); |
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
100% — FF | |
95% — F2 | |
90% — E6 | |
85% — D9 | |
80% — CC | |
75% — BF | |
70% — B3 | |
65% — A6 | |
60% — 99 | |
55% — 8C |
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
HttpClient client = sslHttpStack.getmHttpClient(); | |
HttpEntityEnclosingRequestBase entityRequest; | |
entityRequest = new HttpPost("http://my-server.com.au/my-api/customer/data"); | |
MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); | |
entityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); | |
entityBuilder.addTextBody("someparameter", params.toString()); //params in this case is a JSONObject | |
String uniqueListingId = "images_to_upload"; //used to name any images being uploaded | |
int count = 0; |