This file contains 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
Field[] declaredFields = Intent.class.getDeclaredFields(); | |
for (Field field : declaredFields) { | |
if (field.getName().startsWith("FLAG_")) { | |
try { | |
int flag = field.getInt(null); | |
if ((intent.getFlags() & flag) != 0) { | |
log.d(field.getName()); | |
} |
This file contains 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
data class TasksViewData(val dataLoading : Boolean, | |
val empty: Boolean, | |
@StringRes val currentFilteringLabel : Int, | |
@DrawableRes val noTaskIconRes: Int, | |
@StringRes val noTasksLabel : Int, | |
val tasksAddViewVisible : Boolean, | |
val items: List<Task>, | |
val message: ViewMessage = InvalidMessage) |
This file contains 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 TasksViewModel extends AndroidViewModel { | |
// These observable fields will update Views automatically | |
public final ObservableList<Task> items = new ObservableArrayList<>(); | |
public final ObservableBoolean dataLoading = new ObservableBoolean(false); | |
public final ObservableField<String> currentFilteringLabel = new ObservableField<>(); | |
public final ObservableField<String> noTasksLabel = new ObservableField<>(); | |
public final ObservableField<Drawable> noTaskIconRes = new ObservableField<>(); | |
public final ObservableBoolean empty = new ObservableBoolean(false); | |
public final ObservableBoolean tasksAddViewVisible = new ObservableBoolean(); |
This file contains 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
// Listen to Single Event live-data object that will only report a snackbar message once | |
mTasksViewModel.getSnackbarMessage().observe(this, new SnackbarMessage.SnackbarObserver() { | |
@Override | |
public void onNewMessage(@StringRes int snackbarMessageResourceId) { | |
SnackbarUtils.showSnackbar(getView(), getString(snackbarMessageResourceId)); | |
} | |
}); | |
... | |
// Bind onItemClick onItemSelect to the view-model |
This file contains 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
// BaseReacteFragment method which auto listenes to viewData updates | |
override fun applyViewData(viewData: TasksViewData) { | |
mTasksFragBinding.viewmodel = viewData | |
mListAdapter.tasks = viewData.items | |
SnackbarUtils.showMessage(view, viewData.message) | |
} | |
... | |
// Bind the TasksViewItemActions to the adapter (onItemClick, onItemCheck) | |
mListAdapter = TasksAdapter( |
This file contains 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
interface TasksActions { | |
fun onTaskDetails(taskId: String) | |
fun onNewTask() | |
} | |
class TasksViewModel(private val tasksRepository: TasksRepository, | |
// The injected callbacks for highlevel actions like onNewTask, onTaskDetails | |
private val tasksActions: TasksActions) : BaseReactViewModel<TasksViewData>(), | |
// The taks item Actions | |
TasksViewItemActions, |
This file contains 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
// Definition of the provided dependencies of the MainActivity | |
class MainActivityDependencies(private val activity: FragmentActivity) : Dependencies { | |
override fun taskRepository(): TasksRepository { | |
return TasksRepository.getInstance(TasksRemoteDataSource.instance, TasksLocalDataSource.getInstance(activity)) | |
} | |
fun mainViewModel(): MainViewModel = ViewModelProviders.of(activity).get(MainViewModel::class.java) | |
fun tasksActions(): TasksActions = mainViewModel() |
This file contains 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
class MainViewModel : BaseReactViewModel<Data>(), TasksActions, AddEditActions { | |
override val initialViewData = TasksData | |
override fun onSaveTask() { | |
updateViewData(TasksData) | |
} | |
override fun onTaskDetails(taskId: String) { | |
updateViewData(EditTaskData(taskId)) |
This file contains 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
class OpenRideMapTest : BaseRobotTest( | |
mockDependencyTestRule = mock(locationFound()), | |
testCase = | |
{ | |
inLanding { | |
inLandingList { | |
inItem(2) { click() } | |
} | |
} | |
inDetails { |
This file contains 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
class RideDetails : ScopedActions(idMatcher(R.id.ride_details_container)) { | |
fun inRideEditButton(action: UiActions.() -> Actions) = | |
UiActions(idMatcher(R.id.rideBookedDetailEdit)).action() | |
fun inRideMapButton(action: UiActions.() -> Actions) = | |
UiActions(idMatcher(R.id.map_item)).action() | |
fun inRideStopList(action: List.() -> Actions) = | |
List(R.id.ridesStopsRecycler).action() |
OlderNewer