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 / CreateMomentFragment.java
Created Sep 3, 2014
Get last clicked image path
View CreateMomentFragment.java
private int getLastImageId() {
final String[] imageColumns = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA};
final String imageOrderBy = MediaStore.Images.Media._ID + " DESC";
Cursor imageCursor = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageColumns, null, null, imageOrderBy);
if (imageCursor.moveToFirst()) {
int id = imageCursor.getInt(imageCursor.getColumnIndex(MediaStore.Images.Media._ID));
String fullPath = imageCursor.getString(imageCursor.getColumnIndex(MediaStore.Images.Media.DATA));
Log.d(TAG, "getLastImageId::id " + id);
Log.d(TAG, "getLastImageId::path " + fullPath);
imageCursor.close();
@laaptu
laaptu / MapsAppDirection.java
Created Aug 1, 2014
Using intent to open maps for direction
View MapsAppDirection.java
//http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr="+latitude_source+","+longitude_source+"&daddr="+latitude_dest+","+longitude_dest));
startActivity(intent);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=an+address+city"));
@laaptu
laaptu / EditTextScrollView.java
Created Jul 28, 2014
Edit Text inside scrollview
View EditTextScrollView.java
//http://stackoverflow.com/questions/13812892/enable-scrollable-edittext-within-a-scrollview-and-viewflipper/13815747#13815747
EditText EtOne = (EditText) findViewById(R.id.EditText01);
EtOne.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.comment1) {
v.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
View EmailIntentWithAttachment.java
Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Payment Information");
emailIntent.putExtra(Intent.EXTRA_TEXT, stringBuilder.toString());
emailIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { emailValue });
ArrayList<Uri> uris = new ArrayList<Uri>();
// convert from paths to Android friendly Parcelable Uri's
Uri uri = null;
@laaptu
laaptu / DialogWIthLinkableText.java
Created Jul 22, 2014
Dialog with linkable text, Dialog having clickable text
View DialogWIthLinkableText.java
final TextView tv = new TextView(this);
final SpannableString s = new SpannableString(response);
Linkify.addLinks(s, Linkify.WEB_URLS);
tv.setText(s);
tv.setMovementMethod(LinkMovementMethod.getInstance());
AlertDialog dialog = new AlertDialog.Builder(this)
.setPositiveButton(android.R.string.ok, null)
.setView(tv).create();
dialog.show();
@laaptu
laaptu / CreditCardValid.java
Created Jul 22, 2014
Check whether a credit card number is valid or not? Valid credit card Number. Luhns algorithm
View CreditCardValid.java
//http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Java
public static boolean isEmptyString(String stringValue) {
return stringValue == null || stringValue.trim().length() == 0;
}
public static boolean isCreditCardValid(String number) {
if (isEmptyString(number))
return false;
int s1 = 0, s2 = 0;
View fireexitfeed.json
[
{
"IsAddedByMe": true,
"IsFavorite": true,
"Latitude": 27.684554,
"LocationAddress": "test",
"LocationId": 6068,
"LocationImgUrl": "http://firesonar.blob.core.windows.net/checkinlocations/test.png",
"LocationName": "test",
"Longitude": 85.333882,
@laaptu
laaptu / ViewPagerCurrentFragment.java
Created Jun 20, 2014
Method to get ViewPager Current Fragment
View ViewPagerCurrentFragment.java
Fragment fragment = (Fragment) mPagerAdapter.instantiateItem(mPager, mPager.getCurrentItem());
@laaptu
laaptu / DialogWithLinkText.java
Created Jun 20, 2014
TextView with autolink or link on a dialog
View DialogWithLinkText.java
final TextView tv = new TextView(this);
final SpannableString s = new SpannableString(result);
Linkify.addLinks(s, Linkify.WEB_URLS);
tv.setText(s);
tv.setMovementMethod(LinkMovementMethod.getInstance());
DialogFragment dg = new DialogFragment() {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
@laaptu
laaptu / DialogFragment.java
Created Jun 20, 2014
Using dialog fragment to show dialog
View DialogFragment.java
DialogFragment dg = new DialogFragment() {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setMessage(R.string.submit_confirm_message)
.setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
/*---THIS IS ADDED EXTRA--------*/
postInfoToServer();
You can’t perform that action at this time.