Darstellung angepasst
This commit is contained in:
parent
68baa9e06f
commit
f6cb305ff1
@ -4,6 +4,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.volley.Response;
|
||||
@ -13,6 +14,7 @@ import com.example.aped.R;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainListViewAdapter extends BaseAdapter {
|
||||
@ -30,6 +32,7 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
int temp = mainActivity.xml.getDeviceNames().size();
|
||||
return mainActivity.xml.getDeviceNames().size();
|
||||
}
|
||||
|
||||
@ -50,34 +53,12 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
final ViewGroup viewGroup) {
|
||||
view = mainActivity.getLayoutInflater().inflate(R.layout.listview_layout,
|
||||
null);
|
||||
ImageView imageView = (ImageView) view.findViewById(
|
||||
R.id.images);
|
||||
TextView textViewName = (TextView) view.findViewById(
|
||||
R.id.textName);
|
||||
TextView textViewPin = (TextView) view.findViewById(
|
||||
R.id.textPin);
|
||||
ListView listViewPin = (ListView) view.findViewById(
|
||||
R.id.idListViewPins);
|
||||
ImageView buttonViewFavoriten = (ImageView) view.findViewById(
|
||||
R.id.imageButtonFavoriten);
|
||||
mainActivity.uebergabe.read(mainActivity.xml.getDeviceNames().
|
||||
get(i), new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(final JSONObject response) {
|
||||
try {
|
||||
String firstpinvalue = response.getJSONObject("state").getString(((List<String>) (mainActivity.xml.getPort(mainActivity.xml.getDeviceNames().get(i))).get("pins")).get(0));
|
||||
if(firstpinvalue.equals("1")) {
|
||||
image=R.drawable.green_signal;
|
||||
}else if (firstpinvalue.equals("0")) {
|
||||
image = R.drawable.red_signal;
|
||||
} else{ image = R.drawable.off_signal; }
|
||||
imageView.setImageResource(image);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
image = R.drawable.off_signal;
|
||||
imageView.setImageResource(image);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (mainActivity.favorite.getFavorites().contains(
|
||||
mainActivity.xml.getDeviceNames().get(i))) {
|
||||
@ -106,7 +87,31 @@ public class MainListViewAdapter extends BaseAdapter {
|
||||
}
|
||||
}
|
||||
});
|
||||
textViewPin.setText(((List<String>) (mainActivity.xml.getPort(mainActivity.xml.getDeviceNames().get(i))).get("pins")).get(0));
|
||||
//textViewPin.setText(((List<String>) (mainActivity.xml.getPort(mainActivity.xml.getDeviceNames().get(i))).get("pins")).get(0));
|
||||
|
||||
|
||||
mainActivity.uebergabe.read(mainActivity.xml.getDeviceNames().get(i), new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(final JSONObject response) {
|
||||
try {
|
||||
JSONObject state = response.getJSONObject("state");
|
||||
List<String> pinValues = new ArrayList<>();
|
||||
for(String pinName: ((List<String>)mainActivity.xml.getPort(mainActivity.xml.getDeviceNames().get(i)).get("pins"))){
|
||||
pinValues.add(state.getString(pinName));
|
||||
}
|
||||
PinListViewAdapter pinListViewAdapter = new PinListViewAdapter(mainActivity,mainActivity.xml.getDeviceNames().get(i), pinValues);
|
||||
listViewPin.setAdapter(pinListViewAdapter);
|
||||
} catch (JSONException e) {
|
||||
// Richtigen log erstellen
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
textViewName.setText(mainActivity.xml.getDeviceNames().get(i));
|
||||
buttonViewFavoriten.setImageResource(favoriteImage);
|
||||
return view;
|
||||
|
@ -1,4 +1,74 @@
|
||||
package com.example.aped.ui.all_IOs;
|
||||
|
||||
public class PinListViewAdapter {
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.volley.Response;
|
||||
import com.example.aped.MainActivity;
|
||||
import com.example.aped.R;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PinListViewAdapter extends BaseAdapter {
|
||||
private MainActivity mainActivity;
|
||||
|
||||
private int image;
|
||||
private List<String> pinValues;
|
||||
private String deviceName;
|
||||
|
||||
|
||||
public PinListViewAdapter(MainActivity pMainActivity,String pdevice, List<String> ppinValues){
|
||||
this.mainActivity = pMainActivity;
|
||||
this.deviceName = pdevice;
|
||||
this.pinValues = ppinValues;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
int tempsize = pinValues.size();
|
||||
return pinValues.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(final int position) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(final int position) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int i, View view,
|
||||
final ViewGroup viewGroup) {
|
||||
view = mainActivity.getLayoutInflater().inflate(R.layout.pin_listview_layout,
|
||||
null);
|
||||
ImageView imageView = (ImageView) view.findViewById(
|
||||
R.id.images);
|
||||
TextView textViewPin = (TextView) view.findViewById(
|
||||
R.id.textPin);
|
||||
|
||||
String pinState = pinValues.get(i);
|
||||
|
||||
if(pinState.equals("1")) {
|
||||
image=R.drawable.green_signal;
|
||||
}else if (pinState.equals("0")) {
|
||||
image = R.drawable.red_signal;
|
||||
} else{ image = R.drawable.off_signal; }
|
||||
imageView.setImageResource(image);
|
||||
|
||||
textViewPin.setText(((List<String>) (mainActivity.xml.getPort(deviceName)).get("pins")).get(i));
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
@ -4,42 +4,19 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.all_IOs.AllIOsFragment2">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/images"
|
||||
android:layout_width="71dp"
|
||||
android:layout_height="71dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="2dp"
|
||||
android:layout_toRightOf="@id/images"
|
||||
tools:srcCompat="@drawable/off_signal" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textName"
|
||||
android:layout_width="253dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/images"
|
||||
android:layout_toLeftOf="@id/imageButtonFavoriten"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="TextView"
|
||||
android:textSize="25dp"
|
||||
android:layout_margin="2dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textPin"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/images"
|
||||
android:layout_toLeftOf="@id/imageButtonFavoriten"
|
||||
android:layout_below="@id/textName"
|
||||
android:text="TextView"
|
||||
android:textSize="20dp"
|
||||
android:layout_margin="2dp"
|
||||
android:singleLine="true"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/imageButtonFavoriten"
|
||||
android:layout_width="71dp"
|
||||
@ -53,10 +30,10 @@
|
||||
<ListView
|
||||
android:id="@+id/idListViewPins"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:layout_toLeftOf="@id/imageButtonFavoriten"
|
||||
android:layout_below="@id/textPin"/>
|
||||
android:layout_below="@id/textName"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
@ -3,7 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
Loading…
x
Reference in New Issue
Block a user