Launcher (Main Screen/standby) App BUG: No Boolean parameter is initialized to define the screen direction in CellLayout

Source: Internet
Author: User

Launcher App:/cupcake/packages/apps/Launcher

 

The standby screen is divided into multiple layers. The Desktop Items is set in/res/layout-*/workspace_screen.xml:

 

<Com. android. launcher. CellLayout

......

Launcher: shortAxisCells = "4"
Launcher: longAxisCells = "4"

......

/>

 

4 rows and 4 columns

 

Let's take a look at com. android. launcher. CellLayout, which has parameters defining the screen direction,

Private boolean mPortrait;

 

However, initialization has not been performed, that is, mPortrait = false. Cell settings on the desktop are always initialized Based on Non-portrait (landscape) settings.

 

Let's take a look at the initialization differences between the landscape screen and the landscape screen to see the BUG.

 

Boolean [] [] mOccupied; // array of boolean values of binary Cells

 

If (mPortrait ){
MOccupied = new boolean [mShortAxisCells] [mLongAxisCells];
} Else {
MOccupied = new boolean [mLongAxisCells] [mShortAxisCells];
}

 

If the desktop is displayed on the full screen (the number of cells in the horizontal and vertical directions is different), instead of only four rows and four columns by default, mShortAxisCells = 4, mLongAxisCells = 5, array initialization should be: new boolean [4] [5], but it is actually processed according to non-Portrait screen, initialized to new boolean [5] [4], will generate an array out-of-bounds exception.

 

You can add mPortrait initialization through the screen direction in the constructor. The Code is as follows:

 

Public CellLayout (Context context, AttributeSet attrs, int defStyle)

{
Super (context, attrs, defStyle );
MPortrait = this. getResources (). getConfiguration (). orientation = Configuration. ORIENTATION_PORTRAIT; // Add code

......

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.