Skip to content

Instantly share code, notes, and snippets.

View akshay3015's full-sized avatar

akshay shahane akshay3015

View GitHub Profile
@akshay3015
akshay3015 / post-receive.sh
Created March 27, 2021 19:49 — forked from benfrain/post-receive.sh
post-receive hook for multiple branches
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
@akshay3015
akshay3015 / dependency.gradle
Created July 17, 2019 12:02
gradle dependency resolver
//project build.gradle
ext.sharedGroup = {dependencyHandler->
delegate = dependencyHandler
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'io.reactivex:rxjava:1.0.13'
compile 'io.reactivex:rxandroid:0.25.0'
}
@akshay3015
akshay3015 / whyrx.java
Last active March 2, 2019 09:41
Why we should RxJava?
//1) super simple therading.
//Using imperative approach, moving a piece of code to background thread is hard work. However in RxJava, we could easily define what thread each part of the chain would be in.Use subscribeOn() to define the default thread the entire RxJava chain work on. Use observerOn() to define what the bottom chain thread will be work on.
//2) No need to handle button disaple logic.
mBtnDisposable = RxView.clicks(mBtnCreateProfile)
.throttleFirst(2000, TimeUnit.MILLISECONDS)
.subscribe(v -> addTrip());
// throttle first operator this will basically eliminate all button clicks after first for 2000 mili seconds so no more disable and enable button logics.
step one
public interface DrawerLocker {
public void setDrawerEnabled(boolean enabled);
}
step 2
public class MainActivity extends Activity implements DrawerLocker {
private void changeTabsFont(TabLayout tabLayout) {
Typeface font = Typeface.createFromAsset(getContext().getAssets(), "fonts/AvenirLTStd-Medium.otf");
ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
int tabsCount = vg.getChildCount();
for (int j = 0; j < tabsCount; j++) {
ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
int tabChildsCount = vgTab.getChildCount();
for (int i = 0; i < tabChildsCount; i++) {
View tabViewChild = vgTab.getChildAt(i);
if (tabViewChild instanceof TextView) {
https://github.com/theapache64/CCAvenue-Android-Example/tree/master/app/src/main/java/com/avenues/lib/testotpappnew
package com.ingeniouscar.utils;
import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Environment;
public class MainActivity extends AppCompatActivity
implements GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;
PendingResult<LocationSettingsResult> result;
final static int REQUEST_LOCATION = 199;
public class ValContainer<T> {
private T val;
public ValContainer() {
}
public ValContainer(T v) {
this.val = v;
}
@akshay3015
akshay3015 / DialogFragmentCallback.md
Created January 25, 2018 13:39 — forked from Joev-/DialogFragmentCallback.md
Getting results from DialogFragment to calling Fragment using Callbacks

##Getting results from DialogFragments to another Fragment.

When setting up the DialogFragment make a call to Fragment.setTargetFragment()
Then from DialogFragment you can access the main fragment with Fragment.getTargetFragment()
Use interfaces to provide the required actions to the calling Fragment.

##Example code.

###AddFriendDialogFragment - Calls back to calling fragment.