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 6590027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:14:56+00:00 2026-05-25T17:14:56+00:00

What Design-Pattern would be intelligent in which following Components(simplified) exists: 3 Components – GUI

  • 0

What Design-Pattern would be intelligent in which following Components(simplified) exists:

3 Components
– GUI
– Data fetcher
– Database

Design

I have no Access to the Server in the Internet, its just a Data-Source. The Data which lays in the Internet is always the newer one, the local-Database is just a copy(cache) of the one in the Internet. The GUI can request and update of the local cache, the Service-like-component fetches then asynchronously the newest data, which could take awhile.
The GUI shows only Data from the local Database, which he can fetch synchronously.

So my Question is, what classes would you use for the maybe longterm running Service with Progressbar capabilities ? Are there better Designs for this kind of “problem”? Are there better practices?

  • 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-25T17:14:57+00:00Added an answer on May 25, 2026 at 5:14 pm

    On the Service Like Component:

    • An interface (method) to kick off the update process. Typically this service would return a jobId to indicate a job that is being processed in the background
    • Another interface (method) to get the status based on a particular jobId. The implementation of this service could return a status, percentCompleted or any other relevant info that will tell the caller the current status of the update process. The implementation of this method needs to be able to report an incremental progress (such as reporting the incremental store in the local storage) in order to make an accurate progress bar, otherwise the best the UI could do is show the spinning progress bar.
      • Note that if such incremental reporting is not possible to implement then the Update process should probably use a typical AsyncTask usage which execute update in the background and report to the user when it is finished. If this operation might take a while, you could implement the completion of the update via Android notification bar or push notification.

    Assuming you have the interface to get the progress of the update, you could utilize the AsyncTask onProgressUpdate to report the progress of the update. The method is specifically designed for that.

    Your steps are roughly as follow:

    • Execute the interface to update via one AsyncTask. Since your update is happening asynchronously, this particular task should return fairly quickly with a status reporting whether the execution is running successfully or fail because some exception along with the jobId that it is currently executing
    • Launch another AsyncTask that is pinging the status of the update and report the progress via onProgressUpdate. The AsyncTask roughly looks like
    
    public class GetUpdateStatusAsyncTask extends AsyncTask {
        protected Integer doInBackground(Integer... param) {
            // this is the jobId that you get from the previous AsyncTask that you use to kick off the 
            // the update process
            int jobId = param[0];
            double percentCompleted  = fetchStatus(jobId);
    
            while(percentCompleted != 100.00) {
                publishProgress(percentCompleted);
            }
    
            // return status code
            return 1;
        }
    
        protected void onProgressUpdate(Double... progress) {
            // set the progressBar here
        }
    
        protected void onPostExecute(Long result) {
           // done, handle status code
        }
    
        private double fetchStatus(int jobId) {
            double percentCompleted = 0.0;
            // call interface to get the update based on the jobId
            // return percentCompleted status or make a more complex object if you need 
            // more detail info
            return percentCompleted;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following design pattern: var myObjectWithEvents = new ObjectWithEvents(); using (var mre
Is there a design pattern for the following situation: I have a XML file
Does anybody recommend a design pattern for taking a binary data file, parsing parts
I have learnt the factory method design pattern, and at the same time, I
How do you decide on which design pattern to choose for? My approach to
What would be the disadvantages of using the builder design pattern. Are there any??
I am following the presentation model design pattern suggested by Martin Fowler for my
I'm currently implementing the Factory design pattern in Python and I have a few
I'm trying to design a simple Cocoa application and I would like to have
What would be a good design pattern if I require to test a C++

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.