Android Open Source - ProjectStudio Study Plan Fragment






From Project

Back to project page ProjectStudio.

License

The source code is released under:

Apache License

If you think the Android project ProjectStudio 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

/**
 */*from www  .  j a v a  2s . c o  m*/
 */
package fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.uniutilproject.R;

import java.util.Calendar;

import dialog_fragments.DatePickerDialogFragment;
import dialog_fragments.TimePickerDialogFragment;

/**
 * @author desmond
 */
public class StudyPlanFragment extends Fragment {

    private EditText plan_name_editText;
    private EditText coursename_editText;
    private EditText location_editText;
    private TextView date_textview;
    private TextView time_textview;
    private Button create_button;
    private View view;
    private DrawerLayout parent_drawer;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.studyplan_fragment, container, false);

        //IF DRAWER HAS BEEN DISABLED BY SOME OTHER FRAGMENT
        //ENABLE DRAWER
        parent_drawer = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout);
        if (parent_drawer.getDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) == 0){
            parent_drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
        }

        //INFLATE VIEWS HERE
        if (view != null) {
            plan_name_editText = (EditText) view
                    .findViewById(R.id.card_task_title);
        }
        if (view != null) {
            coursename_editText = (EditText) view
                    .findViewById(R.id.task_et);
        }
        if (view != null) {
            location_editText = (EditText) view
                    .findViewById(R.id.task_location_et);
        }

        if (view != null) {
            date_textview = (TextView) view.findViewById(R.id.task_dateView);
            date_textview.setOnClickListener(new DatePickerListener());
        }

        if (view != null) {
            time_textview = (TextView) view.findViewById(R.id.task_timeView);
            time_textview.setOnClickListener(new TimePickerListener());
        }

        return view;
    }

    // SET DEFAULT DATE ON TEXTVIEW TO BE THE CURRENT DATE

    public void setCurrentDate(TextView date_textview) {

        final Calendar c = Calendar.getInstance();

        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int date = c.get(Calendar.DATE);

        date_textview.setText(new StringBuilder().append(month + 1).append("-")
                .append(date).append("-").append(year));
    }

    //SET DEFAULT TIME ON TEXTVIEW TO BE THE CURRENT DATE
    public void setCurrentTime(TextView time_textview) {

        final Calendar c = Calendar.getInstance();
        int hourOfDay = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);

        if (hourOfDay > 12) {
            time_textview.setText(new StringBuilder().append(hourOfDay)
                    .append(":").append(minute).append("pm").append(""));
        } else {
            time_textview.setText(new StringBuilder().append(hourOfDay)
                    .append(":").append(minute).append("am").append(""));
        }
    }

    // SHOW THE DATEPICKER DIALOG FRAGMENT
    public void showDatePickerFragment(View v) {
        DatePickerDialogFragment datepicker = new DatePickerDialogFragment(
                date_textview);
        datepicker.show(getFragmentManager(), "datePicker_studyplan");
    }

    //SHOW THE TIMEPICKER DIALOG FRAGMENT
    public void showTimePickerFragment(View v) {
        TimePickerDialogFragment timepicker = new TimePickerDialogFragment(time_textview);
        timepicker.show(getFragmentManager(), "timePicker_studyplan");
    }

    //delete when done
    private class TimePickerListener implements OnClickListener {

        @Override
        public void onClick(View v) {
            showTimePickerFragment(v);
        }
    }

    private class DatePickerListener implements OnClickListener {
        @Override
        public void onClick(View v) {
            showDatePickerFragment(v);
        }
    }
}




Java Source Code List

DB_Provider.CourseDataSource.java
DB_Provider.DBManager.java
DB_Provider.DB_ABSTRACTS.java
DB_Provider.ProfessorDataSource.java
DB_Provider.TaskDataSource.java
Drawables.DrawableAlignedButton.java
FontPackage.TypefaceSpan.java
adapters.CourseCardAdapter.java
adapters.ExamsPassedCardAdapter.java
adapters.ExamsPendingCardAdapter.java
adapters.Exams_TabsPagerAdapter.java
adapters.HomeCardAdapter.java
adapters.MatesCardAdapter.java
adapters.NavDrawerListAdapter.java
adapters.ProfessorCardAdapter.java
adapters.TaskCardAdapter.java
adapters.TasksTabPagerAdapter.java
com.example.uniutilproject.BuildConfig.java
com.example.uniutilproject.UniUtil_MainActivity.java
days_fragments.FridayTaskFragment.java
days_fragments.MondayTaskFragment.java
days_fragments.SaturdayTaskFragment.java
days_fragments.SundayTaskFragment.java
days_fragments.ThursdayTaskFragment.java
days_fragments.TuesdayTaskFragment.java
days_fragments.WednesdayTaskFragment.java
dialog_fragments.DatePickerDialogFragment.java
dialog_fragments.MatesDialogFragment.java
dialog_fragments.ProfessorsDialogFragment.java
dialog_fragments.TimePickerDialogFragment.java
fragments.AddCourseFragment.java
fragments.AddProfFragment.java
fragments.AddTaskFragment.java
fragments.CoursesFragment.java
fragments.CursorLoaderListFragment.java
fragments.ExamsFragment.java
fragments.ExamsPassedFragment.java
fragments.ExamsPendingFragment.java
fragments.HomeFragment.java
fragments.MatesFragment.java
fragments.ProfessorsFragment.java
fragments.StudyPlanFragment.java
fragments.TasksFragment.java
fragments.UpdateCourseFragment.java
fragments.UpdateProfessorFragment.java
interfaces.NoticeDialogListener.java
interfaces.package-info.java
model.Course.java
model.Days.java
model.MyParcelable.java
model.NavDrawerItem.java
model.Professor.java
model.Task.java