Skip to content

Instantly share code, notes, and snippets.

Cüneyt AYYILDIZ Swisyn

View GitHub Profile
View WKWebView_tel_sms_mailto_tags_and_appstore_connection.swift
func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
let url = navigationAction.request.URL?.absoluteString
let hostAddress = navigationAction.request.URL?.host
// To connnect app store
if hostAddress == "itunes.apple.com" {
if UIApplication.sharedApplication().canOpenURL(navigationAction.request.URL!) {
@Swisyn
Swisyn / SimpleClient.swift
Created Jun 30, 2018 — forked from sarpsolakoglu/SimpleClient.swift
Simple Swift 4 Rest Client that uses the Codable protocol for JSON conversion
View SimpleClient.swift
//
// SimpleClient.swift
//
// Created by Sarp Solakoglu on 18/09/2017.
// Copyright © 2017 Sarp Solakoglu. All rights reserved.
//
import Foundation
enum RestMethod: String {
@Swisyn
Swisyn / GagSsl.java
Created May 10, 2018 — forked from mefarazath/GagSsl.java
Get OkHttpClient which ignores all SSL errors.
View GagSsl.java
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
String authType) throws CertificateException {
}
@Swisyn
Swisyn / Connectivity.java
Created Apr 28, 2018 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed.
View Connectivity.java
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@Swisyn
Swisyn / Locator.java
Created Apr 28, 2018 — forked from emil2k/Locator.java
Android utility class for getting device location using various methods. Depends on `Connectivity` class found here: https://gist.github.com/emil2k/5130324
View Locator.java
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@Swisyn
Swisyn / README.md
Created Feb 26, 2018 — forked from lopspower/README.md
Hexadecimal color code for transparency
View README.md

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@Swisyn
Swisyn / build.gradle
Created Feb 8, 2018 — forked from dzungpv/build.gradle
Gradle obfuscate string
View build.gradle
apply from: "$rootDir/utils.gradle"
android {
defaultConfig {
buildConfigField 'String', 'SECRET_KEY', toJavaCodeString(SECRET_KEY)
}
}
@Swisyn
Swisyn / InstagramLikeColorTransition.txt
Created Jan 16, 2018 — forked from deepak786/InstagramLikeColorTransition.txt
Instagram Like Gradient Color Transition in Android
View InstagramLikeColorTransition.txt
/******This Gist explains how to create instagram like Gradient color transition in android.******/
1. Create some gradient color drawables inside drawable Folder.
a) color1.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#c44e4e"
android:endColor="#dcb9b9"
android:angle="0"/>
@Swisyn
Swisyn / functions.java
Created Dec 23, 2017
check whether application is working in background
View functions.java
public static boolean isAppIsInBackground(Context context) {
boolean isInBackground = true;
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {
if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
for (String activeProcess : processInfo.pkgList) {
if (activeProcess.equals(context.getPackageName())) {
isInBackground = false;
@Swisyn
Swisyn / functions.java
Created Dec 23, 2017
get time as milliseconds from string date
View functions.java
public static long getTimeMilliSec(String timeStamp) {
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.getDefault());
try {
Date date = format.parse(timeStamp);
return date.getTime();
} catch (ParseException e) {
e.printStackTrace();
}
return 0;
}
You can’t perform that action at this time.