App schneller
App wurde schneller durch Optimierung der Datenbankabfragen und durch besseres Object Handling
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								.idea/caches/gradle_models.ser
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.idea/caches/gradle_models.ser
									
									
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -36,23 +36,30 @@ import android.widget.Toast;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.google.firebase.auth.FirebaseAuth;
 | 
					import com.google.firebase.auth.FirebaseAuth;
 | 
				
			||||||
import com.google.firebase.auth.FirebaseUser;
 | 
					import com.google.firebase.auth.FirebaseUser;
 | 
				
			||||||
 | 
					import com.google.gson.JsonSerializer;
 | 
				
			||||||
import com.squareup.picasso.Picasso;
 | 
					import com.squareup.picasso.Picasso;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.json.JSONException;
 | 
					import org.json.JSONException;
 | 
				
			||||||
import org.w3c.dom.Text;
 | 
					import org.w3c.dom.Text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.ByteArrayOutputStream;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.io.ObjectOutputStream;
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
import java.sql.SQLException;
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.util.Base64;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
 | 
				
			||||||
import at.smartshopper.smartshopper.db.Database;
 | 
					import at.smartshopper.smartshopper.db.Database;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
 | 
					import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.ShoppinglistAdapter;
 | 
					import at.smartshopper.smartshopper.shoppinglist.ShoppinglistAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnItemClicked, ShoppinglistAdapter.OnChangeItemClick, ShoppinglistAdapter.OnShareClick {
 | 
					public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnItemClicked, ShoppinglistAdapter.OnShoppinglistClick, ShoppinglistAdapter.OnChangeItemClick, ShoppinglistAdapter.OnShareClick {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Database db = new Database();
 | 
					    private final Database db = new Database();
 | 
				
			||||||
    private SwipeRefreshLayout ownswiperefresh, sharedswiperefresh;
 | 
					    private SwipeRefreshLayout ownswiperefresh, sharedswiperefresh;
 | 
				
			||||||
    private FloatingActionButton addShoppinglistFab;
 | 
					    private FloatingActionButton addShoppinglistFab;
 | 
				
			||||||
    private PopupWindow popupWindowAdd, popupShare, popupAddShare;
 | 
					    private PopupWindow popupWindowAdd, popupShare, popupAddShare;
 | 
				
			||||||
@@ -336,10 +343,11 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
        sharedRecycler.setHasFixedSize(true);
 | 
					        sharedRecycler.setHasFixedSize(true);
 | 
				
			||||||
        sharedRecycler.setLayoutManager(new LinearLayoutManager(this));
 | 
					        sharedRecycler.setLayoutManager(new LinearLayoutManager(this));
 | 
				
			||||||
        List<Shoppinglist> ownListsList = db.getSharedShoppinglists(uid);
 | 
					        List<Shoppinglist> ownListsList = db.getSharedShoppinglists(uid);
 | 
				
			||||||
        ShoppinglistAdapter shpAdapter = new ShoppinglistAdapter(Dash.this, ownListsList);
 | 
					        ShoppinglistAdapter shpAdapter = new ShoppinglistAdapter(Dash.this, ownListsList, db);
 | 
				
			||||||
        shpAdapter.setOnDelClick(Dash.this);
 | 
					        shpAdapter.setOnDelClick(Dash.this);
 | 
				
			||||||
        shpAdapter.setOnChangeClick(Dash.this);
 | 
					        shpAdapter.setOnChangeClick(Dash.this);
 | 
				
			||||||
        shpAdapter.setOnShareClick(Dash.this);
 | 
					        shpAdapter.setOnShareClick(Dash.this);
 | 
				
			||||||
 | 
					        shpAdapter.setOnShoppinglistClick(Dash.this);
 | 
				
			||||||
        sharedRecycler.setAdapter(shpAdapter);
 | 
					        sharedRecycler.setAdapter(shpAdapter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -354,10 +362,12 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
        ownRecycleView.setHasFixedSize(true);
 | 
					        ownRecycleView.setHasFixedSize(true);
 | 
				
			||||||
        ownRecycleView.setLayoutManager(new LinearLayoutManager(this));
 | 
					        ownRecycleView.setLayoutManager(new LinearLayoutManager(this));
 | 
				
			||||||
        List<Shoppinglist> ownListsList = db.getMyShoppinglists(uid);
 | 
					        List<Shoppinglist> ownListsList = db.getMyShoppinglists(uid);
 | 
				
			||||||
        ShoppinglistAdapter shpAdapter = new ShoppinglistAdapter(Dash.this, ownListsList);
 | 
					        ShoppinglistAdapter shpAdapter = new ShoppinglistAdapter(Dash.this, ownListsList, db);
 | 
				
			||||||
        shpAdapter.setOnDelClick(Dash.this);
 | 
					        shpAdapter.setOnDelClick(Dash.this);
 | 
				
			||||||
        shpAdapter.setOnChangeClick(Dash.this);
 | 
					        shpAdapter.setOnChangeClick(Dash.this);
 | 
				
			||||||
        shpAdapter.setOnShareClick(Dash.this);
 | 
					        shpAdapter.setOnShareClick(Dash.this);
 | 
				
			||||||
 | 
					        shpAdapter.setOnShoppinglistClick(Dash.this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ownRecycleView.setAdapter(shpAdapter);
 | 
					        ownRecycleView.setAdapter(shpAdapter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -646,4 +656,13 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
				
			|||||||
        popupShare.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
					        popupShare.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
				
			||||||
        popupShare.update();
 | 
					        popupShare.update();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onShoppinglistClick(String sl_id, View v) {
 | 
				
			||||||
 | 
					        Intent intent = new Intent(this, ShoppinglistDetails.class);
 | 
				
			||||||
 | 
					        intent.putExtra("sl_id", sl_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        startActivity(intent);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,18 +27,20 @@ import java.sql.SQLException;
 | 
				
			|||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import at.smartshopper.smartshopper.R;
 | 
					import at.smartshopper.smartshopper.R;
 | 
				
			||||||
 | 
					import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
 | 
				
			||||||
import at.smartshopper.smartshopper.db.Database;
 | 
					import at.smartshopper.smartshopper.db.Database;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
 | 
					import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemAdapter;
 | 
					import at.smartshopper.smartshopper.shoppinglist.details.item.ItemAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ItemListActivity extends Activity implements ItemAdapter.OnItemEditClicked, ItemAdapter.OnItemDelClicked {
 | 
					public class ItemListActivity extends Activity implements ItemAdapter.OnItemEditClicked, ItemAdapter.OnItemDelClicked, ItemAdapter.OnItemCheckClicked {
 | 
				
			||||||
    private String group_id, groupNameString;
 | 
					    private String group_id, groupNameString;
 | 
				
			||||||
    private String sl_id;
 | 
					    private String sl_id;
 | 
				
			||||||
    private PopupWindow popupWindowItem;
 | 
					    private PopupWindow popupWindowItem;
 | 
				
			||||||
    private FloatingActionButton fabAddItem;
 | 
					    private FloatingActionButton fabAddItem;
 | 
				
			||||||
    private TextView groupName;
 | 
					    private TextView groupName;
 | 
				
			||||||
    private String colorString;
 | 
					    private String colorString;
 | 
				
			||||||
    private Database db = new Database();
 | 
					    private Database db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private View colorView;
 | 
					    private View colorView;
 | 
				
			||||||
    private SwipeRefreshLayout swipeRefreshLayoutItem;
 | 
					    private SwipeRefreshLayout swipeRefreshLayoutItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,6 +54,7 @@ public class ItemListActivity extends Activity implements ItemAdapter.OnItemEdit
 | 
				
			|||||||
        this.group_id = myIntent.getStringExtra("group_id"); // will return "FirstKeyValue"
 | 
					        this.group_id = myIntent.getStringExtra("group_id"); // will return "FirstKeyValue"
 | 
				
			||||||
        this.sl_id = myIntent.getStringExtra("sl_id"); // will return "SecondKeyValue"
 | 
					        this.sl_id = myIntent.getStringExtra("sl_id"); // will return "SecondKeyValue"
 | 
				
			||||||
        this.groupNameString = myIntent.getStringExtra("groupNameString"); // will return "SecondKeyValue"
 | 
					        this.groupNameString = myIntent.getStringExtra("groupNameString"); // will return "SecondKeyValue"
 | 
				
			||||||
 | 
					        this.db = new Database();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.groupName = (TextView)findViewById(R.id.groupViewName);
 | 
					        this.groupName = (TextView)findViewById(R.id.groupViewName);
 | 
				
			||||||
        this.groupName.setText(groupNameString);
 | 
					        this.groupName.setText(groupNameString);
 | 
				
			||||||
@@ -110,14 +113,16 @@ public class ItemListActivity extends Activity implements ItemAdapter.OnItemEdit
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private void showItems(String group_id, String sl_id) throws SQLException, JSONException {
 | 
					    private void showItems(String group_id, String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        RecyclerView itemsListRecycler = findViewById(R.id.itemsListRecycler);
 | 
					        RecyclerView itemsListRecycler = findViewById(R.id.itemsListRecycler);
 | 
				
			||||||
 | 
					        int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.item_spacing);
 | 
				
			||||||
 | 
					        itemsListRecycler.addItemDecoration(new SpaceItemDecoration(spacingInPixels));
 | 
				
			||||||
        itemsListRecycler.setHasFixedSize(true);
 | 
					        itemsListRecycler.setHasFixedSize(true);
 | 
				
			||||||
        itemsListRecycler.setLayoutManager(new LinearLayoutManager(this));
 | 
					        itemsListRecycler.setLayoutManager(new LinearLayoutManager(this));
 | 
				
			||||||
        List<Item> itemList = new Database().getItemsOfGroup(group_id, sl_id);
 | 
					        List<Item> itemList = db.getItemsOfGroup(group_id, sl_id);
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ItemAdapter itemAdapter = new ItemAdapter(itemList);
 | 
					        ItemAdapter itemAdapter = new ItemAdapter(itemList);
 | 
				
			||||||
        itemAdapter.setOnItemEditClick(this);
 | 
					        itemAdapter.setOnItemEditClick(this);
 | 
				
			||||||
        itemAdapter.setItemDelClick(this);
 | 
					        itemAdapter.setItemDelClick(this);
 | 
				
			||||||
 | 
					        itemAdapter.setOnItemCheckClick(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        itemsListRecycler.setAdapter(itemAdapter);
 | 
					        itemsListRecycler.setAdapter(itemAdapter);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -229,9 +234,24 @@ public class ItemListActivity extends Activity implements ItemAdapter.OnItemEdit
 | 
				
			|||||||
        popupWindowItem.setOutsideTouchable(false);
 | 
					        popupWindowItem.setOutsideTouchable(false);
 | 
				
			||||||
        popupWindowItem.setFocusable(true);
 | 
					        popupWindowItem.setFocusable(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        popupWindowItem.setAnimationStyle(R.style.popup_window_animation_phone);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        popupWindowItem.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
					        popupWindowItem.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
				
			||||||
        popupWindowItem.update();
 | 
					        popupWindowItem.update();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onItemCheckClicked(String uid, String name, String itemId, String groupId, String sl_id, int count) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            swipeRefreshLayoutItem.setRefreshing(true);
 | 
				
			||||||
 | 
					            db.setDoneItem(uid, name, itemId, groupId, sl_id, count);
 | 
				
			||||||
 | 
					            showItems(group_id, sl_id);
 | 
				
			||||||
 | 
					            swipeRefreshLayoutItem.setRefreshing(false);
 | 
				
			||||||
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        } catch (JSONException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,12 +20,19 @@ import android.widget.PopupWindow;
 | 
				
			|||||||
import android.widget.TextView;
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.google.firebase.auth.FirebaseAuth;
 | 
					import com.google.firebase.auth.FirebaseAuth;
 | 
				
			||||||
 | 
					import com.google.gson.Gson;
 | 
				
			||||||
 | 
					import com.google.gson.GsonBuilder;
 | 
				
			||||||
import com.squareup.picasso.Picasso;
 | 
					import com.squareup.picasso.Picasso;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.json.JSONException;
 | 
					import org.json.JSONException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.ByteArrayInputStream;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.sql.SQLException;
 | 
					import java.sql.SQLException;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import at.smartshopper.smartshopper.R;
 | 
					import at.smartshopper.smartshopper.R;
 | 
				
			||||||
 | 
					import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
 | 
				
			||||||
import at.smartshopper.smartshopper.db.Database;
 | 
					import at.smartshopper.smartshopper.db.Database;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
 | 
					import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.details.Details;
 | 
					import at.smartshopper.smartshopper.shoppinglist.details.Details;
 | 
				
			||||||
@@ -34,11 +41,10 @@ import at.smartshopper.smartshopper.shoppinglist.details.group.Group;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGroupEditClicked, DetailsAdapter.OnGroupDeleteClicked, DetailsAdapter.OnCardClicked {
 | 
					public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGroupEditClicked, DetailsAdapter.OnGroupDeleteClicked, DetailsAdapter.OnCardClicked {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Database db = new Database();
 | 
					    private Database db;
 | 
				
			||||||
    private FloatingActionButton fab;
 | 
					    private FloatingActionButton fab;
 | 
				
			||||||
    private String colorString;
 | 
					    private String colorString;
 | 
				
			||||||
    private PopupWindow popupWindow;
 | 
					    private PopupWindow popupWindow;
 | 
				
			||||||
    private PopupWindow popupWindowItem;
 | 
					 | 
				
			||||||
    private Button colorBtn;
 | 
					    private Button colorBtn;
 | 
				
			||||||
    private SwipeRefreshLayout detailsSwiperefresh;
 | 
					    private SwipeRefreshLayout detailsSwiperefresh;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -47,14 +53,11 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
 | 
				
			|||||||
        super.onCreate(savedInstanceState);
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
        setContentView(R.layout.activity_shoppinglist_details);
 | 
					        setContentView(R.layout.activity_shoppinglist_details);
 | 
				
			||||||
        fab = findViewById(R.id.addGroupFab);
 | 
					        fab = findViewById(R.id.addGroupFab);
 | 
				
			||||||
 | 
					        db = new Database();
 | 
				
			||||||
        colorBtn = (Button) findViewById(R.id.groupColor);
 | 
					        colorBtn = (Button) findViewById(R.id.groupColor);
 | 
				
			||||||
        Bundle bundle = getIntent().getExtras();
 | 
					        Intent intent = getIntent();
 | 
				
			||||||
        String sl_id = null; // or other values
 | 
					        String sl_id = intent.getStringExtra("sl_id");
 | 
				
			||||||
        if (bundle != null)
 | 
					 | 
				
			||||||
            sl_id = bundle.getString("sl_id");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Toast.makeText(this, "Click detected on item " + position, Toast.LENGTH_LONG).show();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            Shoppinglist shoppinglist = db.getShoppinglist(sl_id);
 | 
					            Shoppinglist shoppinglist = db.getShoppinglist(sl_id);
 | 
				
			||||||
@@ -105,6 +108,7 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Zeigt ein Popup zum bearbeiten und erstellen von groups
 | 
					     * Zeigt ein Popup zum bearbeiten und erstellen von groups
 | 
				
			||||||
     * Wenn from db true ist wird die groupid benötigt
 | 
					     * Wenn from db true ist wird die groupid benötigt
 | 
				
			||||||
@@ -201,6 +205,8 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
 | 
				
			|||||||
        popupWindow.setOutsideTouchable(false);
 | 
					        popupWindow.setOutsideTouchable(false);
 | 
				
			||||||
        popupWindow.setFocusable(true);
 | 
					        popupWindow.setFocusable(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        popupWindow.setAnimationStyle(R.style.popup_window_animation_phone);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
					        popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
 | 
				
			||||||
        popupWindow.update();
 | 
					        popupWindow.update();
 | 
				
			||||||
@@ -249,12 +255,14 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private void showDetails(String sl_id) throws SQLException, JSONException {
 | 
					    private void showDetails(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        RecyclerView detailsRecycleView = (RecyclerView) findViewById(R.id.groupRecycle);
 | 
					        RecyclerView detailsRecycleView = (RecyclerView) findViewById(R.id.groupRecycle);
 | 
				
			||||||
 | 
					        int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.item_spacing);
 | 
				
			||||||
 | 
					        detailsRecycleView.addItemDecoration(new SpaceItemDecoration(spacingInPixels));
 | 
				
			||||||
        detailsRecycleView.setHasFixedSize(true);
 | 
					        detailsRecycleView.setHasFixedSize(true);
 | 
				
			||||||
        detailsRecycleView.setLayoutManager(new LinearLayoutManager(this));
 | 
					        detailsRecycleView.setLayoutManager(new LinearLayoutManager(this));
 | 
				
			||||||
        List<Details> detailsList = db.getListDetails(sl_id);
 | 
					        List<Details> detailsList = db.getListDetails(sl_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DetailsAdapter detailsAdapter = new DetailsAdapter(detailsList);
 | 
					        DetailsAdapter detailsAdapter = new DetailsAdapter(detailsList, db);
 | 
				
			||||||
        detailsAdapter.setGroupEditClick(this);
 | 
					        detailsAdapter.setGroupEditClick(this);
 | 
				
			||||||
        detailsAdapter.setGroupDeleteClick(this);
 | 
					        detailsAdapter.setGroupDeleteClick(this);
 | 
				
			||||||
        detailsAdapter.setCardClick(this);
 | 
					        detailsAdapter.setCardClick(this);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					package at.smartshopper.smartshopper.customViews;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Rect;
 | 
				
			||||||
 | 
					import android.support.v7.widget.RecyclerView;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int space;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public SpaceItemDecoration(int space) {
 | 
				
			||||||
 | 
					        this.space = space;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void getItemOffsets(Rect outRect, View view,
 | 
				
			||||||
 | 
					                               RecyclerView parent, RecyclerView.State state) {
 | 
				
			||||||
 | 
					        outRect.left = space;
 | 
				
			||||||
 | 
					        outRect.right = space;
 | 
				
			||||||
 | 
					        outRect.bottom = space;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Add top margin only for the first item to avoid double space between items
 | 
				
			||||||
 | 
					        if (parent.getChildLayoutPosition(view) == 0) {
 | 
				
			||||||
 | 
					            outRect.top = space;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            outRect.top = 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -3,17 +3,25 @@ package at.smartshopper.smartshopper.db;
 | 
				
			|||||||
import android.os.StrictMode;
 | 
					import android.os.StrictMode;
 | 
				
			||||||
import android.util.Log;
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.firebase.auth.FirebaseAuth;
 | 
				
			||||||
 | 
					import com.google.gson.JsonSerializer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.json.JSONException;
 | 
					import org.json.JSONException;
 | 
				
			||||||
import org.json.JSONObject;
 | 
					import org.json.JSONObject;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable;
 | 
				
			||||||
import java.sql.Connection;
 | 
					import java.sql.Connection;
 | 
				
			||||||
import java.sql.DriverManager;
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
import java.sql.PreparedStatement;
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
import java.sql.ResultSet;
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
import java.sql.SQLException;
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					import java.text.DateFormat;
 | 
				
			||||||
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Date;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import at.smartshopper.smartshopper.shoppinglist.Member;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
 | 
					import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.details.Details;
 | 
					import at.smartshopper.smartshopper.shoppinglist.details.Details;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.details.group.Group;
 | 
					import at.smartshopper.smartshopper.shoppinglist.details.group.Group;
 | 
				
			||||||
@@ -21,18 +29,28 @@ import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class Database {
 | 
					public class Database {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Connection conect;
 | 
					    private transient Connection conect;
 | 
				
			||||||
    final String HOST = "188.166.124.80";
 | 
					    final private String HOST = "188.166.124.80";
 | 
				
			||||||
    final String DB_NAME = "smartshopperdb";
 | 
					    final private String DB_NAME = "smartshopperdb";
 | 
				
			||||||
    final String USERNAME = "smartshopper-user";
 | 
					    final private String USERNAME = "smartshopper-user";
 | 
				
			||||||
    final String PASSWORD = "jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs";
 | 
					    final private String PASSWORD = "jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs";
 | 
				
			||||||
    final int PORT = 5432;
 | 
					    final private int PORT = 5432;
 | 
				
			||||||
 | 
					    final private int sl_idLength = 10;
 | 
				
			||||||
 | 
					    final private int groupIdLength = 10;
 | 
				
			||||||
 | 
					    final private int itemIdLength = 10;
 | 
				
			||||||
 | 
					    final private int inviteLength = 50;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Macht nix
 | 
					     * Macht nix
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Database() {
 | 
					    public Database() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            connectDatabase();
 | 
				
			||||||
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -49,8 +67,60 @@ public class Database {
 | 
				
			|||||||
        System.out.println("Database connected!");
 | 
					        System.out.println("Database connected!");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Setzt ein Item auf erledigt indem es in Done items verschoben wird
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param uid   Die User id, von dem das item geändert werden soll
 | 
				
			||||||
 | 
					     * @param name  Der name des Items
 | 
				
			||||||
 | 
					     * @param count Die Anzahl des Items
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setDoneItem(String uid, String name, String item_id, String groupId, String sl_id, int count) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        java.sql.Date date = new java.sql.Date(new java.util.Date().getDate());
 | 
				
			||||||
 | 
					        List<Member> members = getMembers(sl_id);
 | 
				
			||||||
 | 
					        Member admin = getAdmin(sl_id);
 | 
				
			||||||
 | 
					        sqlUpdate5ParamLastIsDateAndInt("INSERT INTO \"Done_Purchase\" (purchased_item_id, username, name, count, date) VALUES(?,?,?,?,?)", generateItemId(), admin.getUid(), name, count, date);
 | 
				
			||||||
 | 
					        for (int i = 0; i < members.size(); i++) {
 | 
				
			||||||
 | 
					            sqlUpdate5ParamLastIsDateAndInt("INSERT INTO \"Done_Purchase\" (purchased_item_id, username, name, count, date) VALUES(?,?,?,?,?)", generateItemId(), members.get(i).getUid(), name, count, date);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        sqlUpdate3Param("DELETE FROM \"Item\" WHERE item_id = ? AND group_id = ? AND sl_id = ?", item_id, groupId, sl_id);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Holt den Admin einer Shoppingliste
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param sl_id Die Shoppingliste von welcher der Admin gewünscht ist
 | 
				
			||||||
 | 
					     * @return Member Objekt das mit den Daten des Admins gefüllt ist
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     * @throws JSONException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public Member getAdmin(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        String SQL = "SELECT row_to_json(\"User\") as obj FROM \"User\" JOIN \"Shoppinglist_member\" USING (username) WHERE sl_id = ?";
 | 
				
			||||||
 | 
					        JSONObject jsonObject = new JSONObject(executeQuery(SQL, sl_id));
 | 
				
			||||||
 | 
					        return new Member(jsonObject.getString("username"), jsonObject.getString("message_id"));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Holt alle mitglieder einer Shoppingliste
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param sl_id Die Shoppingliste von der die Mitglieder gefragt sind
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public List<Member> getMembers(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        String SQL = "SELECT row_to_json(\"User\") as obj FROM \"User\" JOIN \"Shoppinglist_member\" USING (username) WHERE sl_id = ?";
 | 
				
			||||||
 | 
					        ArrayList<Member> members = new ArrayList();
 | 
				
			||||||
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQL, sl_id);
 | 
				
			||||||
 | 
					        for(int i = 0; i < jsonObjects.size(); i++){
 | 
				
			||||||
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
 | 
					            members.add(new Member(jsonObject.getString("username"), jsonObject.getString("message_id")));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return members;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Entfernt einen invitelink anhand des invitelinks
 | 
					     * Entfernt einen invitelink anhand des invitelinks
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param invitelink Löscht den invitelink aus der ganzen db
 | 
					     * @param invitelink Löscht den invitelink aus der ganzen db
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     * @throws JSONException
 | 
					     * @throws JSONException
 | 
				
			||||||
@@ -63,51 +133,36 @@ public class Database {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gibt den Invite link einer Shoppingliste zurück, wenn keiner vorhanden ist --> null
 | 
					     * Gibt den Invite link einer Shoppingliste zurück, wenn keiner vorhanden ist --> null
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param sl_id Die shoppinglist von der der invitelimnk gefragt ist
 | 
					     * @param sl_id Die shoppinglist von der der invitelimnk gefragt ist
 | 
				
			||||||
     * @return Der invite link
 | 
					     * @return Der invite link
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     * @throws JSONException
 | 
					     * @throws JSONException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String getInviteLink(String sl_id) throws SQLException, JSONException{
 | 
					    public String getInviteLink(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
        String SQL = "Select invitelink from \"Shoppinglist\" WHERE sl_id = ?";
 | 
					        String SQL = "Select invitelink from \"Shoppinglist\" WHERE sl_id = ?";
 | 
				
			||||||
 | 
					        String returnLink = executeQuery(SQL, sl_id);
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, sl_id);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        rs.next();
 | 
					 | 
				
			||||||
        String returnLink = rs.getString(1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return returnLink;
 | 
					        return returnLink;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Sucht anhand des invitelinks eine Shoppingliste und gibt dessen sl_id zurück
 | 
					     * Sucht anhand des invitelinks eine Shoppingliste und gibt dessen sl_id zurück
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param invitelink Der invitelink nach dem gesucht werden soll
 | 
					     * @param invitelink Der invitelink nach dem gesucht werden soll
 | 
				
			||||||
     * @return Die sl_id die dem invitelink zugeordnet ist
 | 
					     * @return Die sl_id die dem invitelink zugeordnet ist
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     * @throws JSONException
 | 
					     * @throws JSONException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private String getSlIdFromInvite(String invitelink) throws SQLException, JSONException{
 | 
					    private String getSlIdFromInvite(String invitelink) throws SQLException, JSONException {
 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
        String SQL = "Select sl_id from \"Shoppinglist\" WHERE invitelink = ?";
 | 
					        String SQL = "Select sl_id from \"Shoppinglist\" WHERE invitelink = ?";
 | 
				
			||||||
 | 
					        String returnSl_id = executeQuery(SQL, invitelink);
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, invitelink);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        rs.next();
 | 
					 | 
				
			||||||
        String returnSl_id = rs.getString(1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return returnSl_id;
 | 
					        return returnSl_id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Fügt einen invite link zu den shoppinglisten hinzu
 | 
					     * Fügt einen invite link zu den shoppinglisten hinzu
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param invitelink Der invite link der hinzugefügt werden soll
 | 
					     * @param invitelink Der invite link der hinzugefügt werden soll
 | 
				
			||||||
     * @param uid        Der user zu dem der invitelink hinzugefügt werden soll
 | 
					     * @param uid        Der user zu dem der invitelink hinzugefügt werden soll
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
@@ -115,18 +170,19 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public void addInviteLink(String invitelink, String uid) throws SQLException, JSONException {
 | 
					    public void addInviteLink(String invitelink, String uid) throws SQLException, JSONException {
 | 
				
			||||||
        String sl_id = getSlIdFromInvite(invitelink);
 | 
					        String sl_id = getSlIdFromInvite(invitelink);
 | 
				
			||||||
        if(!sl_id.equals("null")){
 | 
					        if (!sl_id.equals("null")) {
 | 
				
			||||||
            sqlUpdate2Param("INSERT INTO \"Shoppinglist_member\" (username, sl_id) VALUES (?, ?)", uid, sl_id);
 | 
					            sqlUpdate2Param("INSERT INTO \"Shoppinglist_member\" (username, sl_id) VALUES (?, ?)", uid, sl_id);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Erstellt einen neuen InviteLink
 | 
					     * Erstellt einen neuen InviteLink
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param sl_id
 | 
					     * @param sl_id
 | 
				
			||||||
     * @return Der neue InviteLink
 | 
					     * @return Der neue InviteLink
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String createInviteLink(String sl_id) throws SQLException{
 | 
					    public String createInviteLink(String sl_id) throws SQLException {
 | 
				
			||||||
        String invitelink = generateInviteLink();
 | 
					        String invitelink = generateInviteLink();
 | 
				
			||||||
        sqlUpdate2Param("UPDATE \"Shoppinglist\" SET invitelink = ? WHERE sl_id = ?", invitelink, sl_id);
 | 
					        sqlUpdate2Param("UPDATE \"Shoppinglist\" SET invitelink = ? WHERE sl_id = ?", invitelink, sl_id);
 | 
				
			||||||
        return invitelink;
 | 
					        return invitelink;
 | 
				
			||||||
@@ -134,32 +190,24 @@ public class Database {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Wenn die Shoppingliste bereits geshared ist wird true zurückgegeben
 | 
					     * Wenn die Shoppingliste bereits geshared ist wird true zurückgegeben
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param sl_id Die Liste die geprüft werden soll
 | 
					     * @param sl_id Die Liste die geprüft werden soll
 | 
				
			||||||
     * @return True wenn die liste bereits geshared ist
 | 
					     * @return True wenn die liste bereits geshared ist
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     * @throws JSONException
 | 
					     * @throws JSONException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public boolean isShared(String sl_id) throws SQLException, JSONException {
 | 
					    public boolean isShared(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" WHERE sl_id = ?";
 | 
					        String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" WHERE sl_id = ?";
 | 
				
			||||||
 | 
					 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, sl_id);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
        boolean returnBoolean = false;
 | 
					        boolean returnBoolean = false;
 | 
				
			||||||
        while(rs.next()){
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQL, sl_id);
 | 
				
			||||||
            JSONObject jsonObject = new JSONObject(rs.getString(1));
 | 
					        for(int i = 0; i < jsonObjects.size(); i++){
 | 
				
			||||||
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
            Log.d("isShared LOG ", jsonObject.getString("invitelink"));
 | 
					            if (jsonObject.getString("invitelink").equals("null")) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if(jsonObject.getString("invitelink").equals("null")){
 | 
					 | 
				
			||||||
                returnBoolean = false;
 | 
					                returnBoolean = false;
 | 
				
			||||||
            }else{
 | 
					            } else {
 | 
				
			||||||
                returnBoolean = true;
 | 
					                returnBoolean = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return returnBoolean;
 | 
					        return returnBoolean;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -177,19 +225,13 @@ public class Database {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gibt den Besitzer einer Shoppingliste zurück
 | 
					     * Gibt den Besitzer einer Shoppingliste zurück
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param sl_id Shoppingliste von der der Besitzer gefunden werden soll
 | 
					     * @param sl_id Shoppingliste von der der Besitzer gefunden werden soll
 | 
				
			||||||
     * @return Die uid des Besitzers
 | 
					     * @return Die uid des Besitzers
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String getShoppinglistOwner(String sl_id) throws SQLException {
 | 
					    public String getShoppinglistOwner(String sl_id) throws SQLException {
 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        String SQL = "Select username from \"Shoppinglist_admin\" WHERE sl_id = ?";
 | 
					        String SQL = "Select username from \"Shoppinglist_admin\" WHERE sl_id = ?";
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					        String owner = executeQuery(SQL, sl_id);
 | 
				
			||||||
        pstmt.setString(1, sl_id);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        String owner = rs.getString(1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return owner;
 | 
					        return owner;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -297,16 +339,7 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public Item getItem(String item_id) throws SQLException, JSONException {
 | 
					    public Item getItem(String item_id) throws SQLException, JSONException {
 | 
				
			||||||
        String SQL = "SELECT row_to_json(\"Item\") AS obj FROM \"Item\" JOIN \"Group\" USING (group_id) WHERE item_id = ?";
 | 
					        String SQL = "SELECT row_to_json(\"Item\") AS obj FROM \"Item\" JOIN \"Group\" USING (group_id) WHERE item_id = ?";
 | 
				
			||||||
 | 
					        JSONObject jsonObject = new JSONObject(executeQuery(SQL, item_id));
 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, item_id);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
        rs.next();
 | 
					 | 
				
			||||||
        String resultString = rs.getString(1);
 | 
					 | 
				
			||||||
        JSONObject jsonObject = new JSONObject(resultString);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return new Item(generateItemId(), jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("count"));
 | 
					        return new Item(generateItemId(), jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("count"));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -320,17 +353,7 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public Group getGroup(String group_id, String sl_id) throws SQLException, JSONException {
 | 
					    public Group getGroup(String group_id, String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        String SQL = "SELECT row_to_json(\"Group\") AS obj FROM \"Group\" WHERE group_id = ? AND sl_id = ?";
 | 
					        String SQL = "SELECT row_to_json(\"Group\") AS obj FROM \"Group\" WHERE group_id = ? AND sl_id = ?";
 | 
				
			||||||
        connectDatabase();
 | 
					        JSONObject jsonObject = new JSONObject(executeQuery2Param(SQL, group_id, sl_id));
 | 
				
			||||||
 | 
					 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        System.out.println(sl_id);
 | 
					 | 
				
			||||||
        pstmt.setString(1, group_id);
 | 
					 | 
				
			||||||
        pstmt.setString(2, sl_id);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
        rs.next();
 | 
					 | 
				
			||||||
        String resultString = rs.getString(1);
 | 
					 | 
				
			||||||
        JSONObject jsonObject = new JSONObject(resultString);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return new Group(jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("color"), jsonObject.getString("hidden"));
 | 
					        return new Group(jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("color"), jsonObject.getString("hidden"));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -357,8 +380,8 @@ public class Database {
 | 
				
			|||||||
     * @param color       Farbe der Shoppingliste
 | 
					     * @param color       Farbe der Shoppingliste
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void addShoppinglist(String name, String description, String username, String color) throws SQLException {
 | 
					    public void addShoppinglist(String name, String description, String username, String color) throws SQLException, JSONException {
 | 
				
			||||||
        String sl_id = generateSL_Id();
 | 
					        String sl_id = generateSL_Id(sl_idLength);
 | 
				
			||||||
        if (!checkIfUserExists(username)) {
 | 
					        if (!checkIfUserExists(username)) {
 | 
				
			||||||
            createUser(username);
 | 
					            createUser(username);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -376,11 +399,7 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private void createAdmin(String sl_id, String username) throws SQLException {
 | 
					    private void createAdmin(String sl_id, String username) throws SQLException {
 | 
				
			||||||
        String SQL = "INSERT INTO \"Shoppinglist_admin\" (username, sl_id) VALUES (?, ?)";
 | 
					        String SQL = "INSERT INTO \"Shoppinglist_admin\" (username, sl_id) VALUES (?, ?)";
 | 
				
			||||||
        connectDatabase();
 | 
					        sqlUpdate2Param(SQL, username, sl_id);
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, username);
 | 
					 | 
				
			||||||
        pstmt.setString(2, sl_id);
 | 
					 | 
				
			||||||
        pstmt.executeUpdate();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -394,13 +413,7 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private void createShoppinglist(String sl_id, String name, String description, String color) throws SQLException {
 | 
					    private void createShoppinglist(String sl_id, String name, String description, String color) throws SQLException {
 | 
				
			||||||
        String SQL = "INSERT INTO \"Shoppinglist\" (sl_id, name, description, color) VALUES (?, ?, ?, ?)";
 | 
					        String SQL = "INSERT INTO \"Shoppinglist\" (sl_id, name, description, color) VALUES (?, ?, ?, ?)";
 | 
				
			||||||
        connectDatabase();
 | 
					        sqlUpdate4Param(SQL, sl_id, name, description, color);
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, sl_id);
 | 
					 | 
				
			||||||
        pstmt.setString(2, name);
 | 
					 | 
				
			||||||
        pstmt.setString(3, description);
 | 
					 | 
				
			||||||
        pstmt.setString(4, color);
 | 
					 | 
				
			||||||
        pstmt.executeUpdate();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -411,11 +424,7 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private void createUser(String username) throws SQLException {
 | 
					    private void createUser(String username) throws SQLException {
 | 
				
			||||||
        String SQL = "INSERT INTO \"User\" (username) VALUES (?)";
 | 
					        String SQL = "INSERT INTO \"User\" (username) VALUES (?)";
 | 
				
			||||||
        connectDatabase();
 | 
					        sqlUpdate(SQL, username);
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, username);
 | 
					 | 
				
			||||||
        pstmt.executeUpdate();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -425,14 +434,14 @@ public class Database {
 | 
				
			|||||||
     * @return True wenn User existiert, False wenn nicht
 | 
					     * @return True wenn User existiert, False wenn nicht
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private boolean checkIfUserExists(String username) throws SQLException {
 | 
					    private boolean checkIfUserExists(String username) throws SQLException, JSONException {
 | 
				
			||||||
        String SQL = "SELECT username FROM \"User\"";
 | 
					        String SQL = "SELECT username FROM \"User\"";
 | 
				
			||||||
        connectDatabase();
 | 
					
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
        ArrayList<String> outUserList = new ArrayList<String>();
 | 
					        ArrayList<String> outUserList = new ArrayList<String>();
 | 
				
			||||||
        while (rs.next()) {
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQL, username);
 | 
				
			||||||
            outUserList.add(rs.getString(1));
 | 
					        for (int i = 0; i < jsonObjects.size(); i++) {
 | 
				
			||||||
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
 | 
					            outUserList.add(jsonObject.getString("username"));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (outUserList.contains(username)) {
 | 
					        if (outUserList.contains(username)) {
 | 
				
			||||||
@@ -440,8 +449,6 @@ public class Database {
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -454,64 +461,36 @@ public class Database {
 | 
				
			|||||||
     * @throws SQLException  Ein PostgreSQL Fehler
 | 
					     * @throws SQLException  Ein PostgreSQL Fehler
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public List<Shoppinglist> getMyShoppinglists(String uid) throws JSONException, SQLException {
 | 
					    public List<Shoppinglist> getMyShoppinglists(String uid) throws JSONException, SQLException {
 | 
				
			||||||
        String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" JOIN \"Shoppinglist_admin\" USING (sl_id) WHERE username = ?";
 | 
					        final String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" JOIN \"Shoppinglist_admin\" USING (sl_id) WHERE username = ?";
 | 
				
			||||||
 | 
					 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ArrayList<Shoppinglist> shoppinglistsList = new ArrayList<Shoppinglist>();
 | 
					        ArrayList<Shoppinglist> shoppinglistsList = new ArrayList<Shoppinglist>();
 | 
				
			||||||
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQL, uid);
 | 
				
			||||||
        ResultSet rs = null;
 | 
					        for (int i = 0; i < jsonObjects.size(); i++) {
 | 
				
			||||||
        try (PreparedStatement pstmt = conect.prepareStatement(SQL)) {
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
            pstmt.setString(1, uid);
 | 
					 | 
				
			||||||
            rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
            System.out.println(uid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            while (rs.next()) {
 | 
					 | 
				
			||||||
                String shoppinglist = rs.getString(1);
 | 
					 | 
				
			||||||
                JSONObject jsonObject = new JSONObject(shoppinglist);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            shoppinglistsList.add(new Shoppinglist(jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("description"), jsonObject.getString("invitelink"), jsonObject.getString("color")));
 | 
					            shoppinglistsList.add(new Shoppinglist(jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("description"), jsonObject.getString("invitelink"), jsonObject.getString("color")));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return shoppinglistsList;
 | 
				
			||||||
        } catch (SQLException ex) {
 | 
					 | 
				
			||||||
            System.out.println(ex.getMessage());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Log.d("DATABASE SHOPPINGLISTS", shoppinglistsList.toString());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return (List<Shoppinglist>) shoppinglistsList;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Verbindet sich mit dem server
 | 
					     * Verbindet sich mit dem server
 | 
				
			||||||
     * Holt alle shared shoppinglists des users
 | 
					     * Holt alle shared shoppinglists des users
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param uid User von dem die Shared Shoppinglists geholt werden sollen
 | 
					     * @param uid User von dem die Shared Shoppinglists geholt werden sollen
 | 
				
			||||||
     * @return Die Shared Shoppinglisten des Users
 | 
					     * @return Die Shared Shoppinglisten des Users
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     * @throws JSONException
 | 
					     * @throws JSONException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public List<Shoppinglist> getSharedShoppinglists(String uid) throws SQLException, JSONException {
 | 
					    public List<Shoppinglist> getSharedShoppinglists(String uid) throws SQLException, JSONException {
 | 
				
			||||||
        connectDatabase();
 | 
					        final String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" JOIN \"Shoppinglist_member\" USING (sl_id) WHERE username = ?";
 | 
				
			||||||
        String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" JOIN \"Shoppinglist_member\" USING (sl_id) WHERE username = ?";
 | 
					 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, uid);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
        System.out.println(uid);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ArrayList<Shoppinglist> shoppinglistArrayList = new ArrayList<Shoppinglist>();
 | 
					        ArrayList<Shoppinglist> shoppinglistArrayList = new ArrayList<Shoppinglist>();
 | 
				
			||||||
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQL, uid);
 | 
				
			||||||
        while(rs.next()){
 | 
					        for (int i = 0; i < jsonObjects.size(); i++) {
 | 
				
			||||||
            String shoppinglist = rs.getString(1);
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
            JSONObject jsonObject = new JSONObject(shoppinglist);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            shoppinglistArrayList.add(new Shoppinglist(jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("description"), jsonObject.getString("invitelink"), jsonObject.getString("color")));
 | 
					            shoppinglistArrayList.add(new Shoppinglist(jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("description"), jsonObject.getString("invitelink"), jsonObject.getString("color")));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return shoppinglistArrayList;
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return (List<Shoppinglist>) shoppinglistArrayList;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -540,7 +519,7 @@ public class Database {
 | 
				
			|||||||
            detailsArrayList.add(detailsTmp);
 | 
					            detailsArrayList.add(detailsTmp);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return (List<Details>) detailsArrayList;
 | 
					        return detailsArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -573,11 +552,11 @@ public class Database {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return Neue Sl_id
 | 
					     * @return Neue Sl_id
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private String generateSL_Id() {
 | 
					    private String generateSL_Id(int length) {
 | 
				
			||||||
        String possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
 | 
					        String possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
 | 
				
			||||||
        String output = "";
 | 
					        String output = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < 8; i++) {
 | 
					        for (int i = 0; i < length; i++) {
 | 
				
			||||||
            output += possible.charAt((int) Math.floor(Math.random() * possible.length()));
 | 
					            output += possible.charAt((int) Math.floor(Math.random() * possible.length()));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -592,7 +571,7 @@ public class Database {
 | 
				
			|||||||
     * @return Neue group_id
 | 
					     * @return Neue group_id
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private String generateGroupId() {
 | 
					    private String generateGroupId() {
 | 
				
			||||||
        return generateSL_Id();
 | 
					        return generateSL_Id(groupIdLength);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -601,7 +580,7 @@ public class Database {
 | 
				
			|||||||
     * @return Neue item_id
 | 
					     * @return Neue item_id
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String generateItemId() {
 | 
					    public String generateItemId() {
 | 
				
			||||||
        return generateSL_Id();
 | 
					        return generateSL_Id(itemIdLength);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -610,10 +589,33 @@ public class Database {
 | 
				
			|||||||
     * @return Neue intielink
 | 
					     * @return Neue intielink
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public String generateInviteLink() {
 | 
					    public String generateInviteLink() {
 | 
				
			||||||
        return generateSL_Id();
 | 
					        return generateSL_Id(inviteLength);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Holt alle erledigten Items eines Users
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return Die erledigten Items in eines Users
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     * @throws JSONException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public List<Item> getDoneItems() throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        final String SQL = "SELECT row_to_json(\"Done_Purchase\") AS obj FROM \"Done_Purchase\" WHERE username = ?";
 | 
				
			||||||
 | 
					        final String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ArrayList<Item> listItems = new ArrayList<Item>();
 | 
				
			||||||
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQL, uid);
 | 
				
			||||||
 | 
					        for (int i = 0; i < jsonObjects.size(); i++) {
 | 
				
			||||||
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
 | 
					            String itemId = jsonObject.getString("purchased_item_id");
 | 
				
			||||||
 | 
					            String name = jsonObject.getString("name");
 | 
				
			||||||
 | 
					            String count = jsonObject.getInt("count") + "";
 | 
				
			||||||
 | 
					            listItems.add(new Item(itemId, null, null, name, count));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return listItems;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Holt alle Items einer bestimmten shoppingliste, angegeben durch die shoppinglist id
 | 
					     * Holt alle Items einer bestimmten shoppingliste, angegeben durch die shoppinglist id
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -624,26 +626,15 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public List<Item> getItems(String sl_id) throws SQLException, JSONException {
 | 
					    public List<Item> getItems(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        String SQL = "SELECT row_to_json(\"Item\") AS obj FROM \"Item\" JOIN \"Group\" USING (group_id) WHERE \"Group\".sl_id = ?";
 | 
					        String SQL = "SELECT row_to_json(\"Item\") AS obj FROM \"Item\" JOIN \"Group\" USING (group_id) WHERE \"Group\".sl_id = ?";
 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ArrayList<Item> listItems = new ArrayList<Item>();
 | 
					        ArrayList<Item> listItems = new ArrayList<Item>();
 | 
				
			||||||
        ResultSet rsitems = null;
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQL, sl_id);
 | 
				
			||||||
        try (PreparedStatement pstmt = conect.prepareStatement(SQL)) {
 | 
					        for (int i = 0; i < jsonObjects.size(); i++) {
 | 
				
			||||||
            pstmt.setString(1, sl_id);
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
            rsitems = pstmt.executeQuery();
 | 
					 | 
				
			||||||
            System.out.println(sl_id);
 | 
					 | 
				
			||||||
            while (rsitems.next()) {
 | 
					 | 
				
			||||||
                String itemsString = rsitems.getString(1);
 | 
					 | 
				
			||||||
                JSONObject jsonObject = new JSONObject(itemsString);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            listItems.add(new Item(jsonObject.getString("item_id"), jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("count")));
 | 
					            listItems.add(new Item(jsonObject.getString("item_id"), jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("count")));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (SQLException ex) {
 | 
					        return listItems;
 | 
				
			||||||
            System.out.println(ex.getMessage());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return (List<Item>) listItems;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -657,32 +648,114 @@ public class Database {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private List<Group> getGroups(String sl_id) throws SQLException, JSONException {
 | 
					    private List<Group> getGroups(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
        String SQLGroups = "SELECT row_to_json(\"Group\") AS obj FROM \"Group\" JOIN \"Shoppinglist\" USING (sl_id) WHERE sl_id = ?";
 | 
					        String SQLGroups = "SELECT row_to_json(\"Group\") AS obj FROM \"Group\" JOIN \"Shoppinglist\" USING (sl_id) WHERE sl_id = ?";
 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ResultSet rsgroups = null;
 | 
					        List<JSONObject> jsonObjects = executeQueryJSONObject(SQLGroups, sl_id);
 | 
				
			||||||
        ArrayList<Group> listGroup = new ArrayList<Group>();
 | 
					        ArrayList<Group> listGroup = new ArrayList<Group>();
 | 
				
			||||||
        try (PreparedStatement pstmt = conect.prepareStatement(SQLGroups)) {
 | 
					        for (int i = 0; i < jsonObjects.size(); i++) {
 | 
				
			||||||
            pstmt.setString(1, sl_id);
 | 
					            JSONObject jsonObject = jsonObjects.get(i);
 | 
				
			||||||
            rsgroups = pstmt.executeQuery();
 | 
					            listGroup.add(new Group(jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("color"), jsonObject.getString("hidden")));
 | 
				
			||||||
            System.out.println(sl_id);
 | 
					        }
 | 
				
			||||||
 | 
					        return listGroup;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Hollt eine Shoppingliste vom server
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param sl_id Shoppingliste welche heruntergelanden werden soll
 | 
				
			||||||
 | 
					     * @return Ein Shoppinglist Objekt
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     * @throws JSONException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public Shoppinglist getShoppinglist(String sl_id) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" JOIN \"Shoppinglist_admin\" USING (sl_id) WHERE sl_id = ?";
 | 
				
			||||||
 | 
					        JSONObject jsonObject = new JSONObject(executeQuery(SQL, sl_id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new Shoppinglist(sl_id, jsonObject.getString("name"), jsonObject.getString("description"), jsonObject.getString("invitelink"), jsonObject.getString("color"));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Führt ein SQL Befehl aus und gibt die antwort in ein JSONObject List
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param SQL   Der SQL der auszuführen ist
 | 
				
			||||||
 | 
					     * @param param 1. Param
 | 
				
			||||||
 | 
					     * @param param 2. Param
 | 
				
			||||||
 | 
					     * @return Das ergebnis als JSONObject
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     * @throws JSONException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public List<JSONObject> executeQueryJSONObject2Param(String SQL, String param, String param2) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        ArrayList<JSONObject> jsonObjects = new ArrayList<JSONObject>();
 | 
				
			||||||
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
 | 
					        ResultSet rsgroups = pstmt.executeQuery();
 | 
				
			||||||
 | 
					        System.out.println(param);
 | 
				
			||||||
        while (rsgroups.next()) {
 | 
					        while (rsgroups.next()) {
 | 
				
			||||||
            String groupString = rsgroups.getString(1);
 | 
					            String groupString = rsgroups.getString(1);
 | 
				
			||||||
            JSONObject jsonObject = new JSONObject(groupString);
 | 
					            JSONObject jsonObject = new JSONObject(groupString);
 | 
				
			||||||
 | 
					            jsonObjects.add(jsonObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
                listGroup.add(new Group(jsonObject.getString("group_id"), jsonObject.getString("sl_id"), jsonObject.getString("name"), jsonObject.getString("color"), jsonObject.getString("hidden")));
 | 
					        return jsonObjects;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } catch (SQLException ex) {
 | 
					    /**
 | 
				
			||||||
            System.out.println(ex.getMessage());
 | 
					     * Führt ein SQL Befehl aus und gibt die antwort in ein JSONObject List
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param SQL   Der SQL der auszuführen ist
 | 
				
			||||||
 | 
					     * @param param 1. Param
 | 
				
			||||||
 | 
					     * @return Das ergebnis als JSONObject
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     * @throws JSONException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public List<JSONObject> executeQueryJSONObject(String SQL, String param) throws SQLException, JSONException {
 | 
				
			||||||
 | 
					        ArrayList<JSONObject> jsonObjects = new ArrayList<JSONObject>();
 | 
				
			||||||
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
 | 
					        ResultSet rsgroups = pstmt.executeQuery();
 | 
				
			||||||
 | 
					        System.out.println(param);
 | 
				
			||||||
 | 
					        while (rsgroups.next()) {
 | 
				
			||||||
 | 
					            String groupString = rsgroups.getString(1);
 | 
				
			||||||
 | 
					            JSONObject jsonObject = new JSONObject(groupString);
 | 
				
			||||||
 | 
					            jsonObjects.add(jsonObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return jsonObjects;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return (List<Group>) listGroup;
 | 
					    /**
 | 
				
			||||||
 | 
					     * Führt ein SQL mit einem Parameter aus und liefert den ersten String
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param SQL   SQL Befehl
 | 
				
			||||||
 | 
					     * @param param 1. Param
 | 
				
			||||||
 | 
					     * @param param 2. Param
 | 
				
			||||||
 | 
					     * @return Erster result String
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private String executeQuery2Param(String SQL, String param, String param2) throws SQLException {
 | 
				
			||||||
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
 | 
					        ResultSet rs = pstmt.executeQuery();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        rs.next();
 | 
				
			||||||
 | 
					        return rs.getString(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Führt ein SQL mit einem Parameter aus und liefert den ersten String
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param SQL   SQL Befehl
 | 
				
			||||||
 | 
					     * @param param 1. Param
 | 
				
			||||||
 | 
					     * @return Erster result String
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private String executeQuery(String SQL, String param) throws SQLException {
 | 
				
			||||||
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
 | 
					        ResultSet rs = pstmt.executeQuery();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        rs.next();
 | 
				
			||||||
 | 
					        return rs.getString(1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Bearbeitet die Eigenschaften einer Shoppingliste
 | 
					     * Bearbeitet die Eigenschaften einer Shoppingliste
 | 
				
			||||||
@@ -721,7 +794,7 @@ public class Database {
 | 
				
			|||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void sqlUpdate4ParamFirstInt(String SQL, int param, String param2, String param3, String param4) throws SQLException {
 | 
					    private void sqlUpdate4ParamFirstInt(String SQL, int param, String param2, String param3, String param4) throws SQLException {
 | 
				
			||||||
        connectDatabase();
 | 
					        //connectDatabase();
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
        pstmt.setInt(1, param);
 | 
					        pstmt.setInt(1, param);
 | 
				
			||||||
        pstmt.setString(2, param2);
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
@@ -730,6 +803,28 @@ public class Database {
 | 
				
			|||||||
        pstmt.executeUpdate();
 | 
					        pstmt.executeUpdate();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Führt einen SQL Befehl durch der keine rückgabe hat.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param SQL    Der SQL befehl
 | 
				
			||||||
 | 
					     * @param param  ein Parameter
 | 
				
			||||||
 | 
					     * @param param2 ein 2. Parameter
 | 
				
			||||||
 | 
					     * @param param3 ein 3. parameter
 | 
				
			||||||
 | 
					     * @param param4 ein 4. Parameter
 | 
				
			||||||
 | 
					     * @param param5 Ein datum des Typen java.sql.Date
 | 
				
			||||||
 | 
					     * @throws SQLException
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void sqlUpdate5ParamLastIsDateAndInt(String SQL, String param, String param2, String param3, int param4, java.sql.Date param5) throws SQLException {
 | 
				
			||||||
 | 
					        //connectDatabase();
 | 
				
			||||||
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
 | 
					        pstmt.setString(3, param3);
 | 
				
			||||||
 | 
					        pstmt.setInt(4, param4);
 | 
				
			||||||
 | 
					        pstmt.setDate(5, param5);
 | 
				
			||||||
 | 
					        pstmt.executeUpdate();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Führt einen SQL Befehl durch der keine rückgabe hat.
 | 
					     * Führt einen SQL Befehl durch der keine rückgabe hat.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -742,7 +837,7 @@ public class Database {
 | 
				
			|||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void sqlUpdate5Param(String SQL, String param, String param2, String param3, String param4, int param5) throws SQLException {
 | 
					    private void sqlUpdate5Param(String SQL, String param, String param2, String param3, String param4, int param5) throws SQLException {
 | 
				
			||||||
        connectDatabase();
 | 
					        //connectDatabase();
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
        pstmt.setString(1, param);
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
        pstmt.setString(2, param2);
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
@@ -763,7 +858,7 @@ public class Database {
 | 
				
			|||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void sqlUpdate4Param(String SQL, String param, String param2, String param3, String param4) throws SQLException {
 | 
					    private void sqlUpdate4Param(String SQL, String param, String param2, String param3, String param4) throws SQLException {
 | 
				
			||||||
        connectDatabase();
 | 
					        //connectDatabase();
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
        pstmt.setString(1, param);
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
        pstmt.setString(2, param2);
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
@@ -782,7 +877,7 @@ public class Database {
 | 
				
			|||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void sqlUpdate3Param(String SQL, String param, String param2, String param3) throws SQLException {
 | 
					    private void sqlUpdate3Param(String SQL, String param, String param2, String param3) throws SQLException {
 | 
				
			||||||
        connectDatabase();
 | 
					        //connectDatabase();
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
        pstmt.setString(1, param);
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
        pstmt.setString(2, param2);
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
@@ -801,7 +896,7 @@ public class Database {
 | 
				
			|||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void sqlUpdate2Param(String SQL, String param, String param2) throws SQLException {
 | 
					    private void sqlUpdate2Param(String SQL, String param, String param2) throws SQLException {
 | 
				
			||||||
        connectDatabase();
 | 
					        //connectDatabase();
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
        pstmt.setString(1, param);
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
        pstmt.setString(2, param2);
 | 
					        pstmt.setString(2, param2);
 | 
				
			||||||
@@ -816,60 +911,10 @@ public class Database {
 | 
				
			|||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private void sqlUpdate(String SQL, String param) throws SQLException {
 | 
					    private void sqlUpdate(String SQL, String param) throws SQLException {
 | 
				
			||||||
        connectDatabase();
 | 
					        //connectDatabase();
 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
				
			||||||
        pstmt.setString(1, param);
 | 
					        pstmt.setString(1, param);
 | 
				
			||||||
        pstmt.executeUpdate();
 | 
					        pstmt.executeUpdate();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Hollt eine Shoppingliste vom server
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param sl_id Shoppingliste welche heruntergelanden werden soll
 | 
					 | 
				
			||||||
     * @return Ein Shoppinglist Objekt
 | 
					 | 
				
			||||||
     * @throws SQLException
 | 
					 | 
				
			||||||
     * @throws JSONException
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public Shoppinglist getShoppinglist(String sl_id) throws SQLException, JSONException {
 | 
					 | 
				
			||||||
        String SQL = "SELECT row_to_json(\"Shoppinglist\") AS obj FROM \"Shoppinglist\" JOIN \"Shoppinglist_admin\" USING (sl_id) WHERE sl_id = ?";
 | 
					 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        System.out.println(sl_id);
 | 
					 | 
				
			||||||
        pstmt.setString(1, sl_id);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
        rs.next();
 | 
					 | 
				
			||||||
        String resultString = rs.getString(1);
 | 
					 | 
				
			||||||
        JSONObject jsonObject = new JSONObject(resultString);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return new Shoppinglist(sl_id, jsonObject.getString("name"), jsonObject.getString("description"), jsonObject.getString("invitelink"), jsonObject.getString("color"));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * NICHT VERWENDEN FUNKTIONIERT NICHT!!
 | 
					 | 
				
			||||||
     * <p>
 | 
					 | 
				
			||||||
     * <p>
 | 
					 | 
				
			||||||
     * NUR EIN KOPIE SAMPLE
 | 
					 | 
				
			||||||
     * <p>
 | 
					 | 
				
			||||||
     * Beim Start wird die Verbindung zum Server hergesetellt. Dann wird das resultSet von dem SQL reqest zurückgegeben
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param SQL Der zumachende SQL Request
 | 
					 | 
				
			||||||
     * @param uid Die UID des Benutzers, für den die Abfrage gemacht wird
 | 
					 | 
				
			||||||
     * @return Das entstandene Result set, mit der Antwort des Servers
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private ResultSet databaseRequest(String SQL, String uid) throws SQLException {
 | 
					 | 
				
			||||||
        connectDatabase();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        PreparedStatement pstmt = conect.prepareStatement(SQL);
 | 
					 | 
				
			||||||
        pstmt.setString(1, uid);
 | 
					 | 
				
			||||||
        ResultSet rs = pstmt.executeQuery();
 | 
					 | 
				
			||||||
        System.out.println(uid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //HIER
 | 
					 | 
				
			||||||
        //WEITER
 | 
					 | 
				
			||||||
        //PROGRAMMIEREN
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return rs;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					package at.smartshopper.smartshopper.db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.gson.JsonElement;
 | 
				
			||||||
 | 
					import com.google.gson.JsonObject;
 | 
				
			||||||
 | 
					import com.google.gson.JsonSerializationContext;
 | 
				
			||||||
 | 
					import com.google.gson.JsonSerializer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SerializableDatabase implements JsonSerializer<Database> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public JsonElement serialize(Database src, Type typeOfSrc, JsonSerializationContext context) {
 | 
				
			||||||
 | 
					        JsonObject object = new JsonObject();
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					package at.smartshopper.smartshopper.shoppinglist;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Member {
 | 
				
			||||||
 | 
					    private String uid, msid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Member(String uid, String msid){
 | 
				
			||||||
 | 
					        this.uid = uid;
 | 
				
			||||||
 | 
					        this.msid = msid;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getUid() {
 | 
				
			||||||
 | 
					        return uid;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getMsid() {
 | 
				
			||||||
 | 
					        return msid;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -33,18 +33,20 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
 | 
				
			|||||||
    private OnChangeItemClick onChangeClick;
 | 
					    private OnChangeItemClick onChangeClick;
 | 
				
			||||||
    private OnItemClicked onClick;
 | 
					    private OnItemClicked onClick;
 | 
				
			||||||
    private OnShareClick onShareClick;
 | 
					    private OnShareClick onShareClick;
 | 
				
			||||||
    private at.smartshopper.smartshopper.db.Database db;
 | 
					    private Database db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //this context we will use to inflate the layout
 | 
					    //this context we will use to inflate the layout
 | 
				
			||||||
    private Context mCtx;
 | 
					    private Context mCtx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //we are storing all the products in a list
 | 
					    //we are storing all the products in a list
 | 
				
			||||||
    private List<Shoppinglist> shoppinglist;
 | 
					    private List<Shoppinglist> shoppinglist;
 | 
				
			||||||
 | 
					    private OnShoppinglistClick onShoppinglistClick;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //getting the context and product list with constructor
 | 
					    //getting the context and product list with constructor
 | 
				
			||||||
    public ShoppinglistAdapter(Context mCtx, List<Shoppinglist> shoppinglist) {
 | 
					    public ShoppinglistAdapter(Context mCtx, List<Shoppinglist> shoppinglist, Database db) {
 | 
				
			||||||
        this.mCtx = mCtx;
 | 
					        this.mCtx = mCtx;
 | 
				
			||||||
        this.shoppinglist = shoppinglist;
 | 
					        this.shoppinglist = shoppinglist;
 | 
				
			||||||
 | 
					        this.db = db;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -72,48 +74,32 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
 | 
				
			|||||||
    public void onBindViewHolder(ShoppinglistViewHolder holder, final int position) {
 | 
					    public void onBindViewHolder(ShoppinglistViewHolder holder, final int position) {
 | 
				
			||||||
        //getting the product of the specified position,
 | 
					        //getting the product of the specified position,
 | 
				
			||||||
        final Shoppinglist shoppinglist = this.shoppinglist.get(position);
 | 
					        final Shoppinglist shoppinglist = this.shoppinglist.get(position);
 | 
				
			||||||
        ImageButton shareButton = holder.share;
 | 
					        final ImageButton shareButton = holder.share;
 | 
				
			||||||
 | 
					        TextView beschreibung = holder.textViewBeschreibung;
 | 
				
			||||||
 | 
					        beschreibung.setText(shoppinglist.getdescription());
 | 
				
			||||||
        Picasso.get().load(R.drawable.share).into(shareButton);
 | 
					        Picasso.get().load(R.drawable.share).into(shareButton);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        db = new Database();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //binding the data with the viewholder views
 | 
					        //binding the data with the viewholder views
 | 
				
			||||||
        holder.textViewTitle.setText(shoppinglist.getname());
 | 
					        holder.textViewTitle.setText(shoppinglist.getname());
 | 
				
			||||||
        System.out.println(shoppinglist.getname());
 | 
					        System.out.println(shoppinglist.getname());
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        holder.itemView.setOnClickListener(new View.OnClickListener() {
 | 
					        holder.itemView.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onClick(View v) {
 | 
					            public void onClick(View v) {
 | 
				
			||||||
 | 
					                onShoppinglistClick.onShoppinglistClick(shoppinglist.getSlId(), v);
 | 
				
			||||||
                Intent intent = new Intent(v.getContext(), ShoppinglistDetails.class);
 | 
					 | 
				
			||||||
                Bundle bundle = new Bundle();
 | 
					 | 
				
			||||||
                bundle.putString("sl_id", shoppinglist.getSlId());
 | 
					 | 
				
			||||||
                intent.putExtras(bundle);
 | 
					 | 
				
			||||||
                v.getContext().startActivity(intent);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        holder.bearbeiten.setOnClickListener(new View.OnClickListener() {
 | 
					        holder.bearbeiten.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onClick(View v) {
 | 
					            public void onClick(View v) {
 | 
				
			||||||
                onChangeClick.onChangeItemClick(shoppinglist.getSlId(), v);
 | 
					                onChangeClick.onChangeItemClick(shoppinglist.getSlId(), v);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        holder.del.setOnClickListener(new View.OnClickListener() {
 | 
					        holder.del.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onClick(View v) {
 | 
					            public void onClick(View v) {
 | 
				
			||||||
                onClick.onItemClick(shoppinglist.getSlId());
 | 
					                onClick.onItemClick(shoppinglist.getSlId());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        shareButton.setOnClickListener(new View.OnClickListener() {
 | 
					        shareButton.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void onClick(View v) {
 | 
					            public void onClick(View v) {
 | 
				
			||||||
@@ -207,7 +193,20 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
 | 
				
			|||||||
        this.onShareClick = onShareClick;
 | 
					        this.onShareClick = onShareClick;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Interface damit onoclick in der dash activity ausgeführt werden kann
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public interface OnShoppinglistClick{
 | 
				
			||||||
 | 
					        void onShoppinglistClick(String sl_id, View v);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Setzt das OnChangeItemClick event
 | 
				
			||||||
 | 
					     * @param onShoppinglistClick Der Click event Listener
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setOnShoppinglistClick(OnShoppinglistClick onShoppinglistClick){
 | 
				
			||||||
 | 
					        this.onShoppinglistClick = onShoppinglistClick;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ import com.squareup.picasso.Picasso;
 | 
				
			|||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import at.smartshopper.smartshopper.R;
 | 
					import at.smartshopper.smartshopper.R;
 | 
				
			||||||
import at.smartshopper.smartshopper.activitys.ItemListActivity;
 | 
					import at.smartshopper.smartshopper.activitys.ItemListActivity;
 | 
				
			||||||
import at.smartshopper.smartshopper.activitys.ShoppinglistDetails;
 | 
					import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
 | 
				
			||||||
import at.smartshopper.smartshopper.db.Database;
 | 
					import at.smartshopper.smartshopper.db.Database;
 | 
				
			||||||
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemShoppinglistDetailsAdapter;
 | 
					import at.smartshopper.smartshopper.shoppinglist.details.item.ItemShoppinglistDetailsAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,9 +26,11 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsAdapter.MyViewHo
 | 
				
			|||||||
    private OnGroupEditClicked onGroupEditClicked;
 | 
					    private OnGroupEditClicked onGroupEditClicked;
 | 
				
			||||||
    private OnGroupDeleteClicked onGroupDeleteClicked;
 | 
					    private OnGroupDeleteClicked onGroupDeleteClicked;
 | 
				
			||||||
    private OnCardClicked onCardClicked;
 | 
					    private OnCardClicked onCardClicked;
 | 
				
			||||||
 | 
					    private Database db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public DetailsAdapter(List<Details> details) {
 | 
					    public DetailsAdapter(List<Details> details, Database db) {
 | 
				
			||||||
        this.details = details;
 | 
					        this.details = details;
 | 
				
			||||||
 | 
					        this.db = db;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -62,6 +64,9 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsAdapter.MyViewHo
 | 
				
			|||||||
        View groupColor = viewHolder.grouoColor;
 | 
					        View groupColor = viewHolder.grouoColor;
 | 
				
			||||||
        ImageButton editGroup = viewHolder.editGroup;
 | 
					        ImageButton editGroup = viewHolder.editGroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int spacingInPixels = viewHolder.itemView.getContext().getResources().getDimensionPixelSize(R.dimen.item_spacing);
 | 
				
			||||||
 | 
					        itemsrecycle.addItemDecoration(new SpaceItemDecoration(spacingInPixels));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        itemsrecycle.setHasFixedSize(true);
 | 
					        itemsrecycle.setHasFixedSize(true);
 | 
				
			||||||
        itemsrecycle.setLayoutManager(new LinearLayoutManager(new Activity()));
 | 
					        itemsrecycle.setLayoutManager(new LinearLayoutManager(new Activity()));
 | 
				
			||||||
        List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> itemsList = details.get(i).getItems();
 | 
					        List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> itemsList = details.get(i).getItems();
 | 
				
			||||||
@@ -70,7 +75,7 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsAdapter.MyViewHo
 | 
				
			|||||||
        itemsrecycle.setAdapter(itemAdapter);
 | 
					        itemsrecycle.setAdapter(itemAdapter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        final Database db = new Database();
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        int cardcolor;
 | 
					        int cardcolor;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,9 +9,11 @@ import android.view.LayoutInflater;
 | 
				
			|||||||
import android.view.View;
 | 
					import android.view.View;
 | 
				
			||||||
import android.view.ViewGroup;
 | 
					import android.view.ViewGroup;
 | 
				
			||||||
import android.widget.CheckBox;
 | 
					import android.widget.CheckBox;
 | 
				
			||||||
 | 
					import android.widget.CompoundButton;
 | 
				
			||||||
import android.widget.ImageView;
 | 
					import android.widget.ImageView;
 | 
				
			||||||
import android.widget.TextView;
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.firebase.auth.FirebaseAuth;
 | 
				
			||||||
import com.squareup.picasso.Picasso;
 | 
					import com.squareup.picasso.Picasso;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.json.JSONException;
 | 
					import org.json.JSONException;
 | 
				
			||||||
@@ -22,12 +24,14 @@ import java.util.List;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import at.smartshopper.smartshopper.R;
 | 
					import at.smartshopper.smartshopper.R;
 | 
				
			||||||
import at.smartshopper.smartshopper.db.Database;
 | 
					import at.smartshopper.smartshopper.db.Database;
 | 
				
			||||||
 | 
					import at.smartshopper.smartshopper.shoppinglist.ShoppinglistAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.MyViewHolder> {
 | 
					public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.MyViewHolder> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> data;
 | 
					    private List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> data;
 | 
				
			||||||
    private OnItemEditClicked onItemEditClick;
 | 
					    private OnItemEditClicked onItemEditClick;
 | 
				
			||||||
    private OnItemDelClicked onItemDelClicked;
 | 
					    private OnItemDelClicked onItemDelClicked;
 | 
				
			||||||
 | 
					    private OnItemCheckClicked onItemCheckClick;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ItemAdapter(List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> data) {
 | 
					    public ItemAdapter(List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> data) {
 | 
				
			||||||
        this.data = data;
 | 
					        this.data = data;
 | 
				
			||||||
@@ -63,27 +67,13 @@ public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.MyViewHolder>
 | 
				
			|||||||
        CheckBox itemErledigt = myViewHolder.erledigtItem;
 | 
					        CheckBox itemErledigt = myViewHolder.erledigtItem;
 | 
				
			||||||
        ImageView itemDel = myViewHolder.itemDel;
 | 
					        ImageView itemDel = myViewHolder.itemDel;
 | 
				
			||||||
        CardView itemCardView = myViewHolder.itemCardView;
 | 
					        CardView itemCardView = myViewHolder.itemCardView;
 | 
				
			||||||
        //View colorBox = myViewHolder.colorBox;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        itemErledigt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
 | 
				
			||||||
        /*
 | 
					            @Override
 | 
				
			||||||
        int cardcolor = 0;
 | 
					            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
 | 
				
			||||||
        try {
 | 
					                onItemCheckClick.onItemCheckClicked(FirebaseAuth.getInstance().getCurrentUser().getUid(), data.get(i).getName(), data.get(i).getItem_id(), data.get(i).getGroup_id(), data.get(i).getSl_id(), Integer.parseInt(itemAnzahl.getText().toString()));
 | 
				
			||||||
            Database db = new Database();
 | 
					 | 
				
			||||||
            cardcolor = Color.parseColor(db.getGroup(data.get(i).getGroup_id(), data.get(i).getSl_id()).getColor());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        } catch (SQLException e) {
 | 
					 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
        } catch (JSONException e) {
 | 
					 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            colorBox.setBackgroundColor(cardcolor);
 | 
					 | 
				
			||||||
        }catch (Exception e){
 | 
					 | 
				
			||||||
            e.printStackTrace();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        itemName.setText(data.get(i).getName());
 | 
					        itemName.setText(data.get(i).getName());
 | 
				
			||||||
@@ -123,6 +113,14 @@ public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.MyViewHolder>
 | 
				
			|||||||
        this.onItemEditClick = onItemEditClick;
 | 
					        this.onItemEditClick = onItemEditClick;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public interface OnItemCheckClicked {
 | 
				
			||||||
 | 
					        void onItemCheckClicked(String uid, String name, String itemId, String groupId, String sl_id, int count);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setOnItemCheckClick(OnItemCheckClicked onItemCheckClick) {
 | 
				
			||||||
 | 
					        this.onItemCheckClick = onItemCheckClick;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int getItemCount() {
 | 
					    public int getItemCount() {
 | 
				
			||||||
        return data.size();
 | 
					        return data.size();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,9 +7,11 @@ import android.view.LayoutInflater;
 | 
				
			|||||||
import android.view.View;
 | 
					import android.view.View;
 | 
				
			||||||
import android.view.ViewGroup;
 | 
					import android.view.ViewGroup;
 | 
				
			||||||
import android.widget.CheckBox;
 | 
					import android.widget.CheckBox;
 | 
				
			||||||
 | 
					import android.widget.CompoundButton;
 | 
				
			||||||
import android.widget.ImageView;
 | 
					import android.widget.ImageView;
 | 
				
			||||||
import android.widget.TextView;
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.firebase.auth.FirebaseAuth;
 | 
				
			||||||
import com.squareup.picasso.Picasso;
 | 
					import com.squareup.picasso.Picasso;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.json.JSONException;
 | 
					import org.json.JSONException;
 | 
				
			||||||
@@ -56,8 +58,7 @@ public class ItemShoppinglistDetailsAdapter extends RecyclerView.Adapter<ItemSho
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, final int i) {
 | 
					    public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, final int i) {
 | 
				
			||||||
        final TextView itemName = myViewHolder.itemName;
 | 
					        final TextView itemName = myViewHolder.itemName;
 | 
				
			||||||
        TextView itemAnzahl = myViewHolder.itemAnzahl;
 | 
					        final TextView itemAnzahl = myViewHolder.itemAnzahl;
 | 
				
			||||||
        CheckBox itemErledigt = myViewHolder.erledigtItem;
 | 
					 | 
				
			||||||
        CardView itemCardView = myViewHolder.itemCardView;
 | 
					        CardView itemCardView = myViewHolder.itemCardView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        itemCardView.setOnClickListener(new View.OnClickListener() {
 | 
					        itemCardView.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
@@ -97,7 +98,6 @@ public class ItemShoppinglistDetailsAdapter extends RecyclerView.Adapter<ItemSho
 | 
				
			|||||||
    public static class MyViewHolder extends RecyclerView.ViewHolder {
 | 
					    public static class MyViewHolder extends RecyclerView.ViewHolder {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TextView itemName, itemAnzahl;
 | 
					        TextView itemName, itemAnzahl;
 | 
				
			||||||
        CheckBox erledigtItem;
 | 
					 | 
				
			||||||
        CardView itemCardView;
 | 
					        CardView itemCardView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public MyViewHolder(View itemView) {
 | 
					        public MyViewHolder(View itemView) {
 | 
				
			||||||
@@ -105,7 +105,6 @@ public class ItemShoppinglistDetailsAdapter extends RecyclerView.Adapter<ItemSho
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            this.itemName = (TextView) itemView.findViewById(R.id.nameItem);
 | 
					            this.itemName = (TextView) itemView.findViewById(R.id.nameItem);
 | 
				
			||||||
            this.itemAnzahl = (TextView) itemView.findViewById(R.id.anzahlItem);
 | 
					            this.itemAnzahl = (TextView) itemView.findViewById(R.id.anzahlItem);
 | 
				
			||||||
            this.erledigtItem = (CheckBox) itemView.findViewById(R.id.erledigtItem);
 | 
					 | 
				
			||||||
            this.itemCardView = (CardView) itemView.findViewById(R.id.itemCardView);
 | 
					            this.itemCardView = (CardView) itemView.findViewById(R.id.itemCardView);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@
 | 
				
			|||||||
    xmlns:tools="http://schemas.android.com/tools"
 | 
					    xmlns:tools="http://schemas.android.com/tools"
 | 
				
			||||||
    android:layout_width="match_parent"
 | 
					    android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="match_parent"
 | 
					    android:layout_height="match_parent"
 | 
				
			||||||
 | 
					    android:layout_margin="8dp"
 | 
				
			||||||
    tools:context=".activitys.ItemListActivity">
 | 
					    tools:context=".activitys.ItemListActivity">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <android.support.v4.widget.SwipeRefreshLayout
 | 
					    <android.support.v4.widget.SwipeRefreshLayout
 | 
				
			||||||
@@ -33,7 +34,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            <android.support.v7.widget.CardView
 | 
					            <android.support.v7.widget.CardView
 | 
				
			||||||
                android:layout_width="match_parent"
 | 
					                android:layout_width="match_parent"
 | 
				
			||||||
                android:layout_height="wrap_content" >
 | 
					                android:layout_height="wrap_content"
 | 
				
			||||||
 | 
					                app:cardElevation="4dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <LinearLayout
 | 
					                <LinearLayout
 | 
				
			||||||
                    android:layout_width="match_parent"
 | 
					                    android:layout_width="match_parent"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,9 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
 | 
					<android.support.v7.widget.CardView 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_width="match_parent"
 | 
				
			||||||
    android:layout_height="match_parent"
 | 
					    android:layout_height="match_parent"
 | 
				
			||||||
    xmlns:app="http://schemas.android.com/apk/res-auto">
 | 
					    app:cardElevation="4dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <TableLayout
 | 
					    <TableLayout
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
@@ -21,11 +22,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                <ImageButton
 | 
					                <ImageButton
 | 
				
			||||||
                    android:id="@+id/groupClose"
 | 
					                    android:id="@+id/groupClose"
 | 
				
			||||||
                    app:srcCompat="@drawable/close"
 | 
					 | 
				
			||||||
                    android:layout_width="wrap_content"
 | 
					                    android:layout_width="wrap_content"
 | 
				
			||||||
                    android:layout_height="wrap_content"
 | 
					                    android:layout_height="wrap_content"
 | 
				
			||||||
                    android:adjustViewBounds="false"
 | 
					                    android:adjustViewBounds="false"
 | 
				
			||||||
                    android:background="@color/fui_transparent" />
 | 
					                    android:background="@color/fui_transparent"
 | 
				
			||||||
 | 
					                    app:srcCompat="@drawable/close" />
 | 
				
			||||||
            </LinearLayout>
 | 
					            </LinearLayout>
 | 
				
			||||||
        </TableRow>
 | 
					        </TableRow>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,8 @@
 | 
				
			|||||||
    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="match_parent"
 | 
					    android:layout_height="match_parent"
 | 
				
			||||||
    app:cardCornerRadius="8dp">
 | 
					    app:cardCornerRadius="8dp"
 | 
				
			||||||
 | 
					    app:cardElevation="4dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <TableLayout
 | 
					    <TableLayout
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,8 @@
 | 
				
			|||||||
    xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
					    xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
				
			||||||
    xmlns:tools="http://schemas.android.com/tools"
 | 
					    xmlns:tools="http://schemas.android.com/tools"
 | 
				
			||||||
    android:layout_width="match_parent"
 | 
					    android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="match_parent">
 | 
					    android:layout_height="match_parent"
 | 
				
			||||||
 | 
					    app:cardElevation="4dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <TableLayout
 | 
					    <TableLayout
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
@@ -68,7 +69,7 @@
 | 
				
			|||||||
        <TableRow
 | 
					        <TableRow
 | 
				
			||||||
            android:layout_width="match_parent"
 | 
					            android:layout_width="match_parent"
 | 
				
			||||||
            android:layout_height="match_parent"
 | 
					            android:layout_height="match_parent"
 | 
				
			||||||
            android:gravity="center" >
 | 
					            android:gravity="center">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <Button
 | 
					            <Button
 | 
				
			||||||
                android:id="@+id/shareCopy"
 | 
					                android:id="@+id/shareCopy"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,10 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
					<android.support.v7.widget.CardView 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_width="match_parent"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
					    android:layout_height="wrap_content"
 | 
				
			||||||
    xmlns:android="http://schemas.android.com/apk/res/android" >
 | 
					    app:cardElevation="4dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <TableLayout
 | 
					    <TableLayout
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@
 | 
				
			|||||||
    android:layout_width="match_parent"
 | 
					    android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="match_parent"
 | 
					    android:layout_height="match_parent"
 | 
				
			||||||
    app:cardCornerRadius="8dp"
 | 
					    app:cardCornerRadius="8dp"
 | 
				
			||||||
 | 
					    app:cardElevation="4dp"
 | 
				
			||||||
    app:cardPreventCornerOverlap="true"
 | 
					    app:cardPreventCornerOverlap="true"
 | 
				
			||||||
    app:cardUseCompatPadding="true">
 | 
					    app:cardUseCompatPadding="true">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,7 @@
 | 
				
			|||||||
    android:layout_width="match_parent"
 | 
					    android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
					    android:layout_height="wrap_content"
 | 
				
			||||||
    app:cardCornerRadius="8dp"
 | 
					    app:cardCornerRadius="8dp"
 | 
				
			||||||
 | 
					    app:cardElevation="4dp"
 | 
				
			||||||
    app:cardPreventCornerOverlap="true"
 | 
					    app:cardPreventCornerOverlap="true"
 | 
				
			||||||
    app:cardUseCompatPadding="true">
 | 
					    app:cardUseCompatPadding="true">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,8 @@
 | 
				
			|||||||
    android:layout_width="match_parent"
 | 
					    android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
					    android:layout_height="wrap_content"
 | 
				
			||||||
    app:cardBackgroundColor="#DBDBDB"
 | 
					    app:cardBackgroundColor="#DBDBDB"
 | 
				
			||||||
    app:cardCornerRadius="8dp">
 | 
					    app:cardCornerRadius="8dp"
 | 
				
			||||||
 | 
					    app:cardElevation="2dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <LinearLayout
 | 
					    <LinearLayout
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,8 @@
 | 
				
			|||||||
    android:layout_width="match_parent"
 | 
					    android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
					    android:layout_height="wrap_content"
 | 
				
			||||||
    app:cardBackgroundColor="#DBDBDB"
 | 
					    app:cardBackgroundColor="#DBDBDB"
 | 
				
			||||||
    app:cardCornerRadius="8dp">
 | 
					    app:cardCornerRadius="8dp"
 | 
				
			||||||
 | 
					    app:cardElevation="2dp">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <LinearLayout
 | 
					    <LinearLayout
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,16 +1,17 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					<?xml version="1.0" encoding="utf-8"?>
 | 
				
			||||||
<android.support.v7.widget.CardView xmlns:tools="http://schemas.android.com/tools"
 | 
					<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
    android:id="@+id/ownLists"
 | 
					 | 
				
			||||||
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
 | 
					    xmlns:card_view="http://schemas.android.com/apk/res-auto"
 | 
				
			||||||
    xmlns:android="http://schemas.android.com/apk/res/android"
 | 
					    xmlns:tools="http://schemas.android.com/tools"
 | 
				
			||||||
 | 
					    android:id="@+id/ownLists"
 | 
				
			||||||
    android:layout_width="match_parent"
 | 
					    android:layout_width="match_parent"
 | 
				
			||||||
    android:layout_height="wrap_content"
 | 
					    android:layout_height="wrap_content"
 | 
				
			||||||
    card_view:cardUseCompatPadding="true"
 | 
					    card_view:cardCornerRadius="8dp"
 | 
				
			||||||
    card_view:cardCornerRadius="8dp">
 | 
					    card_view:cardElevation="4dp"
 | 
				
			||||||
 | 
					    card_view:cardUseCompatPadding="true">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <TableRow
 | 
					    <TableRow
 | 
				
			||||||
        android:layout_width="match_parent"
 | 
					        android:layout_width="match_parent"
 | 
				
			||||||
        android:layout_height="match_parent" >
 | 
					        android:layout_height="match_parent">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <android.support.constraint.ConstraintLayout
 | 
					        <android.support.constraint.ConstraintLayout
 | 
				
			||||||
            android:layout_width="match_parent"
 | 
					            android:layout_width="match_parent"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
<resources>
 | 
					<resources>
 | 
				
			||||||
    <dimen name="fab_margin">16dp</dimen>
 | 
					    <dimen name="fab_margin">16dp</dimen>
 | 
				
			||||||
 | 
					    <dimen name="item_spacing">8dp</dimen>
 | 
				
			||||||
</resources>
 | 
					</resources>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user