mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -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);
|
||||
|
||||
Reference in New Issue
Block a user