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 final class ActivityModule_ProvideMainViewModelFactory implements Factory<MainViewModel> { | |
/*Other Code*/ | |
@Override | |
public MainViewModel get() { | |
return Preconditions.checkNotNull( | |
module.provideMainViewModel(dataManagerProvider.get()), | |
"Cannot return null from a non-@Nullable @Provides method"); | |
} | |
public static Factory<MainViewModel> create( | |
ActivityModule module, Provider<DataManager> dataManagerProvider) { |
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
@PerActivity | |
@Component(modules = arrayOf(NetModule::class, ActivityModule::class), | |
dependencies = arrayOf(AppComponent::class)) | |
interface ActivityComponent { | |
fun inject(mainActivity: MainActivity) | |
} |
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
@Singleton | |
@Component(modules = arrayOf(AppModule::class, NetModule::class)) | |
interface AppComponent { | |
@ApplicationContext | |
fun context(): Context | |
fun dataManager(): DataManager | |
} |
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
mqttc=mqtt.Client("DriverClient",clean_session=False) | |
#YOUR MQTT SERVER USERNAME PASSWORD HERE | |
mqttc.username_pw_set("username","password") | |
#YOUR MQTT SERVER URI AND PORT HERE | |
mqttc.connect("SERVER URI","PORT",60) | |
#Publishing the location update in interval of 1 second. | |
for latLng in latLngList: | |
s=str(latLng) | |
b = bytearray() |
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
private void animateCarOnMap(final List<LatLng> latLngs) { | |
LatLngBounds.Builder builder = new LatLngBounds.Builder(); | |
for (LatLng latLng : latLngs) { | |
builder.include(latLng); | |
} | |
LatLngBounds bounds = builder.build(); | |
CameraUpdate mCameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 2); | |
mMap.animateCamera(mCameraUpdate); | |
if (emission == 1) { | |
marker = mMap.addMarker(new MarkerOptions().position(latLngs.get(0)) |
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
latLngPublishRelay | |
.buffer(2) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(new Consumer<List<LatLng>>() { | |
@Override | |
public void accept(List<LatLng> latLngs) throws Exception { | |
emission++; | |
animateCarOnMap(latLngs); | |
} | |
}); |
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
MQTTHelper mqttHelper = new MQTTHelper(getApplicationContext()); | |
mqttHelper.setCallback(new MqttCallbackExtended() { | |
@Override | |
public void connectComplete(boolean reconnect, String serverURI) { | |
Log.d(TAG, "URI " + serverURI); | |
} | |
@Override | |
public void connectionLost(Throwable cause) { |
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
/** | |
* Used for subscribing to the topic. | |
*/ | |
private void subscribeToTopic() { | |
try { | |
mqttAndroidClient.subscribe(subscriptionTopic, 0, null, new IMqttActionListener() { | |
@Override | |
public void onSuccess(IMqttToken asyncActionToken) { | |
Log.w(TAG, "Subscribed!"); | |
} |
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
private void connect() { | |
MqttConnectOptions mqttConnectOptions = new MqttConnectOptions(); | |
mqttConnectOptions.setAutomaticReconnect(true); | |
mqttConnectOptions.setCleanSession(false); | |
mqttConnectOptions.setUserName(username); | |
mqttConnectOptions.setPassword(password.toCharArray()); | |
try { | |
mqttAndroidClient.connect(mqttConnectOptions, null, new IMqttActionListener() { | |
@Override |
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
JourneyEventBus.getInstance().getOnJourneyEvent() | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(new Consumer<Object>() { | |
@Override | |
public void accept(Object o) throws Exception { | |
if (o instanceof BeginJourneyEvent) { | |
Snackbar.make(linearLayout, "Journey has started", | |
Snackbar.LENGTH_SHORT).show(); | |
} else if (o instanceof EndJourneyEvent) { | |
Snackbar.make(linearLayout, "Journey has ended", |