Code Monkey home page Code Monkey logo

Comments (9)

SimonVT avatar SimonVT commented on May 26, 2024

Yeah, this isn't supported at the moment. I'll see if I can come up with a good approach for how to handle this.

from android-menudrawer.

pommedeterresautee avatar pommedeterresautee commented on May 26, 2024

Hi,

I have exactly the same error in my application.

Is there a dirty workaround available now, until you find a beautiful solution?
As the issue is a saved state, is there a way to reset it to be like I am launching the application in the new state (portrait or landscape)? I don't use onRestore in my activity and I see the issue is there.

I just removed all the code I used in my application to manage the landscape (which disables the code menu drawer and replace it by a classical listview) because I believed the update would implement a working version of the landscape mode (static mode).

Anyway thank you for the library.

Regards

from android-menudrawer.

SimonVT avatar SimonVT commented on May 26, 2024

Can you check if the changes I pushed to the dev branch solves this?

from android-menudrawer.

pommedeterresautee avatar pommedeterresautee commented on May 26, 2024

Thank you for your rapidity !

It is working great on my application.

from android-menudrawer.

pommedeterresautee avatar pommedeterresautee commented on May 26, 2024

I noticed a little bug.

When I launch the app in landscape (with the statically opened menudrawer) or if I rotate, the little triangle to show the selected item in the meny doesn't appear.

This is my init:

  private void initializeSidebar(Bundle inState) {
        if (inState != null) {
            mActivePosition = inState.getInt(STATE_ACTIVE_POSITION);
        }

        mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_CONTENT, Position.LEFT, !portrait);

        mMenuDrawer.setContentView(R.layout.main);
        List<Item> items = new ArrayList<Item>();
        for (ActionChoice current : ActionChoice.values()) {
            items.add(new Item(current.toText(), current.getIcon()));
        }
        MenuListView mList = new MenuListView(this);
        mList.setTopShadow(true);
        mAdapter = new MenuAdapter(MainActivity.this, items, mActivePosition, mMenuDrawer);
        mList.setAdapter(mAdapter);
        mList.setOnItemClickListener(mItemClickListener);
            mList.setOnScrollChangedListener(new MenuListView.OnScrollChangedListener() {
                @Override
                public void onScrollChanged() {
                    mMenuDrawer.invalidate();
                }
            });
            mMenuDrawer.setMenuView(mList);
            mMenuDrawer.setDropShadowSize(InterfaceFunctions.convertDpToPixel(4, this));
    }

from android-menudrawer.

SimonVT avatar SimonVT commented on May 26, 2024

You have to call MenuDrawer#setActiveView(...) for the indicator to show.

from android-menudrawer.

pommedeterresautee avatar pommedeterresautee commented on May 26, 2024

Thank you! I forgot to disable another isPortrait() check I used before the library update.

I am now doing like that:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        Object item = getItem(position);
        if (item instanceof Category) {
            if (v == null) {
                v = mContext.getLayoutInflater().inflate(R.layout.md__category, parent, false);
            }
            ((TextView) v).setText(((Category) item).mTitle);
        } else {
            if (v == null) {
                v = mContext.getLayoutInflater().inflate(R.layout.md__item, parent, false);
            }
            TextView tv = (TextView) v;
            ...
        }

        v.setTag(R.id.mdActiveViewPosition, position);
        if (position == mActivePosition) {
            try {
                //TODO search why it crashes here!
                mMenuDrawer.setActiveView(v, position);
            } catch (Exception e) {
                e.printStackTrace();
            }
...
    }

I noticed that sometimes (with the old library version of course) my users have some crashes on the setActiveView().
As it doesn't happen a lot (like one time per week) and I have several thousands of users, I thought it was not important. But now I am reworking on this part, I take the chance to tell you about it.

Unfortunately I don't find the logs... But may the way I am doing it (in getView) is a bad practice?

from android-menudrawer.

SimonVT avatar SimonVT commented on May 26, 2024

With ListView you have to set the active view in getView() since the view for the position can potentially change every time it's shown.
Next time it crashes, feel free to open a new issue.

from android-menudrawer.

srikanthnama avatar srikanthnama commented on May 26, 2024

Hi.. How to set the First List Item as Default when launch the Application? when i use list.performItemClick(), i am getting errors. Pls Help me to resolve this. Thank you.

from android-menudrawer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.