From cdf305dc84d6f19808ce63d5594629cdfacabbea Mon Sep 17 00:00:00 2001 From: Hema bhagnani Date: Sun, 13 Dec 2020 13:12:00 +0530 Subject: [PATCH] bug fixes --- .idea/codeStyles/Project.xml | 15 ++----- .../com/example/dateyoureve/CreateEvent.java | 16 ++++--- .../example/dateyoureve/PastEventData.java | 12 +++-- .../dateyoureve/PastEventDataAdapter.java | 2 +- .../example/dateyoureve/PastEventsList.java | 45 +++++++++++++++++-- app/src/main/res/layout/my_home_ui.xml | 5 ++- 6 files changed, 68 insertions(+), 27 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 0d15693..663459a 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -3,18 +3,9 @@ - diff --git a/app/src/main/java/com/example/dateyoureve/CreateEvent.java b/app/src/main/java/com/example/dateyoureve/CreateEvent.java index f622e7e..dca1783 100644 --- a/app/src/main/java/com/example/dateyoureve/CreateEvent.java +++ b/app/src/main/java/com/example/dateyoureve/CreateEvent.java @@ -58,7 +58,11 @@ public class CreateEvent extends AppCompatActivity { // request code private final int PICK_IMAGE_REQUEST = 22; Button btnSelectImage,cancel,create,btnTimePicker; - TextInputLayout titleEvent,decriptionEvent,timeInputEvent,notes; + TextInputLayout titleEvent; + TextInputLayout decriptionEvent; + TextInputLayout timeInputEvent; + TextInputLayout notes; + String venue; RadioGroup radioGroupOnOffMode; FirebaseDatabase mDatabase; DatabaseReference databaseReference; @@ -111,7 +115,8 @@ protected void onCreate(Bundle savedInstanceState) { note = notes.getEditText().getText().toString(); time = timeInputEvent.getEditText().getText().toString(); dateEvent = textView.getText().toString(); - if(!title.isEmpty() && !description.isEmpty() && !note.isEmpty()) + venue = selectvenue.getText().toString(); + if(!title.isEmpty() && !description.isEmpty() && !note.isEmpty() && !time.isEmpty() && !dateEvent.isEmpty() && !venue.isEmpty()) { progressDialog.show(); uploadImage(); @@ -152,8 +157,8 @@ public void onTimeSet(TimePicker view, int hourOfDay, DatePickerDialog datePickerDialog =new DatePickerDialog(CreateEvent.this, android.R.style.Theme_DeviceDefault_Dialog, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker datePicker, int year, int month, int date) { - if((date>cdate && month == cmonth && year==cyear) || (date == cdate && month > cmonth && year==cyear) ||(date == cdate && month == cmonth && year > cyear)) - textView.setText(date+"/"+month+"/"+year); + if((date>cdate && month == cmonth && year==cyear) || (date == cdate && month > cmonth && year==cyear) ||(date == cdate && month == cmonth && year > cyear)||((date > cdate && month > cmonth && year > cyear))) + textView.setText(date+"/"+(month+1)+"/"+year); else Toast.makeText(CreateEvent.this, "Please enter valid date", Toast.LENGTH_SHORT).show(); } @@ -201,7 +206,8 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten if ((requestCode == PLACE_PICKER_REQUEST)) { if(data != null) { PlaceParcelable place = YandexPlacePicker.getPlace(data); - location = place.getAddress(); + location =place.getName()+ place.getAddress(); + selectvenue.setText(place.getName()+place.getAddress()); Toast.makeText(this, "You selected: " + place.getClass(), Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/com/example/dateyoureve/PastEventData.java b/app/src/main/java/com/example/dateyoureve/PastEventData.java index 57d3b03..8ff2a4a 100644 --- a/app/src/main/java/com/example/dateyoureve/PastEventData.java +++ b/app/src/main/java/com/example/dateyoureve/PastEventData.java @@ -1,7 +1,11 @@ package com.example.dateyoureve; public class PastEventData { - public PastEventData(String title, String date, String interested_count) { + + public PastEventData(){ + + } + public PastEventData(String title, String date, long interested_count) { this.title = title; this.date = date; this.interested_count = interested_count; @@ -15,12 +19,12 @@ public String getDate() { return date; } - public String getInterested_count() { + public long getInterested_count() { return interested_count; } String title,date; - String interested_count; + long interested_count; public void setTitle(String title) { this.title = title; @@ -30,7 +34,7 @@ public void setDate(String date) { this.date = date; } - public void setInterested_count(String interested_count) { + public void setInterested_count(long interested_count) { this.interested_count = interested_count; } } diff --git a/app/src/main/java/com/example/dateyoureve/PastEventDataAdapter.java b/app/src/main/java/com/example/dateyoureve/PastEventDataAdapter.java index f540887..b1c810e 100644 --- a/app/src/main/java/com/example/dateyoureve/PastEventDataAdapter.java +++ b/app/src/main/java/com/example/dateyoureve/PastEventDataAdapter.java @@ -36,7 +36,7 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { final PastEventData pastEventDataList = pastEventData.get(position); holder.titleView.setText(pastEventDataList.getTitle()); holder.date.setText(pastEventDataList.getDate()); - holder.interested.setText(pastEventDataList.getInterested_count()); + holder.interested.setText(String.valueOf(pastEventDataList.getInterested_count())); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/app/src/main/java/com/example/dateyoureve/PastEventsList.java b/app/src/main/java/com/example/dateyoureve/PastEventsList.java index 7fcb18b..bf6a771 100644 --- a/app/src/main/java/com/example/dateyoureve/PastEventsList.java +++ b/app/src/main/java/com/example/dateyoureve/PastEventsList.java @@ -42,6 +42,48 @@ protected void onCreate(Bundle savedInstanceState) { databaseReferenceCreated.addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) { + for(DataSnapshot dataSnapshot : snapshot.getChildren()) + { + String path = "Events/" + dataSnapshot.getValue().toString(); + databaseReferenceEve = FirebaseDatabase.getInstance().getReference(path); + databaseReferenceEve.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot snapshot) { + DatabaseReference databaseReferenceCount; + String path1 = "Events/" + dataSnapshot.getValue().toString() + "InterestedPeoples"; + databaseReferenceCount= FirebaseDatabase.getInstance().getReference(path1); + + + + databaseReferenceCount.addValueEventListener(new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot snapshot) { + PastEventData obj = snapshot.getValue(PastEventData.class); + obj.setInterested_count(snapshot.getChildrenCount()); + + pastEventData.add(obj); + } + + @Override + public void onCancelled(@NonNull DatabaseError error) { + + } + }); + + + + //pastEventData.add(snapshot.getValue(PastEventData.class)); + myAdapter.notifyDataSetChanged(); + Log.i("test",snapshot.getValue().toString()); + } + + @Override + public void onCancelled(@NonNull DatabaseError error) { + + } + }); + } + } @Override @@ -64,9 +106,6 @@ public void onCancelled(@NonNull DatabaseError error) { } }); - pastEventData.add(new PastEventData("mid terms","10/01/2020","10")); - pastEventData.add(new PastEventData("Projects","20/65/1523","20")); - pastEventData.add(new PastEventData("Office Works","32/12/2021","40")); myAdapter = new PastEventDataAdapter(pastEventData,PastEventsList.this); recyclerView.setAdapter(myAdapter); } diff --git a/app/src/main/res/layout/my_home_ui.xml b/app/src/main/res/layout/my_home_ui.xml index 833bcd3..5ded48b 100644 --- a/app/src/main/res/layout/my_home_ui.xml +++ b/app/src/main/res/layout/my_home_ui.xml @@ -82,12 +82,13 @@