mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
commit
491e32b07f
@ -40,6 +40,7 @@
|
||||
<activity android:name="com.example.listify.ui.LoginPage" />
|
||||
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
||||
<activity android:name="com.example.listify.ListPage" />
|
||||
<activity android:name="com.example.listify.SplashActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -1,34 +1,25 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import android.widget.*;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.example.listify.data.Item;
|
||||
import com.example.listify.data.List;
|
||||
import com.example.listify.data.ListEntry;
|
||||
import com.example.listify.model.Product;
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
public class ListPage extends AppCompatActivity {
|
||||
ListView listView;
|
||||
@ -89,7 +80,7 @@ public class ListPage extends AppCompatActivity {
|
||||
pNames.add(item.getDescription());
|
||||
pStores.add("Kroger");
|
||||
pPrices.add(item.getPrice().toString());
|
||||
pQuantity.add("1");
|
||||
pQuantity.add(entry.getQuantity().toString());
|
||||
pImages.add(R.drawable.placeholder);
|
||||
pListItemPair.add(entry);
|
||||
}
|
||||
@ -156,30 +147,58 @@ public class ListPage extends AppCompatActivity {
|
||||
public void onClick(View v) {
|
||||
int q = Integer.parseInt(pQuantity.get(position)) - 1;
|
||||
pQuantity.set(position, Integer.toString(q));
|
||||
ListEntry le = pListItemPair.remove(position);
|
||||
le.setQuantity(le.getQuantity() - 1);
|
||||
pListItemPair.add(position, le);
|
||||
SynchronousReceiver<Integer> synchronousenforcer = new SynchronousReceiver<>();
|
||||
requestor.deleteObject(le, synchronousenforcer, synchronousenforcer);
|
||||
try {
|
||||
synchronousenforcer.await();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
requestor.postObject(le, synchronousenforcer, synchronousenforcer);
|
||||
synchronousenforcer.await();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
listView.setAdapter(myAdapter);
|
||||
}
|
||||
});
|
||||
if(Integer.parseInt(pQuantity.get(position)) <= 1) {
|
||||
decrQuan.setEnabled(false);
|
||||
}
|
||||
if(Integer.parseInt(pQuantity.get(position)) < 10) {
|
||||
incrQuan.setEnabled(true);
|
||||
}
|
||||
|
||||
incrQuan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int q = Integer.parseInt(pQuantity.get(position)) + 1;
|
||||
pQuantity.set(position, Integer.toString(q));
|
||||
ListEntry le = pListItemPair.remove(position);
|
||||
le.setQuantity(le.getQuantity() + 1);
|
||||
pListItemPair.add(position, le);
|
||||
SynchronousReceiver<Integer> synchronousenforcer = new SynchronousReceiver<>();
|
||||
requestor.deleteObject(le, synchronousenforcer, synchronousenforcer);
|
||||
try {
|
||||
synchronousenforcer.await();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
requestor.postObject(le, synchronousenforcer, synchronousenforcer);
|
||||
synchronousenforcer.await();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
listView.setAdapter(myAdapter);
|
||||
}
|
||||
});
|
||||
if(Integer.parseInt(pQuantity.get(position)) > 1) {
|
||||
decrQuan.setEnabled(true);
|
||||
}
|
||||
if(Integer.parseInt(pQuantity.get(position)) >= 10) {
|
||||
incrQuan.setEnabled(false);
|
||||
}
|
||||
|
||||
removeItem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -221,7 +240,7 @@ public class ListPage extends AppCompatActivity {
|
||||
int product = entry.getProductID();
|
||||
ProductReceiver<Item> pr = new ProductReceiver<>();
|
||||
requestor.getObject(Integer.toString(product), Item.class, pr);
|
||||
pQuantity.add("1");
|
||||
pQuantity.add(entry.getQuantity().toString());
|
||||
pListItemPair.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.example.listify;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -30,12 +31,23 @@ import java.util.Random;
|
||||
public class MainActivity extends AppCompatActivity implements CreateListDialogFragment.OnNewListListener {
|
||||
private AppBarConfiguration mAppBarConfiguration;
|
||||
|
||||
private static final int SPLASH_SCREEN_TIME = 3000; //in milliseconds
|
||||
|
||||
public static AuthManager am = new AuthManager();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent(MainActivity.this, SplashActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, SPLASH_SCREEN_TIME);
|
||||
|
||||
|
||||
//------------------------------Auth Testing---------------------------------------------//
|
||||
|
||||
|
||||
@ -45,9 +45,13 @@ public class Requestor {
|
||||
}
|
||||
|
||||
public void deleteObject(Object toDelete) {
|
||||
deleteObject(toDelete, null, null);
|
||||
}
|
||||
|
||||
public void deleteObject(Object toDelete, Receiver receiver, RequestErrorHandler errorHandler) {
|
||||
String deleteURL = DEV_BASEURL + "/" + toDelete.getClass().getSimpleName();
|
||||
Request deleteRequest = buildBaseRequest(deleteURL, "DELETE", new Gson().toJson(toDelete));
|
||||
launchCall(deleteRequest, null, toDelete.getClass(), null);
|
||||
launchCall(deleteRequest, receiver, toDelete.getClass(), errorHandler);
|
||||
}
|
||||
|
||||
public void deleteObject(String id, Class classType, RequestErrorHandler failureHandler) {
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.example.listify;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_splashscreen);
|
||||
}
|
||||
}
|
||||
@ -39,9 +39,17 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
||||
public void onClick(View v) {
|
||||
EditText emailText = (EditText) findViewById(R.id.editTextTextEmailAddress);
|
||||
EditText passwordText = (EditText) findViewById(R.id.editTextTextPassword);
|
||||
EditText confirmPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
||||
|
||||
String email = emailText.getText().toString();
|
||||
String password = passwordText.getText().toString();
|
||||
String confirmPassword = confirmPasswordText.getText().toString();
|
||||
|
||||
if(!password.equals(confirmPassword)) {
|
||||
TextView invalidCred = findViewById(R.id.textView3);
|
||||
invalidCred.setText("\"Confirm Password\" does not match \"Password\".");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
am.startSignUp(email, password);
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
android:text="Sign up"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textView3"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
@ -27,27 +27,27 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPersonName"
|
||||
android:id="@+id/editTextTextPassword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="23dp"
|
||||
android:ems="10"
|
||||
android:hint="Username"
|
||||
android:hint="Password"
|
||||
android:inputType="textPersonName"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextPassword"
|
||||
android:id="@+id/editTextTextPassword2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="1dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:ems="10"
|
||||
android:hint="Password"
|
||||
android:hint="Confirm Password"
|
||||
android:inputType="textPassword"
|
||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextPersonName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName" />
|
||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextPassword"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextEmailAddress"
|
||||
@ -75,6 +75,7 @@
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text=""
|
||||
app:layout_constraintBottom_toTopOf="@+id/button2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user