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
/** | |
* Used to find details of an apk file placed on the | |
* device, requirements are location of the file. | |
* PackageInfo gives details like package name, version code, version name .. etc | |
**/ | |
String srcApk = Environment.getExternalStorageDirectory()+"/your.apk"; | |
PackageInfo pf = getPackageManager().getPackageArchiveInfo(srcApk, PackageManager.GET_META_DATA); |
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 NumberPagerAdapter extends PagerAdapter { | |
View v; | |
private LayoutInflater inflater; | |
private Context contxt; | |
private LruCache<String, Bitmap> mMemoryCache; |
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 Bitmap overlay(Bitmap baseBitmap, Bitmap bmp2) { | |
Rect dst = new Rect(); | |
final Bitmap bitmapMan = Bitmap.createBitmap(baseBitmap.getWidth(), | |
baseBitmap.getHeight(), baseBitmap.getConfig()); | |
final Canvas canvas = new Canvas(bitmapMan); | |
canvas.drawBitmap(baseBitmap, new Matrix(), null); | |
dst.set(bitmapMan.getWidth() / 4, bitmapMan.getHeight() / 4, | |
bitmapMan.getWidth() * 3 / 4, bitmapMan.getHeight() * 3 / 4); |
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
Toast t = Toast.makeText(this, "Top left!", Toast.LENGTH_SHORT); | |
t.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0); | |
t.show(); |
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 void onPickBoth(View v) { | |
Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT); | |
pickIntent.setType("image/*"); | |
Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
Intent chooserIntent = Intent.createChooser(pickIntent, | |
getString(R.string.activity_main_pick_both)); | |
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, | |
new Intent[] { takePhotoIntent }); |
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
//root of layout | |
final View view = findViewById(R.id.root); | |
ViewTreeObserver vto = view.getViewTreeObserver(); | |
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { | |
@Override | |
public void onGlobalLayout() { | |
ViewTreeObserver vto = view.getViewTreeObserver(); | |
width = profile_Lin.getWidth(); | |
height = profile_Lin.getHeight(); |
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
// making drawable grey | |
ColorMatrix grayMatrix = new ColorMatrix(); | |
grayMatrix.setSaturation(0); | |
ColorMatrixColorFilter grayscaleFilter = new ColorMatrixColorFilter(grayMatrix); | |
//getting a drawable | |
Drawable d = greyBtn.getBackground(); | |
d.setColorFilter(grayscaleFilter); | |
greyBtn.setBackgroundDrawable(d); |
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
// The gesture threshold expressed in dp | |
private static final float GESTURE_THRESHOLD_DP = 16.0f; | |
// Get the screen's density scale | |
final float scale = getResources().getDisplayMetrics().density; | |
// Convert the dps to pixels, based on density scale | |
mGestureThreshold = (int) (GESTURE_THRESHOLD_DP * scale + 0.5f); | |
// Use mGestureThreshold as a distance in pixels... |
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 void tintAndSetCompoundDrawable (Context context, | |
@DrawableRes int drawableRes, int color, TextView textview) { | |
Resources res = context.getResources(); | |
int padding = (int) res.getDimension( | |
R.dimen.activity_horizontal_margin); | |
Drawable drawable = res.getDrawable(drawableRes); | |
drawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY); |
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
for (int i = 0; i < tabLayout.getTabCount(); i++) { | |
TabLayout.Tab tab = tabLayout.getTabAt(i); | |
RelativeLayout relativeLayout = (RelativeLayout) | |
LayoutInflater.from(this).inflate(R.layout.tab_layout, tabLayout, false); | |
TextView tabTextView = (TextView) relativeLayout.findViewById(R.id.tab_title); | |
tabTextView.setText(tab.getText()); | |
tab.setCustomView(relativeLayout); | |
} |
OlderNewer