Merge pull request #86 from ClaytonWWilson/master

Merge code from master
This commit is contained in:
Aaron Sun 2020-11-01 09:22:26 -08:00 committed by GitHub
commit 424f012637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 139 additions and 30 deletions

View File

@ -52,4 +52,5 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
implementation 'com.crystal:crystalrangeseekbar:1.1.3'
implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
}

View File

@ -2,21 +2,30 @@ package com.example.listify.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.chauthai.swipereveallayout.SwipeRevealLayout;
import com.chauthai.swipereveallayout.ViewBinderHelper;
import com.example.listify.ListPage;
import com.example.listify.R;
import com.example.listify.data.List;
import java.util.ArrayList;
public class DisplayShoppingListsAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<List> lists;
private LayoutInflater inflater;
private final ViewBinderHelper binderHelper;
public DisplayShoppingListsAdapter(Activity activity, ArrayList<List> lists){
binderHelper = new ViewBinderHelper();
this.activity = activity;
this.lists = lists;
}
@ -38,18 +47,77 @@ public class DisplayShoppingListsAdapter extends BaseAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (inflater == null) {
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
if (convertView == null) {
convertView = inflater.inflate(R.layout.display_shopping_lists_item, null);
holder = new ViewHolder();
holder.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
holder.frontView = convertView.findViewById(R.id.front_layout);
holder.deleteList = convertView.findViewById(R.id.delete_list);
holder.shareList = convertView.findViewById(R.id.share_list);
holder.textView = (TextView) convertView.findViewById(R.id.shopping_list_name);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
List curList = lists.get(position);
final List curList = lists.get(position);
TextView tvListName = (TextView) convertView.findViewById(R.id.shopping_list_name);
tvListName.setText(curList.getName());
// Bind the view to the unique list ID
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getItemID()));
holder.textView.setText(curList.getName());
holder.deleteList.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: Add database call to delete the list on the server
Toast.makeText(activity, String.format("%s deleted", curList.getName()), Toast.LENGTH_SHORT).show();
lists.remove(position);
// Update listView
notifyDataSetChanged();
}
});
holder.shareList.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: Add database call to share list
Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
// Close the layout
binderHelper.closeLayout(Integer.toString(curList.getItemID()));
}
});
holder.frontView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent listPage = new Intent(activity, ListPage.class);
// Send the list ID
listPage.putExtra("listID", curList.getItemID());
activity.startActivity(listPage);
}
});
return convertView;
}
private class ViewHolder {
SwipeRevealLayout swipeLayout;
View frontView;
View deleteList;
View shareList;
TextView textView;
}
}

View File

@ -178,16 +178,16 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
@Override
public void run() {
shoppingListsView.setAdapter(displayShoppingListsAdapter);
shoppingListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent listPage = new Intent(getContext(), ListPage.class);
// Send the list ID
listPage.putExtra("listID", shoppingLists.get(position).getItemID());
startActivity(listPage);
}
});
// shoppingListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Intent listPage = new Intent(getContext(), ListPage.class);
//
// // Send the list ID
// listPage.putExtra("listID", shoppingLists.get(position).getItemID());
// startActivity(listPage);
// }
// });
loadingLists.setVisibility(View.GONE);
}
});

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8.46,11.88l1.41,-1.41L12,12.59l2.12,-2.12 1.41,1.41L13.41,14l2.12,2.12 -1.41,1.41L12,15.41l-2.12,2.12 -1.41,-1.41L10.59,14l-2.13,-2.12zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>

View File

@ -1,20 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.chauthai.swipereveallayout.SwipeRevealLayout
android:id="@+id/swipe_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/shopping_list_name"
android:layout_height="wrap_content"
app:dragEdge="right"
app:mode="same_level">
<FrameLayout
android:id="@+id/back_layout"
android:layout_width="wrap_content"
android:layout_height="50dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/share_list"
android:src="@drawable/ic_baseline_share_24"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/colorAccent"/>
<ImageView
android:id="@+id/delete_list"
android:src="@drawable/ic_baseline_delete_forever_24"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@android:color/holo_red_dark"/>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/front_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="8dp"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
android:layout_height="50dp">
<TextView
android:id="@+id/shopping_list_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:layout_gravity="center"/>
</FrameLayout>
</com.chauthai.swipereveallayout.SwipeRevealLayout>