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 void displayShelf(List<String> images, RecyclerView items) { | |
// | |
Display display = getWindowManager().getDefaultDisplay(); | |
Point size = new Point(); | |
display.getSize(size); | |
itemWidth = getResources().getDimension(R.dimen.item_width); | |
padding = (size.x - itemWidth) / 2; | |
firstItemWidth = getResources().getDimension(R.dimen.padding_item_width); | |
allPixels = 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
private void connect() { | |
MqttConnectOptions connectOptions = new MqttConnectOptions(); | |
connectOptions.setAutomaticReconnect(true); | |
client = new MqttAndroidClient(this, serverURI, clientId); | |
try { | |
client.connect(connectOptions, new IMqttActionListener() { | |
@Override | |
public void onSuccess(IMqttToken asyncActionToken) { | |
subscribe(); |
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 subscribe() { | |
String subscribeTopic = "inbox"; | |
try { | |
client.subscribe(subscribeTopic, 0, new IMqttMessageListener() { | |
@Override | |
public void messageArrived(final String topic, final MqttMessage message) throws Exception { | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
Toast.makeText(MainActivity.this, message.toString(), Toast.LENGTH_SHORT).show(); |
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 publishMessage(String message) { | |
String publishTopic = "outbox"; | |
MqttMessage msg = new MqttMessage(); | |
msg.setPayload(message.getBytes()); | |
try { | |
client.publish(publishTopic, msg); | |
} catch (MqttException e) { | |
e.printStackTrace(); | |
} | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<navigation xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/login_nav" | |
app:startDestination="@id/loginHomeFragment"> | |
<fragment | |
android:id="@+id/loginHomeFragment" | |
android:name="me.rankov.kaboom.login.LoginHomeFragment" | |
android:label="fragment_login_home" |
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
import 'package:flutter/material.dart'; | |
class HomePage extends StatefulWidget { | |
const HomePage({Key? key}) : super(key: key); | |
@override | |
State<HomePage> createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { |