Fixed user login image flicker/glitch

When the user switches between active/inactive users, currently
the login panel does not smoothly switch users (there is
significant jarring when the list items switch places). The root
of the problem is the following try-catch statement in
GoogleLoginUsersPanel.java:

   ignoreSelection = true;
   try {
       listModel.remove(list.getSelectedIndex());
       listModel.add(0, selectedUser);

       // Re-select the active user
       list.setSelectedIndex(0);
   }
   finally {
       ignoreSelection = false;
   }

listModel.remove() and listModel.add() trigger an update, which
causes UsersListCellRenderer#getListCellRendererComponent() to be
called synchronously. When the "list.getSelectedIndex() == index"
condition is checked, it will return the incorrect value because
the "list.setSelectedIndex(0)" method has not yet been called. The
fix is to check whether or not the user's email addresses are equal.

This CL also adds image caching to the login panel. This way we
can avoid calling Image#getScaledImage() multiple times and can
just reuse an old already scaled down image instead.

Bug: 17783247
Change-Id: Ia6c4fc884bcbf66b83cf800ae71e1d3e93e760c1
7 files changed
tree: 3a16c382b4b94bbc4b49651a8b3b5711971bccf0
  1. lib/
  2. resources/
  3. src/
  4. testSrc/
  5. google-login.iml