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

Added:Google PlaceAutocomplete #801

Closed
wants to merge 7 commits into from
Closed

Added:Google PlaceAutocomplete #801

wants to merge 7 commits into from

Conversation

aggarwalpulkit596
Copy link
Contributor

Fixes #799

Changes: Added Google PlaceAutocomplete for searching events
Screenshots for the change:

videotogif_2019 01 02_01 15 01

@aggarwalpulkit596
Copy link
Contributor Author

@iamareebjamal please review

app/build.gradle Outdated
@@ -102,6 +106,8 @@ dependencies {
testImplementation "androidx.room:room-testing:${roomVersion}"
implementation "com.takisoft.fix:preference-v7:28.0.0.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.android.gms:play-services-places:16.0.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read comments from this PR - #735

@aggarwalpulkit596 aggarwalpulkit596 changed the title Addded:Google PlaceAutocomplete Added:Google PlaceAutocomplete Jan 1, 2019
@fossasia fossasia deleted a comment Jan 1, 2019
@fossasia fossasia deleted a comment Jan 1, 2019
@fossasia fossasia deleted a comment Jan 1, 2019
@aggarwalpulkit596
Copy link
Contributor Author

aggarwalpulkit596 commented Jan 1, 2019

@iamareebjamal i need to disable the search functionality for F-Droid application right?
but when i tried it with playStoreImplementation I'm not able to build the project as class not found for Places API shows up
and we could do one thing use the previous method for f- droid build and current method for playstore build

Copy link
Member

@nikit19 nikit19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build will fail because you didn't handle the case of what happens in the Fdroid build.

// Do your search
searchLocationViewModel.saveSearch(query)
val autocompleteFragment = fragmentManager
.findFragmentById(R.id.place_autocomplete_fragment) as PlaceAutocompleteFragment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use synthetic binding

<androidx.appcompat.widget.SearchView
android:id="@+id/search"
<fragment
android:id="@+id/place_autocomplete_fragment"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camel case

@aggarwalpulkit596
Copy link
Contributor Author

@nikit19 i will handle the case for f- droid but if i use playStoreImplementation i'm not able to import the classes required? what's the solution to that

@nikit19
Copy link
Member

nikit19 commented Jan 2, 2019

What do you mean by handle the case for Fdroid? You can use those imports only in the playstore flavor. Please read about build flavors, you will get a better understanding of how to handle this case.

@aggarwalpulkit596
Copy link
Contributor Author

@nikit19 i meant that if the build type if of play store then only I'll do this process otherwise we can do the previous method

@nikit19
Copy link
Member

nikit19 commented Jan 2, 2019

Yes, but you are not doing that in the code. Try building the project for the playstore flavor, the build will complete. Right now you are implementing the places API only in the playstore flavor but importing it in both the flavors.

@fossasia fossasia deleted a comment Jan 2, 2019
@aggarwalpulkit596
Copy link
Contributor Author

@nikit19 @iamareebjamal this is correct method i guess ?

app/build.gradle Outdated Show resolved Hide resolved
@aggarwalpulkit596
Copy link
Contributor Author

@iamareebjamal can you look at the Travis error i don't find any reason for it to fail

@iamareebjamal
Copy link
Member

iamareebjamal commented Jan 2, 2019

@iamareebjamal
Copy link
Member

* What went wrong:
Execution failed for task ':app:spotlessKotlin'.
> The following files had format violations:
      app/src/playStore/java/org/fossasia/openevent/general/search/SearchLocationActivity.kt
          @@ -28,8 +28,8 @@
           ········val·bundle·=·intent.extras
           ········val·fromSearchFragment·=·bundle?.getBoolean(FROM_SEARCH)·?:·false
           
          -········val·autocompleteFragment·=·fragmentManager.
          -············findFragmentById(R.id.placeAutocompleteFragment)·as·PlaceAutocompleteFragment
          +········val·autocompleteFragment·=·fragmentManager
          +············.findFragmentById(R.id.placeAutocompleteFragment)·as·PlaceAutocompleteFragment
           
           ········autocompleteFragment.setOnPlaceSelectedListener(object·:·PlaceSelectionListener·{
           ············override·fun·onPlaceSelected(place:·Place)·{
          @@ -49,7 +49,6 @@
           
           ············override·fun·onError(status:·Status)·{
           ················Timber.d(status.statusMessage,·"Failed·getting·location")
          -
           ············}
           ········})
           ····}
  Run 'gradlew spotlessApply' to fix these violations.

@aggarwalpulkit596
Copy link
Contributor Author

@iamareebjamal codacy issues are regarding unsafe cast rest all is good i think ?

app/build.gradle Show resolved Hide resolved
app/build.gradle Show resolved Hide resolved
app/build.gradle Show resolved Hide resolved
@@ -24,7 +24,6 @@ class SearchLocationActivity : AppCompatActivity() {
this.supportActionBar?.title = ""
val bundle = intent.extras
val fromSearchFragment = bundle?.getBoolean(FROM_SEARCH) ?: false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required

autocompleteFragment.setOnPlaceSelectedListener(object : PlaceSelectionListener {
override fun onPlaceSelected(place: Place) {
// Save Searched Place String
searchLocationViewModel.saveSearch(place.name as String)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.toString() would work?

@aggarwalpulkit596
Copy link
Contributor Author

@nikit19 i made two different files for f-droid and play store but github is only showing one file but it is actually two seperate files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants