• Breaking News

    [Android][timeline][#f39c12]

    Sunday, February 25, 2018

    Simplifying DiffUtil with RxJava Android Dev

    Simplifying DiffUtil with RxJava Android Dev


    Simplifying DiffUtil with RxJava

    Posted: 25 Feb 2018 10:44 AM PST

    What minimum SDK version do you use for new app?

    Posted: 25 Feb 2018 11:11 AM PST

    My choice is KitKat 4.4 API 19 which makes up 94.3%.

    submitted by /u/jaxondu
    [link] [comments]

    What should I learn to create this app?

    Posted: 25 Feb 2018 06:40 AM PST

    Hey guys. I currently have a project in university to create an application and I might have bitten off more than I can chew. I have been going through the Stanford course on Android development however I'm nervous that some of the features that I need to implement simply won't be covered in the series. I was wondering whether you could review this plan and the below requirements and perhaps point me in the right direction of packages to use or tutorials that help me implement these things. Thanks for any help.

    Requirements: 1. Be able to open up external PDFs. 2. Be able to open up web pages in a seperate viewer. 3. Be able to comment on things inside the app. 4. A chatbox. 5. A calendar. 6. A to-do list.

    submitted by /u/ilovetoprogrum
    [link] [comments]

    How to get job/team experience?

    Posted: 25 Feb 2018 04:10 AM PST

    Hello people, I've been learning Android on my own for a while. I think I have quite a decent beginner-intermediate level and I'm ready to make the jump into team development.

    I'm seriously committed and willing, I have five apps published in the Play Store and I'm still learning new concepts but I know that joining a team will make me learn even faster.

    I would like to have someone that could review my code and I know that working in a team allows for faster work cycle.

    However, the internships I've been trying to apply to turn me down because I'm not a student... At this point I'm willing to work for free.

    I've been told that I could contribute to open source projects. Has anyone some concrete ideas on how to proceed? How to get experience or visibility? Someone there that can look at my code and give me some pointers?

    Like I said, I'm willing and motivated but I could use some direction.

    Thanks in advance, wholeheartedly.

    [I read the FAQ and rules, I hope this is okay. I'm also not linking anything atm, can give links if someone is interested.]

    submitted by /u/lsteamer
    [link] [comments]

    Still searching for my coroutine 'eureka' moment

    Posted: 24 Feb 2018 10:28 PM PST

    I believe I understand the basic concepts, but maybe someone here can help identify my points of confusion.

    You have some intensive CPU-bound or IO-bound work. You want to make sure that you don't do it on the main thread. Solution: do the work in a separate background thread.

    In its most naive form, you'd create a new thread for each task. Here, you can quickly run into trouble because you may have dozens or hundreds of simultaneous background tasks, and threads are heavy and memory-intensive.

    To be fair, though, no experienced developer would do this. Instead, you'd have a thread pool that you submit jobs to. You could use a ThreadPoolExecutor for this, or an Rx Scheduler.

    Now consider coroutines. A coroutine is often described as a lightweight thread. You create a coroutine using a coroutine launcher like launch or async. The coroutine is generally run on some background thread. The default CoroutineDispatcher will run the coroutine in a thread pool.

    On its own, what I've described is (practically speaking) not very different than the ThreadPoolExecutor case. Instead of submitting a Runnable to a thread pool managed by ThreadPoolExecutor, you are launching a Coroutine that is dispatched to a thread pool managed by a CoroutineDispatcher.

    It seems to me that the main difference between multiple coroutines dispatched to a thread pool, and multiple Runnables submitted to a thread pool, is the existence of suspending functions.

    Multiple threads can run on the same core "simultaneously" using preemptive multitasking. This means that the thread can be paused and resumed at any time by the CPU. The thread itself has no control over it.

    In the case of ThreadPoolExector, several Runnables are submitted to the thread pool, and each thread has a queue of these Runnables that it must process. Such threads are subject to the preemptive multitasking pauses and resumes mentioned previously. However, if you ignore those pauses, and look at the thread run time as one contiguous block, you'll see the Runnable queue processed as you would expect any queue to be processed -- one item at a time.

    In the case of coroutines without suspending functions, you have the same behavior. The coroutines are assigned to threads within the pool, and each thread processes the coroutines one at a time.

    So far, I don't see any difference in behavior or performance (theoretically) between the ThreadPoolExecutor solution and the coroutine solution, although there is a definite syntactical difference.

    However, suspending functions offer the ability for coroutines to be processed "simultaneously" within the same thread because a suspending function offers a suspension point, at which the coroutine yields control to another coroutine. In this way, the coroutines are time-sliced within the same thread, but it's cooperative instead of preemptive -- the coroutine has to voluntarily suspend by calling a suspending function.

    Another thing about suspending functions is that they're often touted as "sequential by default". So, if you have the following code:

    launch { val thing = getThing() // suspend fun val foo = getFoo(thing) // suspend fun } 

    The "magic" of suspend functions is that the coroutine can be suspended at getThing and yet this sequential syntax is still possible because the compiler is using Continuations behind the scenes to remember the state of the coroutine so it can resume it when it's done suspending.

    But obviously, if the functions above were not suspending functions, the flow would still be sequential.

    So the question becomes: why should I care whether the coroutine is able to suspend or not? I don't know the answer to this question, but I have a few possibilities in mind.

    1. We should desire for coroutines to suspend while they're just waiting anyway.

    An obvious example is (say) a network api call that takes 2 seconds. It'd be nice if we could fire off the HTTP request, and then suspend while we wait for a response.

    One problem I see with this is illustrated by the following code:

    suspend fun makeExpensiveApiCall(): Result { return api.expensiveCall() // not a suspend fun } 

    As far as I understand (possible point-of-confusion alert), the suspension point here is at the entry point of the function. Suspending here doesn't help, because the HTTP request hasn't been made yet. But, once we call into our non-suspending api method, it's too late. The thread is now blocked waiting for the response. As far as I know, there is no way around this because at some point you're interacting with some low level IO library objects that cannot suspend.

    2. We want to time-slice coroutines so that they appear to be run simultaneously, even if running on the same thread.

    To do a controlled test of this, I implemented a Towers of Hanoi solution, which is recursive and O(n2 ). Solving it for 29 disks takes about a second on my computer, and solving it for 30 disks (as one would expect) takes about 2 seconds. I made the recursive solveHanoi function a suspending function and I launched 3 coroutines that each solved it three times:

    val context = newSingleThreadContext("MyThread") val deferreds= arrayOf(1, 2, 3).map { async(context) { solveHanoi(30, "First run") solveHanoi(30, "Second run") solveHanoi(30, "Third run") } } deferreds.forEach { it.await() } 

    I had some debug println that you can't see here. What they told me was that each coroutine was run one at a time in the order that they were built -- they did not yield to one another even though solveHanoi is a suspending function.

    This behavior did not change if I switched async/await to launch/join.

    I also tried switching out the newSingleThreadContext for an executor.asCoroutineDispatcher (with the executor having one thread) but this also did not change the behavior I'm observing.

    Interestingly, if I inserted a yield() call (from kotlin.coroutines.experimental) as the first statement in solveHanoi, they did appear time-sliced. Actually, maybe that's not all that interesting. In any case, this ran much more slowly (presumably because of the overhead of yielding between coroutines).

    Incidentally, in the case of CPU-bound tasks that are independent from one another (no shared state, such as in a producer/consumer pair), I am not sure that I really care that they are time-sliced to appear to run simultaneously.

    So, in conclusion:

    1. I'm kind of at a loss for why I need suspending functions.
    2. Without suspending functions, I don't understand why coroutines are better than a thread pool other than (a) better syntax than ThreadPoolExecutor or Rx (especially for async scenarios where results are needed), and perhaps (b) less method call overhead than Rx.
    submitted by /u/RageQuitFPS
    [link] [comments]

    Simple Dependency Injection in Kotlin without frameworks (Part 1)

    Posted: 25 Feb 2018 05:26 AM PST

    Efficient way to implement a complex sortable and filterable list in RecyclerView?

    Posted: 25 Feb 2018 02:26 AM PST

    My current implementation is to regenerate the items and inserting the whole thing into the adapter, triggering notifyDataSetChanged(). That way, I would apply all filters and current sort condition before touching the adapter.

    It becomes a huge issue when I have thousands of items in the list. Each filter operation would grind the UI to a halt due to the RecyclerView having to rebind all the items. How do I deal with filtering which adds and remove items dynamically?

    I tried SortedList but it seems you can't just change the sorting order dynamically.

    submitted by /u/geft
    [link] [comments]

    Necessary skills for junior Android developer position? What would you look for?

    Posted: 24 Feb 2018 08:42 PM PST

    I'm trying to make a career change from the business side to android development. I'm curious what skills you would look for on a resume or in a published app?

    My current list is:

    1. Ability to communicate with people -- I can show this through previous experience

    2. Able to code -- My goal is to publish a full functional app in the app store

    3. Show my code is maintainable, that I have a process for development, etc. -- I think this means a few things:

    • my code structure is well laid out

    • things are documented. Both through comments and something like a readme doc

    • Using some type of source control system. Git is mentioned in just about every job posting in my area, so it's the one I've chosen to learn

       

    EDIT: Clarifying a few things

    submitted by /u/Zajimavy
    [link] [comments]

    Kotlin' booby trap: Never use init in open/abstract classes

    Posted: 25 Feb 2018 12:53 AM PST

    If you use an init { ... } block in an open or an abstract class and you extend from it, there is a very high chance that, at runtime, when an object of your extended class is constructed, it blows up with an unexpected null or invalid state.

    The solution/advice from JetBrains is to simply not use init { ... } block in open/abstract classes. The reason is due to derived class initialization order and the explanation is in the link below.

    I discovered this counter-intuitive and dangerous Kotlin behavior the hard way (crashes + long debugging session), so it's worth sharing it:

    https://kotlinlang.org/docs/reference/classes.html#derived-class-initialization-order

    submitted by /u/sebaslogen
    [link] [comments]

    Charitable giving?

    Posted: 25 Feb 2018 03:30 PM PST

    Does anyone know how I can hook up in-app-purchasing but have everything go towards a charity?

    Google has donations api, but it hasn't been released and I haven't seen any development on that page for almost two years. There are other apps on the play store that are oriented towards charity, and I'm not sure how they do it without breaking google TOS.

    Any ideas?

    submitted by /u/HyperionCantos
    [link] [comments]

    Hi. I’m looking to create some gaming apps for my business such as a quiz and a storyboard game. Where should I start? Is this something I could learn to make myself, or should I get a professional to do it for me?

    Posted: 25 Feb 2018 03:24 PM PST

    Confused with Android Studio, need help with playing media from SD Card...

    Posted: 25 Feb 2018 03:16 PM PST

    I'm new to android development. I have understanding of Java, but the libraries built for android are a bit confusing. I understand the purpose of Activities, intents, etc., but some of the classes and methods don't seem very intuitive to me.

    I'm trying to build an app that plays media from the SD card. Does anyone have any pointers or resources that would point me in the direction of doing that?

    I know how to play audio and video files stored locally, but I don't get how to do it from the SD card. Everything I try gives me crazy errors.

    Thanks!

    submitted by /u/smalls3486
    [link] [comments]

    From hero to HERO journey for Rx. This series has total 8 parts. Which start from very basic concepts.

    Posted: 25 Feb 2018 12:40 AM PST

    Kotlin: When to Use Lazy or Lateinit

    Posted: 24 Feb 2018 05:29 PM PST

    How do I make an app that reads from external storage?

    Posted: 25 Feb 2018 01:39 PM PST

    Hey guys, I had an idea for an app but a key element of it is to be able to read files from an external flash/hard drive to use said files. How can I go about getting permission to access the files and getting the app to respond to it? (Eg app accesses file on flash drive then uses a text file on it requested by an algorithm in the app)

    submitted by /u/mrcluelessness
    [link] [comments]

    Are Java 8 language features commonly used in Android projects these days?

    Posted: 25 Feb 2018 09:16 AM PST

    I've worked exclusively with Kotlin on Android for the past 2 years and lost a bit of touch with the Java side of things. Are Java 8 language features standard for Android development with Java these days? Are there any drawbacks? What's the biggest benefits?

    submitted by /u/FourteenEgg
    [link] [comments]

    Complex domain using Clean Architecture?

    Posted: 24 Feb 2018 10:44 PM PST

    I feel like I don't completely understand how to build complex domain layer using "Clean Architecture" approach.

    When you read all of these "Clean Architecture" articles there are always trivial examples with 3 or 4 interactors, where all work done by backend. These interactors usually looks like "GetOrders" or "PostComment" class with single method inside it. Ok, it's clear, but let's go deeper.

    Simple example: in my app I have to create or edit locations on map of the earth. To solve this problem I create class, containing current state of location building, and set of methods to create valid location entity.

    interface LocationEditor { fun editExistingLocation(id: Long): Completable fun createNewLocation(): Completable fun setTitle(title: String) fun setCoordinates(coordinates: GeoCoordinates) fun setTimeZone(timeZoneId: TimeZoneId) fun valid(): Observable<Boolean> fun locationAssembly(): Observable<LocationAssembly> fun saveChanges(): Single<Location> } 

    In presentation layer I have several independent custom views (with their own ViewModel-s) that share one common LocationEditor and use only methods they are interested in. So in example TitleView use "setTitle(...)" method and receive title updates from "locationAssembly()" method. How should I implement this feature using "single method interactors"? Where to keep intermediate state? Is it a good idea to separate these highly-coupled methods in LocationEditor from each other into multiple classes?

    More complex one: in other application I have a video player that have to:

    • work with android's MediaPlayer receiving events and sending commands to it

    • show video on android's SurfaceView

    • work with android's AudioManager

    • have dynamic playlist based on API's data with automatically switch between playlist items

    • control playback speed, calculate actual playing position and after returning into "play" state automatically build new dynamic video stream URL

    It's not even half of player's features. Again, I create many classes to build it, each solves single problem, then I combine them in one Player facade class that gives me access to players modules. Shouldn't I implement it different in terms of "Clean Architecture" approach?

    I'd glad to hear your advice or maybe to get link to some open source project answering my question :)

    submitted by /u/alexeyterekhov
    [link] [comments]

    Learning android development

    Posted: 25 Feb 2018 08:55 AM PST

    Could a Samsung phone be a bad choice for a developer?

    Posted: 25 Feb 2018 05:00 AM PST

    Hi everyone, I stared developing for Android about 16month ago, so I just "lived" the Nougat -> Oreo change. Actually my best "up-to-date" driver is a Nexus 5X, but 8.1 should be the last release.

    Until 2 months ago I was sure to buy a Pixel 2, but now a client gave me an old S8 for make some test with Samsung Dex, and I'm really loving this phone.

    Today Samsung will present the S9 and in very tempted to buy it but, as everyone knows, Samsung releases only 1 big update (if lucky) and they always are the slowest to do it.

    Could it be a bad solution for a Developer? Should I go for a Pixel 2?

    EDIT: I think I talked too much about brands and stuff, so the question could be misleading. The core of question is: since Oreo bring many changes (notification channels, background services, etc) made it be a MUST HAVE: is it always like this? How important is for a developer to always have the last update on his phone?

    submitted by /u/4face91
    [link] [comments]

    Bluetooth Low Energy on Android, Part 2

    Posted: 24 Feb 2018 06:03 PM PST

    App downloads down by more than 50% due to new Play store search UI

    Posted: 24 Feb 2018 11:53 PM PST

    Our app currently has best ever ranking on play store for all the keywords we optimised, but due to new app search UI on play store, app won't be visible to user's search result even on 2nd (if Ad takes 2nd position) or 3rd position, so downloads are down. Anyone experiencing this, how you people planning to tackle this issue?

    We think this is (new search UI) going to be bad for all devs, what you people think?

    submitted by /u/sloppyind
    [link] [comments]

    No comments:

    Post a Comment

    Fashion

    Beauty

    Travel