Week 4: 10/13 - 10/19

October 13, 2017


Lu Meng

We have had the place autocomplete function in our app, but how can we get the photos of the place that the user selects?

  1. I used the PlaceSelectionListener which handles returning a place in response to the user's selection to get the place id.
  2. Since I used the Google Place API and the version number is 11.0.4, I needed to let app connect to the Google Play services API client. To do this, I built a new class and I used this class to get the photos of the places.

  3. Since I built another class to fetch the place photos from the Internet in the step 2, I needed to pass the place id from this class to another one.
    In the original class:

    private void getID() {
        id = placeID;
    }
    public static String getPlaceID() {
        return id;
    }

In the new class:

    private String placeId = theOriginalClass.getPlaceID();
Taining Zhang
Finished Work

Use the ListView to show the user's comments:

  1. Build the content layout xml file.
  2. Create a new customized adapter extends the ArrayAdapter.
public CustomListAdapter(@NonNull Context context, String[] username, String[] usercomments) {
        super(context, R.layout.custom_list, username);
        this.usercomments = usercomments;
        this.username = username;
    }

Write place information to firebase through realtime database function

  1. Store the place_id into the JSON tree.
  2. Pass the place_id to the info activity.

Problems

When I try to get the comments from the database, at first I used the addValueEventListener to get the data from database. Also, add the comments get from the database out of that Listener. However, I got nothing, then I try to put the comments into the ListView in this Listener function like following:

Comment.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                List<String> usernames = new ArrayList<>();
                List<String> contents = new ArrayList<>();

                for(DataSnapshot comment : dataSnapshot.getChildren()) {
                    usernames.add(comment.child("user").getValue(String.class));
                    contents.add(comment.child("Content").getValue(String.class));
                }
                alert(usernames.size() + "");
                final String[] userName = new String[usernames.size() + 1];
                String[] comments = new String[contents.size() + 1];
                for(int i = 0; i < usernames.size(); i++) {
                    userName[i] = usernames.get(i);
                    comments[i] = contents.get(i);
                }
                final CustomListAdapter listAdapter = new CustomListAdapter(context, userName, comments);
                listView = (ListView) findViewById(R.id.listView);
                listView.setAdapter(listAdapter);
                ...
}

This may because this function is executing in another thread and the list of comments cannot get out of the thread.

Wanqing Chen

Finished work

User will enter main view first. New user can choose registration button to register.

Registration View. Users can register with their email and set up the password.

After registration, it will jump to Login View. Users can log in.

There is a welcome page after successful login.

We can manage users through our firebase account.

Problems

When I was trying to run the app, it got stuck at the view of processing registration information. I checked the running information of Android Monitor and found following report:

10-19 12:11:02.109 17613-17663/com.example.tainingzhang.tripsharing_v0 E/FA: Discarding data. Failed to send app launch

10-19 12:11:02.109 17613-17663/com.example.tainingzhang.tripsharing_v0 E/FA: Failed to get app instance id

which means the data could not be sent to Firebase from the app. The solution is to either update the emulator to get Play Services 11 installed on it, or downgrade the firebase dependency to match Google Play Services installed on the emulator.

results matching ""

    No results matching ""