package com.example.yochi.shiftcal;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.provider.ContactsContract;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.Date;
import java.sql.Timestamp;

/**
 * Created by yochi on 2017/01/17.
 */
class DateAdapter extends BaseAdapter {

    private Context mContext;
    private LayoutInflater mLayoutInflater;
    private Timestamp top = null;

    private static class DateViewHolder {
        public TextView  title;
        public TextView  contents;
    }

    DateAdapter(Context context) {
      mContext = context;
      mLayoutInflater = LayoutInflater.from(context);

      if(top == null){
        // 現在月の１日の曜日からカレンダー表示の左上日付を求める
        top = new Timestamp(new Date().getTime());

      }
      // カレンダー最終日（top+42日）
      Timestamp bottom = new Timestamp(top.getTime());

      // calテーブルからカレンダー表示分のデータ取得
      ShiftDao dao = new ShiftDao();
    }

    public int getCount() {
        return 7*6;
    }

    public Object getItem(int position) {
        // 日にち計算
        return position + "日";
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

      DateViewHolder holder;
      if (convertView == null) {
        convertView = mLayoutInflater.inflate(R.layout.date_layout, null);
        holder = new DateViewHolder();
        convertView.setTag(holder);
      } else {
          holder = (DateViewHolder)convertView.getTag();
      }

      holder.title.setText((String)getItem(position));

      return convertView;
    }
}

@@ -830,274 +830,38 @@
     
-if(top == null)%7B%0A        // %E7%8F%BE%E5%9C%A8%E6%9C%88%E3%81%AE%EF%BC%91%E6%97%A5%E3%81%AE%E6%9B%9C%E6%97%A5%E3%81%8B%E3%82%89%E3%82%AB%E3%83%AC%E3%83%B3%E3%83%80%E3%83%BC%E8%A1%A8%E7%A4%BA%E3%81%AE%E5%B7%A6%E4%B8%8A%E6%97%A5%E4%BB%98%E3%82%92%E6%B1%82%E3%82%81%E3%82%8B%0A        top = new Timestamp(new Date().getTime());%0A%0A      %7D%0A      // %E3%82%AB%E3%83%AC%E3%83%B3%E3%83%80%E3%83%BC%E6%9C%80%E7%B5%82%E6%97%A5%EF%BC%88top+42%E6%97%A5%EF%BC%89%0A      Timestamp bottom = new Timestamp(top.getTime());%0A%0A      // cal%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%81%8B%E3%82%89%E3%82%AB%E3%83%AC%E3%83%B3%E3%83%80%E3%83%BC%E8%A1%A8%E7%A4%BA%E5%88%86%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E5%8F%96%E5%BE%97%0A      ShiftDao dao = new ShiftDao(
+moveMonth(new Date().getTime()
 );%0A 
@@ -1549,11 +1549,395 @@
 w;%0A    %7D
+%0A%0A    public moveMonth(Timestamp month)%7B%0A%0A        // %E7%8F%BE%E5%9C%A8%E6%9C%88%E3%81%AE%EF%BC%91%E6%97%A5%E3%81%AE%E6%9B%9C%E6%97%A5%E3%81%8B%E3%82%89%E3%82%AB%E3%83%AC%E3%83%B3%E3%83%80%E3%83%BC%E8%A1%A8%E7%A4%BA%E3%81%AE%E5%B7%A6%E4%B8%8A%E6%97%A5%E4%BB%98%E3%82%92%E6%B1%82%E3%82%81%E3%82%8B%0A        top = DateUtil.getMonthlyCalendarTop(month);%0A        // %E3%82%AB%E3%83%AC%E3%83%B3%E3%83%80%E3%83%BC%E6%9C%80%E7%B5%82%E6%97%A5%EF%BC%88top+42%E6%97%A5%EF%BC%89%0A        Timestamp bottom = DateUtil.getMonthlyCalendarLast(month);%0A%0A        // cal%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%81%8B%E3%82%89%E3%82%AB%E3%83%AC%E3%83%B3%E3%83%80%E3%83%BC%E8%A1%A8%E7%A4%BA%E5%88%86%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E5%8F%96%E5%BE%97%0A        ShiftDao dao = new ShiftDao();%0A        ArrayList%3CShiftDao%3E shiftList = dao.getMonthlyShift(top, bottom);%0A    %7D
 %0A%7D%0A

add moveMonth