Code Conventions und auf Englisch übersetzt
This commit is contained in:
parent
4073adce47
commit
20c18ce389
@ -46,7 +46,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
/** zur Verwendung von xml anstatt der direkten Einbindung.*/
|
||||
public IXML xml;
|
||||
/** zur Verwendung von uebergabe anstatt der direkten Einbindung.*/
|
||||
public Communicator uebergabe;
|
||||
public Communicator delivery;
|
||||
/** Handler for the custom user configurations. **/
|
||||
public ConfigurationHandler configurationHandler;
|
||||
/** zur Verwendung von favorite anstatt der direkten Einbindung.*/
|
||||
@ -61,9 +61,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
ensurePermissions();
|
||||
setupConfigs();
|
||||
favorite = configurationHandler;
|
||||
uebergabe = new Communicator(configurationHandler.getAddress(),
|
||||
delivery = new Communicator(configurationHandler.getAddress(),
|
||||
configurationHandler.getPort(), this);
|
||||
uebergabe.downloadXML();
|
||||
delivery.downloadXML();
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
@ -105,7 +105,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
MaterialAlertDialogBuilder(MainActivity.this);
|
||||
//alert.setTitle(R.string.action_set_connection);
|
||||
View view2 = LayoutInflater.from(MainActivity.this).inflate(R.
|
||||
layout.alert_dialog_ip_pot_eingabe, null);
|
||||
layout.alert_dialog_ip_pot, null);
|
||||
EditText ipAdress = (EditText) view2.findViewById(R.id.
|
||||
editTextIp);
|
||||
ipAdress.setText(configurationHandler.getAddress());
|
||||
@ -127,7 +127,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
+ ":" + configurationHandler.
|
||||
getPort() + " is set",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
uebergabe = new Communicator(
|
||||
delivery = new Communicator(
|
||||
configurationHandler.getAddress(),
|
||||
configurationHandler.getPort(),
|
||||
MainActivity.this);
|
||||
@ -172,13 +172,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
break;
|
||||
|
||||
case R.id.action_download_xml:
|
||||
uebergabe.downloadXML();
|
||||
delivery.downloadXML();
|
||||
Toast.makeText(this, "Downloaded .xml",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case R.id.action_upload_xml:
|
||||
try {
|
||||
uebergabe.uploadXML();
|
||||
delivery.uploadXML();
|
||||
Toast.makeText(this, "Upload .xml executed",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, "Upload .xml failed",
|
||||
|
@ -19,19 +19,19 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
*/
|
||||
private MainActivity mainActivity;
|
||||
/**
|
||||
* Welche ansicht gewählt wurde 0 für all IOs, 1 für favorite IOs.
|
||||
* Which view was selected, 0 for all IOs, 1 for favorite IOs.
|
||||
*/
|
||||
private int favoriteMode;
|
||||
/**
|
||||
* Name des devices für den aktuellen durchlauf.
|
||||
* Name of the device for the current run.
|
||||
*/
|
||||
private String deviceName;
|
||||
/**
|
||||
* Bild für Favorit oder nicht.
|
||||
* Image for favorite or not.
|
||||
*/
|
||||
private int favoriteImage;
|
||||
/**
|
||||
* Liste der beim öffnen der Favoritenansicht bestehenden Favoriten.
|
||||
* List of favorites existing when opening the favorites view.
|
||||
*/
|
||||
private List<String> favoritenList;
|
||||
|
||||
@ -46,9 +46,8 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
this.favoriteMode = pFavoriteMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Anzahl der Anzeigen
|
||||
* @return devices number
|
||||
*/
|
||||
@Override
|
||||
public int getCount() {
|
||||
@ -117,7 +116,6 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
if (favoriteMode == 0) {
|
||||
deviceName = mainActivity.xml.getDeviceNames().get(i);
|
||||
} else {
|
||||
List<String> test = favoritenList;
|
||||
deviceName = favoritenList.get(i);
|
||||
}
|
||||
if (mainActivity.favorite.getFavorites().contains(deviceName)) {
|
||||
|
@ -18,26 +18,21 @@ import java.util.List;
|
||||
|
||||
public class PinView {
|
||||
/**
|
||||
* Einbinden der MainActivity.
|
||||
* Include the MainActivity.
|
||||
*/
|
||||
private MainActivity mainActivity;
|
||||
/**
|
||||
* Statusbild für den atuellen durchlauf.
|
||||
* Image for state.
|
||||
*/
|
||||
private int image;
|
||||
/**
|
||||
* Werte der Pins.
|
||||
* Values of the pins.
|
||||
*/
|
||||
private List<String> pinValues = new ArrayList<>();
|
||||
/**
|
||||
* Gerätenamen.
|
||||
* Device name.
|
||||
*/
|
||||
private String deviceName;
|
||||
/**
|
||||
* DutyCycle.
|
||||
*/
|
||||
private String dutyValue;
|
||||
|
||||
|
||||
/**
|
||||
* @param pMainActivity
|
||||
@ -53,13 +48,12 @@ public class PinView {
|
||||
* @return view
|
||||
*/
|
||||
public View getView(final int i) {
|
||||
dutyValue = "";
|
||||
View view = mainActivity.getLayoutInflater().inflate(R.layout.
|
||||
pin_listview_layout, null);
|
||||
TextView textViewPin = (TextView) view.findViewById(R.id.textPin);
|
||||
textViewPin.setText(((List<String>) (mainActivity.xml.getPort(
|
||||
deviceName)).get("pins")).get(i));
|
||||
mainActivity.uebergabe.read(deviceName, new Response.
|
||||
mainActivity.delivery.read(deviceName, new Response.
|
||||
Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(final JSONObject response) {
|
||||
@ -92,7 +86,7 @@ public class PinView {
|
||||
(mainActivity.xml.getPort(
|
||||
deviceName)).get("pins")).
|
||||
get(i) + "\":" + setState + "}}");
|
||||
mainActivity.uebergabe.write(deviceName, jsonObject,
|
||||
mainActivity.delivery.write(deviceName, jsonObject,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(final JSONObject response
|
||||
@ -108,11 +102,12 @@ public class PinView {
|
||||
MaterialAlertDialogBuilder alert =
|
||||
new MaterialAlertDialogBuilder(mainActivity);
|
||||
View viewAlert = mainActivity.getLayoutInflater().
|
||||
inflate(R.layout.alert_dialog_pwm, null);
|
||||
inflate(R.layout.alert_dialog_duty, null);
|
||||
RangeSlider readDuty = (RangeSlider) viewAlert.
|
||||
findViewById(R.id.range_slider_duty);
|
||||
readDuty.setValues((float) Float.valueOf(pinValues.
|
||||
get(i)));
|
||||
get(i).equals("None") ? "0" : pinValues.get(i))
|
||||
);
|
||||
alert.setView(viewAlert);
|
||||
alert.setPositiveButton("set",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@ -123,15 +118,13 @@ public class PinView {
|
||||
intValue();
|
||||
try {
|
||||
JSONObject jsonObject =
|
||||
new JSONObject(
|
||||
"{\"output\":{\""
|
||||
+ ((List<String>)
|
||||
(mainActivity.xml.
|
||||
getPort(deviceName)).
|
||||
get("pins")).get(i)
|
||||
+ "\":\"" + value
|
||||
+ "\"}}");
|
||||
mainActivity.uebergabe.write(
|
||||
new JSONObject("{\"output\":{\""
|
||||
+ ((List<String>) (
|
||||
mainActivity.xml.getPort(
|
||||
deviceName)).get("pins")
|
||||
).get(i) + "\":\""
|
||||
+ value + "\"}}");
|
||||
mainActivity.delivery.write(
|
||||
deviceName, jsonObject,
|
||||
new Response.
|
||||
Listener<JSONObject>() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user