Code Conventions
This commit is contained in:
parent
8b8cc32697
commit
465c9aa9ba
@ -17,32 +17,46 @@ import java.util.List;
|
||||
|
||||
|
||||
public class MainListViewAdapter extends BaseAdapter {
|
||||
|
||||
/**
|
||||
* Einbinden der MainActivity.
|
||||
*/
|
||||
private MainActivity mainActivity;
|
||||
|
||||
/**
|
||||
* Welche ansicht gewählt wurde 0 für all IOs, 1 für favorite IOs.
|
||||
*/
|
||||
private int favoriteMode;
|
||||
|
||||
/**
|
||||
* Name des devices für den aktuellen durchlauf.
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* Bild für den atuellen durchlauf.
|
||||
*/
|
||||
private int image;
|
||||
|
||||
/**
|
||||
* Bild für Favorit oder nicht.
|
||||
*/
|
||||
private int favoriteImage;
|
||||
/**
|
||||
* Liste der beim öffnen der Favoritenansicht bestehenden Favoriten.
|
||||
*/
|
||||
private List<String> favoritenList;
|
||||
|
||||
|
||||
List<String> favoritenList;
|
||||
|
||||
|
||||
public MainListViewAdapter(MainActivity pMainActivity,int pFavoriteMode){
|
||||
/**
|
||||
* @param pMainActivity
|
||||
* @param pFavoriteMode
|
||||
*/
|
||||
public MainListViewAdapter(final MainActivity pMainActivity,
|
||||
final int pFavoriteMode) {
|
||||
this.mainActivity = pMainActivity;
|
||||
this.favoriteMode = pFavoriteMode;
|
||||
/**
|
||||
* pFavoriteMode 0 oder 1 möglich
|
||||
* 1 für wir befinden uns in Anzeige favorite IOs
|
||||
* 0 für wir befinden uns in Anzeige all IOs
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Anzahl der Anzeigen
|
||||
*/
|
||||
@Override
|
||||
public int getCount() {
|
||||
int devices;
|
||||
@ -50,28 +64,43 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
devices = mainActivity.xml.getDeviceNames().size();
|
||||
} else {
|
||||
devices = mainActivity.favorite.getFavorites().size();
|
||||
favoritenList = new ArrayList<>(mainActivity.favorite.getFavorites()) ;
|
||||
favoritenList = new ArrayList<>(mainActivity.favorite.
|
||||
getFavorites());
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param position
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getItem(final int position) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param position
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public long getItemId(final int position) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i
|
||||
* @param view
|
||||
* @param viewGroup
|
||||
* @return view
|
||||
*/
|
||||
@Override
|
||||
public View getView(final int i, View view,
|
||||
final ViewGroup viewGroup) {
|
||||
view = mainActivity.getLayoutInflater().inflate(R.layout.listview_layout,
|
||||
null);
|
||||
view = mainActivity.getLayoutInflater().inflate(R.layout.
|
||||
listview_layout, null);
|
||||
TextView textViewName = (TextView) view.findViewById(
|
||||
R.id.textName);
|
||||
LinearLayout linearLayoutPin = (LinearLayout) view.findViewById(
|
||||
@ -97,7 +126,8 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
public void onClick(final View view) {
|
||||
|
||||
if (favoriteMode == 0) {
|
||||
deviceName = mainActivity.xml.getDeviceNames().get(i);
|
||||
deviceName = mainActivity.xml.getDeviceNames().
|
||||
get(i);
|
||||
} else {
|
||||
List<String> test = favoritenList;
|
||||
deviceName = favoritenList.get(i);
|
||||
@ -116,15 +146,8 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
buttonViewFavoriten.setImageResource(
|
||||
favoriteImage);
|
||||
}
|
||||
/**Intent intentneustart = mainActivity.getIntent();// gegen richtigen Befehl tauschen da nur die visualisierung neu gestartet werden soll
|
||||
mainActivity.finish();
|
||||
mainActivity.startActivity(intentneustart);*/
|
||||
}
|
||||
});
|
||||
//textViewPin.setText(((List<String>) (mainActivity.xml.getPort(mainActivity.xml.getDeviceNames().get(i))).get("pins")).get(0));
|
||||
|
||||
|
||||
|
||||
|
||||
mainActivity.uebergabe.read(deviceName,
|
||||
new Response.Listener<JSONObject>() {
|
||||
@ -143,7 +166,8 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
get("pins"))) {
|
||||
pinValues.add(state.getString(pinName));
|
||||
}
|
||||
PinView pinView = new PinView(mainActivity,deviceName, pinValues);
|
||||
PinView pinView = new PinView(mainActivity, deviceName,
|
||||
pinValues);
|
||||
for (int j = 0; j < ((List<String>)mainActivity.xml.
|
||||
getPort(deviceName).
|
||||
get("pins")).size(); j++) {
|
||||
@ -156,16 +180,18 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
String name = null;
|
||||
switch((mainActivity.xml.getPort(deviceName)).get("protocol").toString()){
|
||||
switch ((mainActivity.xml.getPort(deviceName)).get("protocol").
|
||||
toString()) {
|
||||
case "PWM":
|
||||
name = ((mainActivity.xml.getPort(deviceName)).get("protocol").toString() + ": " + deviceName + " (" + (mainActivity.xml.getPort(deviceName)).get("frequency").toString() + "Hz)" );
|
||||
name = ((mainActivity.xml.getPort(deviceName)).get("protocol").
|
||||
toString() + ": " + deviceName + " (" + (mainActivity.
|
||||
xml.getPort(deviceName)).get("frequency").toString()
|
||||
+ "Hz)");
|
||||
break;
|
||||
default:
|
||||
name = ((mainActivity.xml.getPort(deviceName)).get("protocol").toString() + ": " + deviceName);
|
||||
name = ((mainActivity.xml.getPort(deviceName)).get("protocol").
|
||||
toString() + ": " + deviceName);
|
||||
break;
|
||||
}
|
||||
textViewName.setText(name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user