Git Product home page Git Product logo

Comments (16)

HBiSoft avatar HBiSoft commented on June 24, 2024 1

@gantonious Ok great, thank you once again for your quick reply.

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024 1

Okay I updated to version 0.3.2. How does this look: https://github.com/gantonious/MaterialDayPicker/blob/dev/app/src/main/java/ca/antonious/sampleapp/MainActivity.java#L25

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024

It should be possible! The getSelectedDays() method returns a list of MaterialDayPicker.Weekday which is an enum type not a string type so to get your snipped working try doing (notice how I dropped the quotes in the contains method):

if (daysSelected.contains(MaterialDayPicker.Weekday.TUESDAY)) {
    Toast.makeText(getContext(), "TUESDAY", Toast.LENGTH_SHORT).show();
}

from materialdaypicker.

HBiSoft avatar HBiSoft commented on June 24, 2024

@gantonious Thank you for the quick reply. Ok, I got that working, but is there a way to check when a day is unselected? Or should I handle it with a separate boolean?

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024

Right now there is no simple method to check. You can iterate through the daysSelected list you have and check if the date is NOT in the list. I just created an issue #3 to add methods to directly query if a day is selected or unselected. I will try and get those in the afternoon and get a new version of the lib up later today.

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024

Okay you can now check if a day is selected by doing:

boolean isTuesdaySelected = materialDayPicker.isSelected(MaterialDayPicker.Weekday.TUESDAY);

Here is the new compile dependency:

dependencies {
    compile 'ca.antonious:materialdaypicker:0.3.1'
}

from materialdaypicker.

HBiSoft avatar HBiSoft commented on June 24, 2024

@gantonious Thank you. But it is still a issue because if I have the following:

boolean isTuesdaySelected = materialDayPicker.isSelected(MaterialDayPicker.Weekday.TUESDAY);

if (isTuesdaySelected == true){
    Toast.makeText(getContext(), "TUESDAY - true", Toast.LENGTH_SHORT).show
}else if (isTuesdaySelected == false){
    Toast.makeText(getContext(), "TUESDAY - false", Toast.LENGTH_SHORT).show();
}

Inside of setDaySelectionChangedListener , then when I press on lets say Friday, it will also return isTuesdaySelected == false instead of just returning the day that was selected's state.

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024

So what I'm understanding is that you want to get the day of the week as well as its state inside the listener when you select a day?

from materialdaypicker.

HBiSoft avatar HBiSoft commented on June 24, 2024

@gantonious Yes exactly

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024

Okay I'll look into something

from materialdaypicker.

HBiSoft avatar HBiSoft commented on June 24, 2024

@gantonious Okay thank you.

from materialdaypicker.

HBiSoft avatar HBiSoft commented on June 24, 2024

Perfect, thank you so much for taking the time to resolve this issue. Much appreciated!

from materialdaypicker.

HBiSoft avatar HBiSoft commented on June 24, 2024

@gantonious One last suggestion would be to have the ability to set a single day, currently setSelectedDays has to be done like this:

materialDayPicker.setSelectedDays(MaterialDayPicker.Weekday.MONDAY, MaterialDayPicker.Weekday.TUESDAY);

But the issue is that if I want to store a selected day in a database and restore the specific selected day in OnCreate like this:

//Set MONDAY
if (myDb.getAll().containsKey("MONDAY")){
    materialDayPicker.setSelectedDays(MaterialDayPicker.Weekday.MONDAY);
}
//Set TUESDAY
if (myDb.getAll().containsKey("TUESDAY")){
    materialDayPicker.setSelectedDays(MaterialDayPicker.Weekday.TUESDAY);
 }

Then materialDayPicker.setSelectedDays(MaterialDayPicker.Weekday.MONDAY); will not be set because it is overwritten by materialDayPicker.setSelectedDays(MaterialDayPicker.Weekday.TUESDAY);

In order for me to achieve the desired result I will have to create a LARGE amount of if statements.

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024

Can't you use:

materialDayPicker.selectDay(MaterialDayPicker.Weekday.MONDAY)

That will not override your last selection. Also sorry for the late reply.

from materialdaypicker.

AbhishekHari29 avatar AbhishekHari29 commented on June 24, 2024

Hey there! Thank you for creating this amazing tool. I'm having a problem with resizing the dial (circle) size. If I change the layout property, it just ignored days that cannot fit into it. How can I make it smaller in order to fit it properly into a CardView

cardview_MaterialDayPicker
Capture

from materialdaypicker.

gantonious avatar gantonious commented on June 24, 2024

Similar to colour customization. The button and text size can be updated in your app's resource. If you don't have any dimension resources specified in your app you can create a new src/main/res/values/dimens.xml file and place the following dimensions in it:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="day_button_size">40dp</dimen>
    <dimen name="day_button_max_font_size">22sp</dimen>
</resources>

Unfortunately this will apply globally to your app. There is no way to currently override this on a per view basis.

from materialdaypicker.

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.