Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to update Query in Firebase and Firestore Adapters. #1660

Merged
merged 17 commits into from Aug 1, 2019

Conversation

@PatilShreyas
Copy link
Contributor

PatilShreyas commented Jul 20, 2019

This PR Implements a method to change/update Query in both Firebase as well as Firestore Adapters. (Issue #1614)

@PatilShreyas PatilShreyas requested a review from samtstern as a code owner Jul 20, 2019
@PatilShreyas

This comment has been minimized.

Copy link
Contributor Author

PatilShreyas commented Jul 20, 2019

@samtstern There are some Auth lint errors exists that's why Trivis CI failed.

@PatilShreyas

This comment has been minimized.

Copy link
Contributor Author

PatilShreyas commented Jul 22, 2019

@samtstern These are errors.

  The first 3 errors (out of 84) were:
  /home/travis/build/firebase/FirebaseUI-Android/auth/src/main/res/layout/fui_auth_method_picker_layout.xml:11: Error: This view is not constrained horizontally: at runtime it will jump to the left unless you add a horizontal constraint [MissingConstraints]
      <me.zhanghai.android.materialprogressbar.MaterialProgressBar
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/travis/build/firebase/FirebaseUI-Android/auth/src/main/res/layout-land/fui_auth_method_picker_layout.xml:12: Error: This view is not constrained horizontally: at runtime it will jump to the left unless you add a horizontal constraint [MissingConstraints]
      <me.zhanghai.android.materialprogressbar.MaterialProgressBar
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/travis/build/firebase/FirebaseUI-Android/auth/src/main/res/layout/fui_confirmation_code_layout.xml:9: Error: This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints [MissingConstraints]
      <me.zhanghai.android.materialprogressbar.MaterialProgressBar
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  The first 3 errors (out of 4) were:
  /home/travis/build/firebase/FirebaseUI-Android/app/src/main/res/layout/auth_method_picker_custom_layout.xml:81: Error: This namespace declaration is redundant [RedundantNamespace]
      <com.firebase.ui.auth.util.ui.SupportVectorDrawablesButton xmlns:android="http://schemas.android.com/apk/res/android"
                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/travis/build/firebase/FirebaseUI-Android/app/src/main/res/layout-land/auth_method_picker_custom_layout.xml:98: Error: This namespace declaration is redundant [RedundantNamespace]
      <com.firebase.ui.auth.util.ui.SupportVectorDrawablesButton xmlns:android="http://schemas.android.com/apk/res/android"
                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/travis/build/firebase/FirebaseUI-Android/app/src/main/res/values/strings.xml:26: Error: Duplicate string value Google, used in logo_google, providers_google and tos_pp_google [DuplicateStrings]
      <string name="providers_google">Google</string>
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /home/travis/build/firebase/FirebaseUI-Android/app/src/main/res/values/strings.xml:46: Duplicates value in providers_google
      /home/travis/build/firebase/FirebaseUI-Android/app/src/main/res/values/strings.xml:50: Duplicates value in providers_google
@samtstern samtstern added this to the 5.0.1 milestone Jul 23, 2019
Copy link
Member

samtstern left a comment

@PatilShreyas thanks for this! Just a few comments.

*
* @param newQuery is a new updated query.
*/
public abstract void updateQuery(@NonNull Query newQuery);

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 23, 2019

Member

Should this be added in BaseObservableSnapshotArray instead? It seems a bit strange that this would be the only method defined on ObservableSnapshotArray

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 23, 2019

Author Contributor

Because BaseObservableSnapshotArray is inherited in both ObservableSnapshotArray of Firestore as well as Firebase realtime database too. And most importantly, the Query class of both databases are not the same.

  • Firestore Query Class: com.google.firebase.firestore.Query
  • Firebase Query Class: com.google.firebase.database.Query

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 23, 2019

Author Contributor

If we add this method in BaseObservableSnapshotArray then Query parameter will be different for them. What else can we do here?

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 24, 2019

Member

I would say let's just not make this part of the base class at all, it can just be something implemented in each of the Array classes.

That will also allow us to give the indexed version a better name: updateKeyQuery()

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 24, 2019

Author Contributor

We have instantiated FirestoreArray by its superclass references in Adapter classes. So, Will it be fine them to be instantiated as Array classes?

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 24, 2019

Author Contributor

Fine 😃. Okay then 👍 .

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 25, 2019

Author Contributor

I have some questions.

  • If I instantiate mSnapshots as FirebaseArray' as then how to take care of FirebaseIndexArray`?
  • How could we know that when to call updateQuery() or updateKeyQuery()?
    In FirebaseRecyclerAdapter if I create an instance of FirebaseArray then we can't instantiate FirebaseIndexArray. How to do it?

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 25, 2019

Member

Oh no that is a problem ... any ideas? I don't know why I am so opposed to adding updateQuery to the ObservabeSnapshotArray classes ... it just feels wrong. But maybe that is the best way.

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 25, 2019

Author Contributor

I also thought a lot about it before implementation in ObservableSnapshotArray class. But I can't find anything helpful.

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 25, 2019

Author Contributor

I had one idea. But that idea was not much good to implement. Means, it's not good practice to implement. I had idea to use instanceof to check whether it's instance of Firebase array or index array. We will check it in our method and by casting we will call array class method. That was the idea.

@@ -25,6 +26,7 @@ public boolean areItemsTheSame(@NonNull DataSnapshot oldItem,
return oldItem.getKey().equals(newItem.getKey());
}

@SuppressLint("DiffUtilEquals")

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 23, 2019

Member

Why is this lint suppression added in this PR when nothing else about this file changed?

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 23, 2019

Author Contributor

Because it caused an error when I run the command gradlew assembleDebug proguard-tests:build check

When I checked that class, it's showing me the red line under return statement showing a suggestion to add this line.

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 24, 2019

Member

Ok I am fine with this, although I bet if we revert the unrelated changes in this PR, this will go away.

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 24, 2019

Author Contributor

Oh! Okay.

repositories {
jcenter()
}

plugins {
`kotlin-dsl`
kotlin("jvm") version "1.3.41"

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 23, 2019

Member

Can you explain why we need all of these kotlin changes in this PR? Are they related?

This comment has been minimized.

Copy link
@PatilShreyas

PatilShreyas Jul 23, 2019

Author Contributor

No. I just updated it as it's on my system.

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 24, 2019

Member

Ok let's revert these changes since they are not related to the feature.

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

This comment has been minimized.

Copy link
@samtstern

samtstern Jul 24, 2019

Member

Let's also revert this, this could be a big change and I want to do it separately (when I have time to verify the release process with gradle 5)

PatilShreyas and others added 4 commits Jul 25, 2019
Change-Id: I3d6465a15171b2cd5629d93e5745585552129d2d
Mistake
Change-Id: Iacc39b3b49d1b6e5ce753ee0ab3a11ac975b9de0
@samtstern

This comment has been minimized.

Copy link
Member

samtstern commented Jul 25, 2019

@PatilShreyas ok I did some thinking and experimenting. First I found better words to explain myself :-) the reason I am not comfortable with updateQuery on ObservableSnapshotArray is because that class previous did not know that Query existed at all.

Second I think it may be better to structure this as setOptions where instead of just replacing the query you replace the whole options object you used to start the Adapter. Here's an example of how that might look (for RTDB only):
PatilShreyas#2

What do you think?

@PatilShreyas

This comment has been minimized.

Copy link
Contributor Author

PatilShreyas commented Jul 26, 2019

Right @samtstern!

[WIP] Update Query Experiments
@PatilShreyas

This comment has been minimized.

Copy link
Contributor Author

PatilShreyas commented Jul 30, 2019

@samtstern I have merged your PR and make changes as you suggested. Also implemented in Firestore adapter. Also, tested updateOptions on adapter.

@samtstern

This comment has been minimized.

Copy link
Member

samtstern commented Aug 1, 2019

@PatilShreyas sorry I missed your last comment! Thanks for working with me on this, LGTM.

@samtstern samtstern merged commit d7aec38 into firebase:version-5.0.1-dev Aug 1, 2019
2 checks passed
2 checks passed
cla/google All necessary CLAs are signed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@PatilShreyas

This comment has been minimized.

Copy link
Contributor Author

PatilShreyas commented Aug 2, 2019

Anytime! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.