Store uiPosition

This will later be changeable and can then be used to sort lists received by the UI controller
This commit is contained in:
NMerz
2020-11-14 15:55:29 -05:00
parent 7cb9639f9a
commit 421fceb364
7 changed files with 51 additions and 28 deletions

View File

@@ -1,27 +1,15 @@
package com.example.listify;
import android.app.Dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import com.amplifyframework.auth.AuthException;
import android.view.View;
import android.widget.*;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import com.bumptech.glide.Glide;
import com.example.listify.data.List;
import com.example.listify.data.ListEntry;
import com.example.listify.model.Product;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONException;
import java.io.IOException;
@@ -239,7 +227,7 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
com.example.listify.data.List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
com.example.listify.data.List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli(), -1);
Thread t = new Thread(new Runnable() {
@Override

View File

@@ -205,7 +205,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli(), -1);
try {
requestor.postObject(newList, idReceiver, idReceiver);

View File

@@ -9,18 +9,20 @@ public class List {
long lastUpdated;
final ListEntry[] entries;
boolean shared;
Integer uiPosition;
public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared) {
public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared, Integer uiPosition) {
this.itemID = itemID;
this.name = name;
this.owner = owner;
this.lastUpdated = lastUpdated;
this.entries = entries;
this.shared = false;
this.uiPosition = uiPosition;
}
public List(Integer itemID, String name, String owner, long lastUpdated) {
this(itemID, name, owner, lastUpdated, null, false);
public List(Integer itemID, String name, String owner, long lastUpdated, Integer uiPosition) {
this(itemID, name, owner, lastUpdated, null, false, uiPosition);
}
@Override
@@ -32,6 +34,7 @@ public class List {
", lastUpdated=" + lastUpdated +
", entries=" + Arrays.toString(entries) +
", shared=" + shared +
", uiPosition=" + uiPosition +
'}';
}
@@ -78,4 +81,12 @@ public class List {
public void setShared(boolean shared) {
this.shared = shared;
}
public Integer getUiPosition() {
return uiPosition;
}
public void setUiPosition(Integer uiPosition) {
this.uiPosition = uiPosition;
}
}

View File

@@ -88,7 +88,7 @@ public class HomeFragment extends Fragment implements CreateListDialogFragment.O
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli() , -1);
try {
requestor.postObject(newList, idReceiver, idReceiver);