Skip to content

Instantly share code, notes, and snippets.

View bangarharshit's full-sized avatar

Harshit Bangar bangarharshit

  • Twitter
View GitHub Profile
onView(withId(R.id.my_view))
onView(allOf(withId(R.id.my_view), withText("Hello!")))
onView(allOf(withId(R.id.my_view), not(withText("Unwanted"))))
package com.drawers.myapplication;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.util.AttributeSet;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import rx.Observable;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created by harshitbangar on 19/08/16.
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());
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){
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;
/*
* 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());
}
});
/*
* 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);
@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
###
### 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/