New Design

This commit is contained in:
Georg Reisinger 2019-01-31 12:22:47 +01:00
parent 4398cce781
commit b55bee5fba
20 changed files with 477 additions and 317 deletions

@ -1,153 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="imageWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="imageAssetPanel">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="actionbar">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="image">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="assetType" value="IMAGE" />
<entry key="imageAsset" value="C:\Users\georg\Downloads\close.png" />
<entry key="outputName" value="logo" />
<entry key="theme" value="CUSTOM" />
<entry key="themeColor" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="launcher">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="foregroundImage">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="scalingPercent" value="66" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="backgroundAssetType" value="COLOR" />
<entry key="backgroundColor" value="353535" />
<entry key="backgroundLayerName" value="ic_launcher_background" />
<entry key="foregroundImage" value="C:\Users\georg\Downloads\close.png" />
<entry key="foregroundLayerName" value="ic_launcher_foreground" />
<entry key="outputName" value="close" />
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="launcherLegacy">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="notification">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipArt">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="color" value="000000" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="outputIconType" value="ACTIONBAR" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
<entry key="vectorWizard">
<value>
<PersistentState />
</value>
</entry>
</map>
</option>
</component>
</project>

Binary file not shown.

6
.idea/gradle.xml generated

@ -8,12 +8,6 @@
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>

40
.idea/misc.xml generated

@ -1,41 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="10">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="9">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
</list>
</value>
</option>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

2
.idea/vcs.xml generated

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>

@ -39,4 +39,5 @@ dependencies {
implementation 'com.android.support:swiperefreshlayout:28.0.0-alpha1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.github.danielnilsson9:color-picker-view:1.4.0@aar'
implementation 'com.android.support:recyclerview-v7:28.0.0'
}

@ -12,7 +12,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".activitys.Colorpicker"></activity>
<activity
android:name=".activitys.ItemListActivity"
android:label="@string/title_activity_item_list"></activity>
<activity android:name=".activitys.Colorpicker" />
<activity android:name=".activitys.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

@ -187,6 +187,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
}else{
colorstring = "#" + dbShoppinglist.getcolor();
}
this.color = colorstring;
colorBtn.setBackgroundColor(Color.parseColor(colorstring));
name.setText(dbShoppinglist.getname());
description.setText(dbShoppinglist.getdescription());
@ -410,11 +411,9 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
public void onItemClick(String sl_id) {
try {
db.delShoppinglist(sl_id);
showOwnShoppingList(FirebaseAuth.getInstance().getCurrentUser().getUid());
refreshOwnShoppinglist(FirebaseAuth.getInstance().getCurrentUser().getUid());
} catch (SQLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}

@ -0,0 +1,79 @@
package at.smartshopper.smartshopper.activitys;
import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import org.json.JSONException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import at.smartshopper.smartshopper.R;
import at.smartshopper.smartshopper.db.Database;
import at.smartshopper.smartshopper.shoppinglist.details.Details;
import at.smartshopper.smartshopper.shoppinglist.details.DetailsAdapter;
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemAdapter;
public class ItemListActivity extends Activity implements ItemAdapter.OnItemEditClicked, ItemAdapter.OnItemDelClicked {
private String group_id;
private String sl_id;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Intent myIntent = getIntent(); // gets the previously created intent
this.group_id = myIntent.getStringExtra("group_id"); // will return "FirstKeyValue"
this.sl_id = myIntent.getStringExtra("sl_id"); // will return "SecondKeyValue"
try {
showItems(group_id, sl_id);
} catch (SQLException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
private void showItems(String group_id, String sl_id) throws SQLException, JSONException {
RecyclerView itemsListRecycler = findViewById(R.id.itemsListRecycler);
itemsListRecycler.setHasFixedSize(true);
itemsListRecycler.setLayoutManager(new LinearLayoutManager(this));
List<Item> itemList = new Database().getItemsOfGroup(group_id, sl_id);
ItemAdapter itemAdapter = new ItemAdapter(itemList);
itemAdapter.setOnItemEditClick(this);
itemAdapter.setItemDelClick(this);
itemsListRecycler.setAdapter(itemAdapter);
}
@Override
public void onBackPressed() {
finish();
Intent intent = new Intent(this, ShoppinglistDetails.class);
intent.putExtra("sl_id", sl_id);
startActivity(intent);
}
@Override
public void onItemDelClicked(String item_id, String group_id, String sl_id) {
}
@Override
public void onItemEditClicked(String item_id, String group_id, String sl_id, String newname, int newcount) {
}
}

@ -6,7 +6,6 @@ import android.os.Build;
import android.os.Bundle;
import android.app.Activity;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
@ -20,24 +19,23 @@ import android.widget.PopupWindow;
import android.widget.Toast;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.squareup.picasso.Picasso;
import org.json.JSONException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import at.smartshopper.smartshopper.R;
import at.smartshopper.smartshopper.db.Database;
import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
import at.smartshopper.smartshopper.shoppinglist.ShoppinglistAdapter;
import at.smartshopper.smartshopper.shoppinglist.details.Details;
import at.smartshopper.smartshopper.shoppinglist.details.DetailsAdapter;
import at.smartshopper.smartshopper.shoppinglist.details.group.Group;
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGroupEditClicked, DetailsAdapter.OnGroupDeleteClicked, DetailsAdapter.OnItemAddClicked {
public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGroupEditClicked, DetailsAdapter.OnGroupDeleteClicked, DetailsAdapter.OnItemAddClicked, DetailsAdapter.OnCardClicked {
private Database db = new Database();
private FloatingActionButton fab;
@ -122,9 +120,9 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
if (fromDB) {
Group dbgroup = db.getGroup(groupid, sl_id);
String colorstring;
if(dbgroup.getColor().contains("#")){
if (dbgroup.getColor().contains("#")) {
colorstring = dbgroup.getColor();
}else{
} else {
colorstring = "#" + dbgroup.getColor();
}
color.setBackgroundColor(Color.parseColor(colorstring));
@ -207,9 +205,9 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
int color = Integer.parseInt(data.getData().toString());
this.colorString = colorToHexString(color);
String colorstring;
if(this.colorString.contains("#")){
if (this.colorString.contains("#")) {
colorstring = this.colorString;
}else{
} else {
colorstring = "#" + this.colorString;
}
int colorint = Color.parseColor(colorstring);
@ -239,16 +237,19 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
RecyclerView detailsRecycleView = (RecyclerView) findViewById(R.id.groupRecycle);
detailsRecycleView.setHasFixedSize(true);
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.setGroupEditClick(this);
detailsAdapter.setGroupDeleteClick(this);
detailsAdapter.setItemAddClick(this);
detailsAdapter.setCardClick(this);
detailsRecycleView.setAdapter(detailsAdapter);
}
private void showPopupItemEdit(final boolean fromDB, final String sl_id, final String group_id, String item_id, View v) throws SQLException, JSONException {
final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
@ -359,4 +360,13 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
}
}
@Override
public void onCardClick(String group_id, String sl_id, View v) {
finish();
Intent intent = new Intent(this, ItemListActivity.class);
intent.putExtra("group_id", group_id);
intent.putExtra("sl_id", sl_id);
startActivity(intent);
}
}

@ -61,6 +61,44 @@ public class Database {
sqlUpdate2Param("DELETE FROM \"Group\" WHERE group_id = ? AND sl_id = ?", group_id, sl_id);
}
/**
* Bearbeitet ein Item in der Datenbank
* @param item_id Daqs zu bearbeitende item
* @param group_id Die gruppe in dem da sitem ist
* @param sl_id die shoppinglist in dem das item ist
* @param newname der neue name
* @param newcount die neue anzahl
* @throws SQLException
* @throws JSONException
*/
public void editItem(String item_id, String group_id, String sl_id, String newname, int newcount) throws SQLException, JSONException {
Item olditem = getItem(item_id);
if (!olditem.getName().equals(newname) && newname != null) {
sqlUpdate4Param("UPDATE \"Item\" SET name = ? WHERE item_id = ? AND group_id = ? AND sl_id = ?", newname, item_id, group_id, sl_id);
}
/*
if (!oldgroup.getHidden().equals(newhidden) && newhidden != null) {
sqlUpdate3Param("UPDATE \"Group\" SET hidden = ? WHERE group_id = ? AND sl_id = ?", newhidden, group_id, sl_id);
}
*/
if (Integer.parseInt(olditem.getCount()) != newcount) {
sqlUpdate4ParamFirstInt("UPDATE \"Item\" SET count = ? WHERE item_id = ? AND group_id = ? AND sl_id = ?", newcount, item_id, group_id, sl_id);
}
}
/**
* Löscht ein item
* @param item_id Item id
* @param group_id group id
* @param sl_id shoppoinglist id
*/
public void deleteItem(String item_id, String group_id, String sl_id) throws SQLException {
sqlUpdate3Param("DELETE FROM \"Item\" WHERE item_id = ? AND group_id = ? AND sl_id = ?", item_id, group_id, sl_id);
}
/**
* Fügt ein neues Item der Datenbank hinzu
* @param group_id Die group id in der das neue item angezeigt werden soll
@ -342,6 +380,28 @@ public class Database {
}
/**
* Holt alle Items einer bestimmten gruppe
* @param group_id Gruppe welche geholt werden soll
* @param sl_id Die Shoppinglist in der sich die gruppe befindet
* @return
* @throws SQLException
* @throws JSONException
*/
public List<Item> getItemsOfGroup(String group_id, String sl_id) throws SQLException, JSONException {
List<Details> details = getListDetails(sl_id);
ArrayList<Item> result = new ArrayList<Item>();
for(Details d : details){
String group_idtmp = d.getGroup().getGroup_id();
if(group_idtmp.equals(group_id)){
result = d.getItems();
}
}
return result;
}
/**
* Generiert eine neue 8 stellige sl_id
*
@ -386,7 +446,7 @@ public class Database {
* @throws SQLException
* @throws JSONException
*/
private 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 = ?";
connectDatabase();
@ -482,17 +542,15 @@ public class Database {
* @param param2 ein 2. Parameter
* @param param3 ein 3. parameter
* @param param4 ein 4. Parameter
* @param param5 ein 5. Parameter
* @throws SQLException
*/
private void sqlUpdate5Param(String SQL, String param, String param2, String param3, String param4, String param5) throws SQLException {
private void sqlUpdate4ParamFirstInt(String SQL, int param, String param2, String param3, String param4) throws SQLException {
connectDatabase();
PreparedStatement pstmt = conect.prepareStatement(SQL);
pstmt.setString(1, param);
pstmt.setInt(1, param);
pstmt.setString(2, param2);
pstmt.setString(3, param3);
pstmt.setString(4, param4);
pstmt.setString(5, param5);
pstmt.executeUpdate();
}

@ -100,7 +100,7 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
cardcolor = Color.parseColor("#FFFFFF");
}
holder.ownList.setCardBackgroundColor(cardcolor);
holder.shoppinglistColor.setBackgroundColor(cardcolor);
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
@ -172,6 +172,7 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
ImageView imageView;
CardView ownList;
ImageButton bearbeiten, del;
View shoppinglistColor;
public ShoppinglistViewHolder(View itemView) {
super(itemView);
@ -183,6 +184,7 @@ public class ShoppinglistAdapter extends RecyclerView.Adapter<ShoppinglistAdapte
ownList = itemView.findViewById(R.id.ownLists);
bearbeiten = itemView.findViewById(R.id.bearbeiteShoppinglist);
del = itemView.findViewById(R.id.deleteShoppinglist);
shoppinglistColor = itemView.findViewById(R.id.shoppinglistColor);
itemView.setOnClickListener(new View.OnClickListener() {
@Override

@ -19,6 +19,7 @@ import com.squareup.picasso.Picasso;
import java.util.List;
import at.smartshopper.smartshopper.R;
import at.smartshopper.smartshopper.activitys.ShoppinglistDetails;
import at.smartshopper.smartshopper.customViews.RoundCornersTransformation;
import at.smartshopper.smartshopper.db.Database;
import at.smartshopper.smartshopper.shoppinglist.ShoppinglistAdapter;
@ -30,6 +31,7 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsAdapter.MyViewHo
private OnGroupEditClicked onGroupEditClicked;
private OnItemAddClicked onItemAddClicked;
private OnGroupDeleteClicked onGroupDeleteClicked;
private OnCardClicked onCardClicked;
public DetailsAdapter(List<Details> details) {
this.details = details;
@ -63,30 +65,42 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsAdapter.MyViewHo
TextView groupName = viewHolder.groupName;
ImageButton deleteGroup = viewHolder.deleteGroup;
RecyclerView itemsrecycle = viewHolder.itemsrecycle;
TextView ownerName = viewHolder.ownerName;
ImageView ownerImage = viewHolder.ownerImage;
CardView cardViewGroup = viewHolder.cardViewGroups;
View groupColor = viewHolder.grouoColor;
ImageButton editGroup = viewHolder.editGroup;
ImageButton addItem = viewHolder.addItem;
final Database db = new Database();
groupName.setText(details.get(i).getGroup().getName());
ownerName.setText("Kein SQL");
cardViewGroup.setCardBackgroundColor(Color.parseColor(details.get(i).getGroup().getColor()));
Picasso.get().load(R.drawable.delete).into(deleteGroup);
Picasso.get().load(R.drawable.user).resize(250, 250).transform(new RoundCornersTransformation(30, 30, true, true)).into(ownerImage);
Picasso.get().load(R.drawable.add).into(addItem);
Picasso.get().load(R.drawable.bearbeiten).into(editGroup);
itemsrecycle.setHasFixedSize(true);
itemsrecycle.setLayoutManager(new LinearLayoutManager(new Activity()));
List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> itemsList = details.get(i).getItems();
ItemAdapter itemAdapter = new ItemAdapter(itemsList);
itemsrecycle.setAdapter(itemAdapter);
final Database db = new Database();
int cardcolor;
try {
cardcolor = Color.parseColor(details.get(i).getGroup().getColor());
} catch (Exception e) {
cardcolor = Color.parseColor("#FFFFFF");
}
groupColor.setBackgroundColor(cardcolor);
groupName.setText(details.get(i).getGroup().getName());
Picasso.get().load(R.drawable.delete).into(deleteGroup);
Picasso.get().load(R.drawable.add).into(addItem);
Picasso.get().load(R.drawable.bearbeiten).into(editGroup);
viewHolder.groupCard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onCardClicked.onCardClick(details.get(i).getGroup().getGroup_id(), details.get(i).getGroup().getSl_idd(), v);
}
});
addItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -109,7 +123,20 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsAdapter.MyViewHo
});
}
/**
* Interface damit onoclick in der Shoppinglistdetails activity ausgeführt werden kann
*/
public interface OnCardClicked {
void onCardClick(String group_id, String sl_id, View v);
}
/**
* Setzt das OnChangeItemClick event
* @param onCardClicked Der Click event Listener
*/
public void setCardClick(OnCardClicked onCardClicked){
this.onCardClicked = onCardClicked;
}
/**
* Interface damit onoclick in der Shoppinglistdetails activity ausgeführt werden kann
@ -166,22 +193,21 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsAdapter.MyViewHo
*/
public static class MyViewHolder extends RecyclerView.ViewHolder {
TextView groupName, ownerName;
TextView groupName;
ImageButton deleteGroup, editGroup, addItem;
RecyclerView itemsrecycle;
ImageView ownerImage;
CardView cardViewGroups;
View grouoColor;
CardView groupCard;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
this.groupName = (TextView) itemView.findViewById(R.id.groupName);
this.deleteGroup = (ImageButton) itemView.findViewById(R.id.deleteGroup);
this.itemsrecycle = (RecyclerView) itemView.findViewById(R.id.itemsRecycle);
this.ownerName = (TextView) itemView.findViewById(R.id.ownerName);
this.ownerImage = (ImageView) itemView.findViewById(R.id.ownerImage);
this.cardViewGroups = (CardView) itemView.findViewById(R.id.cardViewGroup);
this.grouoColor = (View) itemView.findViewById(R.id.groupColorView);
this.editGroup = (ImageButton) itemView.findViewById(R.id.editGroup);
this.addItem = (ImageButton) itemView.findViewById(R.id.addItem);
this.groupCard = (CardView) itemView.findViewById(R.id.cardViewGroup);
}

@ -5,11 +5,13 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.List;
import com.squareup.picasso.Picasso;
import java.util.List;
import at.smartshopper.smartshopper.R;
@ -17,14 +19,17 @@ import at.smartshopper.smartshopper.R;
public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.MyViewHolder> {
private List<at.smartshopper.smartshopper.shoppinglist.details.item.Item> data;
private OnItemEditClicked onItemEditClick;
private OnItemDelClicked onItemDelClicked;
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;
}
/**
* Erstellt einen Neuen view holder mit aktueller view
*
* @param viewGroup
* @param i
* @return
@ -40,20 +45,52 @@ public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.MyViewHolder>
/**
* Setzt alle Daten in die View elemente
*
* @param myViewHolder Das View Holder Objekt mit allen elementen
* @param i Der Index welcher aus der data list genommen werden soll
* @param i Der Index welcher aus der data list genommen werden soll
*/
@Override
public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i) {
TextView itemName = myViewHolder.itemName;
TextView itemAnzahl = myViewHolder.itemAnzahl;
ImageView itemBearbeiten = myViewHolder.itemBearbeiten;
public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, final int i) {
final TextView itemName = myViewHolder.itemName;
final TextView itemAnzahl = myViewHolder.itemAnzahl;
CheckBox itemErledigt = myViewHolder.erledigtItem;
ImageView itemDel = myViewHolder.itemDel;
itemName.setText(data.get(i).getName());
itemAnzahl.setText(data.get(i).getCount());
Picasso.get().load(R.drawable.bearbeiten).into(itemBearbeiten);
Picasso.get().load(R.drawable.delete).into(itemDel);
/*
itemName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onItemEditClick.onItemEditClicked(data.get(i).getItem_id(), data.get(i).getGroup_id(), data.get(i).getSl_id(), itemName.getText().toString(), Integer.parseInt(itemAnzahl.getText().toString()));
}
});
itemDel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onItemDelClicked.onItemDelClicked(data.get(i).getItem_id(), data.get(i).getGroup_id(), data.get(i).getSl_id());
}
});
*/
}
public interface OnItemDelClicked {
void onItemDelClicked(String item_id, String group_id, String sl_id);
}
public void setItemDelClick(OnItemDelClicked onItemDelClicked){
this.onItemDelClicked = onItemDelClicked;
}
public interface OnItemEditClicked {
void onItemEditClicked(String item_id, String group_id, String sl_id, String newname, int newcount);
}
public void setOnItemEditClick(OnItemEditClicked onItemEditClick) {
this.onItemEditClick = onItemEditClick;
}
@Override
@ -64,18 +101,19 @@ public class ItemAdapter extends RecyclerView.Adapter<ItemAdapter.MyViewHolder>
/**
* Haltet alle elemente. Durch ein Objekt von dem kann jedes Element welches hier drinnen angeführt ist verwendet werden
*/
public static class MyViewHolder extends RecyclerView.ViewHolder{
public static class MyViewHolder extends RecyclerView.ViewHolder {
TextView itemName, itemAnzahl;
ImageView itemBearbeiten, itemDel;
ImageView itemDel;
CheckBox erledigtItem;
public MyViewHolder(View itemView){
public MyViewHolder(View itemView) {
super(itemView);
this.itemName = (TextView)itemView.findViewById(R.id.nameItem);
this.itemAnzahl = (TextView)itemView.findViewById(R.id.anzahlItem);
this.itemBearbeiten = (ImageView)itemView.findViewById(R.id.itemBearbeiten);
this.itemDel = (ImageView)itemView.findViewById(R.id.itemDel);
this.itemName = (TextView) itemView.findViewById(R.id.nameItem);
this.itemAnzahl = (TextView) itemView.findViewById(R.id.anzahlItem);
this.itemDel = (ImageView) itemView.findViewById(R.id.itemDel);
this.erledigtItem = (CheckBox) itemView.findViewById(R.id.erledigtItem);
}
}
}

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listview_background_shape">
<stroke
android:width="2dp"
android:color="#ff207d94" />
<padding
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
<corners android:radius="5dp" />
<solid android:color="#ff207d94" />
</shape>

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activitys.ItemListActivity">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/groupViewColorView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:src="@drawable/rechteck"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/guideline5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/groupViewName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="GroupName"
android:textAlignment="center"
android:textColor="@android:color/background_dark"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/itemsListRecycler"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline5"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Guideline
android:id="@+id/guideline5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="29dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/itemsListRecycler"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline5" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>

@ -11,14 +11,47 @@
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
<LinearLayout
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="match_parent">
<View
android:id="@+id/groupColorView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:src="@drawable/rechteck"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/guideline3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.RecyclerView
android:id="@+id/itemsRecycle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline3"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:padding="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline3"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/groupName"
@ -27,10 +60,12 @@
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Name"
android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/deleteGroup"
app:layout_constraintStart_toEndOf="@+id/ownerImage"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/addItem"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
@ -55,28 +90,6 @@
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/bearbeiten" />
<ImageView
android:id="@+id/ownerImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/colorAccent" />
<TextView
android:id="@+id/ownerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:text="OwnerName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ownerImage" />
<ImageButton
android:id="@+id/addItem"
android:layout_width="wrap_content"
@ -90,11 +103,12 @@
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/itemsRecycle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.constraint.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="27dp" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>

@ -3,50 +3,45 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/itemCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:cardBackgroundColor="#DBDBDB"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal"
android:padding="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
<CheckBox
android:id="@+id/erledigtItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/nameItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
android:text="ItemName" />
<TextView
android:id="@+id/nameItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ItemName" />
<TextView
android:id="@+id/anzahlItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Anzahl" />
</LinearLayout>
<TextView
android:id="@+id/anzahlItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Anzahl" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/itemBearbeiten"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/bearbeiten" />
<ImageView
android:id="@+id/itemDel"
android:layout_width="wrap_content"
@ -54,6 +49,8 @@
android:layout_weight="1"
app:srcCompat="@drawable/delete" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>

@ -16,18 +16,34 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/shoppinglistColor"
android:layout_width="0dp"
android:layout_height="0dp "
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:src="@drawable/rechteck"
card_view:layout_constraintBottom_toBottomOf="parent"
card_view:layout_constraintEnd_toStartOf="@+id/guideline4"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:orientation="vertical"
card_view:layout_constraintBottom_toBottomOf="parent"
card_view:layout_constraintEnd_toStartOf="@+id/guideline"
card_view:layout_constraintStart_toStartOf="parent"
card_view:layout_constraintTop_toTopOf="parent">
card_view:layout_constraintStart_toStartOf="@+id/guideline4"
card_view:layout_constraintTop_toTopOf="parent"
card_view:layout_constraintVertical_bias="0.436">
<ImageView
android:id="@+id/shoppinglistOwner"
@ -55,7 +71,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
card_view:layout_constraintGuide_begin="96dp" />
card_view:layout_constraintGuide_begin="111dp" />
<LinearLayout
android:id="@+id/linearLayout"
@ -105,6 +121,7 @@
card_view:layout_constraintGuide_begin="343dp" />
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
@ -132,6 +149,13 @@
</LinearLayout>
<android.support.constraint.Guideline
android:id="@+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
card_view:layout_constraintGuide_begin="32dp" />
</android.support.constraint.ConstraintLayout>
</TableRow>

@ -3,4 +3,5 @@
<string name="title_activity_dash">Dash</string>
<string name="title_activity_shoppinglist_detail">ShoppinglistDetail</string>
<string name="title_activity_shoppinglist_details">ShoppinglistDetails</string>
<string name="title_activity_item_list">ItemListActivity</string>
</resources>