profile
viewpoint
Shaishav Gandhi ShaishavGandhi @uber San Francisco https://shaishav.dev Android @ Uber

ShaishavGandhi/BundleX 7

Generate readable extensions on Bundle to easily bind and set extras.

ShaishavGandhi/BeBetter 3

Personal productivity app that helps you decrease your mobile usage

Glassdoor/PreferenceX 2

Declarative extensions on SharedPreferences and Editor with the help of annotation processing

ShaishavGandhi/assistant 1

Lightweight assistant server that can take HTTP requests with query, resolve them and answer questions

ShaishavGandhi/Android-Interview-Questions 0

Collection of Android and Java related questions and topics to know

ShaishavGandhi/android-ktx 0

A set of Kotlin extensions for Android app development.

ShaishavGandhi/android-simple-tooltip 0

A simple library based on PopupWindow to create Tooltips on Android. 💚

ShaishavGandhi/AndroidCharts 0

An easy-to-use Android charts library with animation.

ShaishavGandhi/appboy-android-sdk 0

Public repo for the Braze Android SDK

issue closedsquare/moshi

How to parse fields with the same key but different values

This is driving me crazy. I spent the whole day and I still cannot figure out the issue I'm facing.

Our backend sends a json response that can contain different values for the same key every time.

Example of First variation:

{
  "title": "2",
  "profile_image": {
    "profile_image_id": "4581542",
    "sized": "media/up/2020/48/460e689e286ca46b1006b62269ee21a22b6bdabf2496506e34e5d07c5d42c20f_user_photo_160674563705555.sized.JPG",
    "sized_w": "556",
    "sized_h": "555",
    "thumb": "media/up/2020/48/460e689e286ca46b1006b62269ee21a22b6bdabf2496506e34e5d07c5d42c20f_user_photo_160674563705555.thumb.JPG",
    "thumb_w": "90",
    "thumb_h": "90"
  },
  "profile": {
    "title": "2",
    "first_name": "John",
    "last_name": "Doe",
    "user_online_status": false
  }
}

And below is an another variation of the same response. Notice the profile_image field is now an Array type and user_online_status can also be a string or a boolean.

{
  "title": "2",
  "profile_image": [
    
  ],
  "profile": {
    "title": "2",
    "first_name": "John",
    "last_name": "Doe",
    "user_online_status": "0"
  }
}

How can I parse such responses using Retrofit and Moshi without creating extra model classes? Can I use a custom adapter Maybe? Could you give me an example? I tried to make an adapter of my own but didn't managed to get far

class SkipEmptyProfileAdapter {
    

    @FromJson
    fun fromJson(reader: JsonReader): UserProfileDataResponse? {
        val moshi = Moshi.Builder().build()

        reader.beginObject()
        while (reader.hasNext()) {
            if (reader.nextName() == "profile_image") {
                Timber.i("PROFILE IMAGE")
                val pls = reader.peek()
                if (pls == JsonReader.Token.BEGIN_ARRAY)
                    return null
            }
        }
        reader.endObject()
        return null
    }

}

Can you help me out?

closed time in 14 minutes

ThanosFisherman

issue commentsquare/moshi

How to parse fields with the same key but different values

Stack Overflow is the place for questions like this, this is a forum for bugs in Moshi.

That being said, it looks like you're moving in the right direction. A custom type adapter and peek() is the right way to deal with that kind of garbage. I'd recommend continuing down that path and handling the other possible cases, and head to Stack Overflow if you end up stuck on a specific part.

ThanosFisherman

comment created time in 14 minutes

issue openedsquare/moshi

How to parse fields with the same key but different values

This is driving me crazy. I spent the whole day and I still cannot figure out the issue I'm facing.

Our backend sends a json response that can contain different values for the same key every time.

Example of First variation:

{
  "title": "2",
  "profile_image": {
    "profile_image_id": "4581542",
    "sized": "media/up/2020/48/460e689e286ca46b1006b62269ee21a22b6bdabf2496506e34e5d07c5d42c20f_user_photo_160674563705555.sized.JPG",
    "sized_w": "556",
    "sized_h": "555",
    "thumb": "media/up/2020/48/460e689e286ca46b1006b62269ee21a22b6bdabf2496506e34e5d07c5d42c20f_user_photo_160674563705555.thumb.JPG",
    "thumb_w": "90",
    "thumb_h": "90"
  },
  "profile": {
    "title": "2",
    "first_name": "John",
    "last_name": "Doe",
    "user_online_status": false
  }
}

And below is an another variation of the same response. Notice the profile_image field is now an Array type and user_online_status can also be a string or a boolean.

{
  "title": "2",
  "profile_image": [
    
  ],
  "profile": {
    "title": "2",
    "first_name": "John",
    "last_name": "Doe",
    "user_online_status": "0"
  }
}

How can I parse such responses using Retrofit and Moshi without creating extra model classes? Can I use a custom adapter Maybe? Could you give me an example? I tried to make an adapter of my own but didn't managed to get far

class SkipEmptyProfileAdapter {
    

    @FromJson
    fun fromJson(reader: JsonReader): UserProfileDataResponse? {
        val moshi = Moshi.Builder().build()

        reader.beginObject()
        while (reader.hasNext()) {
            if (reader.nextName() == "profile_image") {
                Timber.i("PROFILE IMAGE")
                val pls = reader.peek()
                if (pls == JsonReader.Token.BEGIN_ARRAY)
                    return null
            }
        }
        reader.endObject()
        return null
    }

}

Can you help me out?

created time in 35 minutes

issue closedsquare/kotlinpoet

How to judge whether the parameter of annotation is nullable?

val isNullable = parameterElement.asType().asTypeName().isNullable

When I do, it always returns null

closed time in an hour

plumcookingwine

issue openedsquare/kotlinpoet

How to judge whether the parameter of annotation is nullable?

val isNullable = parameterElement.asType().asTypeName().isNullable

When I do, it always returns null

created time in an hour

created repositoryJakeWharton/dockerfile-shebang

Treat your Dockerfiles as self-contained, editable scripts

created time in 5 hours

issue commentsquare/moshi

Expected BEGIN_OBJECT but was BEGIN_ARRAY

@ZacSweers please help!

franquicidad

comment created time in 7 hours

push eventReactiveX/RxJava

akarnokd+ci

commit sha cfe9f3fe2f2063cfac138eb12a6f29f4e19061fe

CI build: 6 for snapshot

view details

push time in 7 hours

issue openedReactiveX/RxJava

3.0.8-RC1 release preparation

Version 3.0.8-RC1 - December 2, 2020 (Maven)

JavaDocs

This is a pre-release for 3.0.8 to verify the release process still works after the switch to GitHub actions (#7114).

Bugfixes

  • Remove unnecessary cancel/dispose calls from terminating using (#7121)

Documentation

  • Flowable scan/scanWith backpressure documentation update (#7110)

created time in 7 hours

push eventReactiveX/RxJava

David Karnok

commit sha bfd242da5de53bd16f8c7d52c83e0968010bba2c

3.x: Remove unnecessary cancel/dispose calls from terminating using (#7121)

view details

push time in 7 hours

PR merged ReactiveX/RxJava

3.x: Remove unnecessary cancel/dispose calls from terminating using 3.x Bug Cleanup

Following up on a Gitter.im report, the onComplete/onError methods of the using operators were calling cancel/dispose on the upstream even though there is no reason to do such a thing and is also not allowed by Reactive Streams rule 2.3.

The original code's side-effect was that given a nested using pair, an onComplete/onError of the inner sequence would trigger a cancellation and resource release in the outer before/while the onComplete/onError signals propagate downstream and return back on a non-eager setting.

+4 -10

1 comment

3 changed files

akarnokd

pr closed time in 7 hours

issue commentcashapp/paparazzi

Add support for test filtering to Gradle tasks

Haven't looked at the Gradle plugin implementation, but I wonder if this can be achieved by simply inheriting from the right Gradle task types, smth like Test. Will take a closer look.

Egorand

comment created time in 10 hours

push eventgoogle/truth

travis-ci

commit sha b216afa66f6a01015fb71875306acc58ca3d4926

Latest javadoc on successful travis build 1118 auto-pushed to gh-pages.

view details

push time in 10 hours

issue openedcashapp/paparazzi

Add support for test filtering to Gradle tasks

As test suites grow, it would be handy to be able to pass filtering arguments to Paparazzi tasks, similar to Gradle's built-in test tasks (see Test filtering):

./gradlew views:recordPaparazziDebug --tests FooView

created time in 10 hours

delete branch google/truth

delete branch : test_344063799

delete time in 10 hours

PR merged google/truth

Special failure message for StringSubject.matches when the regex is a string match for the actual value. cla: yes

Special failure message for StringSubject.matches when the regex is a string match for the actual value.

Fixes #789 Fixes #783

RELNOTES=n/a

+41 -2

0 comment

2 changed files

copybara-service[bot]

pr closed time in 10 hours

issue closedgoogle/truth

Better message if assertThat(string).matches(equalString) fails

As noted in https://stackoverflow.com/q/64616887/28465, it's easy for users to write matches when they mean isEqualTo. (Perhaps we should have picked a name like "matchesRegex"; oops.) If someone writes matches("$5") and the input string is "$5," our failure message could say "Hey, that doesn't match the regex, but did you mean isEqualTo?"

(If users make this mistake with doesNotMatch, there's usually not much we can do to detect it, since the test just passes silently....)

closed time in 10 hours

cpovirk

PR closed google/truth

Changed failure message of StringSubject.matches and added test cases P2 cla: yes type=enhancement

Added an additional message to hint at the use of isEqualTo in case of a failed test where most likley a exact equality assertion was needed instead of a regex.

Added two test cases to StringSubjectTest to test for the correct failure messages. This PR is in reference to https://github.com/google/truth/issues/783#issue-737794162

+33 -2

3 comments

2 changed files

alexw0610

pr closed time in 10 hours

push eventgoogle/truth

alexw0610

commit sha 2feb0608b46c424cdd6620b4923f6c2f3db18473

Special failure message for StringSubject.matches when the regex is a string match for the actual value. Fixes #789 Fixes #783 RELNOTES=n/a PiperOrigin-RevId: 344820187

view details

push time in 10 hours

PR closed google/truth

Changed failure message of StringSubject.matches and added test cases P2 cla: yes type=enhancement

Added an additional message to hint at the use of isEqualTo in case of a failed test where most likley a exact equality assertion was needed instead of a regex.

Added two test cases to StringSubjectTest to test for the correct failure messages. This PR is in reference to https://github.com/google/truth/issues/783#issue-737794162

+33 -2

3 comments

2 changed files

alexw0610

pr closed time in 10 hours

issue closedgoogle/truth

Better message if assertThat(string).matches(equalString) fails

As noted in https://stackoverflow.com/q/64616887/28465, it's easy for users to write matches when they mean isEqualTo. (Perhaps we should have picked a name like "matchesRegex"; oops.) If someone writes matches("$5") and the input string is "$5," our failure message could say "Hey, that doesn't match the regex, but did you mean isEqualTo?"

(If users make this mistake with doesNotMatch, there's usually not much we can do to detect it, since the test just passes silently....)

closed time in 10 hours

cpovirk

push eventgoogle/truth

alexw0610

commit sha 2feb0608b46c424cdd6620b4923f6c2f3db18473

Special failure message for StringSubject.matches when the regex is a string match for the actual value. Fixes #789 Fixes #783 RELNOTES=n/a PiperOrigin-RevId: 344820187

view details

push time in 10 hours

push eventgoogle/truth

cpovirk

commit sha a8e6a2d5b27402462b4adf94444e77b2b335c5b1

Special failure message for StringSubject.matches when the regex is a string match for the actual value. Fixes #789 Fixes #783 RELNOTES=n/a PiperOrigin-RevId: 344063799

view details

push time in 10 hours

PR opened google/truth

Special failure message for StringSubject.matches when the regex is a string match for the actual value.

Special failure message for StringSubject.matches when the regex is a string match for the actual value.

Fixes #789 Fixes #783

RELNOTES=n/a

+41 -2

0 comment

2 changed files

pr created time in 10 hours

create barnchgoogle/truth

branch : test_344063799

created branch time in 10 hours

pull request commentReactiveX/RxJava

3.x: Remove unnecessary cancel/dispose calls from terminating using

Codecov Report

Merging #7121 (0f4523e) into 3.x (3d5fece) will increase coverage by 0.04%. The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                3.x    #7121      +/-   ##
============================================
+ Coverage     99.49%   99.53%   +0.04%     
+ Complexity     6670     6669       -1     
============================================
  Files           742      742              
  Lines         47275    47267       -8     
  Branches       6374     6374              
============================================
+ Hits          47037    47048      +11     
+ Misses          112      100      -12     
+ Partials        126      119       -7     
Impacted Files Coverage Δ Complexity Δ
...va3/internal/operators/flowable/FlowableUsing.java 100.00% <ø> (ø) 2.00 <0.00> (ø)
...internal/operators/observable/ObservableUsing.java 100.00% <ø> (ø) 2.00 <0.00> (ø)
...l/operators/observable/ObservableFlatMapMaybe.java 92.25% <0.00%> (-4.93%) 2.00% <0.00%> (ø%)
...vex/rxjava3/internal/operators/maybe/MaybeAmb.java 96.96% <0.00%> (-3.04%) 10.00% <0.00%> (-1.00%)
...l/operators/observable/ObservableTimeoutTimed.java 99.15% <0.00%> (-0.85%) 3.00% <0.00%> (ø%)
.../operators/observable/ObservableCombineLatest.java 99.38% <0.00%> (-0.62%) 6.00% <0.00%> (ø%)
...a/io/reactivex/rxjava3/subjects/ReplaySubject.java 98.75% <0.00%> (-0.42%) 49.00% <0.00%> (ø%)
...ternal/operators/observable/ObservableFlatMap.java 97.87% <0.00%> (-0.36%) 3.00% <0.00%> (ø%)
...java3/internal/operators/flowable/FlowableZip.java 100.00% <0.00%> (+1.02%) 6.00% <0.00%> (ø%)
...ernal/operators/flowable/FlowableFromIterable.java 100.00% <0.00%> (+1.04%) 5.00% <0.00%> (ø%)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3d5fece...0f4523e. Read the comment docs.

akarnokd

comment created time in 10 hours

PR opened ReactiveX/RxJava

3.x: Remove unnecessary cancel/dispose calls from terminating using 3.x Bug Cleanup

Following up on a Gitter.im report, the onComplete/onError methods of the using operators were calling cancel/dispose on the upstream even though there is no reason to do such a thing and is also not allowed by Reactive Streams rule 2.3.

The original code's side-effect was that given a nested using pair, an onComplete/onError of the inner sequence would trigger a cancellation and resource release in the outer before/while the onComplete/onError signals propagate downstream and return back on a non-eager setting.

+4 -10

0 comment

3 changed files

pr created time in 11 hours

push eventsquare/kotlinpoet

Tomasz Krakowiak

commit sha a61e88f6f3e050d601145f88ca149299f1423b14

#1016 Delegated constructor call in external class is not allowed

view details

Tomasz Krakowiak

commit sha 27835f26081b1e6c540d2c612057f86d9e2bddb2

#1018 Expect classes cannot initialize supertypes

view details

Egor Andreevich

commit sha f028a95776d0b58eda5b2492d157b8d39c88a939

Merge pull request #1017 from NiematojakTomasz/issue-1016 #1016 Delegated constructor call in external class is not allowed

view details

push time in 11 hours

issue closedsquare/kotlinpoet

Expect classes cannot initialize supertypes

Sample incorrectly generated code:

public expect open abstract class AbortSignal : EventTarget() {
  public open val aborted: Boolean?
}

Error: "Expected classes cannot initialize supertypes"

closed time in 11 hours

NiematojakTomasz
more