Skip to content

Instantly share code, notes, and snippets.

View vicky7230's full-sized avatar
🎯
Focusing

Vipin Kumar vicky7230

🎯
Focusing
View GitHub Profile
public class LocationIntentService extends IntentService {
private GoogleApiClient mGoogleApiClient;
public LocationIntentService() {
super(LocationIntentService.class.getName());
}
@Override
protected void onHandleIntent(Intent intent) {
public class GridDividerDecoration extends RecyclerView.ItemDecoration {
private static final int[] ATTRS = {android.R.attr.listDivider};
private Drawable mDivider;
private int mInsets;
public GridDividerDecoration(Context context) {
TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
val subject = PublishSubject.create<String>()
search_edit_text.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
subject.onNext(s.toString())
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun search(subject: PublishSubject<String>) {
compositeDisposable.add(
subject
.debounce(300, TimeUnit.MILLISECONDS)
.filter(Predicate { it: String ->
return@Predicate it.isNotEmpty()
})
.distinctUntilChanged()
.switchMap(Function<String, ObservableSource<Recipes>> { it ->
query = it
public class NoteSyncJob extends Job {
public static final String TAG = "job_note_sync";
@Override
@NonNull
protected Result onRunJob(@NonNull Params params) {
List<Note> notes = AppDatabase.getNotes();
if (notes.size() > 0) {
NoteSyncApi.sync(notes);
public class NoteApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
JobManager.create(this).addJobCreator(new NoteJobCreator());
}
}
public class NoteJobCreator implements JobCreator {
@Override
@Nullable
public Job create(@NonNull String tag) {
switch (tag) {
case NoteSyncJob.TAG:
return new NoteSyncJob();
default:
return null;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
//Schedule Note Syncing
NoteSyncJob.scheduleJob();
}
}
/*
* BottomNavigationLayout library for Android
* Copyright (c) 2016. Nikola Despotoski (http://github.com/NikolaDespotoski).
* 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
@vicky7230
vicky7230 / OnItemSelectedListener.java
Created March 15, 2018 05:21 — forked from andreynovikov/OnItemSelectedListener.java
Complete working solution for Android action bar tabs with fragments having separate back stack for each tab.
// Custom interface that enables communication between Fragment and its Activity
public interface OnItemSelectedListener
{
public void onItemSelected(String item);
}