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
View SomeFragment.java
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
@laaptu
laaptu / HideKeyboard.java
Last active Aug 29, 2015
Hiding soft keyboard programmatically. The view passed should not be null and it doesn't matter that the view is to be the current edittext where there is focus. It can be any view until and unless it is present in the layout
View HideKeyboard.java
public void hideSoftInputKeyBoard(View view) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null && view != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
@laaptu
laaptu / TextViewClickableUnderlineColorChange.java
Last active Aug 29, 2015
How to make a Texview clickable, underline and change color to certain portion
View TextViewClickableUnderlineColorChange.java
//Terms of Service
String tobeClickable = getString(R.string.tos);
int index = getString(R.string.terms_of_service).indexOf(tobeClickable);
int length = index + tobeClickable.length();
//I agree to FireSonar's Terms of Service
Spannable spannableString = new SpannableString(
getString(R.string.terms_of_service));
ClickableSpan clickableSpan = new ClickableSpan() {
View test.json
{
"following": [
{
"name" : "john doe",
"following" : true,
"created_at" : "1 hour ago",
"picture" : "http://i.imgur.com/DA8VXak.jpg"
},
{
"name" : "john doe",
@laaptu
laaptu / BaseEditText.java
Last active Aug 29, 2015
How to apply themes to the Custom Views in Android
View BaseEditText.java
public class BaseEditText extends EditText {
public BaseEditText(Context context) {
this(context, null);
}
public BaseEditText(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public BaseEditText(Context context, AttributeSet attrs, int defStyle) {
@laaptu
laaptu / GetImagePathFromCamera
Created Jun 17, 2014
Method to get image path from Camera Intent
View GetImagePathFromCamera
Cursor cursor = getContentResolver().query(Media.EXTERNAL_CONTENT_URI, new String[]{Media.DATA, Media.DATE_ADDED, MediaStore.Images.ImageColumns.ORIENTATION}, Media.DATE_ADDED, null, "date_added ASC");
if(cursor != null && cursor.moveToFirst())
{
do {
uri = Uri.parse(cursor.getString(cursor.getColumnIndex(Media.DATA)));
photoPath = uri.toString();
}while(cursor.moveToNext());
cursor.close();
}
@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();
@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 / ViewPagerCurrentFragment.java
Created Jun 20, 2014
Method to get ViewPager Current Fragment
View ViewPagerCurrentFragment.java
Fragment fragment = (Fragment) mPagerAdapter.instantiateItem(mPager, mPager.getCurrentItem());
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,
You can’t perform that action at this time.