Skip to content

Instantly share code, notes, and snippets.

View hasankucuk's full-sized avatar

Hasan Küçük hasankucuk

View GitHub Profile
fun Fragment.isGranted(permission: AppPermission) = run {
context?.let {
(PermissionChecker.checkSelfPermission(it, permission.permissionName
) == PermissionChecker.PERMISSION_GRANTED)
} ?: false
}
fun Fragment.shouldShowRationale(permission: AppPermission) = run {
shouldShowRequestPermissionRationale(permission.permissionName)
}
@hasankucuk
hasankucuk / ActivitiesLaunchingWay.kt
Created September 27, 2021 08:48 — forked from wajahatkarim3/ActivitiesLaunchingWay.kt
Kotlin Extensions for simpler, easier and funw way of launching of Activities
/**
* Kotlin Extensions for simpler, easier and funw way
* of launching of Activities
*/
inline fun <reified T : Any> Activity.launchActivity (
requestCode: Int = -1,
options: Bundle? = null,
noinline init: Intent.() -> Unit = {})
{
@hasankucuk
hasankucuk / SwipeEvents.java
Created May 2, 2021 19:23 — forked from bmutinda/SwipeEvents.java
Android swipe events detector
package bmutinda.com.androidutils.libs;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by Mutinda Boniface on 7/5/2015.
*/
public class SwipeEvents implements View.OnTouchListener {
private SwipeCallback swipeCallback;
@hasankucuk
hasankucuk / JsoupOgTagParser.kt
Created April 17, 2021 19:19 — forked from anandwana001/JsoupOgTagParser.kt
Android Kotlin - Extract og tags from website using jsoup
class JsoupOgTagParser(var urlToParse: String) : AsyncTask<Void, Void, Void?>() {
private var title: String? = null
private var desc: String? = null
private var image: String? = null
private var url: String? = null
private var listener: Listener? = null
override fun doInBackground(vararg voids: Void): Void? {
val con = Jsoup.connect(urlToParse)
@hasankucuk
hasankucuk / android_aes_encrpytor.java
Created November 26, 2020 12:52 — forked from sdogruyol/android_aes_encrpytor.java
AES Encryption Singleton Class in Android Using CBC / PKCS7Padding
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
@hasankucuk
hasankucuk / gist:93bc5734a83447139d9da0e343b9c56a
Created August 6, 2020 19:21 — forked from smyykb/gist:c342f332d3c1017373189de7659caba6
Change Author template in Android Studio
You can overwrite the ${USER} variable in the template file with the
#set( $VARIABLE = "value")
function. Go to Settings -> File and Code Templates -> Includes -> File Header prepend the #set() function call, for example:
#set( $USER = "Your name" )
/**
* Created by ${USER} on ${DATE}.
*/
@hasankucuk
hasankucuk / material_design_colors.xml
Created June 23, 2020 19:56
material_design_colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Red -->
<color name="material_red_50">#FFEBEE</color>
<color name="material_red_100">#FFCDD2</color>
<color name="material_red_200">#EF9A9A</color>
<color name="material_red_300">#E57373</color>
<color name="material_red_400">#EF5350</color>
<color name="material_red_500">#F44336</color>
<color name="material_red_600">#E53935</color>
@hasankucuk
hasankucuk / DateUtilsFormatDateTime.java
Created July 4, 2019 06:52 — forked from MizzleDK/DateUtilsFormatDateTime.java
Examples with DateUtils.formatDateTime()
long date = 1407869895000L; // August 12, 2014, 8:58PM
// August 12, 2014 (default)
DateUtils.formatDateTime(this, date, 0);
// Aug 12, 2014 (default with abbreviated month)
DateUtils.formatDateTime(this, date, DateUtils.FORMAT_ABBREV_MONTH);
// August 12 (date without year)
DateUtils.formatDateTime(this, date, DateUtils.FORMAT_NO_YEAR);
@hasankucuk
hasankucuk / KeyboardUtils.java
Created April 30, 2019 10:27 — forked from lopspower/KeyboardUtils.java
Force Hide Keyboard Android
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
public class KeyboardUtils {
public static void hideKeyboard(Activity activity) {
View view = activity.findViewById(android.R.id.content);