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
| DEBUG = false | |
| def puts(s) | |
| print("@Tool@: ") | |
| super | |
| end | |
| def help |
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
| #For this file, you might execute following codes after update your ignore file. | |
| #git rm -r --cached . | |
| #git add . | |
| *.iml | |
| .gradle | |
| /local.properties | |
| /.idea/workspace.xml | |
| /.idea/libraries | |
| .DS_Store |
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 static int getActionBarHeight(Context cxt) { | |
| int[] abSzAttr; | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | |
| abSzAttr = new int[] { android.R.attr.actionBarSize }; | |
| } else { | |
| abSzAttr = new int[] { R.attr.actionBarSize }; | |
| } | |
| TypedArray a = cxt.obtainStyledAttributes(abSzAttr); | |
| return a.getDimensionPixelSize(0, -1); | |
| } |
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
| @BindingAdapter(value = *arrayOf("imageUris", "errorDrawableRes"), requireAll = false) | |
| @JvmStatic | |
| fun setImage(view: ImageView, imageUris: Array<Uri>?, @DrawableRes errorDrawableRes: Int) { | |
| when (imageUris == null || imageUris.isEmpty()) { | |
| true -> { | |
| when (errorDrawableRes > 0) { | |
| true -> view.setImageResource(errorDrawableRes) | |
| false -> view.setImageBitmap(null) | |
| } | |
| return |
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
| inline fun <reified T : Any, reified E : Any> E.getValueOf(propertyName: String): T? = | |
| E::class.memberProperties | |
| .find { it.name == propertyName } | |
| .apply { | |
| when { | |
| this == null -> throw IllegalArgumentException("Property <$propertyName> not found for class <${T::class}>!") | |
| else -> isAccessible = true | |
| } | |
| } | |
| ?.invoke(this) as T? |
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
| // Usage: | |
| // drawable1.bytesEqualTo(drawable2) | |
| // drawable1.pixelsEqualTo(drawable2) | |
| // bitmap1.bytesEqualTo(bitmap1) | |
| // bitmap1.pixelsEqualTo(bitmap2) | |
| fun <T : Drawable> T.bytesEqualTo(t: T?) = toBitmap().bytesEqualTo(t?.toBitmap(), true) | |
| fun <T : Drawable> T.pixelsEqualTo(t: T?) = toBitmap().pixelsEqualTo(t?.toBitmap(), 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
| private boolean sendRequest() throws Exception | |
| { | |
| URL url = new URL("http://example.com"); | |
| HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection( ); | |
| int statusCode = urlConnection.getResponseCode( ); | |
| return statusCode == 200; | |
| } | |
| public static void setConnectivity( boolean enabled) throws Exception | |
| { |
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
| // For WIFI: Easy | |
| (context.getSystemService(WIFI_SERVICE) as WifiManager).run { | |
| calculateSignalLevel( | |
| connectionInfo.rssi, | |
| netStatusView.strengthLevelCount | |
| ) | |
| } | |
| // Define listener | |
| private val phoneStateEvents by lazy { LISTEN_SERVICE_STATE or LISTEN_SIGNAL_STRENGTHS or LISTEN_DATA_CONNECTION_STATE or LISTEN_DATA_ACTIVITY } |
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
| fun <E : Activity, T : KClass<out E>> T.showSingleTopActivity( | |
| context: E?, | |
| args: Bundle? = null | |
| ) = | |
| context?.run { | |
| with(Intent(this, [email protected])) { | |
| if (args != null) | |
| putExtras(args) | |
| flags = FLAG_ACTIVITY_SINGLE_TOP or FLAG_ACTIVITY_CLEAR_TOP | |
| ActivityCompat.startActivity(this@run, this, EMPTY) |