« first day (2721 days earlier)      last day (2228 days later) » 

7:00 PM
it is too abstract and philosophic
 
but let's say I'm expecting something like LiveData<PagedList<MyInterface>> right? And I return LiveData<PagedList<MyImplementation>>. Even though MyImplementation implements the interface, they're not the same type so the compiler breaks. I'm not sure what to do here. Have it expect something like LiveData<PagedList<T: MyInterface>>?
 
PagedList and LiveData need to be covariant
or contravariant, I always confuse these two words
and then it'll just work
 
@AdamMc331 closed as not a question
 
hm
 
7:02 PM
that's "in" and "out" keywords before type parameters in… okay it's easy to find anyway
 
@AdamMc331 use T
 
yeah but I don't define these generic classes so idk if I can do that lol
 
use generics i mean
 
I think I'm just an idiot here tbh
3
 
you can curse the author
maybe also do a forceful cast
 
7:03 PM
just use T extends MyInterface
 
or whatever, there are many ways to do it dirty
 
i dont see a problem ^
 
List<? extends Object> covariantList = aList;
List<? super String> contravariantList = aList;
for reference
 
yes, that's in Java
hm, the original question was for Java as well? I thought it's Kotlin
 
7:04 PM
an unchecked cast could work
I'm using Kotlin
I might post this on SO because I'm not sure I fully understand what I'm asking either
 
it will get duped
 
this is risky β€” might get roasted
 
people ask about this all the time
 
oh yeah
it's a good investment of ~10 minutes to read about it and practice a little bit
 
yes kotlin has decent docs on in and out, I read them earlier this week
 
7:07 PM
yeah I understand that a bit but I don't think that's my problem here.
 
what else could it be?
unless you show us more code, this is the only relevant thing here AFAIK
 
So I have a `LiveData<PagedList<SocialPhoto>>`, that's the field I want to populate.

I have two calls, one returns a `PagedList<FacebookPhoto>` and one returned `PagedList<InstagramPhoto>`. I want to assign it to the live data, but I can't because it'll say expected `PagedList<SocialPhoto>`
 
if you can change field type, choose a more general type
if you can't and also can't change class definitions β€” cast is the only way to go
 
generics
is the answer adam
 
Sounds like I'm stuck with it. Otherwise I create a class like class SocialPagedList<T: SocialPhoto> : PagedList<T>
But since PagedList isn't a class I wrote, I don't think I can change anything.
 
7:10 PM
what is the signature of PagedList
 
> "that's the field I want to populate" β€” can you change the type of this field?
 
It's a java class public abstract class PagedList<T> extends AbstractList<T> {
Idk how sarge. I have it like this:
val photos: LiveData<PagedList<SocialPhoto>> = Transformations.switchMap(photosResult) {
    it.pagedList as LiveData<PagedList<SocialPhoto>>
}
 
is it from your code, that you are allowed to edit?
you already have a cast there btw
 
PagedList is not from my code, no. It's part of the paging library in arch components
I know I added it after we started talking
 
the code you quoted above
 
7:12 PM
I'd like to not have it, but I will keep it if it's my only option.
 
is it yours?
 
The kotlin photos property is my class. The message two lines up is not.
 
what is the original type of "it.pagedList"?
 
ooo you might have broke this open. It's this class
data class Listing<T>(
val pagedList: LiveData<PagedList<T>>,
val networkState: LiveData<NetworkState>,
val refreshState: LiveData<NetworkState>,
val refresh: () -> Unit,
val retry: () -> Unit
)
 
that is, if you remove the cast and the type hint
 
7:13 PM
and I do have access to it, so maybe I can force the type on my listing
 
this data class seems almighty
 
no doing data class Listing<T: SocialPhoto> doesn't work
haha ripped straight from the arch components sample tim
gonna end up owing oracle billions at this rate oops
 
written by the guys who think it's cool to write logic in xml files
3
 
I'm just gonna do the ugly cast I guess
thanks everyone
 
you're welcome
android is such a funny thing, instead of getting rid of the lifecycles altogether and saving state at a lower level, a lot of interesting problems are invented, along with complex solutions
 
7:21 PM
lmao
so you mean android sucks
well isnt that something we already know?
 
from user perspective, it's the least evil right now
and iOS sucks more in both perspectives
 
@AdamMc331 what is your problem exactly?
 
he just spent 30min explaining it :D
 
I mean they were creating a new OS so they could implement state saving transparently: as an application launches, contents from filesystem are copied straight to its memory and stack pointers and registers restored as well. (and exceptions are thrown in if there are accesses to saved file descriptors or sockets, but maybe it's possible to somehow save them as well) And then all this bullshit would not be needed. Am I right or am I missing something?
…as a second thought, there's already such a thing as swap files, so the above could be unnecessary as well
14
Q: Why don't most Android devices have swap area as typical OS does?

JackWMDoes any Android today support swap area which is suppose to boost the performance? What are the considerations that make most Android devices drop that feature?

maybe I am missing an elephant in the room but it looks like a terrible design decision
 
the OS was meant to be "modern" which as I understand it, means it's unstable and you need to expect it to crash at any moment
I think with what you are suggesting Sarge, it would be easy to get stuck in a bad state
 
7:37 PM
well, swap files are used just fine on desktop systems
and it can be made so it's used only to keep "inactive" application's contents
 
oh, yeah the swap thing was probably a performance issue way back when
that's one of the two causes of almost all android platform headaches
the other one was the time pressure they were under to get it out to compete with iOS
 
I am not sure why it was not possible to "simply" use swap in a more optimal way and be done, in the end it's almost the same: some data goes to "disk" and back when an app wents to "background"/"foreground"
the amount of data would be a bit more (because not everything needs to be saved) but a lot less of bullshit code needs to be written for any applications
there are still lots of applications that don't manage lifecycle correctly, and it all would not exist if they decided to go with swap and not invent monsters
that could be a net win, because quality of apps also matters
time pressure is a bummer but after a while they could gradually change this in a backwards compatible way? like, there's no lifecycle from API X, but there's a dummy replacement so older apps can run without recompiling (and function correctly because swap is used to deal with state transparently) and after another 10 years it's completely gone and nobody needs to know about it at that point
phones which aren't artificially locked too much by closed source drivers can already run regular distros like Debian just fine, I've heard
so they certainly won't have obstacles to do this in 10 years
 
sounds like a fun side project for you Sarge
deprecate the android lifecycle
 
could be that Fu…ia already works like that? had anyone looked?
@eski if I got paid, sure, no problem, otherwise it's too much work for a single person
there's a lot of details to deal with for doing all of it smoothly
 
7:53 PM
consider reviewing Red-black trees then apply at the Android team of google :D
 
The problem with red black trees is that they can't photosynthesize due to a lack of chlorophyll.
3
 
the cool thing about them is their melanin though
 
hmm… never thought about applying to google
but maybe it could fly
 
Our slack writes a custom response anytime someone says rick roll
@RaghavSood I want this in the next version of the bot.
 
make sure to use the link which actually works
 
I remember someone posting rick roll here and it was always blocked for my country
it wouldn't penetrate my disabled autoplay anyway, but this looks like not even trying to win
it's almost like sending Windows malware to GNU/Linux users
2
 
lol
@MehdiB. damn i missed some message in between it seems
 
Oh but to answer your questions about the context even though no one asked
Type curl parrot.live in your terminal. It's safe I think.
It just prints party parrots to your console haha
 
i dont have a terminal i am safe
 
likely story
 
8:08 PM
wow there is a kotlin version of butterknife
lmao love the name kotterknife
 
they should make a kotlin version of lint, kotLint
 
it's called ktlint actually
it exists
 
they missed a golden opportunity
 
oh nice
damn i cant wait to start kotlin now
those java 8 features :)
 
8:11 PM
yeah dave, your name idea would be kotLIT!
 
that's even better eski
except that should be a fork of Kotlin not a lint tool
Like all exceptions start with "Bro, something's up:"
 
you just made me recall what I did as a kid
in my early programs, one of the options/buttons/etc. always was named "launch missiles" or something
 
8:36 PM
@androidFan you have access. Start by reading the rules and confirm you have read them before saying anything else
 
8:46 PM
@TimCastelijns Yes, I have read the rules
 
welcome, androidFan
 
9:25 PM
I hate Android layouts most of the time
it's so unintuitive to get what I want
 
really? i tend to find the opposite, especially ever since constraint layout
 
I want this:
[custom input field widget][textview button]
I tried with a linear, horizontal layout, and either the input field is squished to 0 width,
or it fills the entire screen and squishes the textview button
I've tried setting 0dp on the widget, match parent, and wrap content
I have wrap_content on the textview button
I tried putting them in a relative layout, and I get the same thing
 
So you're only showing one at a time?
or is that what's happening and you want them to each take up half
 
I want the textview to be wrap content, to take up the space it needs, and the widget to fill the rest
 
1word ConstraintLayout
 
9:30 PM
Constraint layout can do this
+1 Dave
 
what parameters do I need to set on the ConstraintLayout?
 
also if Horizontal LinearLayout
textview = wrap_content
inputfieldWidget.width = 0dp, inputFieldWidget.weight = 1,

should also work
 
no, I'll try the Constraint layout
I need more experience with it anyway
 
Constraint layout
1.you would constrain the textview to the right side, and set the width to wrap content
2. Set input width to 0dp, constraint left to parent and right to textview
so it would be like [<left anchor> 0dp stretchy <right anchor>][wrap_content textview<right anchor>]
and you'll need to set the appropriate top and bottom constraints
 
9:35 PM
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/resend_code_field"
 
in the two widgets?
 
on your SBTextInputLayout
need to add id
 
I don't think there's a benefit to using ConstraintLayout if it doesn't flatten the view hierarchy
 
let me just edit the paste rq
try that out
one really cool feature of constraint layout is complex animations using auto transitions and programmatic editing on a constraint set
you can size down and slide and do all sorts of neat things
 
9:41 PM
didn't work until I added to the TextView the constraint, but now it looks right, thanks Dave.
 
np
 
what an awkward mix of lowerCamelCase with underscores
layout_constraintRight_toRightOf
 
protip: if you just start typing

"leftToleft" Android Studio will auto complete pretty intuitively
 
yeah I've figured out most of those tricks
 
It took me an hour or two to stop typing layout_constraint first
 
9:48 PM
we finally upgraded to gradle 3.0 and it's been nice today being able to compile the app with only XML changes and have it launch in less than 3 minutes
ok, I can struggle with this one for several more minutes or just ask...
I've got the general layout working, input is taking up all the space leftover by the Resend Code text
but the Resend Code text gravity is wrong
I need it either centered in the layout or bottom of the layout
tried gravity and layout gravity with a few settings, and they did nothing
do I need to set something on the constraint layout?
 
hmm
 
constrain topToTopof parent and same for bottom
gravity is ignored in constraint layouts except text gravity
by constraining to top and bottom with fixed size (wrap_content or explicit) you vertically center it
if you want bottom, leave off the top constraint etc
 
ok
thanks
works
 
np, another tip is layout margins only apply to element they are defined on, with these constraints
TextViewA will constrain to the padding of TextViewB, ignoring any of TextView b's margins
but margins set on TextViewA will apply
i.e in your example, setting marginRight on input would work to create spacing, but setting marginLeft on the button would not (unless you also constrained the left of the button to the right of the input)
 
10:06 PM
wow this chat is worth a save
for CL users
 
10:45 PM
I'll give an extra 100 to anyone who posts an answer that beats @DaveS and takes the 400
 
lmao
 

« first day (2721 days earlier)      last day (2228 days later) »