Skip to content

Instantly share code, notes, and snippets.

View gauravrai1's full-sized avatar

Gaurav Rai gauravrai1

View GitHub Profile
@gauravrai1
gauravrai1 / ExampleRVAdapter.kt
Created May 14, 2021 11:07
Recycler View Template
class ExampleRVAdapter(
var data: List<String>? = null,
val context: Context? = null):
RecyclerView.Adapter<ExampleRVAdapter.ViewHolder>() {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): ViewHolder {
val view = LayoutInflater.from(parent.context)
@gauravrai1
gauravrai1 / FileToGetDataIn.kt
Created June 7, 2020 16:52
Example of passing data using Interface in Android (Kotlin)
class FileToGetDataIn extends Activity, cat{
lateinit var mahInterface: cat;
override fun onCreate() {
// Pass as intentt
FileToPassDataFrom().apply(this.setCatInterface(this@FileToPassDataFrom)
}
@gauravrai1
gauravrai1 / button_animator_state.xml
Created December 2, 2019 13:21
Gist for implementing elevation change when button is pressed.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true">
<set>
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueFrom="3dp"
android:valueTo="0dp"
android:valueType="floatType" />
public class Request {
String city;
String address;
String vacancy;
String department;
@gauravrai1
gauravrai1 / Home.java
Created January 26, 2018 11:56
Interface for fragment
package ctize.connectplus.com.communitize;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@gauravrai1
gauravrai1 / Home.Java
Created January 24, 2018 13:56
Interface
private listner = Update_Interface;
onCreate(){
Fragment f = getActivity().getFragmentManager().findFragmentById(R.id.fragment_update);
setListner((Update_fragment) f);
}
public void post_data(View view) {
String timeStamp = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) + "";
long posttime = Long.parseLong( list_items.getTime());
long nowtime = Long.parseLong(timeStamp);
long diff = nowtime - posttime;
int diffe = (int) diff;
@gauravrai1
gauravrai1 / haversini.php
Created August 9, 2017 19:01
haversini formula - PHP working
<?php
function getDistance($latitude1, $longitude1, $latitude2, $longitude2) {
$earth_radius = 6371;
$distanceLat = deg2rad($latitude2 - $latitude1);
$distanceLon = deg2rad($longitude2 - $longitude1);
//part1 of the formula
@gauravrai1
gauravrai1 / java file
Last active July 27, 2017 04:05
Snippet for AutoCompleteView (Android)
String[] cities = { "Mumbai","Chennai","Delhi","Banglore","Kolkata","Nagpur","Pune","Nashik","Ahemdabad","Vadodara","Kochin"};
ArrayAdapter<String> adaptercity = new ArrayAdapter<String>(this,android.R.layout.select_dialog_singlechoice, cities); //pass our array of string
AutoCompleteTextView acTextViewcity = (AutoCompleteTextView) findViewById(R.id.city);//initialize your view
acTextViewcity.setThreshold(1);//set the number of element to be choosen
acTextViewcity.setAdapter(adaptercity); //set the array within the adapter here
@gauravrai1
gauravrai1 / GPSTracker.java
Created July 22, 2017 08:54
This JAVA Class Helps The Users To Determine Their Current Location Easily, Efficiently & Hassle-Free.
/*
FEATURES:
- One Line Implementation
- Simple Calls To Retreive Latitude & Longitude In DOUBLE Format
- Simple Calls To Retreive Latitude & Longitude In STRING Format