Skip to content

Instantly share code, notes, and snippets.

View bangarharshit's full-sized avatar

Harshit Bangar bangarharshit

  • Twitter
View GitHub Profile
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment_chatlist, menu);
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
inboxMenuItem = menu.findItem(R.id.menu_search);
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_search"
app:showAsAction="always"
android:title="@string/search"
/>
###
### ejabberd configuration file
###
###
### The parameters used in this configuration file are explained in more detail
### in the ejabberd Installation and Operation Guide.
### Please consult the Guide in case of doubts, it is included with
### your copy of ejabberd, and is also available online at
### http://www.process-one.net/en/ejabberd/docs/
@bangarharshit
bangarharshit / build-erlang-17.0.sh
Created November 20, 2015 12:31 — forked from bryanhunter/build-erlang-17.0.sh
Build Erlang 17.0 on a fresh Ubuntu box (tested on 12.04 and 14.04)
#!/bin/bash
# Pull this file down, make it executable and run it with sudo
# wget https://gist.githubusercontent.com/bryanhunter/10380945/raw/build-erlang-17.0.sh
# chmod u+x build-erlang-17.0.sh
# sudo ./build-erlang-17.0.sh
if [ $(id -u) != "0" ]; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
/*
* The code is taken from ProjectMaxs. For details please look - https://github.com/ProjectMAXS/maxs/blob/73043374fa4ec0ce0d881bb8d42a241ef80fa9eb/transport-xmpp/src/org/projectmaxs/transport/xmpp/xmppservice/XMPPService.java
*/
final Roster roster = Roster.getInstanceFor(connection);
// Setup the roster store
File rosterStoreDirectory = FileUtil.getFileDir(mContext, "rosterStore");
RosterStore rosterStore = DirectoryRosterStore.init(rosterStoreDirectory);
roster.setRosterStore(rosterStore);
/*
* The code is taken from ProjectMaxs. For details please look - https://github.com/ProjectMAXS/maxs/blob/73043374fa4ec0ce0d881bb8d42a241ef80fa9eb/transport-xmpp/src/org/projectmaxs/transport/xmpp/xmppservice/XMPPService.java
*/
xmppConnection.addStanzaAcknowledgedListener(new StanzaListener() {
@Override
public void processPacket(Stanza packet) throws SmackException.NotConnectedException, InterruptedException {
removePacket(packet.getStanzaId());
}
});
public class ApplicationLifeCycleHandler implements Application.ActivityLifecycleCallbacks {
// Using the approach defined here - http://steveliles.github.io/is_my_android_app_currently_foreground_or_background.html
public interface Listener {
public void onBecameForeground();
public void onBecameBackground();
}
public class ClienStateIndicationListener implements Listener {
XMPPConnection xmppConnection;
import android.text.TextUtils;
import io.realm.Case;
import io.realm.Realm;
import io.realm.RealmObject;
import io.realm.RealmResults;
public class RealmFullTextSearch {
public static <T extends RealmObject> RealmResults<T> search(Realm realm, Class<T> modelClass, String query, String fieldName, boolean partialSearch){
import rx.Subscriber;
/**
* Created by harshitbangar on 19/08/16.
*/
public class MainClass {
public static void main(String[] args) {
QueueLibraryManager queueLibraryManager = new QueueLibraryManager();
queueLibraryManager.addToQueue("arbit").subscribe(new TestSubscriber());