Behebung diverser Design Fehler im gesammtem Projekt

This commit is contained in:
m_broelemann 2020-12-30 13:09:09 +01:00
parent ff777de343
commit 7467c310b3
4 changed files with 19 additions and 30 deletions

View File

@ -2,33 +2,21 @@ package com.example.aped.communication;
import android.content.Context;
import android.util.Log;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import kotlin.NotImplementedError;
public class Communicator{
public class Communicator {
private String address;
private int port;
private RequestQueue requestQueue;
public Communicator(String address, int port, Context context){
public Communicator(String address, int port, Context context) {
this.address = address;
this.port = port;
requestQueue = Volley.newRequestQueue(context);
@ -41,7 +29,7 @@ public class Communicator{
requestString,
null,
responseListener,
error -> Log.e("Communicator","Error during READ: " + error.getMessage())
error -> Log.e("Communicator", "Error during READ: " + error.getMessage())
);
requestQueue.add(request);
}
@ -53,7 +41,8 @@ public class Communicator{
requestString,
message,
responseListener,
error -> {Log.e("Communicator", "Error during WRITE: " + error.getMessage()); error.printStackTrace();}
error -> {
Log.e("Communicator", "Error during WRITE: " + error.getMessage()); error.printStackTrace(); }
);
requestQueue.add(request);
}

View File

@ -6,20 +6,20 @@ import java.util.List;
public interface IXML {
/**
* reads the list of available devices from the XML
* reads the list of available devices from the XML.
* @return the device names as a list of strings
*/
List<String> getDeviceNames();
/**
* reads the value info of a given device from the XML
* reads the value info of a given device from the XML.
* @param deviceName the name of the relevant device
* @return the value info as a Dictionary
*/
Dictionary<String, Object> getValueInfo(String deviceName);
/**
* reads the port information of a given device from the XML
* reads the port information of a given device from the XML.
* @param deviceName the name of the relevant device
* @return the value info as a Dictionary
*/

View File

@ -7,7 +7,7 @@ import java.util.List;
* implementation for the favorites interface
* does not use persistent storage!
*/
public class TestFavorites implements IFAVORITES{
public class TestFavorites implements IFAVORITES {
private List<String> favorites = new ArrayList<>();

View File

@ -19,22 +19,22 @@ public class TestXML implements IXML {
@Override
public Dictionary<String, Object> getValueInfo(String deviceName) {
Dictionary<String,Object> returnDict = new Hashtable<>();
returnDict.put("type","boolean");
returnDict.put("unit","");
returnDict.put("Offset",1.0);
returnDict.put("Factor",1.0);
Dictionary<String, Object> returnDict = new Hashtable<>();
returnDict.put("type", "boolean");
returnDict.put("unit", "");
returnDict.put("Offset", 1.0);
returnDict.put("Factor", 1.0);
return returnDict;
}
@Override
public Dictionary<String, Object> getPort(String deviceName) {
Dictionary<String, Object> returnDict = new Hashtable<>();
returnDict.put("protocol","DI");
Dictionary<String,Object> pins = new Hashtable<>();
pins.put("GPIO2",true);
pins.put("GPIO3",false);
returnDict.put("pins",pins);
returnDict.put("protocol", "DI");
Dictionary<String, Object> pins = new Hashtable<>();
pins.put("GPIO2", true);
pins.put("GPIO3", false);
returnDict.put("pins", pins);
return returnDict;
}
}