mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Merge pull request #93 from ClaytonWWilson/aaron-branch-2
Aaron branch 2
This commit is contained in:
commit
6ff5e9ab30
@ -42,7 +42,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
Button decrQuan;
|
Button decrQuan;
|
||||||
Button removeItem;
|
Button removeItem;
|
||||||
Button clearAll;
|
Button clearAll;
|
||||||
Button shareList;
|
//Button shareList;
|
||||||
|
|
||||||
TextView tvTotalPrice;
|
TextView tvTotalPrice;
|
||||||
ProgressBar loadingListItems;
|
ProgressBar loadingListItems;
|
||||||
@ -70,6 +70,15 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
|
|
||||||
final int listID = (int) getIntent().getSerializableExtra("listID");
|
final int listID = (int) getIntent().getSerializableExtra("listID");
|
||||||
|
|
||||||
|
Properties configs = new Properties();
|
||||||
|
try {
|
||||||
|
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
|
requestor.getObject(Integer.toString(listID), List.class, this);
|
||||||
|
|
||||||
listView = findViewById(R.id.listView);
|
listView = findViewById(R.id.listView);
|
||||||
myAdapter = new MyAdapter(this, pNames, pStores, pPrices, pQuantity, pImages);
|
myAdapter = new MyAdapter(this, pNames, pStores, pPrices, pQuantity, pImages);
|
||||||
listView.setAdapter(myAdapter);
|
listView.setAdapter(myAdapter);
|
||||||
@ -100,7 +109,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
shareList = (Button) findViewById(R.id.buttonShare);
|
/*shareList = (Button) findViewById(R.id.buttonShare);
|
||||||
shareList.setOnClickListener(new View.OnClickListener() {
|
shareList.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -114,16 +123,6 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
|
EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
|
||||||
String sharedEmail = sharedEmailText.getText().toString();
|
String sharedEmail = sharedEmailText.getText().toString();
|
||||||
//String[] sharedEmailList = sharedEmails.split(", ");
|
|
||||||
//for(String email : sharedEmailList) {
|
|
||||||
//Properties configs = new Properties();
|
|
||||||
//try {
|
|
||||||
// configs = AuthManager.loadProperties(ListPage.this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
|
||||||
//} catch (IOException | JSONException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
//}
|
|
||||||
//Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
|
||||||
//SynchronousReceiver<Integer> ls = new SynchronousReceiver<>();
|
|
||||||
ListShare listShare = new ListShare(listID, sharedEmail);
|
ListShare listShare = new ListShare(listID, sharedEmail);
|
||||||
try {
|
try {
|
||||||
requestor.postObject(listShare);
|
requestor.postObject(listShare);
|
||||||
@ -131,7 +130,6 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||||
@ -141,16 +139,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
|
|
||||||
Properties configs = new Properties();
|
|
||||||
try {
|
|
||||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
|
||||||
} catch (IOException | JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
|
||||||
requestor.getObject(Integer.toString(listID), List.class, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,22 +1,34 @@
|
|||||||
package com.example.listify.adapter;
|
package com.example.listify.adapter;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.chauthai.swipereveallayout.SwipeRevealLayout;
|
import com.chauthai.swipereveallayout.SwipeRevealLayout;
|
||||||
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
||||||
|
import com.example.listify.AuthManager;
|
||||||
import com.example.listify.ListPage;
|
import com.example.listify.ListPage;
|
||||||
import com.example.listify.R;
|
import com.example.listify.R;
|
||||||
|
import com.example.listify.Requestor;
|
||||||
import com.example.listify.data.List;
|
import com.example.listify.data.List;
|
||||||
|
import com.example.listify.data.ListShare;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
@ -49,6 +61,14 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
|||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
|
|
||||||
|
Properties configs = new Properties();
|
||||||
|
try {
|
||||||
|
configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json");
|
||||||
|
} catch (IOException | JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
|
|
||||||
if (inflater == null) {
|
if (inflater == null) {
|
||||||
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
}
|
}
|
||||||
@ -78,6 +98,12 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// TODO: Add database call to delete the list on the server
|
// TODO: Add database call to delete the list on the server
|
||||||
|
|
||||||
|
try {
|
||||||
|
requestor.deleteObject(Integer.toString(curList.getItemID()), List.class);
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
Toast.makeText(activity, String.format("%s deleted", curList.getName()), Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, String.format("%s deleted", curList.getName()), Toast.LENGTH_SHORT).show();
|
||||||
lists.remove(position);
|
lists.remove(position);
|
||||||
@ -92,6 +118,32 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// TODO: Add database call to share list
|
// TODO: Add database call to share list
|
||||||
|
|
||||||
|
View codeView = inflater.inflate(R.layout.activity_sharedemail, null);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
builder.setView(codeView);
|
||||||
|
builder.setTitle("Share list");
|
||||||
|
builder.setMessage("Please enter the email of the user who you want to share the list with.");
|
||||||
|
builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
|
||||||
|
String sharedEmail = sharedEmailText.getText().toString();
|
||||||
|
ListShare listShare = new ListShare(curList.getItemID(), sharedEmail);
|
||||||
|
try {
|
||||||
|
requestor.postObject(listShare);
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {}
|
||||||
|
});
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
// Close the layout
|
// Close the layout
|
||||||
|
|||||||
@ -16,33 +16,33 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonClear"
|
android:id="@+id/buttonClear"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="1dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="1dp"
|
||||||
android:text="Clear All"
|
android:text="Clear All"
|
||||||
android:textSize="10sp"/>
|
android:textSize="10sp"/>
|
||||||
|
|
||||||
<Button
|
<!--<Button
|
||||||
android:id="@+id/buttonShare"
|
android:id="@+id/buttonShare"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="26dp"
|
android:layout_marginStart="26dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="Share"
|
android:text="Share"
|
||||||
android:textSize="10sp"/>
|
android:textSize="10sp"/>-->
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/listView"
|
android:id="@+id/listView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="600dp"
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="50dp"
|
||||||
android:paddingBottom="20dp">
|
android:paddingBottom="20dp"/>
|
||||||
</ListView>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -67,4 +67,5 @@
|
|||||||
android:text="@string/default__00_00"/>
|
android:text="@string/default__00_00"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
Loading…
Reference in New Issue
Block a user