Skip to content

Instantly share code, notes, and snippets.

Kshitij Aggarwal funkyidol

View GitHub Profile
@funkyidol
funkyidol / applozic.d.ts
Last active Nov 20, 2017
Applozic Web chat Integration
View applozic.d.ts
interface AppLozicStatic {
initPlugin(): any;
}
declare var AppLozic : AppLozicStatic;
export = AppLozic;
View LoginPresenter.java
package com.sample.medicalconferenceapp.login;
import android.text.TextUtils;
import com.sample.medicalconferenceapp.R;
import com.sample.medicalconferenceapp.login.LoginContract.Presenter;
import com.sample.medicalconferenceapp.model.UserRepo;
import com.sample.medicalconferenceapp.model.pojo.UserPojo;
/**
@funkyidol
funkyidol / RealmHelper.java
Created Mar 21, 2016
RealmHelper class to create a singular place for handling Realm instances
View RealmHelper.java
public class RealmHelper {
private static RealmConfiguration config;
private static Realm realmInstance;
public static Realm getWriteInstance(Context context) {
if (realmInstance == null || realmInstance.isClosed()) {
// TODO: 15/10/15 Update the code to use Realm.isClosed()
realmInstance = getInstance(context);
View FacebookLoginActivity.java
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.facebook.AppEventsLogger;
import com.facebook.Session;
import com.facebook.SessionState;
@funkyidol
funkyidol / DateTime.java
Created Oct 3, 2013
Date/Time formatter
View DateTime.java
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
//get current date time with Calendar()
Calendar cal = Calendar.getInstance();
System.out.println(dateFormat.format(cal.getTime()));
@funkyidol
funkyidol / ReadFile.java
Created Oct 3, 2013
Read small files from storage
View ReadFile.java
BufferedReader br = new BufferedReader(new FileReader("file.txt"));
try {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append('\n');
line = br.readLine();
}
@funkyidol
funkyidol / PeriodicStartService.java
Last active Dec 24, 2015
Starting Service at specific intervals controlled using AlarmManager
View PeriodicStartService.java
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(this, MyService.class);
PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
// Start every 30 seconds
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30*1000, pintent);
You can’t perform that action at this time.