Skip to content

morristech/HorizontalPicker-1

 
 

Repository files navigation

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.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%