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
if (!TextUtils.isEmpty(mQuery)) { | |
searchItem.expandActionView(); | |
searchView.setQuery(mQuery, false); | |
searchView.clearFocus(); | |
} |
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
MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() { | |
@Override | |
public boolean onMenuItemActionExpand(MenuItem item) { | |
//your code | |
return true; //or false in case you don't want to expand | |
} | |
@Override | |
//Control the behaviour of the {@link SearchView}'s own back button | |
public boolean onMenuItemActionCollapse(MenuItem item) { |
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 static List<Book> getBooksInfoFromJson(String jsonStr) { | |
List<Book> booksList = new ArrayList<>(); | |
if (jsonStr == null || jsonStr.equals("")) { | |
return booksList; | |
} | |
try { | |
JSONObject rootObj = new JSONObject(jsonStr); | |
JSONArray itemsArray = rootObj.getJSONArray("items"); |
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
MyAsynkTask task = new MyAsynkTask(); | |
// Create multiple threads. | |
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, arg1); |
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
final class BitmapUtils { | |
/** | |
* Define a size of the memory available for an LruCache object. | |
*/ | |
private static int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); | |
private static int cacheSize = maxMemory / 8; | |
/** | |
* Create the LruCache object and define its size. |
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
<activity | |
android:windowSoftInputMode="adjustPan"> | |
</activity> |
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 final class QueryUtils { | |
/** | |
* For every known problem with fetching data there is an error code created | |
* which is then used to provide a user with an idea of what's gone wrong | |
*/ | |
static int errorCode; | |
public QueryUtils() { |
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 MainActivity extends AppCompatActivity { | |
String mQuery; | |
... | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
getMenuInflater().inflate(R.menu.options_menu, menu); | |
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); | |
MenuItem searchItem = menu.findItem(R.id.search); |
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
xmlns:tools="http://schemas.android.com/tools" |
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
String dateString = "2017-04-12T05:41:46Z" | |
SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'"); | |
Date convertedDate; | |
String formattedDate = ""; | |
try { | |
convertedDate = sourceFormat.parse(dateString); | |
//will return "12 Apr 2017" | |
formattedDate = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.UK).format(convertedDate); |
OlderNewer