Skip to content

Instantly share code, notes, and snippets.

View kobeumut's full-sized avatar
🏠
Working from home

Umut ADALI kobeumut

🏠
Working from home
View GitHub Profile
@kobeumut
kobeumut / UiThreadExample.java
Last active August 25, 2017 07:03
thread that has not called Looper.prepare() Android Error
runOnUiThread(new Runnable() {
public void run() {
//Your code is in here
}
});
@kobeumut
kobeumut / UnabletoAddWindow.java
Created August 11, 2017 08:50
This is a common problem, you can not reach the context first and therefore it is null. What you need to do here is that if you use "ActivityName.this" instead of getApplicationContext(), context etc. your problem will be resolved.
/*
This is a common problem, you can not reach the context first and therefore it is null.
What you need to do here is that if you use "ActivityName.this" instead of getApplicationContext(),
context etc. your problem will be resolved.
*/
//For example Alert Dialog;
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); //Activity name
alertDialog.setMessage("Test Messages");
alertDialog.setPositiveButton("OK", listener);
AlertDialog alert = alertDialog.create();
@kobeumut
kobeumut / MultiDexSample.java
Last active August 25, 2017 07:03
MultiDex Error
android {
...
defaultConfig {
multiDexEnabled true
...
}
}
dependencies {
// add dependency
@kobeumut
kobeumut / hideKeyboard.kt
Created August 21, 2017 07:06
Close opened keyboard on Android programatically
//For Kotlin
val inputManager:InputMethodManager =getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(currentFocus.windowToken, InputMethodManager.SHOW_FORCED)
//For Java
InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED);
@kobeumut
kobeumut / MyServiceClass.kt
Last active August 25, 2017 08:48 — forked from BurakDizlek/MyServiceClass.kt
Retrofit Settings Sample
object MyService {
private val TIMEOUTOFSECOND = 15
private val _instanceOfService: Service by lazy { setupHttpClient() }
fun on(): Service {
return _instanceOfService
}
@kobeumut
kobeumut / CustomAnkoView.kt
Created September 8, 2017 14:21
Add custom or absent view groups to Anko DSL
inline fun ViewManager.lottieAnimationView() = lottieAnimationView {}
inline fun ViewManager.lottieAnimationView(theme: Int = 0, init: LottieAnimationView.() -> Unit) = ankoView({ LottieAnimationView(it) }, theme, init)
//then use it
frameLayout {
lottieAnimationView()
}
@kobeumut
kobeumut / jqueryIframeSelector(contents).js
Created September 9, 2017 12:24
How to select element in iframe, firstly find iframe selector then select your element
//for example my iframe's id is myframe and then write want to element in iframe that my element's name is myTable
$('#myframe').contents().find('#myTable');
//Remove All Empty Columns in the Entire Workbook
function removeEmptyColumns() {
var ss = SpreadsheetApp.getActive();
var allsheets = ss.getSheets();
for (var s in allsheets){
var sheet=allsheets[s]
var maxColumns = sheet.getMaxColumns();
var lastColumn = sheet.getLastColumn();
if (maxColumns-lastColumn != 0){
sheet.deleteColumns(lastColumn+1, maxColumns-lastColumn);
@kobeumut
kobeumut / new_id_increase_sql_query.sql
Created September 29, 2017 06:12
New id field sql query with increasing number.
SET @serial=0;
UPDATE table_name SET new_product_id = @serial := @serial+1
@kobeumut
kobeumut / kotlin-Restriction-Vetoable.kt
Last active October 3, 2017 13:25
if you only want to use within your restriction you use vetoable
//if you only want to use within your restriction you use vetoable
var name by vetoable("adali") { property: KProperty<*>, oldValue, newValue ->
newValue.startsWith("A")
}
name = "umut"
// # : name = "adali" ->because name not startwith S so
name = "Adanalı"
// # : name = "adanali" -> that's it