Skip to content

Instantly share code, notes, and snippets.

🤙
Forever coding

Mitch Tabian mitchtabian

🤙
Forever coding
Block or report user

Report or block mitchtabian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mitchtabian
mitchtabian / GoogleMaps.java
Created Sep 26, 2018
Launch Google maps app and get directions
View GoogleMaps.java
String latitude = String.valueOf(49.08);
String longitude = String.valueOf(122.45);
Uri gmmIntentUri = Uri.parse("google.navigation:q=" + latitude + "," + longitude);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
try{
if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(mapIntent);
}
View fragment_user_list.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
View MainActivity.java
private boolean checkMapServices(){
if(isServicesOK()){
if(isMapsEnabled()){
return true;
}
}
return false;
}
private void buildAlertMessageNoGps() {
View SessionManager.java
public void authenticateWithId(final LiveData<AuthResource<User>> source) {
if(cachedUser != null){
cachedUser.setValue(AuthResource.loading((User)null));
cachedUser.addSource(source, new Observer<AuthResource<User>>() {
@Override
public void onChanged(AuthResource<User> userAuthResource) {
cachedUser.setValue(userAuthResource);
cachedUser.removeSource(source);
if(userAuthResource.status.equals(AuthResource.AuthStatus.ERROR)){
@mitchtabian
mitchtabian / UserListFragment.java
Last active May 27, 2019
Calculating Directions with Google Directions API
View UserListFragment.java
private void calculateDirections(Marker marker){
Log.d(TAG, "calculateDirections: calculating directions.");
com.google.maps.model.LatLng destination = new com.google.maps.model.LatLng(
marker.getPosition().latitude,
marker.getPosition().longitude
);
DirectionsApiRequest directions = new DirectionsApiRequest(mGeoApiContext);
directions.alternatives(true);
View NoteActivity.java
private GestureDetector mGestureDetector;
private void setListeners(){
mGestureDetector = new GestureDetector(this, this);
linedEditText.setOnTouchListener(this);
check.setOnClickListener(this);
viewTitle.setOnClickListener(this);
View home.html
<p><strong>Table of Contents:</strong></p>
<ul>
<li><a href='#1'>Introduction</a></li>
<li><a href='#2'>Methods for onPressed</a></li>
<li><a href='#3'>FlatButton</a></li>
<li><a href='#4'>RaisedButton</a></li>
<li><a href='#5'>IconButton</a></li>
<li><a href='#6'>OutlineButton</a></li>
<li><a href='#7'>Final Thoughts</a></li>
View Thing.kt
public LiveData<Resource<PlaylistContents>> observePlaylistData(String id) {
if (playlistContentsLiveData == null) {
playlistContentsLiveData = new MutableLiveData<>();
playlistContentsLiveData.postValue(Resource.loading((PlaylistContents) null));
apiService.getPlaylistContents(CharParser.removeEmptySpaces(id))
.subscribeOn(Schedulers.io())
.subscribe(data -> playlistContentsLiveData.postValue(Resource.success(data)),
e -> playlistContentsLiveData.postValue(Resource.error(e.getMessage(), (PlaylistContents) null)));
View Thing.kt
class MovieRepository @Inject
constructor(var apiService: ApiService) {
fun fetchDiscoverMovies(page: Int): LiveData<Resource<DiscoverMovieResponse>> {
return LiveDataReactiveStreams.fromPublisher(
apiService.fetchDiscoverMovie(page) // returns Flowable<DiscoverMovieResponse>
.subscribeOn(Schedulers.io())
.map { d: DiscoverMovieResponse -> Resource.success(d) }
.onErrorReturn { e -> Resource.error(e.message, null) }
)
View NoteViewModel.java
package com.codingwithmitch.unittesting2.ui.note;
import android.util.Log;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.codingwithmitch.unittesting2.models.Note;
import com.codingwithmitch.unittesting2.repository.NoteRepository;
You can’t perform that action at this time.