Android Open Source - BonetCalendarView Custom Year Provider






From Project

Back to project page BonetCalendarView.

License

The source code is released under:

Apache License

If you think the Android project BonetCalendarView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bonet.example.bonetcalendarviewactivity;
//www .ja  v  a2  s . c  om
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.AdapterView.OnItemClickListener;

import com.bonet.views.BtCalendarView;
import com.bonet.views.BtMonth;
import com.bonet.views.BtYearViewProvider;
import com.bonet.views.MonthListAdapter;

public class CustomYearProvider extends BtYearViewProvider {

  private GridView mGridView;
  
  private MonthListAdapter mAdapter;
  
  public CustomYearProvider(BtCalendarView parentCalendar, int year) {
    super(parentCalendar, year);
    
    mAdapter = new CustomYearAdapter(parentCalendar, year);
  }

  @Override
  public View getView() {
    /* Using list view to display the year can look boring, 
     * and take a lot of space. Here we create a YearProvider
     * that displays the months in a grid view */
    
    if(mGridView == null){
      // inflates the grid view
      mGridView = (GridView)LayoutInflater.from(getCalendar().getContext()).inflate(R.layout.grid_view, null);
      
      // 4 columns seems nice
      mGridView.setNumColumns(3);
      
      // Sets the adapter
      mGridView.setAdapter(mAdapter);
      
      // Sets the listener
      mGridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position,long arg3) {
          if(! (getCalendar() ==null))
            getCalendar().notifyMonthChanged(new BtMonth(getYear(),position));
        }
      });
    }
    
    return mGridView;
  }

  @Override
  public void updateView() {
    mAdapter.notifyDataSetChanged();
  }

}




Java Source Code List

com.bonet.example.bonetcalendarviewactivity.CustomDayGridAdapter.java
com.bonet.example.bonetcalendarviewactivity.CustomGridCalendarActivity.java
com.bonet.example.bonetcalendarviewactivity.CustomGridCalendar.java
com.bonet.example.bonetcalendarviewactivity.CustomMonthProvider.java
com.bonet.example.bonetcalendarviewactivity.CustomYearAdapter.java
com.bonet.example.bonetcalendarviewactivity.CustomYearProvider.java
com.bonet.example.bonetcalendarviewactivity.ExampleActivity.java
com.bonet.example.bonetcalendarviewactivity.GridCalendarActivity.java
com.bonet.example.bonetcalendarviewactivity.ListCalendarActivity.java
com.bonet.views.BtCalendarView.java
com.bonet.views.BtCalendar.java
com.bonet.views.BtDate.java
com.bonet.views.BtMonthViewProvider.java
com.bonet.views.BtMonth.java
com.bonet.views.BtYearViewProvider.java
com.bonet.views.DayGridAdapter.java
com.bonet.views.DayListAdapter.java
com.bonet.views.GridBtMonthViewProvider.java
com.bonet.views.ListBtMonthViewProvider.java
com.bonet.views.ListBtYearViewProvider.java
com.bonet.views.MonthListAdapter.java
com.bonet.views.OnDateSelectedListener.java
com.bonet.views.package-info.java