Various layout improvements

This commit is contained in:
Clayton Wilson 2020-10-09 01:35:16 -04:00
parent 38aea790d8
commit c1a8103da8
8 changed files with 60 additions and 54 deletions

View File

@ -46,28 +46,26 @@ public class UserDeleter implements CallHandler {
awsCognitoIdentityProvider.adminDeleteUser(adminDeleteUserRequest); awsCognitoIdentityProvider.adminDeleteUser(adminDeleteUserRequest);
try {
PreparedStatement statement = connection.prepareStatement(GET_LISTS);
statement.setString(1, cognitoID);
System.out.println(statement);
ResultSet userLists = statement.executeQuery();
while (userLists.next()) {
int listID = userLists.getInt("listID");
statement = connection.prepareStatement(DELETE_LIST_PRODUCT); PreparedStatement statement = connection.prepareStatement(GET_LISTS);
statement.setInt(1, listID); statement.setString(1, cognitoID);
System.out.println(statement); System.out.println(statement);
statement.executeQuery(); ResultSet userLists = statement.executeQuery();
} while (userLists.next()) {
int listID = userLists.getInt("listID");
statement = connection.prepareStatement(DELETE_LISTS); statement = connection.prepareStatement(DELETE_LIST_PRODUCT);
statement.setString(1, cognitoID); statement.setInt(1, listID);
System.out.println(statement); System.out.println(statement);
statement.executeQuery(); statement.executeQuery();
connection.commit();
} finally {
connection.close();
} }
statement = connection.prepareStatement(DELETE_LISTS);
statement.setString(1, cognitoID);
System.out.println(statement);
statement.executeQuery();
connection.commit();
return null; return null;
} }
} }

View File

@ -29,6 +29,7 @@ public class CreateListDialogFragment extends DialogFragment {
@Override @Override
public Dialog onCreateDialog(final Bundle savedInstanceState) { public Dialog onCreateDialog(final Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater // Get the layout inflater
LayoutInflater inflater = requireActivity().getLayoutInflater(); LayoutInflater inflater = requireActivity().getLayoutInflater();
@ -59,7 +60,7 @@ public class CreateListDialogFragment extends DialogFragment {
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
try { try {
onNewListListener = (OnNewListListener) getActivity(); onNewListListener = (OnNewListListener) getTargetFragment();
} catch (ClassCastException e) { } catch (ClassCastException e) {
Log.e("CreateListDialogFragment", "onAttach: ClassCastException: " + e.getMessage()); Log.e("CreateListDialogFragment", "onAttach: ClassCastException: " + e.getMessage());
} }

View File

@ -74,11 +74,11 @@ public class ListPickerDialogFragment extends DialogFragment {
userListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() { userListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
for (int i = 0; i < parent.getChildCount(); i++) { // for (int i = 0; i < parent.getChildCount(); i++) {
parent.getChildAt(i).setBackgroundColor(Color.TRANSPARENT); // parent.getChildAt(i).setBackgroundColor(Color.TRANSPARENT);
} // }
parent.getChildAt(position).setBackgroundColor(Color.GREEN); // parent.getChildAt(position).setBackgroundColor(Color.GREEN);
// view.setBackgroundColor(Color.GREEN); // view.setBackgroundColor(Color.GREEN);
selectedListIndex = position; selectedListIndex = position;
} }

View File

@ -132,7 +132,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
NavigationView navigationView = findViewById(R.id.nav_view); NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each menu should be considered as top level destinations. // Passing each menu ID as a set of Ids because each menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder( mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow, R.id.nav_lists) R.id.nav_home, R.id.nav_lists)
.setDrawerLayout(drawer) .setDrawerLayout(drawer)
.build(); .build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);

View File

@ -36,6 +36,7 @@ import static com.example.listify.MainActivity.am;
public class ListsFragment extends Fragment implements CreateListDialogFragment.OnNewListListener { public class ListsFragment extends Fragment implements CreateListDialogFragment.OnNewListListener {
ArrayList<List> shoppingLists = new ArrayList<>(); ArrayList<List> shoppingLists = new ArrayList<>();
DisplayShoppingListsAdapter displayShoppingListsAdapter;
ListView shoppingListsView; ListView shoppingListsView;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -67,7 +68,7 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
// Set adapter and display this users lists // Set adapter and display this users lists
DisplayShoppingListsAdapter displayShoppingListsAdapter = new DisplayShoppingListsAdapter(getActivity(), shoppingLists); displayShoppingListsAdapter = new DisplayShoppingListsAdapter(getActivity(), shoppingLists);
shoppingListsView.setAdapter(displayShoppingListsAdapter); shoppingListsView.setAdapter(displayShoppingListsAdapter);
shoppingListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() { shoppingListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
@ -81,11 +82,13 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
}); });
FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.new_list_fab); FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.new_list_fab);
Fragment thisFragment = this;
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CreateListDialogFragment createListDialogFragment = new CreateListDialogFragment(); CreateListDialogFragment createListDialogFragment = new CreateListDialogFragment();
createListDialogFragment.show(getActivity().getSupportFragmentManager(), "Create New List"); createListDialogFragment.show(getFragmentManager(), "Create New List");
createListDialogFragment.setTargetFragment(thisFragment, 0);
} }
}); });
@ -108,7 +111,9 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
try { try {
requestor.postObject(newList, idReceiver, idReceiver); requestor.postObject(newList, idReceiver, idReceiver);
System.out.println(idReceiver.await()); newList.setItemID(idReceiver.await());
shoppingLists.add(newList);
displayShoppingListsAdapter.notifyDataSetChanged();
Toast.makeText(getContext(), String.format("%s created", name), Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), String.format("%s created", name), Toast.LENGTH_LONG).show();
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(getContext(), "An error occurred", Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "An error occurred", Toast.LENGTH_LONG).show();

View File

@ -18,7 +18,9 @@
android:layout_height="300dp" android:layout_height="300dp"
android:divider="@color/list_divider" android:divider="@color/list_divider"
android:dividerHeight="1dp" android:dividerHeight="1dp"
android:choiceMode="multipleChoiceModal"/> android:layout_marginHorizontal="50dp"
android:choiceMode="singleChoice"
android:listSelector="@color/colorAccent"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height" android:layout_height="10dp"
android:background="@drawable/side_nav_bar" android:background="@drawable/side_nav_bar"
android:gravity="bottom" android:gravity="bottom"
android:orientation="vertical" android:orientation="vertical"
@ -12,24 +12,24 @@
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark"> android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView <!-- <ImageView-->
android:id="@+id/imageView" <!-- android:id="@+id/imageView"-->
android:layout_width="wrap_content" <!-- android:layout_width="wrap_content"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:contentDescription="@string/nav_header_desc" <!-- android:contentDescription="@string/nav_header_desc"-->
android:paddingTop="@dimen/nav_header_vertical_spacing" <!-- android:paddingTop="@dimen/nav_header_vertical_spacing"-->
app:srcCompat="@mipmap/ic_launcher_round" /> <!-- app:srcCompat="@mipmap/ic_launcher_round" />-->
<TextView <!-- <TextView-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:paddingTop="@dimen/nav_header_vertical_spacing" <!-- android:paddingTop="@dimen/nav_header_vertical_spacing"-->
android:text="@string/nav_header_title" <!-- android:text="@string/nav_header_title"-->
android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <!-- android:textAppearance="@style/TextAppearance.AppCompat.Body1" />-->
<TextView <!-- <TextView-->
android:id="@+id/textView" <!-- android:id="@+id/textView"-->
android:layout_width="wrap_content" <!-- android:layout_width="wrap_content"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:text="@string/nav_header_subtitle" /> <!-- android:text="@string/nav_header_subtitle" />-->
</LinearLayout> </LinearLayout>

View File

@ -8,14 +8,14 @@
android:id="@+id/nav_home" android:id="@+id/nav_home"
android:icon="@drawable/ic_menu_camera" android:icon="@drawable/ic_menu_camera"
android:title="@string/menu_home" /> android:title="@string/menu_home" />
<item <!-- <item-->
android:id="@+id/nav_gallery" <!-- android:id="@+id/nav_gallery"-->
android:icon="@drawable/ic_menu_gallery" <!-- android:icon="@drawable/ic_menu_gallery"-->
android:title="@string/menu_gallery" /> <!-- android:title="@string/menu_gallery" />-->
<item <!-- <item-->
android:id="@+id/nav_slideshow" <!-- android:id="@+id/nav_slideshow"-->
android:icon="@drawable/ic_menu_slideshow" <!-- android:icon="@drawable/ic_menu_slideshow"-->
android:title="@string/menu_slideshow" /> <!-- android:title="@string/menu_slideshow" />-->
<item <item
android:id="@+id/nav_lists" android:id="@+id/nav_lists"
android:icon="@drawable/ic_baseline_list_alt_28" android:icon="@drawable/ic_baseline_list_alt_28"