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
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)){
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;
View NoteInsertUpdateHelper.java
public abstract class NoteInsertUpdateHelper<T> {
public static final String ACTION_INSERT = "ACTION_INSERT";
public static final String ACTION_UPDATE = "ACTION_UPDATE";
public static final String GENERIC_ERROR = "Something went wrong";
private MediatorLiveData<Resource<T>> result = new MediatorLiveData<>();
public NoteInsertUpdateHelper(){
init();
View NoteViewModel.java
public class NoteViewModel extends ViewModel {
private static final String TAG = "NoteViewModel";
// inject
private final NoteRepository noteRepository;
// vars
private MutableLiveData<Note> note = new MutableLiveData<>();
View MockitoExtension.java
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
import org.junit.jupiter.api.extension.ExtensionContext.Store;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolver;
import org.junit.jupiter.api.extension.TestInstancePostProcessor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.lang.reflect.Parameter;
View ApiServiceNotifierTest.java
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.RepetitionInfo;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import static org.junit.jupiter.api.Assertions.*;
@DisplayName("Api Service Test")
You can’t perform that action at this time.