|
Trying some stupid poo poo Edit: it boots now brand engager fucked around with this message at 02:50 on Mar 8, 2018 |
# ? Mar 8, 2018 02:38 |
|
|
# ? May 28, 2024 16:30 |
|
At the end of the day even if you got that working, it's still going to be an ARM emulator and slow as hell. I know you can't run an x86 emulator on EC2, but maybe telling jenkins to ship it to firebase test lab is an option for you there if you don't want local physical infrastructure.
|
# ? Mar 8, 2018 02:49 |
|
Is there any way to change the colors used for specific days in a CalendarView widget? Most of the color related methods are deprecated, and subclassing the widget hasn't exposed anything that can change colors.
|
# ? Mar 29, 2018 00:05 |
|
You might want to use the material backport on GitHub and customize it in this case. Not sure how far back you need to support or how much you care about device L&F
|
# ? Mar 29, 2018 14:42 |
|
Volmarias posted:You might want to use the material backport on GitHub and customize it in this case. Not sure how far back you need to support or how much you care about device L&F Our minimum API level is at 15 right now. I might just abandon the color thing for now since this is for a class group project.
|
# ? Mar 29, 2018 20:12 |
|
I've been working on a basic app (list view displaying all entries in a DB table, detail view for inserting and updating entries) using the MVVM pattern with Room and LiveData and I've run into a few things I haven't been able to figure out. I'm trying to have the both the insert and update features use the same code. If the detail activity is passed a valid ID, it fetches the item from the DB and populates the views. If it is passed no ID or an ID that doesn't exist in the DB, it creates a new Item (with default values) and populates the views. My issue right now is when creating a new item, I'm not sure where I should be tying the new item object to a LiveData object. With what I have now (see below), the new item is successfully inserted into the DB when the save button is clicked, but because the activity is still observing LiveData with a null item, the views are all updated to show the default values again after the insert triggers the onChanged callback. My first instinct was to have the repository's loadItemById method or VM's getObservableItem or init methods check if the LiveData's value is null, and if so, create/return a new LiveData object with the value set to a new Item(). However, it seems DAO queries that return LiveData objects are automatically run asynchronously, so there's no guarantee the LiveData's value will be set when these methods are called even when data for the given ID already exists in the DB. Another thought I had was to use MutableLiveData instead of LiveData for the detail view, then if getValue returns null in the activity's onChanged callback, call setValue with a new Item. However, Room can't return MutableLiveData, only LiveData (which behind the scenes is returned as ComputableLiveData), and it doesn't seem like this can be cast to MutableLiveData. I believe I could get around this by having the query just return an Item, then creating the MutableLiveData inside the repository, but a) I'm not sure the activity should be concerned with this, and b) I feel like I'm doing something wrong if I'm not able to take advantage of Room's ability to return LiveData objects. I could also just make a separate workflow that doesn't use LiveData when the detail view is being used to create a new Item, then reload the view with the newly inserted ID after the initial save is complete. Again, I feel like I'm missing an easy way to make my initial approach work. Here's a simplified version of what I'm working with: DAO: code:
code:
code:
code:
|
# ? Apr 6, 2018 02:49 |
|
It seems like you would know before opening the detailview whether there was an existing item, so you either get a livedata attached to a DB entry, or you create a new DB entry, and then pass the livedata associated with the new entry. Similarly when you update, you should be able to just update the DB directly, and allow the changes to propogate forward to your ui.
|
# ? Apr 8, 2018 21:53 |
|
That could work, but I think the new entry really shouldn't be inserted into the DB until the user saves the entry from the detail view. They aren't committing to creating a new item just by hitting the FAB (e.g. like Google Calendar). I could a) delete the entry if the user back/cancels out of the creation workflow, and b) add a DB flag that marks whether or not an entry is 'live' so that the placeholder inserted into the DB isn't returned by any queries that select all items in the meantime, but that seems like a kinda hacky approach imo. What I did for now is just not use LiveData when creating a new item, and when the user saves (which inserts the item into the DB), the activity finishes and returns to the list view (so I don't have to worry about getting the ID of the newly inserted item to rebuild the detail view with LiveData). I think not using LiveData for creation makes sense, since there isn't really an data to observe until it is inserted into the DB.
|
# ? Apr 9, 2018 22:48 |
|
Shouldn't your ViewModel be handling all that anyway? When the user is entering data into the view it's just there in the UI, it only gets passed to the VM when they press insert or whatever. Then the VM inserts it, gets back some data from the Model and tells the View what to display
|
# ? Apr 9, 2018 23:46 |
|
I believe it does, but maybe I'm missing something. The activity observes the LiveData provided by the VM for changes. On change, the activity gets the new values from the VM and uses them to update the views. When the user hits 'save', the current values of the views are passed to the VM and the VM is in charge of persisting the changes (which it does via a repository class, since I'll eventually have both a web server and the local DB as data sources). All I was missing with my original approach for the create workflow was how to get a LiveData object with ID back to the VM after performing the insert. The insert query can return the ID of the newly inserted element, but because the insert happens asynchronously, it isn't as straightforward as having the the repository's insert method return a LiveData object tied to the new row. That's what I hadn't figured out how to do yet. It's no longer necessary now that the detail view just returns to the list view after the user saves a new item, but it'd still be nice to know how to do properly.
|
# ? Apr 10, 2018 02:07 |
|
From the last hour of research it seems that the Google Play Store situation in China is FUBAR. Those of you that are in the know, is that a correct assessment? Am I missing some new information that could improve that assessment (that is, plans for Google to actually provide the real thing there)? Does anyone have any experience with China that's willing to share?
|
# ? Apr 13, 2018 16:47 |
|
Volguus posted:From the last hour of research it seems that the Google Play Store situation in China is FUBAR. Those of you that are in the know, is that a correct assessment? Am I missing some new information that could improve that assessment (that is, plans for Google to actually provide the real thing there)? Does anyone have any experience with China that's willing to share? Is it russia or china that requires you to submit source code to the government for review before you are legally allowed to sell it in their country?
|
# ? Apr 13, 2018 18:56 |
|
Splinter posted:I believe it does, but maybe I'm missing something. The activity observes the LiveData provided by the VM for changes. On change, the activity gets the new values from the VM and uses them to update the views. When the user hits 'save', the current values of the views are passed to the VM and the VM is in charge of persisting the changes (which it does via a repository class, since I'll eventually have both a web server and the local DB as data sources). Well I'm no expert on this, but if I'm reading you right you want to do something like this? *fires up the ol notepad.exe* pre:enter data -> get item from DB ----------------------------> display item | | -> no item -> insert data as new item - You could put it in the ViewModel, exposing a MutableLiveData object (as plain LiveData) for the observer to subscribe to, and keeping Room's LiveData internal to the VM. That way you can only publish 'real' data to your observer, and if your Room query returns null, you can tell it to do an insert instead, and publish that result. Trouble is you then have to hang on to what data you were trying to fetch, and pass it along when you get the empty result, as in "oh it's not there? Insert all this then" and keep track of it all since these are asynchronous events. It's a lot easier if you can add a fetchOrInsert method in your repo, which should always publish one set of valid data, and you can just hand that LiveData object to your observer You also might want to look at Transformations, which I don't think are a good fit for what you're doing, but it's probably handy to know when you want to tweak the results. It's nowhere near as powerful as something like Rx though baka kaba fucked around with this message at 21:06 on Apr 13, 2018 |
# ? Apr 13, 2018 21:03 |
|
FAT32 SHAMER posted:Is it russia or china that requires you to submit source code to the government for review before you are legally allowed to sell it in their country? Oi, I have no idea. Never heard of it. Like I've never heard that Google does not do business in China and that there are 400 Android App Stores in there with a handful having the lion's share. drat.
|
# ? Apr 13, 2018 23:12 |
Yeah this thread made me read up a bit on Chinese app stores and lol
|
|
# ? Apr 13, 2018 23:48 |
|
I've started looking into creating a video editor app and wanted to do it in Xamarin. I've been googling around for the past hour or so, and it seems if I want to do something like this (my first idea is to allow a user to load in a pre-recorded video and split it up into shorter clips) I should be using FFmpeg? I found this library but haven't really looked to much into it yet. Are there better options out there? From what I've read while googling, people are saying FFmpeg is really hard to work with, though most of those posts are from a few years ago. Is that still the case? Am I in for some hurting?
|
# ? Apr 15, 2018 03:36 |
|
You will want to use something much higher level than ffmpeg itself such as libmpv or libvlc. The libavcodec and libavformat APIs are not realistically usable without in-depth knowledge of how video formats work, and things like frame-accurate seeking in a video file is literally hundreds of lines of code.
|
# ? Apr 15, 2018 06:40 |
|
This is probably the stupidest and simplest question, but what is the best way to differentiate layouts for the differences in say, the Nexus 7 vs Nexus 9 vs Nexus 10? I started developing my app with the intention of the company purchasing Pixel C's for the consultants who would be using it, however, Google decided to not make the Pixel C anymore + it has a dumbass pixel density + screen ratio. I just finished optimizing the screen layout for the Nexus 9 but I want to make sure it will work on most 7"/9"/10" samsung/google tablets and I'm not sure how to actually test and verify this since there are no plugins for samsung tablets in android studio (that i could find, anyways) I currently have them differentiating by xhdpi but it turns out the Nexus 7/9/10 are all xhdpi so they will all use the same layout. Google's Support Different Screen Sizes says quote:Use the smallest width qualifier e; nope, that defaults to the nexus 4 ughhh FAT32 SHAMER fucked around with this message at 14:58 on Apr 17, 2018 |
# ? Apr 17, 2018 14:44 |
|
Generally, don't have a million different buckets. Make the design flexible and work well on all screen sizes as much as you can. Having said that, it often makes sense to at least have a phone layout and a tablet layout, and sometimes it makes sense to do three layouts for phones, 7in tablets and 10in tablets. Keep in mind that users can change the DPI on the device so you cannot guarantee anything, but you can make sensible choices and make sure everything scales well to a reasonable degree (bigger and smaller) for each bucket. That should be all you need to do. As you tried, sw buckets are the easiest way to do this. But your numbers are all way too big to be useful. Use the provided ones. The fact that "that's all using mdpi" is irrelevant because dpi is density independent by definition. So if you definitely need three totally different layouts, start with dp600 and dp720 and see how that works. The you can try dp800 or something if you want to cater to bigger devices in some specific way. But I would really avoid having more than three buckets if you can, you'll just end up in a mess trying to keep them all updated. It also makes testing horrible. Edit: For the "how do I Samsung tablet on the emulator" just find out the size and resolution and plug the numbers into a custom emulator profile. Be aware that specific devices can have rendering bugs and such that will not show up by doing this. If a certain device will be very common amongst your users, I'd try to get a physical device for testing. But for just checking that the layout sizes properly, you can use the emulator. Tunga fucked around with this message at 16:10 on Apr 17, 2018 |
# ? Apr 17, 2018 16:04 |
|
Tunga posted:Generally, don't have a million different buckets. Make the design flexible and work well on all screen sizes as much as you can. Hey thanks! i didnt think about 1536px being 720dp I believe that Samsung tablets have the same resolution as the nexus tablets that are built into android studio, so hopefully this works out e; the Samsung Galaxy Tab S3 is using the sw600dp bucket for some reason, even though it has the exact same screen resolution as the Nexus 7 i hate samsung FAT32 SHAMER fucked around with this message at 19:02 on Apr 17, 2018 |
# ? Apr 17, 2018 16:41 |
|
FAT32 SHAMER posted:e; the Samsung Galaxy Tab S3 is using the sw600dp bucket for some reason, even though it has the exact same screen resolution as the Nexus 7 But also, if that's the bucket it matches then that's the bucket it matches. If it has similar DP width to the N7 then it'll show roughly the same amount of stuff on the screen. That's how the DP system works. Don't try to micromanage this poo poo for every device, that's a fool's game on Android.
|
# ? Apr 17, 2018 22:39 |
|
Unless you have a very specific market for your app, optimizing for tablets in general is a waste. They're like 0.01% of Android device usage and they all suck. Just make a UI that's pretty flexible and leave it at that. A layout made for landscape on a big phone will work well enough for a tablet, even if it's not totally perfect.
|
# ? Apr 17, 2018 23:18 |
|
baka kaba posted:Well I'm no expert on this, but if I'm reading you right you want to do something like this? *fires up the ol notepad.exe* I've figured it out now, but this is what I was doing, which I don't think is all that unusual: pre:@list view -> click existing item -> populate Item from DB -------> display item detail | v ^ | item not found | v v | -> click 'new' FAB -----> populate Item with defaults - Before switching to using LiveData, it was super trivial to use virtually the same code path for all scenarios. With LiveData, either I'm not using LiveData in the new item scenario, in which case I'd need to get LiveData after the insert to remain in the detail view (making 'new' a more distinct workflow). Or I'm using MutableLiveData, in which case I need to do extra work in the repo or VM to build the MutableLiveData rather than just passing the LiveData returned by Room to the VM which is then observed by Activity/Fragment.
|
# ? Apr 17, 2018 23:32 |
|
Tunga posted:Nexus 7 (2013) is 1920x1200. Galaxy Tab S3 is 2043x1536, at least according to a quick Google. Culd be that the S3 is like 780dp or something. Just play with numbers or get a display metrics app from Play and find out the exact numbers. I realized that it IS pulling the sw720dp bucket, but since I had made that bucket for 9” screens it’s got a ton of space in some views. Spec calls for it to look good on tablets that are common or ones that the company would buy for consultants, and they specifically mentioned the Nexus 7 & 9, Tab S3, and the ZenPad 3S 10 so I gotta figure out a more flexible layout for differentiating the Nexus 9 and the ZenPad/Tab S3
|
# ? Apr 17, 2018 23:53 |
|
FAT32 SHAMER posted:I realized that it IS pulling the sw720dp bucket, but since I had made that bucket for 9” screens it’s got a ton of space in some views.
|
# ? Apr 18, 2018 00:02 |
|
Tunga posted:You're making your layouts in a really weird way if this is true. Feel free to post some example XML and we can advise. Oh dang i thought I had this part down. Ok so this one is a simple 6 "button" layout that has 1 clickable element and the remaining five are empty dotted-line boxes to placehold features that will be added as various business units get their portion of the app completed: XML code:
I didnt screencap the action bar because it has the company name in it, but its the blue part that kind of sticks out up top. As you can see, the 9.7" tablets that are 2048x1536 are using the sw720dp view that I made, but because it has more screen real estate, it has a bunch of emptiness in the corner. I know in iOS you are able to make it dynamically fill a screen by using constraints, and I know that Google recently(ish) came out with their own constraintview, but prior to the spec update we were only supporting the Pixel C instead of any given device. There are more complicated views in the app that involve programmatically injecting ExpandableListView parent/children dynamically that I can share as well, but i wouldnt be able to share a screenshot. This view has two ELVs: one that acts as a sidebar that displays a categories and subcategories, whether the question has been answered, and a score for that category, and another that acts as a question holder that has a question in the ELV parent with a switch to enable and disable it, and 4 boxes that display potential bad, mediocre, good, and world class answers plus a comment section to leave additional comments if need be: activity_edit_draft.xml XML code:
XML code:
XML code:
XML code:
XML code:
Any feedback would be super appreciated, I know it's a lot to dump on you but imo the best way to learn is to get yelled at by someone who knows what's up so you can do it the correct way and always remember it FAT32 SHAMER fucked around with this message at 14:38 on Apr 18, 2018 |
# ? Apr 18, 2018 13:44 |
|
You have a lot of hardcoded widths which will leave you white space around them. So that's the cause of the problem. But then the question is what do you want it to look like instead? Scaled items to fill the width? Scaled items to fill the height? Scaled items to fill both dimensions and potentially change shape? Square items with even gaps around the edges? Square items with gaps between them? All of these are doable but you have to define what you want it to do. It could be as simple as setting gravity="center" on the parent view or it might require a more flexible view like ConstraintLayout. Android devices can be any size and any shape, so the first rule of layouts is to assume nothing and design accordingly. Tunga fucked around with this message at 15:47 on Apr 18, 2018 |
# ? Apr 18, 2018 15:43 |
|
Tunga posted:If you hardcode the widths everywhere then of course you get white space around them. Yeah that makes sense. Scaled items to fill both dimensions is basically all we need since this is tablet only. How do LinearLayout weights work for both dimensions? Do you use horizontal LinearLayouts with vertical LinearLayouts inside of it? Is there a way to dictate "yeah, i want this element to occupy 30% of the screen from the centre"? Is there a good guide that explains this topic? the android documents are helpful but only to a certain extent
|
# ? Apr 18, 2018 15:52 |
|
FAT32 SHAMER posted:Yeah that makes sense. Scaled items to fill both dimensions is basically all we need since this is tablet only. How do LinearLayout weights work for both dimensions? Do you use horizontal LinearLayouts with vertical LinearLayouts inside of it? Is there a way to dictate "yeah, i want this element to occupy 30% of the screen from the centre"? I don't know if it is a requirement that you design your screens using linear layout, but if you can switch over to ConstraintLayout instead, you might find an easier time, and from what I have read, due to a lack of nesting, ConstraintLayout is a noticeable amount faster (on complex screens) from not having to traverse a bunch of trees. In addition, some people, myself included find ConstraintLayout to be much easier to read and reason about than a bunch of nested views.
|
# ? Apr 18, 2018 16:02 |
|
FAT32 SHAMER posted:Yeah that makes sense. Scaled items to fill both dimensions is basically all we need since this is tablet only. How do LinearLayout weights work for both dimensions? Do you use horizontal LinearLayouts with vertical LinearLayouts inside of it? As a slight aside, I think you can get rid of the FrameLayout in the top file since it just contains one thing. I only looked quickly though so might be missing some nuance of the layout. FAT32 SHAMER posted:Is there a way to dictate "yeah, i want this element to occupy 30% of the screen from the centre"? FAT32 SHAMER posted:Is there a good guide that explains this topic? the android documents are helpful but only to a certain extent
|
# ? Apr 18, 2018 16:06 |
|
ReverendCode posted:I don't know if it is a requirement that you design your screens using linear layout, but if you can switch over to ConstraintLayout instead, you might find an easier time, and from what I have read, due to a lack of nesting, ConstraintLayout is a noticeable amount faster (on complex screens) from not having to traverse a bunch of trees. Tunga posted:Yes, that's the simplest version of such a layout. It's also possible to do this in a ConstraintLayout using chains in both directions. That gives you more control but is more fiddly to set up. It may be worth doing though, as mentioned above, as it makes the layout easier to modify later. Performance differences are honestly kind of negligible when you're talking about two nested LinearLayouts but for more complicated layouts ConstraintLayout is an improvement. Excellent, thanks so much. I havent had a whole lot of time to gently caress around with this because we were doing a bare bones version of this before to show that we had the capability to do it, and now the business unit leads have determined that 1) we can definitely do it and so far the result is great 2) we want to flex this new (to the company) competency and move away from shared excels to modernize the consultancy business, so now i actually have time in the budget to dick with this stuff
|
# ? Apr 18, 2018 16:11 |
|
You might want to check this out too https://material.io/guidelines/layout/responsive-ui.html
|
# ? Apr 18, 2018 19:50 |
|
Is there a way to choose a font size dynamically for a given view? or will that be the main thing that drives me to use buckets now that i have figured out (and fallen in love with) ConstraintViews
|
# ? Apr 19, 2018 15:54 |
|
You can do this if that's what you mean https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview.html
|
# ? Apr 19, 2018 16:50 |
|
baka kaba posted:You can do this if that's what you mean nice, thanks
|
# ? Apr 19, 2018 16:56 |
|
I haven't done any Android dev in years, but I'm wanting to set something up for my home automation setup that involves getting screenshots from my shield tv. Is it going to be possible or crazy difficult to develop an Android TV app that serves up a screenshot of the screen via http on my local network?
|
# ? Apr 22, 2018 17:28 |
|
Thermopyle posted:I haven't done any Android dev in years, but I'm wanting to set something up for my home automation setup that involves getting screenshots from my shield tv. Check out the MediaProjection APIs, it might do what you want. https://developer.android.com/reference/android/media/projection/MediaProjection.html Google also has a sample: https://github.com/googlesamples/android-ScreenCapture
|
# ? Apr 23, 2018 20:14 |
|
Oh, that looks interesting, I will dig deeper. Thanks!
|
# ? Apr 23, 2018 20:56 |
|
Is there a way to pan to an edittext when you're using a constraintlayout? The keyboard covers some of my EditTexts and all of the solutions online say to stick it in a scrollview. Is there a better solution than that?
|
# ? Apr 27, 2018 15:20 |
|
|
# ? May 28, 2024 16:30 |
|
FAT32 SHAMER posted:Is there a way to pan to an edittext when you're using a constraintlayout? The keyboard covers some of my EditTexts and all of the solutions online say to stick it in a scrollview. Is there a better solution than that? https://developer.android.com/guide/topics/manifest/activity-element#wsoft It sounds like you want adjustPan. But be careful with these and make sure your layout works well on different device sizes.
|
# ? Apr 27, 2018 16:19 |