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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:15:55+00:00 2026-06-06T00:15:55+00:00

I am currently having trouble with a live wallpaper that does some very intensive

  • 0

I am currently having trouble with a live wallpaper that does some very intensive drawing. However , upon testing my code I find the wallpaper is laggy and is destroyed when the screen gets rotated.

Within my draw method I have this :

mRectArray = new Rect[] {
                new Rect(0, 0, c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 2),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 2,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 3),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 3,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 4),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 4,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 5),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 5,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 6),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 6,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 7),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 7,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 8),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 8,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 9),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 9,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 10),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 10,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 11),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 11,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 12),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 12,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 13),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 13,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 14),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 14,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 15),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 15,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 16),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 16,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 17),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 17,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 18),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 18,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 19),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 19,
                        c.getWidth(),
                        (c.getHeight() + statusBarHeight) / 20 * 20),

                new Rect(0, 0, right1,
                        (c.getHeight() + statusBarHeight) / 20),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20, right2,
                        (c.getHeight() + statusBarHeight) / 20 * 2),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 2,
                        right3, (c.getHeight() + statusBarHeight) / 20 * 3),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 3,
                        right4, (c.getHeight() + statusBarHeight) / 20 * 4),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 4,
                        right5, (c.getHeight() + statusBarHeight) / 20 * 5),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 5,
                        right6, (c.getHeight() + statusBarHeight) / 20 * 6),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 6,
                        right7, (c.getHeight() + statusBarHeight) / 20 * 7),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 7,
                        right8, (c.getHeight() + statusBarHeight) / 20 * 8),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 8,
                        right9, (c.getHeight() + statusBarHeight) / 20 * 9),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 9,
                        right10,
                        (c.getHeight() + statusBarHeight) / 20 * 10),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 10,
                        right11,
                        (c.getHeight() + statusBarHeight) / 20 * 11),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 11,
                        right12,
                        (c.getHeight() + statusBarHeight) / 20 * 12),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 12,
                        right13,
                        (c.getHeight() + statusBarHeight) / 20 * 13),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 13,
                        right14,
                        (c.getHeight() + statusBarHeight) / 20 * 14),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 14,
                        right15,
                        (c.getHeight() + statusBarHeight) / 20 * 15),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 15,
                        right16,
                        (c.getHeight() + statusBarHeight) / 20 * 16),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 16,
                        right17,
                        (c.getHeight() + statusBarHeight) / 20 * 17),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 17,
                        right18,
                        (c.getHeight() + statusBarHeight) / 20 * 18),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 18,
                        right19,
                        (c.getHeight() + statusBarHeight) / 20 * 19),
                new Rect(0, (c.getHeight() + statusBarHeight) / 20 * 19,
                        right20,
                        (c.getHeight() + statusBarHeight) / 20 * 20),

                new Rect(c.getWidth() / 20, c.getHeight() / 15,
                        c.getWidth() / 20 * 8, c.getHeight() / 15 * 4),

                new Rect(c.getWidth() / 20, c.getHeight() / 15,
                        c.getWidth() / 20 * 8, c.getHeight() / 15 * 8), };

That’s 40 rectangle constantly being initialized onDraw.
Now, the problem is these rectangles must be constantly initialized as i’m animating the right side of 20 of the rectangles…

I have another 40 or so if statements for animating the rectangles..

How can I condense my code so that performance isn’t sacrificed??

  • 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-06-06T00:15:57+00:00Added an answer on June 6, 2026 at 12:15 am

    initialize your array in onSurfaceChange() by using height and width of onSurfaceChange() function.

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

Sidebar

Related Questions

I am currently having trouble with the following (here is some sample code first):
I'm currently having trouble getting example code for using tweepy to access Twitter's Streaming
The part of the application that I am currently having trouble getting to work
I'm currently having some trouble with getting certain input fields passed along when a
I am currently having trouble getting a value from an AsyncTask that gets data
I'm currently having some trouble with my shared hosting as I can't use sessions
I'm very new to MSpec and BDD in general and are currently having trouble
I am currently having some trouble using my client side validation. I am using
Problem: https://postimg.cc/image/tunhwh8qj/ The trouble I am currently having is that the border around my
I am currently having some trouble wrapping my head around this issue. I had

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.