Skip to content

Instantly share code, notes, and snippets.

View afshin-hoseini's full-sized avatar
🎯
Focusing

Afshin Hoseini afshin-hoseini

🎯
Focusing
View GitHub Profile
@afshin-hoseini
afshin-hoseini / LibLevel_build.gradle
Created February 23, 2017 05:54
How to enable lambda in Android library
// Java8 not fully supported in library projects yet, https://code.google.com/p/android/issues/detail?id=211386
// this is a temporary workaround to get at least lambdas compiling
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"
}
}
@afshin-hoseini
afshin-hoseini / DatabaseManager.java
Last active February 10, 2017 07:40
Reflection methods
/**
*This method searchs for classes of type DatabaseManager and then checks if they have any public static method annotated
*with @createTables. If exists this will invoke them to make tables database.
*/
protected boolean createTables(SQLiteDatabase db, DatabaseType databaseType)
{
boolean success = true;
if(databaseType == DatabaseType.AppDb) {
@afshin-hoseini
afshin-hoseini / Geometry.java
Created February 7, 2017 07:26
Geometry functions
/*
* (C) 2004 - Geotechnical Software Services
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
@afshin-hoseini
afshin-hoseini / Reflection methods in Android
Last active January 7, 2017 05:43
Finding all classes available in an android application.
//To list all methods in android application
public void listAllClasses() {
try {
DexFile df = new DexFile(getPackageCodePath());
for (Enumeration<String> iter = df.entries(); iter.hasMoreElements();) {
String classPath = iter.nextElement();
}
} catch (Exception e) {
@afshin-hoseini
afshin-hoseini / FlingBehavior
Created October 9, 2016 20:12
Fling behavior for appbar and recyclerview
package ir.abrishamapp.abrishamandroidapp.Activities.OrdersLayer.DetailsViewer;
import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@afshin-hoseini
afshin-hoseini / puller.php
Created August 18, 2016 13:52
Git web hook puller
<?php
//______________________________________________
function gitInit() {
$currentDir = getcwd();
@afshin-hoseini
afshin-hoseini / UISearchControllerWithIndicator.swift
Last active February 14, 2016 08:14
A simple UISearchController with an activity indicator at search icon.
//
// UISearchControllerWithIndicator.swift
//
// Created by Afshin Hoseini on 2/10/16.
// https://github.com/afshin-hoseini
//
import Foundation
import UIKit
@afshin-hoseini
afshin-hoseini / CustomBlurView.swift
Created February 13, 2016 06:07
Custom blur view which you can determine blur radius for
//
// APCustomBlurView.swift
// Created by Collin Hundley on 1/15/16.
//
import UIKit
public class APCustomBlurView: UIVisualEffectView {
private let blurEffect: UIBlurEffect