package kz.arta.synergy.workflow.mobile.android.forms.general.components.repeat;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import kz.arta.synergy.workflow.mobile.android.R;
import kz.arta.synergy.workflow.mobile.android.common.ActivityConst;
import kz.arta.synergy.workflow.mobile.android.forms.general.components.repeat.days.DayList;
import kz.arta.synergy.workflow.mobile.android.forms.general.components.repeat.weeks.WeekList;

/**
 * Created by neox on 25.04.16.
 * Компонент "Период повторения"
 */
public class RepeatPeriodActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.repeat_period_activity);

        Activity activity = this;

        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }

        int type = getIntent().getIntExtra(RepeatPeriodConst.PERIOD_REPEAT_TYPE, RepeatPeriodConst.WEEKS);
        String[] selected = getIntent().getStringArrayExtra(ActivityConst.SELECTED);

        TextView title = (TextView) findViewById(R.id.repeat_period_action_bar_title);

        if (type == RepeatPeriodConst.WEEKS) {
            title.setText(R.string.every_week);
            WeekList weekList = new WeekList();
            weekList.setSelected(selected);
            weekList.setActivity(activity);
            weekList.init();
        } else if (type == RepeatPeriodConst.DAYS) {
            title.setText(R.string.every_month);
            DayList dayList = new DayList();
            dayList.setType(type);
            dayList.setSelected(selected);
            dayList.setActivity(activity);
            dayList.init();
        } else if (type == RepeatPeriodConst.YEARS) {
            title.setText(R.string.every_year);
            DayList dayList = new DayList();
            dayList.setSelected(selected);
            dayList.setType(type);
            dayList.setActivity(activity);
            dayList.init();
        }
    }
}
