dynamic content update
This commit is contained in:
parent
341b3edc35
commit
54988dd51e
@ -8,16 +8,18 @@ import android.app.AlertDialog;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.jg_cody.Teraplex.ui.rooms.ListItem;
|
||||
import de.jg_cody.Teraplex.ui.rooms.*;
|
||||
|
||||
public class AddButtonDialogSingle extends DialogFragment {
|
||||
private EditText editTextUsername;
|
||||
private EditText editTextPassword;
|
||||
|
||||
private EditText command, name, button_name;
|
||||
private EditText editText_command, editText_name, editText_button_name;
|
||||
private AddButtonDialogListener listener;
|
||||
|
||||
/**
|
||||
@ -31,9 +33,9 @@ public class AddButtonDialogSingle extends DialogFragment {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.addbuttondialog_single, null);
|
||||
|
||||
command = getActivity().findViewById(R.id.dialogSingle_editText_command);
|
||||
name = getActivity().findViewById(R.id.dialogSingle_editText_name);
|
||||
button_name = getActivity().findViewById(R.id.dialogSingle_editText_buttonName);
|
||||
editText_command = getActivity().findViewById(R.id.dialogSingle_editText_command);
|
||||
editText_name = getActivity().findViewById(R.id.dialogSingle_editText_name);
|
||||
editText_button_name = getActivity().findViewById(R.id.dialogSingle_editText_buttonName);
|
||||
|
||||
|
||||
builder.setView(view)
|
||||
@ -47,9 +49,11 @@ public class AddButtonDialogSingle extends DialogFragment {
|
||||
.setPositiveButton("ADD", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
String username = editTextUsername.getText().toString();
|
||||
String password = editTextPassword.getText().toString();
|
||||
listener.applyTexts(username, password);
|
||||
String command = editText_command.getText().toString();
|
||||
String name = editText_name.getText().toString();
|
||||
String button = editText_button_name.getText().toString();
|
||||
listener.applyTexts(name,command,button);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -73,19 +77,9 @@ public class AddButtonDialogSingle extends DialogFragment {
|
||||
|
||||
|
||||
public interface AddButtonDialogListener {
|
||||
void applyTexts(String username, String password);
|
||||
void applyTexts(String name, String command, String button);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name.getText().toString();
|
||||
}
|
||||
public String getButtonName()
|
||||
{
|
||||
return button_name.getText().toString();
|
||||
}
|
||||
public String getCommand()
|
||||
{
|
||||
return command.getText().toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -53,7 +53,7 @@ import de.jg_cody.Teraplex.ui.Konsole.KonsoleFragment;
|
||||
import de.jg_cody.Teraplex.ui.home.HomeFragment;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements AddButtonDialogSingle.AddButtonDialogListener {
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
public static int RESULT_LOAD_IMAGE = 0;
|
||||
private AppBarConfiguration mAppBarConfiguration;
|
||||
|
||||
@ -186,11 +186,6 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialogSi
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void applyTexts(String username, String password) {
|
||||
|
||||
}
|
||||
|
||||
public void menurighttopeinstellungen(MenuItem i) {
|
||||
EinstellungenFragment pef = new EinstellungenFragment();
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
|
@ -32,7 +32,7 @@ import de.jg_cody.Teraplex.MainActivity;
|
||||
import de.jg_cody.Teraplex.R;
|
||||
import de.jg_cody.Teraplex.ui.rooms.*;
|
||||
|
||||
public class FlurFragment extends Fragment{
|
||||
public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddButtonDialogListener{
|
||||
|
||||
private FlurViewModel flurViewModel;
|
||||
|
||||
@ -113,9 +113,6 @@ public class FlurFragment extends Fragment{
|
||||
public void openDialog1() {
|
||||
AddButtonDialogSingle addButtonDialogSingle = new AddButtonDialogSingle();
|
||||
addButtonDialogSingle.show(getActivity().getSupportFragmentManager(), "example dialog");
|
||||
items.add(new ListItemSingle(addButtonDialogSingle.getCommand(),1, addButtonDialogSingle.getName(), addButtonDialogSingle.getButtonName()));
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -128,4 +125,11 @@ public class FlurFragment extends Fragment{
|
||||
public void addItems(View v) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTexts(String name, String command, String button) {
|
||||
items.add(new ListItemSingle(1,name,command,button));
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ import android.widget.Button;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.jg_cody.Teraplex.R;
|
||||
import de.jg_cody.Teraplex.ui.Flur.FlurFragment;
|
||||
|
||||
public class ListAdapter extends ArrayAdapter {
|
||||
|
||||
@ -44,29 +43,38 @@ public class ListAdapter extends ArrayAdapter {
|
||||
ListItem listViewItem = objects.get(position);
|
||||
int listViewItemType = getItemViewType(position);
|
||||
|
||||
|
||||
String[] s = listViewItem.getStrings();
|
||||
if (convertView == null) {
|
||||
|
||||
if (listViewItemType == SINGLEBUTTON) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.singlebutton, null);
|
||||
|
||||
Button bRun = convertView.findViewById(R.id.bRun);
|
||||
Button text = convertView.findViewById(R.id.TEXT);
|
||||
bRun.setText(listViewItem.getText());
|
||||
Button bRun = convertView.findViewById(R.id.singleButton_button);
|
||||
Button text = convertView.findViewById(R.id.singleButton_text);
|
||||
|
||||
bRun.setText(s[2]);
|
||||
text.setText(s[0]);
|
||||
//text.setText(listViewItemType.get)
|
||||
|
||||
viewHolder = new ViewHolderSingleButton(bRun , listViewItem.getText());
|
||||
convertView.setTag(viewHolder);
|
||||
//viewHolder = new ViewHolderSingleButton(bRun , listViewItem.getText());
|
||||
//convertView.setTag(viewHolder);
|
||||
|
||||
}
|
||||
else if (listViewItemType == DOUBLEBUTTON) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.doublebutton, null);
|
||||
Button bLeft = (Button) convertView.findViewById(R.id.bLeft);
|
||||
Button bRight = (Button) convertView.findViewById(R.id.bRight);
|
||||
Button bLeft = (Button) convertView.findViewById(R.id.doubleButton_bLeft);
|
||||
Button bRight = (Button) convertView.findViewById(R.id.doubleButton_bRight);
|
||||
Button text = (Button) convertView.findViewById(R.id.doubleButton_text);
|
||||
|
||||
viewHolder = new ViewHolderDoubleButton(bLeft,bRight,listViewItem.getText());
|
||||
bLeft.setText(s[3]);
|
||||
bRight.setText(s[4]);
|
||||
text.setText(s[0]);
|
||||
|
||||
convertView.setTag(viewHolder);
|
||||
|
||||
|
||||
//viewHolder = new ViewHolderDoubleButton(bLeft,bRight,listViewItem.getText());
|
||||
|
||||
//convertView.setTag(viewHolder);
|
||||
|
||||
}
|
||||
else if(listViewItemType == OPTION3BUTTON)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package de.jg_cody.Teraplex.ui.rooms;
|
||||
|
||||
public class ListItem {
|
||||
public abstract class ListItem {
|
||||
private String text;
|
||||
private int type;
|
||||
|
||||
@ -10,13 +10,7 @@ public class ListItem {
|
||||
|
||||
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
abstract public String[] getStrings();
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
|
@ -52,4 +52,9 @@ public class ListItemDouble extends ListItem{
|
||||
return button2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStrings() {
|
||||
String[] s = {name, command1, command2, button1,button2};
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package de.jg_cody.Teraplex.ui.rooms;
|
||||
|
||||
public class ListItemSingle extends ListItem{
|
||||
String buttonName;
|
||||
String command;
|
||||
String name;
|
||||
|
||||
public ListItemSingle(String command, int type, String buttonName, String name) {
|
||||
public ListItemSingle(int type, String name,String command,String buttonName ) {
|
||||
super(type);
|
||||
this.name = name;
|
||||
this.buttonName = buttonName;
|
||||
this.command = command;
|
||||
|
||||
}
|
||||
public void setButtonName(String buttonName)
|
||||
@ -26,4 +28,18 @@ public class ListItemSingle extends ListItem{
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setCommand(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
public String getCommand()
|
||||
{
|
||||
return command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStrings() {
|
||||
String[] s = {name, command, buttonName};
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/bLeft"
|
||||
android:id="@+id/doubleButton_bLeft"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="5dp"
|
||||
@ -21,20 +21,19 @@
|
||||
app:backgroundTint="@null" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/TEXT"
|
||||
android:id="@+id/doubleButton_text"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_middle"
|
||||
android:insetLeft="25dp"
|
||||
android:insetRight="25dp"
|
||||
android:text="Button2"
|
||||
android:text="Button1"
|
||||
app:backgroundTint="@null" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bRight"
|
||||
android:id="@+id/doubleButton_bRight"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="5dp"
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/TEXT"
|
||||
android:id="@+id/singleButton_text"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="5dp"
|
||||
@ -21,7 +21,7 @@
|
||||
app:backgroundTint="@null" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bRun"
|
||||
android:id="@+id/singleButton_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_margin="5dp"
|
||||
|
Loading…
Reference in New Issue
Block a user