Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:20:27+00:00 2026-05-26T16:20:27+00:00

I have spent too many hours on this and I have so far continued

  • 0

I have spent too many hours on this and I have so far continued to live without the publishProgress() feature… fortunately the onPostExecute also runs in the UI thread so I have had to create N threads for every image I want to load instead of one big thread that was to update the listview. So, not fatal but a real annoyance.

First of all, big thianks to these pages for providing more insight and ways to [reference 2!] have a pure Scala implementation…

(1) http://blog.nelsonsilva.eu/2009/10/31/scala-on-android-101-proguard-xmlparser-and-function2asynctask which is a workaround for: issues.scala-lang.org browse SI-1459 (New users limited to 2 links)

(2) va.eu/2009/10/31/scala-on-android-101-proguard-xmlparser-and-function2asynctask which is a workaround for: SAME AS ABOVE

(3) http://www.assembla.com/code/scala-eclipse-toolchain/git/nodes/docs/android-examples/android-sdk/Wiktionary/src/com/example/android/wiktionary/MyAsyncTask.java?rev=f2fdb3144d0225487cafc7d628adf64889772db4

Sadly, none of them seemed to work for me on Scala 2.8.1 with Android 2.2.2 running Android-x86 on Virtual box, Ubuntu 11.04.

Here’s my actual code, garbage removed, just the essentials… if somebody can tell me how to make the callback get called I will be very happy and it’s not even Christmas yet. I’ve spent hours on the this and cannot get it to work at all, I have tried every variation of “Progress” type, as using AnyRef actually works but any other type doesn’t work as the “Params” type, see (2) above for the details on that one.

Alas, I get the preExecute (not shown), doInBackground and postExecute but no publish progress callbacks to be seen. 🙁

The code…

private class FeedLoaderTask(val activity: ActivityFeedReader) 
  extends android.os.AsyncTask[AnyRef, Seq[FeedEntry], Seq[FeedEntry]]
{
  /** @brief dialog to show our progress */
  private var dlgBusy:ProgressDialog = null;


  override def onPreExecute() {
    dlgBusy = ProgressDialog.show(...)
  }

  override protected def doInBackground(params: AnyRef*): Seq[FeedEntry] = {
    // resorted to AnyRef for reasons explained above although
    val url = params.apply(0).asInstanceOf[String]
    log.d("FeedLoaderTask: doInBackground: " + url)
    val feeds = new FeedReader(url).extract
    log.d("Got them, total: " + feeds.length)
    publishProgress()//feeds) // <--- seems to "call" but does not arrive
    feeds
  }

  protected def onProgressUpdate(feeds: Seq[FeedEntry]): Void = {
    // work damn you, WORK!
    log.d("FeedLoaderTask: onProgressUpdate: " + feeds.length)
    return null
  }

  override protected def onPostExecute (feeds: Seq[FeedEntry]) {
    dlgBusy.dismiss()
    dlgBusy = null
    feeds.length match {
    case 0 => messageAndTerminate(R.string.rss_failed_msg)
    case _ =>
      listAdapter = new FeedListAdapter(...)
      activity.setListAdapter(listAdapter)
      ...blah blah more code...
   }
  }
}

So, I have a work-around (maybe even a better way) of doing what I want but I hate not being able to do what I want.

This would be a nice one to see solved as its’s beaten me… this is my first Android app and I nearly finished it once in Java but I got so frikking cheesed off with all the typing and cruft that I started from scratch and taught myself Scala at the same time. I know Erlang, LISP and Haskell so that helped. All I can say is “LEARN SCALA NOW!”… the XML support is awesome, my original RSS parsing code (four classes!) is now in a single file and about 80 lines of code, using the XML API to find elements, extract attributes etc.

All the best,
🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:20:28+00:00Added an answer on May 26, 2026 at 4:20 pm

    I just tried something similar and, well, ran into the same issue as you did.
    I solved it with

    defining the class as

    class FeedLoaderTask(val activity: ActivityFeedReader)
      extends AsyncTask[AnyRef, AnyRef, Seq[FeedEntry]]
    

    and my onProgressUpdate as:

    override def onProgressUpdate(params: AnyRef*) {
      val feeds = params(0).asInstanceOf[Seq[FeedEnty]]
      ...
    }
    

    As you can see, it is similar to the doInBackground() method (note that you do not necessarily need to explicitly call apply() in Scala and void methods do not need to declare a return type and the “=”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that I have spent too many hours trying to resolve.
I have spent hours in this problem and my fellows couldn't help me out.
i have spent a few hours on this to no avail. I have an
Recently my team has spent too many hours setting up machines with previous product
I have spent way too much time looking for the files owner icon to
Have spent an hour trying to solve this - but to no avail. I'm
I have spent all Friday and Saturday on this and I am running out
I have spent about half a day searching for an answer to this question
EDIT: Got too confusing with so many different edits, so this is where I'm
On one of my sites, I have a problem with too many NEW users

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.