This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Transfer Learning for Natural Language Processing (MEAP) and have Paul Azunre on-line!
See this thread for details.
Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Helper Not recognized incoming request ..Help please :)

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all ! So break down...I am building something for class and the Helper in our code doesn't recognize the incoming request and just stays stuck without any updates. Can you all take a look and let me know any changes you would make? Appreciated  in advance


 
Saloon Keeper
Posts: 11882
253
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could tell us where it gets stuck.
 
Marr Yenn
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am checking with my members and will post an update ! Thanks
 
Marr Yenn
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is where we belive it is messing up. The helper and walker cannot communicate and is failing in the map activity which I have included.


[code=java] public void onCancelled(@NonNull DatabaseError databaseError) {

                       }
                   });
               }
           }

           @Override
           public void onKeyExited(String key) {

           }

           @Override
           public void onKeyMoved(String key, GeoLocation location) {

           }

           @Override
           public void onGeoQueryReady() {
               if(!helperFound) {
                   radius++;
                   getClosestHelper();
               }
           }

           @Override
           public void onGeoQueryError(DatabaseError error) {

           }
       });
   }

   private Marker mHelperMarker;
   private DatabaseReference helperLocationRef;
   private ValueEventListener helperLocationRefListener;
   private void getHelperLocation() {
       helperLocationRef = FirebaseDatabase.getInstance().getReference().child("helpersWorking").child(helperFoundId).child("l");
       helperLocationRefListener = helperLocationRef.addValueEventListener(new ValueEventListener() {
           @Override
           public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
               if (dataSnapshot.exists() && requestBol) {
                   List<Object> map = (List<Object>) dataSnapshot.getValue();
                   double locationLat = 0;
                   double locationLng = 0;
                   mRequest.setText("Helper Found");
                   if (map.get(0) != null) {
                       locationLat = Double.parseDouble(map.get(0).toString());
                   }
                   if (map.get(1) != null) {
                       locationLng = Double.parseDouble(map.get(1).toString());
                   }
                   LatLng helperLatLng = new LatLng(locationLat, locationLng);
                   if (mHelperMarker != null) {
                       mHelperMarker.remove();
                   }
                   Location loc1 = new Location("");
                   loc1.setLatitude(pickupLocation.latitude);
                   loc1.setLongitude(pickupLocation.longitude);

                   Location loc2 = new Location("");
                   loc2.setLatitude(helperLatLng.latitude);
                   loc2.setLongitude(helperLatLng.longitude);

                   float distance = loc1.distanceTo(loc2);

                   if (distance < 100) {
                       mRequest.setText("Helper's Here");
                   } else {
                       mRequest.setText("Helper Found: " + String.valueOf(distance));
                   }

                   mHelperMarker = mMap.addMarker(new MarkerOptions().position(helperLatLng).title("your helper").icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_helper)));
               }
           }

           @Override
           public void onCancelled(@NonNull DatabaseError databaseError) {

           }
       });
   }

   private void getHelperInfo() {
       mHelperInfo.setVisibility(View.VISIBLE);
       DatabaseReference mWalkerDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child("Helpers").child(helperFoundId);
       mWalkerDatabase.addListenerForSingleValueEvent(new ValueEventListener() {
           @Override
           public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
               if (dataSnapshot.exists() && dataSnapshot.getChildrenCount() > 0) {
                   Map<String, Object> map = (Map<String, Object>) dataSnapshot.getValue();
                   if (dataSnapshot.child("name") != null) {
                       mHelperName.setText(dataSnapshot.child("name").getValue().toString());
                   }
                   if (dataSnapshot.child("phone") != null) {
                       mHelperPhone.setText(dataSnapshot.child("phone").getValue().toString());
                   }
                   if (dataSnapshot.child("profileImageUrl").getValue() != null) {
                       Glide.with(getApplication()).load(dataSnapshot.child("profileImageUrl").getValue().toString()).into(mHelperProfileImage);
                   }

                   float ratingSum = 0;
                   float ratingsTotal = 0;
                   float ratingsAvg = 0;
                   for (DataSnapshot child : dataSnapshot.child("rating").getChildren()) {
                       ratingSum = ratingSum + Integer.valueOf(child.getValue().toString());
                       ratingsTotal++;
                   }
                   if (ratingsTotal != 0) {
                       ratingsAvg = ratingSum/ratingsTotal;
                       mRatingBar.setRating(ratingsAvg);
                   }
               }
           }

           @Override
           public void onCancelled(@NonNull DatabaseError databaseError) {

           }
       });
   }

   private DatabaseReference walkHasEndedRef;
   private ValueEventListener walkHasEndedRefListener;

   private void getHasWalkEnded() {
       walkHasEndedRef = FirebaseDatabase.getInstance().getReference().child("Users").child("Helpers").child(helperFoundId).child("walkerRequest").child("walkerWalkId");
       walkHasEndedRefListener = walkHasEndedRef.addValueEventListener(new ValueEventListener() {
           @Override
           public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
               if (dataSnapshot.exists()) {

               } else {
                   endWalk();
               }
           }





 
Rancher
Posts: 4548
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing I would do is add some debugging statements in there.  If you haven't got logging set up then simply add in a load of System.out.println calls in so you can track where the app is going, and where it's getting stuck.
That way you don't have to guess.
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
Try Free Java/.NET Libraries for Word Excel PowerPoint and PDF
htttp://www.e-iceblue.com/free-apis.html
    Bookmark Topic Watch Topic
  • New Topic