Skip to content

Instantly share code, notes, and snippets.

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

Simone Mapelli nadar71

🏠
Working from home
View GitHub Profile
@nadar71
nadar71 / longPress.java
Last active January 23, 2019 10:01
Set position in a map by long pressing. Used in Android, google maps v2.
// set position by long press
mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng latLng) {
// First check if myMarker is null
if (myManualPositionMarker == null) {
// Marker was not set yet. Add marker:
myManualPositionMarker = mMap.addMarker(new MarkerOptions()
.position(latLng)
.title("My positions")
@nadar71
nadar71 / UserLocation_using_FusedLocationApi.java
Last active January 23, 2019 10:05
Map use location with marker activity, one with deprecated FusedLocationApi, the other updated using FusedLocationProviderClient. Requesting permissions template. Got from here : https://stackoverflow.com/questions/34582370/how-can-i-show-current-location-on-a-google-map-on-android-marshmallow/34582595#34582595. Checked only the second with vali…
import android.Manifest;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
@nadar71
nadar71 / MapLocationActivity_deprecated.java
Created January 22, 2019 14:43
Map use location with marker activity, one with deprecated FusedLocationApi, the other updated.
public class MapLocationActivity extends AppCompatActivity
implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener {
GoogleMap mGoogleMap;
SupportMapFragment mapFrag;
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;
@nadar71
nadar71 / banner.lua
Created February 4, 2017 15:53 — forked from revmob-sdk/banner.lua
RevMob Corona SDK
-- You may add this code in the main.lua file
require 'revmob'
local REVMOB_IDS = { ["Android"] = "Android App Id", ["iPhone OS"] = "IPhone OS App Id" }
RevMob.startSession(REVMOB_IDS)
local banner = RevMob.createBanner({x = display.contentWidth / 2, y = display.contentHeight - 20, width = 300, height = 40 })
-- You can also register listeners for Ad events:
revmobListener = function (event)
local targetDevice = ( system.getInfo( "model" ) )
local isTall = ( "iPhone" == system.getInfo( "model" ) ) and ( display.pixelHeight > 960 )
if isTall == false and targetDevice == "iPhone" then
application =
{
content =
{
width = 320,
height = 480,
@nadar71
nadar71 / line_intersection.lua
Created January 26, 2017 13:34 — forked from CoronaSDK/line_intersection.lua
Intersection of 2 lines for a Corona SDK Application
function intersection(p11,p12,p21,p22)
local Z = (p12.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p12.x-p11.x);
local Ca = (p12.y-p11.y)*(p21.x-p11.x)-(p21.y-p11.y)*(p12.x-p11.x);
local Cb = (p21.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p21.x-p11.x);
if Z == 0 and Ca == 0 and Cb == 0 then return nil end
if Z == 0 then return nil end
@nadar71
nadar71 / corona-custom.lua
Created January 26, 2017 13:33 — forked from PeterDwyer/corona-custom.lua
Texturepacker template for Corona to add support for sequencedata, based on the folder structure.
-- created with TexturePacker (http://www.codeandweb.com/texturepacker)
--
-- {{smartUpdateKey}}
--
-- local sheetInfo = require("mysheet")
-- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() )
-- local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite")}} )
--
{% load filter %}
@nadar71
nadar71 / coronasdk-rating.lua
Created January 26, 2017 13:32 — forked from cjanis/coronasdk-rating.lua
Corona SDK Rating Prompt
-- show rating prompt
local function ratingPrompt()
local function ask()
local function answer(event)
if ("clicked" == event.action) then
if (event.index == 1) then
system.openURL("http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=440754678")
data.rated = "yes"
writeData()
elseif (event.index == 2) then
@nadar71
nadar71 / unzip_folder.lua
Created January 26, 2017 13:32 — forked from peter-mach/unzip_folder.lua
Unzipping the compressed folder with CoronaSDK zip plugin
local zip = require 'plugin.zip'
local zipFileName = 'zippedFolder.zip'
local function unzipListener( event )
print('unzipping complete')
end
local unzipOptions = {
zipFile = event.response.fileName,
zipBaseDir = system.TemporaryDirectory,
@nadar71
nadar71 / FuncDelegate.lua
Created January 26, 2017 13:29 — forked from erinlin/FuncDelegate.lua
[CoronaSDK/Lua] Function Delegate
-------------------------------------
-- function delegate
-- Author: Erin Lin
-- www.erinylin.com
-- 簡易模擬 C# delegate
-- licensed under the MIT license.
-- 2015, 02
-------------------------------------
--[[
Usage1: