This file contains hidden or 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
| /** | |
| * this class creates a thumbnail url of a youtube video using its url | |
| * | |
| * supports the below link formats: | |
| * => the original format of the youtube url e.g. https://www.youtube.com/watch?v=<watchId>&feature=youtu.be | |
| * => the shortcut format of the youtube url e.g. https://youtu.be/<watchId> | |
| */ | |
| public class ThumbnailUrlExtractor { | |
| private static final String LINK_FORMAT_1 = "watch?v="; |
This file contains hidden or 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 static void hideKeyboard(Activity activity) { | |
| InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); | |
| View view = activity.getCurrentFocus(); | |
| if (view == null) { | |
| view = new View(activity); | |
| } | |
| if (inputMethodManager != null){ |
This file contains hidden or 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
| //This line will select n row starting from top | |
| listview.setSelectionFromTop(n, 0); |
This file contains hidden or 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
| boolean value = cursor.getInt(boolean_column_index) > 0; |
This file contains hidden or 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
| //If you are using an ActionBarActivity then you can tell Android to use the Toolbar as the ActionBar like so: | |
| Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); | |
| setSupportActionBar(toolbar); | |
| //And now to make sure that the back arrow is gonna show | |
| getSupportActionBar().setDisplayHomeAsUpEnabled(true); //or for fragments //((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); | |
| getSupportActionBar().setDisplayShowHomeEnabled(true); //or for fragments //((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(true); |
This file contains hidden or 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
| <!-- considering that we need 2 lines at most --> | |
| android:maxLines="2" | |
| android:ellipsize="end" |
This file contains hidden or 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
| <!-- considering that we need 2 lines at most --> | |
| android:maxLines="2" | |
| android:ellipsize="end" |
This file contains hidden or 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
| Display display = getWindowManager().getDefaultDisplay(); | |
| Point size = new Point(); //we're using this because the display.getWidth() is deprecated | |
| display.getSize(size); | |
| int viewWidth = size.x / 2; | |
| int viewHeight = size.y / 3; | |
| View ourView = findViewById(R.id.our_view_id); |
This file contains hidden or 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
| view.setEnabled(false); | |
| view.setOnClickListener(null); |
This file contains hidden or 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 MyApplication extends Application { | |
| private static Context context; | |
| public void onCreate() { | |
| super.onCreate(); | |
| MyApplication.context = getApplicationContext(); | |
| } | |
| public static Context getAppContext() { |
NewerOlder