nomanr / WeekCalendar

A simple weekly calendar.
646 stars 128 forks source link

day names at the bottom #11

Open jay-parapps opened 8 years ago

jay-parapps commented 8 years ago

Hi,

How can I have the day names ate the bottom row of the grid instead of above?

I suposed I have to edit this class? https://github.com/nomanr/WeekCalendar/blob/master/weekcalendar/src/main/java/noman/weekcalendar/WeekCalendar.java

Thank you for any advice.

nomanr commented 8 years ago

Yes in that class write this line

addView(weekPager);

before this

addView(daysName, 0);
jay-parapps commented 8 years ago

Thank you for the quick response

Would I have to download the source code you think?

Or can I pull it off by using the graddle just extending+overriding stuff and using the extended classes instead?

nomanr commented 8 years ago

Gradle dependency won't work, you've to download the source code and import the project as a module. Then it'll work.

Regards Noman Rafique

On Wed, Feb 3, 2016 at 11:27 PM, jay-parapps notifications@github.com wrote:

Thank you for the quick response

Would I have to download the source code you think?

Or can I pull it off by using the graddle just extending the classes and using the extended classes instead?

— Reply to this email directly or view it on GitHub https://github.com/nomanr/WeekCalendar/issues/11#issuecomment-179390640.

jay-parapps commented 8 years ago

hmm... I'm curious why not? Looks like there are some private methods and variables involved :(

jay-parapps commented 8 years ago

Since some stuff is private, I tried just reverting the views on extended class constructor, but the day names never show up.

View view = getChildAt(0); removeView(view); addView(view);

maybe just reverting the other the are added will not work either?

nomanr commented 8 years ago

Yes the variables are private, try it if it works then post it here.

jay-parapps commented 8 years ago

Just tried creating a new project on android studio by doing File > Import from rep > Github and passing it the repo url: https://github.com/nomanr/WeekCalendar.git

Got a bunch of errors and an invalid Android project.

Will try some other way

jay-parapps commented 8 years ago

Downloading the project do disk first and opening works, but then I get the same results that I got thru my hack: numbers are in the top row but the week names do not show up.

What I did was reverse the order of the lines, as you told me to:

`WeekPager weekPager = new WeekPager(getContext(), attrs); addView(weekPager);

    if (!typedArray.getBoolean(R.styleable.WeekCalendar_hideNames, false)) {
        daysName = getDaysNames();
        addView(daysName);
    }`
jay-parapps commented 8 years ago

So appearently the internal ViewPager is doing some kind of blackmagic which completely prevents subsequent views to be shown, even putting the viewpager alone inside it's own parent container did not help.

The only way I was able to pull it off is to make getDaysNames() public so it could be used from the activity, and then I add the subcomponent that I get from this method as a separate view outside of the calendar widget itself. A total hack, I know, but works for the meantime.

GridView daysView = weekCalendar.getDaysNames(); LinearLayout container = (LinearLayout) findViewById(R.id.calendar_container); container.addView(daysView);