mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
Change some stuff
This commit is contained in:
@@ -68,10 +68,6 @@ public class dropdownType extends inputType {
|
||||
text_options = (String[]) objects.get(2).get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public PowerSpinnerView dropdown = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
@@ -100,6 +96,8 @@ public class dropdownType extends inputType {
|
||||
dropdown.setSpinnerPopupElevation(14);
|
||||
|
||||
|
||||
|
||||
|
||||
dropdown.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener<IconSpinnerItem>() {
|
||||
@Override
|
||||
public void onItemSelected(int oldIndex, @Nullable IconSpinnerItem oldItem, int newIndex,
|
||||
|
||||
@@ -29,6 +29,12 @@ public class FieldsFragment extends Fragment {
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
binding = FragmentDataFieldsBinding.inflate(inflater, container, false);
|
||||
|
||||
binding.saveButton.setVisibility(View.GONE);
|
||||
binding.editButton.setVisibility(View.GONE);
|
||||
binding.upButton.setVisibility(View.GONE);
|
||||
binding.addButton.setVisibility(View.GONE);
|
||||
binding.downButton.setVisibility(View.GONE);
|
||||
|
||||
load_field_menu();
|
||||
|
||||
return binding.getRoot();
|
||||
@@ -88,12 +94,13 @@ public class FieldsFragment extends Fragment {
|
||||
|
||||
private void display_fields(inputType[] version_values) {
|
||||
binding.fieldsArea.removeAllViews();
|
||||
binding.fieldsArea.setReorderingEnabled(true);
|
||||
binding.fieldsArea.setReorderingEnabled(false);
|
||||
|
||||
TextView e = null;
|
||||
binding.addButton.setOnClickListener(view -> {
|
||||
e.setText("123");
|
||||
});
|
||||
binding.saveButton.setVisibility(View.GONE);
|
||||
binding.editButton.setVisibility(View.GONE);
|
||||
binding.upButton.setVisibility(View.VISIBLE);
|
||||
binding.addButton.setVisibility(View.VISIBLE);
|
||||
binding.downButton.setVisibility(View.VISIBLE);
|
||||
|
||||
for(int i = 0; i < version_values.length; i++){
|
||||
TableRow tr = new TableRow(getContext());
|
||||
@@ -120,24 +127,48 @@ public class FieldsFragment extends Fragment {
|
||||
binding.fieldsArea.addView(tr);
|
||||
|
||||
tr.setOnClickListener(v -> {
|
||||
binding.editButton.setVisibility(View.VISIBLE);
|
||||
trOnClick(version_values, tr);
|
||||
});
|
||||
}
|
||||
selindex = -1;
|
||||
|
||||
binding.upButton.setOnClickListener(v -> {
|
||||
if(selindex != 0) {
|
||||
binding.saveButton.setVisibility(View.VISIBLE);
|
||||
binding.fieldsArea.updateRowOrder(selindex, selindex - 1);
|
||||
selindex -= 1;
|
||||
}
|
||||
});
|
||||
|
||||
binding.downButton.setOnClickListener(v -> {
|
||||
if(selindex != version_values.length-1) {
|
||||
binding.saveButton.setVisibility(View.VISIBLE);
|
||||
binding.fieldsArea.updateRowOrder(selindex, selindex + 1);
|
||||
selindex += 1;
|
||||
}
|
||||
});
|
||||
|
||||
binding.saveButton.setOnClickListener(v -> {
|
||||
binding.saveButton.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
private int selindex = -1;
|
||||
|
||||
private void trOnClick(inputType[] version_values, TableRow tr){
|
||||
int index = -1;
|
||||
selindex = -1;
|
||||
for(int i = 0; i < binding.fieldsArea.getChildCount(); i++){
|
||||
View v = binding.fieldsArea.getChildAt(i);
|
||||
|
||||
if(v.equals(tr)) {
|
||||
tr.setBackgroundColor(background_color);
|
||||
index = i;
|
||||
selindex = i;
|
||||
} else
|
||||
binding.fieldsArea.getChildAt(i).setBackgroundColor(unfocused_background_color);
|
||||
}
|
||||
|
||||
onFieldSelect(version_values[binding.fieldsArea.getReorderedIndexes().get(index)]);
|
||||
onFieldSelect(version_values[binding.fieldsArea.getReorderedIndexes().get(selindex)]);
|
||||
}
|
||||
|
||||
private void onFieldSelect(inputType field){
|
||||
|
||||
@@ -112,7 +112,8 @@ public class ReorderableTableLayout extends TableLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRowOrder(int fromIndex, int toIndex) {
|
||||
public void updateRowOrder(int fromIndex, int toIndex) {
|
||||
saveOriginalOrder();
|
||||
if (fromIndex < toIndex) {
|
||||
for (int i = fromIndex; i < toIndex; i++) {
|
||||
Collections.swap(rows, i, i + 1);
|
||||
|
||||
@@ -1,18 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_button"
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Save"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/up_button"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="↑"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/add_button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_button"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="+"
|
||||
android:textSize="48sp"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/down_button"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="↓"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/add_button" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/edit_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Edit"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
Reference in New Issue
Block a user