Skip to content

Instantly share code, notes, and snippets.

View abdul-rehman-2050's full-sized avatar
🎯
Focusing

Abdul Rehman abdul-rehman-2050

🎯
Focusing
View GitHub Profile
@abdul-rehman-2050
abdul-rehman-2050 / Raspberry Pi Ultrasonic HC-SR04
Created January 12, 2018 16:56 — forked from shahrulnizam/Raspberry Pi Ultrasonic HC-SR04
Raspberry Pi Lesson: Ultrasonic HC-SR04
import RPi.GPIO as GPIO
import time
TRIG = 24
ECHO = 23
GPIO.setmode(GPIO.BCM)
GPIO.setup(TRIG,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)
@abdul-rehman-2050
abdul-rehman-2050 / listDialog.kt
Created December 13, 2017 19:37
creating alert dialog with ArrayList<String>
fun showDialogWithList(arrayList: ArrayList<String>){
val builderSingle = AlertDialog.Builder(this@MainActivity)
builderSingle.setIcon(R.mipmap.ic_launcher_foreground)
builderSingle.setTitle("Select One Name:-")
builderSingle.setNegativeButton("cancel") { dialog, which -> dialog.dismiss() }
val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, arrayList)
builderSingle.setAdapter(adapter) { dialog, which ->
val strName = adapter.getItem(which)
val builderInner = AlertDialog.Builder(this@MainActivity)
builderInner.setMessage(strName)
@abdul-rehman-2050
abdul-rehman-2050 / main_menu.xml
Created December 12, 2017 19:46
Creating Option menu in Android Kotlin
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/mm_signout"
android:icon="@drawable/ic_exit_to_app_black_24dp"
android:title="SignOut"
app:showAsAction="ifRoom" />
<item android:id="@+id/help"
android:icon="@drawable/ic_help_outline_black_24dp"
android:title="Help" />
#include <Average.h>
#define WINDOW_SIZE 30
#define IR_REC_PIN A0
int ref_val = 0;
Average<int> an_buff(30);
int calibrate()
{
fun whatsApp() {
val smsNumber = "923224522526"
val isWhatsappInstalled = whatsappInstalledOrNot("com.whatsapp")
if (isWhatsappInstalled) {
val sendIntent = Intent("android.intent.action.MAIN")
sendIntent.component = ComponentName("com.whatsapp", "com.whatsapp.Conversation")
sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators(smsNumber) + "@s.whatsapp.net")//phone number without "+" prefix
sendIntent.putExtra(Intent.EXTRA_TEXT, "dummy text from app");
package com.bluetooth.home.auto;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.util.UUID;
import android.os.Build;
package pl.kpob.utils.extensions
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.support.v4.content.ContextCompat
import android.view.WindowManager
import flow.Flow
import org.jetbrains.anko.AlertDialogBuilder
import pl.sisms.gminformix.utils.extensions.supportsLollipop
@abdul-rehman-2050
abdul-rehman-2050 / botomNavigationView.kt
Last active November 16, 2017 11:01
creating botom navigation bar
private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
when (item.itemId) {
R.id.navigation_home -> {
message.setText(R.string.title_home)
return@OnNavigationItemSelectedListener true
}
R.id.navigation_dashboard -> {
message.setText(R.string.title_dashboard)
return@OnNavigationItemSelectedListener true
}
package com.a2050.rehman.abdul.dialogtest
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_main.*
import android.content.DialogInterface
import android.R.array
LayoutInflater factory = LayoutInflater.from(this);
final View deleteDialogView = factory.inflate(R.layout.mylayout, null);
final AlertDialog deleteDialog = new AlertDialog.Builder(this).create();
deleteDialog.setView(deleteDialogView);
deleteDialogView.findViewById(R.id.yes).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//your business logic
deleteDialog.dismiss();
}