GithubHelp home page GithubHelp logo

horizontalpicker-1's Introduction

HorizontalPicker

DatePicker horizontal con selección smooth por día.

Características

  • Selección de fecha con smooth swipe.
  • Selección de fecha clickando un dia.
  • Selección de fecha desde el objeto HorizontalPicker.
  • Vista de mes y año.
  • Botón Today para seleccionar el día actual de manera rapida.
  • Días de la semana y meses en el idioma por defecto.
  • Configuración de cantidad de dias a generar (Default 120).
  • Configuración de offset de dias a generar antes del dia actual (Default 7).

Notas

  • De momento, solo es posible generar una cantidad finita de dias y este numero se genera en el hilo principal, por lo cual es recomendable no usar un numero mayor a 500.
  • Este proyecto utiliza la libreria JodaTime para el manejo de las fechas.

Ejemplos de uso

1- Añade la dependencia a tu proyecto

dependencies {
    compile 'com.github.jhonnyx2012:horizontal-picker:1.0.5'
}

2- Declara un HorizontalPicker en tu layout de la siguiente manera:

 <com.github.jhonnyx2012.horizontalpicker.HorizontalPicker
        android:id="@+id/datePicker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

3- Setea un listener al HorizontalPicker para escuchar los cambios de fecha e inicia el picker.

public class MainActivity extends AppCompatActivity implements DatePickerListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        HorizontalPicker picker= (HorizontalPicker) findViewById(R.id.datePicker);
        picker
                .setListener(this)
                .init();
    }

    @Override
    public void onDateSelected(DateTime dateSelected) {
        Log.i("HorizontalPicker","Fecha seleccionada="+dateSelected.toString());
    }
}

4- Tambien puedes configurar la cantidad de dias a generar, el offset y setear una fecha directamente al picker.

    picker
          .setListener(this)
          .setDays(20)
          .setOffset(10)
          .init();
    picker.setDate(new DateTime().plusDays(4));

Screenshots

Screenshot

License

  Copyright 2017 Jhonny Barrios

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

horizontalpicker-1's People

Contributors

anaistroncoso avatar jhonnypapinotas avatar jhonnyx2012 avatar

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.