Skip to content

Instantly share code, notes, and snippets.

View thanhit93's full-sized avatar
🎯
Focusing

Thanh Truong thanhit93

🎯
Focusing
View GitHub Profile
@thanhit93
thanhit93 / genymotionwithplay.txt
Created December 2, 2016 15:46 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
public static void expand(final View v) {
v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
// Older versions of android (pre API 21) cancel animations for views with a height of 0.
v.getLayoutParams().height = 1;
v.setVisibility(View.VISIBLE);
Animation a = new Animation()
{
@Override
http://stackoverflow.com/questions/7263291/viewpager-pageradapter-not-updating-the-view
There are several ways to achieve this.
The first option is easier, but bit more inefficient.
Override getItemPosition in your PagerAdapter like this:
public String getDeviceName() {
String manufacturer = Build.MANUFACTURER;
String model = Build.MODEL;
if (model.startsWith(manufacturer)) {
return capitalize(model);
} else {
return capitalize(manufacturer) + " " + model;
}
source: https://www.tenforums.com/tutorials/49586-windows-license-type-determine-if-oem-retail-volume.html
Open Command Prompt: type slmgr -dli
http://www.makeuseof.com/tag/everything-know-windows-product-keys/
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
if (scrollView != null) {
if (scrollView.getChildAt(0).getBottom() <= (scrollView.getHeight() + scrollView.getScrollY())) {
//scroll view is at bottom
} else {
//scroll view is not at bottom
}
}
WindowManager mgr = (WindowManager) getSystemService(WINDOW_SERVICE);
boolean hasSoftKey = Utils.hasSoftKeys(mgr, NPTApplication.this);
public static boolean hasSoftKeys(WindowManager windowManager, Context c) {
boolean hasSoftwareKeys = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Display d = windowManager.getDefaultDisplay();
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
@thanhit93
thanhit93 / gist:954435928f511dff3f51753a9065d90f
Created July 13, 2018 16:20
swipe-to-dismiss-for-recyclerview
As of v27.0, the Android support team has included an ItemTouchHelper class that makes swipe-to-dismiss and drag-and-drop pretty simple. This may not be as full-featured as some of the libraries out there, but it comes directly from the Android team.
Update your build.gradle to import v27.+ of the RecyclerView library
compile 'com.android.support:recyclerview-v7:27.+'
Instantiate an ItemTouchHelper with an appropriate SimpleCallback
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
[...]
@Override
@thanhit93
thanhit93 / Note
Created July 21, 2018 02:48
AppBar Layout
It doesn't look like there's anything in the APIs, but the following seems to be working for me. It might need testing.
boolean fullyExpanded =
(appBarLayout.getHeight() - appBarLayout.getBottom()) == 0;
Edit: The above solution does seem to work, but since I wanted to test this condition when the appbar was scrolled, I ended up using the following solution with OnOffsetChangedListener.
class Frag extends Fragment implements AppBarLayout.OnOffsetChangedListener {
private boolean appBarIsExpanded = true;
private AppBarLayout appBarLayout;
@thanhit93
thanhit93 / terminal
Created April 7, 2019 12:54 — forked from FreddyPoly/terminal
[REACT NATIVE] Get SHA1
Debug SHA1 (root of project)
keytool -J-Duser.language=en -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Release SHA1 (/android/app/)
keytool -J-Duser.language=en -list -v -keystore mystore.keystore