×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    23

    Firmware bug or code bug displaying list on 3650

    Hello, here is the full content of the class I use to display menus in my game.

    Basically it's a list but it allows associating an action id to the item.

    This works very well on all the phones I have tested. (7210, 3510i,6610 and other brands).

    Somehow my publisher in Canada has this report:

    On 3650. Double selection on the Main Menu. As a result 2 items will be selected: the top one and the 4th one [New Game and the Mode].

    I don't own a 3650 but I am totally unable to reproduce this behaviour in any emulator. Since I was having doubts I even overrided the setSelectedIndex() to make sure only the desired item got selected by explicitely setting them all to false before (I sometimes call this method myself in the rest of the game to go to the default position.) This didn't change anything.

    Is is possible for a list of IMPLICIT type to have multiple selection ? Or is there bug completely bugged?


    Here is the full code of my menu source:


    package com.linku.mobile.games.common;


    import java.io.IOException;
    import java.util.Hashtable;
    import java.util.Vector;

    import javax.microedition.lcdui.Choice;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.List;

    public class MenuMIDlet extends List implements CommandListener
    {

    private Command cmdSel = null;
    private Command cmdBack = null;
    private Hashtable allImages = new Hashtable();
    private boolean loadIcons = true;
    private BaseGame actionParent = null;
    private static MenuMIDlet singleTon = null;
    public Vector items = new Vector();

    private MenuMIDlet()
    {
    //le titre est sette par la suite normalment
    super("", Choice.IMPLICIT);

    if (cmdSel == null)
    {
    cmdSel = new Command("OK", Command.SCREEN, 1);
    cmdBack = new Command(Utils.getTrans("BACK"), Command.BACK, 2);
    this.addCommand(cmdSel);
    this.addCommand(cmdBack);
    }

    }

    public static MenuMIDlet getInstance(String title, boolean loadTheIcons)
    {
    if (singleTon == null)
    singleTon = new MenuMIDlet();

    singleTon.setTitle(title);
    singleTon.loadIcons = loadTheIcons;

    singleTon.clear();

    return singleTon;
    }

    public static void setActionParent(BaseGame ba)
    {
    singleTon.actionParent = ba;
    }

    public static void prepare()
    {
    singleTon.setCommandListener(singleTon);

    singleTon.setSelectedIndex(0, true);
    }

    public void commandAction(Command c, Displayable s)
    {

    if (items == null)
    return;

    //System.out.println("Selected index:"+singleTon.getSelectedIndex());

    if (getSelectedIndex() >= 0 && getSelectedIndex() < singleTon.size())
    {
    MenuLine el = (MenuLine) items.elementAt(this.getSelectedIndex());

    if (el != null)
    {
    if (c == cmdBack)
    {
    actionParent.actionCalled(el.actionBack, el.actionBackParam);
    } else
    {
    //System.out.println("Action Type:"+c.getCommandType());
    //System.out.println("Action Called: "+el.action+":"+el.actionParam);
    actionParent.actionCalled(el.action, el.actionParam);
    }

    }
    }

    }

    public void clear()
    {
    // for (int i = 0; i != items.size(); i++)

    while (singleTon.size() > 0)
    singleTon.delete(0);

    singleTon.items.removeAllElements();

    //allImages.clear();
    }

    public class MenuLine
    {
    int icon = 0;
    int action = 0;
    int actionParam = 0;
    int actionBack = 0;
    int actionBackParam = 0;
    String label = "NOLABEL";
    public MenuLine(int icon, String label, int action, int actionParam, int actionBack, int actionBackParam)
    {
    this.icon = icon;
    this.label = label;
    this.action = action;
    this.actionParam = actionParam;
    this.actionBack = actionBack;
    this.actionBackParam = actionBackParam;
    }
    }

    public void addItem(
    int iconID,
    String label,
    int actionID,
    int actionParam,
    int actionBackID,
    int actionBackParamID)
    {
    MenuLine el = new MenuLine(iconID, label, actionID, actionParam, actionBackID, actionBackParamID);
    items.addElement(el);
    Image x = null;

    if (loadIcons)
    {
    x = (Image) allImages.get("" + iconID);
    if (x == null)
    {
    try
    {
    x = Image.createImage("/icons/icon_" + iconID + ".png");
    allImages.put("" + iconID, x);
    } catch (IOException e)
    {
    }
    }
    }
    singleTon.append(label, x);
    }

    public void setSelectedIndex(int id, boolean value)
    {
    //There seems to be a bug on certain devices (Series 60)
    //where multiple items can be set in an implicit list
    //if calling directly setSelectedIndex
    //this WAS SUPPOSED TO avoid the bug by setting them all to false before setting to on
    boolean[] flags = new boolean[this.size()];
    for (int i = 0; i != flags.length; i++)
    flags[i] = false;

    //set our selected id
    flags[id] = true;

    // System.out.println("Selecting:"+id+":"+value);
    //Sets all the flags in one command
    this.setSelectedFlags(flags);

    //super.setSelectedIndex(id, value);
    }
    }
    package com.linku.mobile.games.common;

    /**
    * @author root
    *
    * To change this generated comment edit the template variable "typecomment":
    * Window>Preferences>Java>Templates.
    * To enable and disable the creation of type comments go to
    * Window>Preferences>Java>Code Generation.
    */

    import java.io.IOException;
    import java.util.Hashtable;
    import java.util.Vector;

    import javax.microedition.lcdui.Choice;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.List;

    public class MenuMIDlet extends List implements CommandListener
    {

    private Command cmdSel = null;
    private Command cmdBack = null;
    private Hashtable allImages = new Hashtable();
    private boolean loadIcons = true;
    private BaseGame actionParent = null;
    private static MenuMIDlet singleTon = null;
    public Vector items = new Vector();

    private MenuMIDlet()
    {
    //le titre est sette par la suite normalment
    super("", Choice.IMPLICIT);

    if (cmdSel == null)
    {
    cmdSel = new Command("OK", Command.SCREEN, 1);
    cmdBack = new Command(Utils.getTrans("BACK"), Command.BACK, 2);
    this.addCommand(cmdSel);
    this.addCommand(cmdBack);
    }

    }

    public static MenuMIDlet getInstance(String title, boolean loadTheIcons)
    {
    if (singleTon == null)
    singleTon = new MenuMIDlet();

    singleTon.setTitle(title);
    singleTon.loadIcons = loadTheIcons;

    singleTon.clear();

    return singleTon;
    }

    public static void setActionParent(BaseGame ba)
    {
    singleTon.actionParent = ba;
    }

    public static void prepare()
    {
    singleTon.setCommandListener(singleTon);

    singleTon.setSelectedIndex(0, true);
    }

    public void commandAction(Command c, Displayable s)
    {

    if (items == null)
    return;

    //System.out.println("Selected index:"+singleTon.getSelectedIndex());

    if (getSelectedIndex() >= 0 && getSelectedIndex() < singleTon.size())
    {
    MenuLine el = (MenuLine) items.elementAt(this.getSelectedIndex());

    if (el != null)
    {
    if (c == cmdBack)
    {
    actionParent.actionCalled(el.actionBack, el.actionBackParam);
    } else
    {
    //System.out.println("Action Type:"+c.getCommandType());
    //System.out.println("Action Called: "+el.action+":"+el.actionParam);
    actionParent.actionCalled(el.action, el.actionParam);
    }

    }
    }

    }

    public void clear()
    {
    // for (int i = 0; i != items.size(); i++)

    while (singleTon.size() > 0)
    singleTon.delete(0);

    singleTon.items.removeAllElements();

    //allImages.clear();
    }

    public class MenuLine
    {
    int icon = 0;
    int action = 0;
    int actionParam = 0;
    int actionBack = 0;
    int actionBackParam = 0;
    String label = "NOLABEL";
    public MenuLine(int icon, String label, int action, int actionParam, int actionBack, int actionBackParam)
    {
    this.icon = icon;
    this.label = label;
    this.action = action;
    this.actionParam = actionParam;
    this.actionBack = actionBack;
    this.actionBackParam = actionBackParam;
    }
    }

    public void addItem(
    int iconID,
    String label,
    int actionID,
    int actionParam,
    int actionBackID,
    int actionBackParamID)
    {
    MenuLine el = new MenuLine(iconID, label, actionID, actionParam, actionBackID, actionBackParamID);
    items.addElement(el);
    Image x = null;

    if (loadIcons)
    {
    x = (Image) allImages.get("" + iconID);
    if (x == null)
    {
    try
    {
    x = Image.createImage("/icons/icon_" + iconID + ".png");
    allImages.put("" + iconID, x);
    } catch (IOException e)
    {
    }
    }
    }
    singleTon.append(label, x);
    }

    public void setSelectedIndex(int id, boolean value)
    {
    //There seems to be a bug on certain devices (Series 60)
    //where multiple items can be set in an implicit list
    //if calling directly setSelectedIndex
    //this WAS SUPPOSED TO avoid the bug by setting them all to false before setting to on
    boolean[] flags = new boolean[this.size()];
    for (int i = 0; i != flags.length; i++)
    flags[i] = false;

    //set our selected id
    flags[id] = true;

    // System.out.println("Selecting:"+id+":"+value);
    //Sets all the flags in one command
    this.setSelectedFlags(flags);

    //super.setSelectedIndex(id, value);
    }
    }

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    23

    3650 bug

    Ok, from what I have been told else, calling setselectedindex on a 3650 will cause this bug. So I'll just disable this on a 3650...

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    The 7650 also has this problem....
    http://discussion.forum.nokia.com/fo...50+list+bug%2A

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×