Code Optimierung
This commit is contained in:
parent
42747e6a9e
commit
bf50432f6e
@ -322,7 +322,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
try {
|
try {
|
||||||
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_idString));
|
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_idString));
|
||||||
myFirebaseSender.addMember(db.getAdmin(sl_idString));
|
myFirebaseSender.addMember(db.getAdmin(sl_idString));
|
||||||
myFirebaseSender.sendMessage(name.getText().toString() + pushEndString +" Von " + db.getUser(username).getName(),name.getText().toString() + pushEndString);
|
myFirebaseSender.sendMessage(name.getText().toString() + pushEndString + " Von " + db.getUser(username).getName(), name.getText().toString() + pushEndString);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -745,7 +745,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
|
|||||||
try {
|
try {
|
||||||
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
||||||
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
||||||
myFirebaseSender.sendMessage("Das Sharing von " + spl.getname() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " aufgehoben!",spl.getname() + " sharing wurde geändert!");
|
myFirebaseSender.sendMessage("Das Sharing von " + spl.getname() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " aufgehoben!", spl.getname() + " sharing wurde geändert!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -162,7 +162,7 @@ public class ItemListActivity extends Activity implements ItemAdapter.OnItemEdit
|
|||||||
try {
|
try {
|
||||||
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
||||||
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
||||||
myFirebaseSender.sendMessage(item.getName() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " gelöscht!","Item: " + item.getName() + " wurde gelöscht!");
|
myFirebaseSender.sendMessage(item.getName() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " gelöscht!", "Item: " + item.getName() + " wurde gelöscht!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -268,7 +268,7 @@ public class ItemListActivity extends Activity implements ItemAdapter.OnItemEdit
|
|||||||
try {
|
try {
|
||||||
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
||||||
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
||||||
myFirebaseSender.sendMessage(name.getText().toString() + pushEndSting + " Von: " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName(),"Item: " + name.getText().toString() + pushEndSting);
|
myFirebaseSender.sendMessage(name.getText().toString() + pushEndSting + " Von: " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName(), "Item: " + name.getText().toString() + pushEndSting);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -320,7 +320,7 @@ public class ItemListActivity extends Activity implements ItemAdapter.OnItemEdit
|
|||||||
try {
|
try {
|
||||||
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
||||||
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
||||||
myFirebaseSender.sendMessage(item.getName() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " gekauft!","Item Erledigt: " + item.getName() + "!");
|
myFirebaseSender.sendMessage(item.getName() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " gekauft!", "Item Erledigt: " + item.getName() + "!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -89,7 +89,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
String picture = " ";
|
String picture = " ";
|
||||||
try {
|
try {
|
||||||
picture = user.getPhotoUrl().toString();
|
picture = user.getPhotoUrl().toString();
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// Get new Instance ID token
|
// Get new Instance ID token
|
||||||
|
@ -217,7 +217,7 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
|
|||||||
try {
|
try {
|
||||||
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
||||||
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
||||||
myFirebaseSender.sendMessage(name.getText().toString() + pushEndString + " Von: " + db.getUser(username).getName(),"Gruppe: " + name.getText().toString() + pushEndString);
|
myFirebaseSender.sendMessage(name.getText().toString() + pushEndString + " Von: " + db.getUser(username).getName(), "Gruppe: " + name.getText().toString() + pushEndString);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -344,7 +344,7 @@ public class ShoppinglistDetails extends Activity implements DetailsAdapter.OnGr
|
|||||||
try {
|
try {
|
||||||
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
MyFirebaseSender myFirebaseSender = new MyFirebaseSender(db.getMembers(sl_id));
|
||||||
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
myFirebaseSender.addMember(db.getAdmin(sl_id));
|
||||||
myFirebaseSender.sendMessage(group.getGroupName() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " gelöscht!","Gruppe: " + group.getGroupName() + " wurde gelöscht!");
|
myFirebaseSender.sendMessage(group.getGroupName() + " wurde von " + db.getUser(FirebaseAuth.getInstance().getCurrentUser().getUid()).getName() + " gelöscht!", "Gruppe: " + group.getGroupName() + " wurde gelöscht!");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -3,7 +3,6 @@ package at.smartshopper.smartshopper.db;
|
|||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
|
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
import com.google.firebase.auth.FirebaseAuth;
|
||||||
import com.google.firebase.messaging.FirebaseMessaging;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -104,32 +103,32 @@ public class Database {
|
|||||||
|
|
||||||
private Member generateNewSecureMember(String username, String message_id, String name, String picture, String email) throws SQLException {
|
private Member generateNewSecureMember(String username, String message_id, String name, String picture, String email) throws SQLException {
|
||||||
String newusername = "", newmessage_id = "", newname = "", newpicture = "", newemail = "";
|
String newusername = "", newmessage_id = "", newname = "", newpicture = "", newemail = "";
|
||||||
if(username.isEmpty()){
|
if (username.isEmpty()) {
|
||||||
newusername = "EMPTY";
|
newusername = "EMPTY";
|
||||||
}else {
|
} else {
|
||||||
newusername = username;
|
newusername = username;
|
||||||
}
|
}
|
||||||
if(message_id.isEmpty()){
|
if (message_id.isEmpty()) {
|
||||||
newmessage_id = "EMPTY";
|
newmessage_id = "EMPTY";
|
||||||
}else {
|
} else {
|
||||||
newmessage_id = message_id;
|
newmessage_id = message_id;
|
||||||
}
|
}
|
||||||
if(name.isEmpty()){
|
if (name.isEmpty()) {
|
||||||
newname = "EMPTY";
|
newname = "EMPTY";
|
||||||
}else {
|
} else {
|
||||||
newname = name;
|
newname = name;
|
||||||
}
|
}
|
||||||
if(picture.isEmpty() || picture.equals(" ")){
|
if (picture.isEmpty() || picture.equals(" ")) {
|
||||||
newpicture = "https://i0.wp.com/www.windowspower.de/wp-content/uploads/2015/10/profilbilde-windows-10.jpg?fit=610%2C340&ssl=1";
|
newpicture = "https://i0.wp.com/www.windowspower.de/wp-content/uploads/2015/10/profilbilde-windows-10.jpg?fit=610%2C340&ssl=1";
|
||||||
}else {
|
} else {
|
||||||
newpicture = picture;
|
newpicture = picture;
|
||||||
}
|
}
|
||||||
if(email.isEmpty()){
|
if (email.isEmpty()) {
|
||||||
newemail = "EMPTY";
|
newemail = "EMPTY";
|
||||||
}else {
|
} else {
|
||||||
newemail = email;
|
newemail = email;
|
||||||
}
|
}
|
||||||
if(username.equals(newusername)) {
|
if (username.equals(newusername)) {
|
||||||
if (!name.equals(newname) || !message_id.equals(newmessage_id) || !picture.equals(newpicture) || !email.equals(newemail)) {
|
if (!name.equals(newname) || !message_id.equals(newmessage_id) || !picture.equals(newpicture) || !email.equals(newemail)) {
|
||||||
updateUser(username, newmessage_id, newname, newpicture, newemail);
|
updateUser(username, newmessage_id, newname, newpicture, newemail);
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ public class MyFirebaseSender {
|
|||||||
messageIds = tmp;
|
messageIds = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMember(Member member){
|
public void addMember(Member member) {
|
||||||
if(!messageIds.contains(member.getMsid())){
|
if (!messageIds.contains(member.getMsid())) {
|
||||||
messageIds.add(member.getMsid());
|
messageIds.add(member.getMsid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user