New issue
Advanced search Search tips

Issue 807732 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2018
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Fix WrongViewCast in Shell.java

Project Member Reported by wnwen@chromium.org, Jan 31 2018

Issue description

Not sure if this is a false positive or valid: content/shell/android/java/src/org/chromium/content_shell/Shell.java#onFinishInflate

Error: ../SRC_ROOT1/content/shell/android/java/src/org/chromium/content_shell/Shell.java:150 Unexpected implicit cast to `Drawable`: layout tag was `LinearLayout`: WrongViewCast [warning]
        mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground();
                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

Comment 1 by wnwen@chromium.org, Jan 31 2018

From: http://tools.android.com/tips/lint-checks

WrongViewCast
-------------
Summary: Mismatched view type

Priority: 9 / 10
Severity: Fatal
Category: Correctness

Keeps track of the view types associated with ids and if it finds a usage of
the id in the Java code it ensures that it is treated as the same type.

At first blush, that looks to be a false positive.  The error in detection looks like it is evaluating only:

(ClipDrawable) findViewById(R.id.toolbar)

But in fact, we are casting getDrawable() to a ClipDrawable, which is correct.
Project Member

Comment 3 by bugdroid1@chromium.org, Feb 1 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e09f8de14e1138f1687db2492f662b040168e362

commit e09f8de14e1138f1687db2492f662b040168e362
Author: Ted Choc <tedchoc@google.com>
Date: Thu Feb 01 00:00:32 2018

Pacify Wrong Cast lint warning by re-arranging Shell.java.

Previous warning:
Shell.java:150 Unexpected implicit cast to `Drawable`: layout tag was `LinearLayout`: WrongViewCast [warning]
        mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground();

Apparently, the lint cast check is a bit too overzealous and doesn't
understand when you access a property immediately.

BUG= 807732 

Change-Id: I4bd9ac6685e4bd9eae480dbdd19e5e67d0e9ff4f
Reviewed-on: https://chromium-review.googlesource.com/895401
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533478}
[modify] https://crrev.com/e09f8de14e1138f1687db2492f662b040168e362/content/shell/android/java/src/org/chromium/content_shell/Shell.java

Status: Fixed (was: Assigned)

Sign in to add a comment