Giter Club home page Giter Club logo

Comments (16)

Michenux avatar Michenux commented on August 24, 2024

Do you call the notifyDatasetChanged on the adapter ?

2013/11/20 TheoTzaferis [email protected]

Hey,

I have used your Navigation Drawer and its really awesome. The best one
I've used. I modified it a bit so I can have my own backgroundcolor and
don't have to use an image. I added a method, that has the name
createColor and gets a color as an additional paramter to the create
-method.

What I have are 3 sections. The user is able to select one item from each
section and the fragment gets changed dependent on the user selection. This
works without any problems. The filtering works perfectly fine.

The only thing I want to do know is to highlight the selections by also
giving them a blue background. But the problem is that only the settings
that I've defined at the beginning are the ones that get blue

This is my Config

@OverRide
protected NavDrawerActivityConfiguration getNavDrawerConfiguration() {
NavMenuSection topCharts;
NavMenuSection sources;
NavMenuSection sort;
NavMenuSection links;

NavMenuItem today;
NavMenuItem week;
NavMenuItem month;
NavMenuItem year;
NavMenuItem allBlogs;
NavMenuItem onlyBlogs;
NavMenuItem allNetworks;
NavMenuItem facebook;
NavMenuItem twitter;
NavMenuItem google;
NavMenuItem fliesBlog;
NavMenuItem feedback;
NavMenuItem impress;


topCharts   = NavMenuSection.create(100, "Top-Charts"   );
sources     = NavMenuSection.create(200, "Quellen"      );
sort        = NavMenuSection.create(300, "Sortierung"   );
links       = NavMenuSection.create(400, "Links"        );

Log.v ( "getNavdrawerConfiguration" , "timefilter: " + this.getTimefilter() );
Log.v ( "getNavdrawerConfiguration" , "blogfilter: " + this.getBlogfilter() );
Log.v ( "getNavdrawerConfiguration" , "socialfilter: " + this.getSocialfilter() );

if ( this.getTimefilter() == null || this.getTimefilter().equals ( "main" ) ){
    today       = NavMenuItem.createColor   (101, "Heute"   , false, this, getResources().getColor(R.color.actionBarOwn));
    week        = NavMenuItem.create        (102, "Woche"   , false, this);
    month       = NavMenuItem.create        (103, "Monat"   , false, this);
    year        = NavMenuItem.create        (104, "Jahr"    , false, this);
} else if ( this.getTimefilter().equals ( "week" ) ){
    today       = NavMenuItem.create        (101, "Heute"   , false, this);
    week        = NavMenuItem.createColor   (102, "Woche"   , false, this, getResources().getColor(R.color.actionBarOwn));
    month       = NavMenuItem.create        (103, "Monat"   , false, this);
    year        = NavMenuItem.create        (104, "Jahr"    , false, this);
} else if ( this.getTimefilter().equals ( "month" ) ){
    today       = NavMenuItem.create        (101, "Heute"   , false, this);
    week        = NavMenuItem.create        (102, "Woche"   , false, this);
    month       = NavMenuItem.createColor   (103, "Monat"   , false, this, getResources().getColor(R.color.actionBarOwn));
    year        = NavMenuItem.create        (104, "Jahr"    , false, this);
} else {
    today       = NavMenuItem.create        (101, "Heute"   , false, this);
    week        = NavMenuItem.create        (102, "Woche"   , false, this);
    month       = NavMenuItem.create        (103, "Monat"   , false, this);
    year        = NavMenuItem.createColor   (104, "Jahr"    , false, this, getResources().getColor(R.color.actionBarOwn));
}

if ( this.getBlogfilter() == null || this.getBlogfilter().equals ( "main" ) ){
    allBlogs    = NavMenuItem.createColor   (201, "Alle Quellen"    , false, this, getResources().getColor(R.color.actionBarOwn));
    onlyBlogs   = NavMenuItem.create        (202, "Nur Blogs"       , false, this);
} else {
    allBlogs    = NavMenuItem.create        (201, "Alle Quellen"    , false, this);
    onlyBlogs   = NavMenuItem.createColor   (202, "Nur Blogs"       , false, this, getResources().getColor(R.color.actionBarOwn));
}

if ( this.getSocialfilter() == null || this.getSocialfilter().equals ( "main" ) ){
    allNetworks = NavMenuItem.createColor   (301, "Alle Netzwerke"  , false, this, getResources().getColor(R.color.actionBarOwn));
    facebook    = NavMenuItem.create        (302, "Facebook"        , false, this);
    twitter     = NavMenuItem.create        (303, "Twitter"         , false, this);
    google      = NavMenuItem.create        (304, "Google+"         , false, this);
} else if ( this.getSocialfilter().equals ( "facebook" ) ){
    allNetworks = NavMenuItem.create        (301, "Alle Netzwerke"  , false, this);
    facebook    = NavMenuItem.createColor   (302, "Facebook"        , false, this, getResources().getColor(R.color.actionBarOwn));
    twitter     = NavMenuItem.create        (303, "Twitter"         , false, this);
    google      = NavMenuItem.create        (304, "Google+"         , false, this);
} else if ( this.getSocialfilter().equals ( "twitter" ) ){
    allNetworks = NavMenuItem.create        (301, "Alle Netzwerke"  , false, this);
    facebook    = NavMenuItem.create        (302, "Facebook"        , false, this);
    twitter     = NavMenuItem.createColor   (303, "Twitter"         , false, this, getResources().getColor(R.color.actionBarOwn));
    google      = NavMenuItem.create        (304, "Google+"         , false, this);
} else {
    allNetworks = NavMenuItem.create        (301, "Alle Netzwerke"  , false, this);
    facebook    = NavMenuItem.create        (302, "Facebook"        , false, this);
    twitter     = NavMenuItem.create        (303, "Twitter"         , false, this);
    google      = NavMenuItem.createColor   (304, "Google+"         , false, this, getResources().getColor(R.color.actionBarOwn));
}

fliesBlog   = NavMenuItem.create(401, "10000 Flies Blog", false, this);
feedback    = NavMenuItem.create(402, "Feedback"        , false, this);
impress     = NavMenuItem.create(403, "Impressum"       , false, this);

NavDrawerItem[] menu = new NavDrawerItem[] {
        topCharts,
        today,
        week,
        month,
        year,
        sources,
        allBlogs,
        onlyBlogs,
        sort,
        allNetworks,
        facebook,
        twitter,
        google,
        links,
        fliesBlog,
        feedback,
        impress,
};

NavDrawerActivityConfiguration navDrawerActivityConfiguration = new NavDrawerActivityConfiguration();
navDrawerActivityConfiguration.setMainLayout(R.layout.activity_main);
navDrawerActivityConfiguration.setDrawerLayoutId(R.id.drawer_layout);
navDrawerActivityConfiguration.setLeftDrawerId(R.id.left_drawer);
navDrawerActivityConfiguration.setNavItems(menu);
navDrawerActivityConfiguration
        .setDrawerShadow(R.drawable.drawer_shadow);
 navDrawerActivityConfiguration.setDrawerOpenDesc(R.string.open_drawer);
 navDrawerActivityConfiguration.setDrawerCloseDesc(R.string.mainTitle);
navDrawerActivityConfiguration.setBaseAdapter(new NavDrawerAdapter(
        this, R.layout.navdrawer_item, menu));
return navDrawerActivityConfiguration;

}

As you can see, when a certain filter is set the Navigation Menu should
change. The logcat, also tells me the set timefilter, socialfilter and
blogfilter. So that would mean, that the app always comes again into the
NavigationDrawreConfiguration but doesn't set it.

I tried so many things like invalidateOptionsmenu and clear the adapter.
But none of them worked. I would be really happy if you could tell me how
exactly I can do that!


Reply to this email directly or view it on GitHubhttps://github.com//issues/1
.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

Hey. Yes I tried that. Maybe it was just the different place, where I did it? The things I've done were to create a

NavDrawerAdapter navDrawerAdapter;

And then, in the onNavItemSelected I set navDrawerAdapter.notifyDataSetChanged - Is it the wrong place? I have a MainActivity where the navigationconfiguration is locted and a fragment where the whole data gets displayed. Where exactly do I have to set that? When I do it as I said either nothing happens or a NullPointerException is thrown. And it is for this line

this.onNavItemSelected(selectedItem.getId()); in AbstractNavDrawerActivity.java

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

Hey. I'm still stuck to this problem. I'll try to make it more clear. The MainActivity.class has the method getNavDrawerConfiguration where I assign the menu items and sections to a NavDrawerItem object and then configurate it like in your example.

In the MainActivity there is also the method onNavItemSelected Dependend on the case I open up a fragment. Now, when a fragment gets opened I set the options dependent on the click. This works without problems. The fragment gets replaced into a FrameLayout from the activity_main.xml like that: ft.replace(R.id.content_frame, new MainFragment()); After it has changed I would like to refresh the NavDrawer

What I tried was to create a new Adapter.

NavDrawerAdapter navDrawerAdapter

and then, after the commit, calling navDrawerAdapter.notifyDataSetChanged() but that line crashes the app with a NullPointerException - When I try to initialize the variable I have to give a context, textViewReference and the objects I want to pass. But the objects I want to pass are only created in the getNavDrawerConfiguration. So I can't assign them.

I hope this is detailed enough, because this is the last part of the app I need to finish my app!

from yourappidea.

Michenux avatar Michenux commented on August 24, 2024

Hi,

Is it possible for you to send the source code of your project ?

2013/11/21 TheoTzaferis [email protected]

Hey. I'm still stuck to this problem. I'll try to make it more clear. The
MainActivity.class has the method getNavDrawerConfiguration where I
assign the menu items and sections to a NavDrawerItem object and then
configurate it like in your example.

In the MainActivity there is also the method onNavItemSelected Dependend
on the case I open up a fragment. Now, when a fragment gets opened I set
the options dependent on the click. This works without problems. The
fragment gets replaced into a FrameLayout from the activity_main.xml like
that: ft.replace(R.id.content_frame, new MainFragment()); After it has
changed I would like to refresh the NavDrawer

What I tried was to create a new Adapter.

NavDrawerAdapter navDrawerAdapter

and then, after the commit, calling
navDrawerAdapter.notifyDataSetChanged() but that line crashes the app
with a NullPointerException - When I try to initialize the variable I
have to give a context, textViewReference and the objects I want to pass.
But the objects I want to pass are only created in the
getNavDrawerConfiguration. So I can't assign them.

I hope this is detailed enough, because this is the last part of the app I
need to finish my app!


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28965695
.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

Hi,

I'm unfortunate that it is in fact not. It's a project for a customer. The only thing I could send you would be the MainActivity and the classes I got from you. Would that be enough? I don't think you would need the fragments, would you? The MainActivity is anyway the only class where I'm doing the logic of the Navigation Drawer. The fragments aren't affected by that.

from yourappidea.

Michenux avatar Michenux commented on August 24, 2024

And could you create a simple project with the minimal code to reproduce
the issue ?

2013/11/21 TheoTzaferis [email protected]

Hi,

I'm unfortunate that it is in fact not. It's a project for a customer. The
only thing I could send you would be the MainActivity and the classes I
got from you. Would that be enough? I don't think you would need the
fragments, would you?


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28965978
.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

Basically yes. Give me some minutes, I will do that right now.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

https://mega.co.nz/#!DVEETIJa!SgS0e2HdMzLpd1NhF7XiCkAI-qsgI7nWmpYyYVQq-kY

Here you go. When you now click on Week I want that Week gets the background and not today!

from yourappidea.

Michenux avatar Michenux commented on August 24, 2024

I'm at work now, i will try this evening.

2013/11/21 TheoTzaferis [email protected]

https://mega.co.nz/#!DVEETIJa!SgS0e2HdMzLpd1NhF7XiCkAI-qsgI7nWmpYyYVQq-kY

Here you go. When you now click on Week I want that Week gets the
background and not today!


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28967489
.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

Thanks in advance. It would be awesome if you could help me! This is the last thing I need for the app

from yourappidea.

Michenux avatar Michenux commented on August 24, 2024

Look at this.
But i think this is not the best way.
You should use t the attribute ?activatedBackgroundIndicator to change the
color of the selected item of the list.

best regards
Laurent

2013/11/21 TheoTzaferis [email protected]

Thanks in advance. It would be awesome if you could help me! This is the
last thing I need for the app


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28970306
.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

Hey. Did you forget to attatch something? Because i cant see anything except your text.
Yeah the avtivatedBackgroundIndicator only works for one item doesnt it? I need it for multiple dependent on the click. Max 3 at once and only 1 per section

from yourappidea.

Michenux avatar Michenux commented on August 24, 2024

sorry.

2013/11/21 TheoTzaferis [email protected]

Hey. Did you forget to attatch something? Because i cant see anything
except your text.
Yeah the avtivatedBackgroundIndicator only works for one item doesnt it? I
need it for multiple dependent on the click. Max 3 at once and only 1 per
section


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-29029743
.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

No problem. :) But I still can't see anything except your texts

from yourappidea.

Michenux avatar Michenux commented on August 24, 2024

http://www.michenux.net/download/TestHelp1.zip

This is not the best solution because i recreate the adapter each time.
I recreate it because it is an ArrayAdapter and you can't modify it (clear
and add elements).
It would be best to write an Adapter owning a List, instantiate it once
only, and when needed, modify the data inside, and call its method
notifyDataSetChanged().

2013/11/22 TheoTzaferis [email protected]

No problem. :) But I still can't see anything except your texts


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-29052833
.

from yourappidea.

kobelobster avatar kobelobster commented on August 24, 2024

A thousand thanks! I will use this for my first release and then, in the second release try to use an Adapter owning a List!

from yourappidea.

Related Issues (16)

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.