This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LocationIntentService extends IntentService { | |
| private GoogleApiClient mGoogleApiClient; | |
| public LocationIntentService() { | |
| super(LocationIntentService.class.getName()); | |
| } | |
| @Override | |
| protected void onHandleIntent(Intent intent) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class NoteApplication extends Application { | |
| @Override | |
| public void onCreate() { | |
| super.onCreate(); | |
| JobManager.create(this).addJobCreator(new NoteJobCreator()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class NoteJobCreator implements JobCreator { | |
| @Override | |
| @Nullable | |
| public Job create(@NonNull String tag) { | |
| switch (tag) { | |
| case NoteSyncJob.TAG: | |
| return new NoteSyncJob(); | |
| default: | |
| return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MainActivity extends AppCompatActivity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_about); | |
| //Schedule Note Syncing | |
| NoteSyncJob.scheduleJob(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Custom interface that enables communication between Fragment and its Activity | |
| public interface OnItemSelectedListener | |
| { | |
| public void onItemSelected(String item); | |
| } |