The phenomenon of the singleton pattern

1: Pay attention when using the singleton mode!

   Problem:
      In the MobileOA project, the LoginPopup login prompt box tool class uses the singleton mode, but in the showPopupWindow
      method, the callback function parameter of the function uses the mode that a single instance exists! Therefore, when multiple "fuzzy query user names" are displayed for the same login
      , the hashcode address of the callback function instance is the same, but
      the callback function corresponds to the callback function of the OnLoginItemClickListener interface implemented in the LoginActivity class:
           control instance
       edLoginName
       edLoginPd
    The hashcode value is the same, resulting in the content assignment of the editText control content of the same hashcode address!


   Phenomenon:
      When switching to the login page for many times, the fuzzy query is used to prompt the prompt of multiple user names. Click on the prompt box entry
      , but the content of the "username, password" editText in the page is not displayed!


   Solution:
      Test the content of the OnLoginItemClickListener interface implementation function:
           edLoginName
           edLoginPd control.

      The result is: the pop-up toast has content, but it is not displayed!


      It should be thought that the control instance of edLoginName and edLoginPd should be different!
      For the OnLoginItemClickListener parameter in the showPopupWindow function in the LoginPopup tool class,
      "same example mode" should not be set.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326733314&siteId=291194637