Search in sources :

Example 1 with MainActivity

use of com.example.mobileterm.MainActivity in project MobileTerm by vivi108.

the class iCalendarFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_i_calendar, container, false);
    calendarView = rootView.findViewById(R.id.calendarView);
    // 중간에 몇월 몇일 보여주는
    diaryTextView = rootView.findViewById(R.id.diaryTextView);
    save_Btn = rootView.findViewById(R.id.save_Btn);
    del_Btn = rootView.findViewById(R.id.del_Btn);
    cha_Btn = rootView.findViewById(R.id.cha_Btn);
    // 일정 추가된 날짜 클릭 시 어떤 일정있나 보여주는 칸
    textView2 = rootView.findViewById(R.id.textView2);
    // textView3 = rootView.findViewById(R.id.textView3); //맨 위 달력이라 표시
    // 선택 날짜 일정 수정하는 칸
    contextEditText = rootView.findViewById(R.id.contextEditText);
    ctype = rootView.findViewById(R.id.ctype);
    radIndividual = rootView.findViewById(R.id.radIndividual);
    radGroup = rootView.findViewById(R.id.radGroup);
    radGroup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            int radioId = ctype.getCheckedRadioButtonId();
            if (radGroup.getId() == radioId) {
                MainActivity activity = (MainActivity) getActivity();
                activity.onFragmentChanged(1);
            }
        }
    });
    // 날짜가 변경될 때 이벤트를 받기 위한 리스너
    calendarView.setOnDateChangedListener(new OnDateSelectedListener() {

        // 선택된 날짜를 알려주는 메서드
        @Override
        public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
            // 중간 날짜 표시, 저장 버튼, 일정 수정 - 보이도록
            diaryTextView.setVisibility(View.VISIBLE);
            save_Btn.setVisibility(View.VISIBLE);
            contextEditText.setVisibility(View.VISIBLE);
            // 어떤 일정 있나, 수정, 삭제 버튼 - 안보이도록 - 아직 어떤 작업도 수행 안됐으니
            textView2.setVisibility(View.INVISIBLE);
            cha_Btn.setVisibility(View.INVISIBLE);
            del_Btn.setVisibility(View.INVISIBLE);
            // 중간 날짜 어케 보여줄지 + 일정 추가되는 칸 초기화
            diaryTextView.setText(String.format("%d / %d / %d", date.getYear(), date.getMonth() + 1, date.getDay()));
            contextEditText.setText("");
            // 빨간 점 찍기 -------------
            calendarView.setSelectedDate(CalendarDay.today());
            calendarView.addDecorator(new EventDecorator(Color.RED, Collections.singleton(CalendarDay.today())));
            // 이제 날짜 체크 후 일정 삽입 or 수정 작업
            checkDay(date.getYear(), date.getMonth() + 1, date.getDay());
        }
    });
    // 저장 버튼 클릭 시
    save_Btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // 아마 일정 저장
            saveDiary(readDay);
            // 일정을 쓰면 그 내용을 str로 저장
            str = contextEditText.getText().toString();
            // t2(일정 보여주는)에 str 저장
            textView2.setText(str);
            // 저장 버튼을 클릭 한 후 - 저장버튼과 edittext 안보이고 수정, 삭제 버튼, 일정 보여주는 거 보이게함
            save_Btn.setVisibility(View.INVISIBLE);
            cha_Btn.setVisibility(View.VISIBLE);
            del_Btn.setVisibility(View.VISIBLE);
            contextEditText.setVisibility(View.INVISIBLE);
            textView2.setVisibility(View.VISIBLE);
        }
    });
    return rootView;
}
Also used : ViewGroup(android.view.ViewGroup) MainActivity(com.example.mobileterm.MainActivity) OnDateSelectedListener(com.prolificinteractive.materialcalendarview.OnDateSelectedListener) MaterialCalendarView(com.prolificinteractive.materialcalendarview.MaterialCalendarView) CalendarDay(com.prolificinteractive.materialcalendarview.CalendarDay) MaterialCalendarView(com.prolificinteractive.materialcalendarview.MaterialCalendarView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with MainActivity

use of com.example.mobileterm.MainActivity in project MobileTerm by vivi108.

the class gCalendarFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_g_calendar, container, false);
    calendarView = rootView.findViewById(R.id.calendarView);
    // 중간에 몇월 몇일 보여주는
    diaryTextView = rootView.findViewById(R.id.diaryTextView);
    save_Btn = rootView.findViewById(R.id.save_Btn);
    del_Btn = rootView.findViewById(R.id.del_Btn);
    cha_Btn = rootView.findViewById(R.id.cha_Btn);
    // 일정 추가된 날짜 클릭 시 어떤 일정있나 보여주는 칸
    textView2 = rootView.findViewById(R.id.textView2);
    // textView3 = rootView.findViewById(R.id.textView3); //맨 위 달력이라 표시
    // 선택 날짜 일정 수정하는 칸
    contextEditText = rootView.findViewById(R.id.contextEditText);
    ctype = rootView.findViewById(R.id.ctype);
    radIndividual = rootView.findViewById(R.id.radIndividual);
    radGroup = rootView.findViewById(R.id.radGroup);
    radIndividual.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            int radioId = ctype.getCheckedRadioButtonId();
            if (radIndividual.getId() == radioId) {
                MainActivity activity = (MainActivity) getActivity();
                activity.onFragmentChanged(0);
            }
        }
    });
    // 날짜가 변경될 때 이벤트를 받기 위한 리스너
    calendarView.setOnDateChangedListener(new OnDateSelectedListener() {

        // 선택된 날짜를 알려주는 메서드
        @Override
        public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
            // 중간 날짜 표시, 저장 버튼, 일정 수정 - 보이도록
            diaryTextView.setVisibility(View.VISIBLE);
            save_Btn.setVisibility(View.VISIBLE);
            contextEditText.setVisibility(View.VISIBLE);
            // 어떤 일정 있나, 수정, 삭제 버튼 - 안보이도록 - 아직 어떤 작업도 수행 안됐으니
            textView2.setVisibility(View.INVISIBLE);
            cha_Btn.setVisibility(View.INVISIBLE);
            del_Btn.setVisibility(View.INVISIBLE);
            // 중간 날짜 어케 보여줄지 + 일정 추가되는 칸 초기화
            diaryTextView.setText(String.format("%d / %d / %d", date.getYear(), date.getMonth() + 1, date.getDay()));
            contextEditText.setText("");
            // 빨간 점 찍기 -------------
            calendarView.setSelectedDate(CalendarDay.today());
            calendarView.addDecorator(new EventDecorator(Color.RED, Collections.singleton(CalendarDay.today())));
            // 이제 날짜 체크 후 일정 삽입 or 수정 작업
            checkDay(date.getYear(), date.getMonth() + 1, date.getDay());
        }
    });
    // 저장 버튼 클릭 시
    save_Btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // 아마 일정 저장
            saveDiary(readDay);
            // 일정을 쓰면 그 내용을 str로 저장
            str = contextEditText.getText().toString();
            // t2(일정 보여주는)에 str 저장
            textView2.setText(str);
            // 저장 버튼을 클릭 한 후 - 저장버튼과 edittext 안보이고 수정, 삭제 버튼, 일정 보여주는 거 보이게함
            save_Btn.setVisibility(View.INVISIBLE);
            cha_Btn.setVisibility(View.VISIBLE);
            del_Btn.setVisibility(View.VISIBLE);
            contextEditText.setVisibility(View.INVISIBLE);
            textView2.setVisibility(View.VISIBLE);
        }
    });
    return rootView;
}
Also used : ViewGroup(android.view.ViewGroup) MainActivity(com.example.mobileterm.MainActivity) OnDateSelectedListener(com.prolificinteractive.materialcalendarview.OnDateSelectedListener) MaterialCalendarView(com.prolificinteractive.materialcalendarview.MaterialCalendarView) CalendarDay(com.prolificinteractive.materialcalendarview.CalendarDay) MaterialCalendarView(com.prolificinteractive.materialcalendarview.MaterialCalendarView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with MainActivity

use of com.example.mobileterm.MainActivity in project MobileTerm by vivi108.

the class BoardItemFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_board_item, container, false);
    MainActivity mainActivity = (MainActivity) getActivity();
    BoardInfo selectedBoardItem = mainActivity.sendBoardItem();
    TextView nameTextViewBoardItem = rootView.findViewById(R.id.nameTextViewBoardItem);
    TextView contentTextViewBoardItem = rootView.findViewById(R.id.contentTextViewBoardItem);
    TextView titleTextViewBoardItem = rootView.findViewById(R.id.titleTextViewBoardItem);
    nameTextViewBoardItem.setText(selectedBoardItem.getName());
    contentTextViewBoardItem.setText(selectedBoardItem.getContent());
    titleTextViewBoardItem.setText(selectedBoardItem.getTitle());
    return rootView;
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) MainActivity(com.example.mobileterm.MainActivity) Nullable(androidx.annotation.Nullable)

Example 4 with MainActivity

use of com.example.mobileterm.MainActivity in project MobileTerm by vivi108.

the class BoardFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_board_main, container, false);
    searchEditText = rootView.findViewById(R.id.searchEditText);
    listView = rootView.findViewById(R.id.listView);
    db = FirebaseFirestore.getInstance();
    db.collection("BulletinBoard").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {

        @Override
        public void onComplete(@NonNull Task<QuerySnapshot> task) {
            if (task.isSuccessful()) {
                for (QueryDocumentSnapshot document : task.getResult()) {
                    if (document.exists()) {
                        String title = (String) document.getData().get("Title");
                        String content = (String) document.getData().get("Content");
                        String tags = (String) document.getData().get("Tags");
                        String name = (String) document.getData().get("Name");
                        BoardInfo data = new BoardInfo(title, tags, content, name);
                        arrayList.add(data);
                    }
                }
                adapter = new ListViewAdapter(rootView.getContext(), arrayList);
                listView.setAdapter(adapter);
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                        MainActivity activity = (MainActivity) getActivity();
                        Log.d("boardItemClicked", "by setOnItemCLick");
                        activity.onFragmentChanged(arrayList.get(i));
                    }
                });
            }
        }
    });
    rootView.findViewById(R.id.searchButton).setOnClickListener(onClickListener);
    rootView.findViewById(R.id.filterButton).setOnClickListener(onClickListener);
    rootView.findViewById(R.id.startWriteButton).setOnClickListener(onClickListener);
    return rootView;
}
Also used : QueryDocumentSnapshot(com.google.firebase.firestore.QueryDocumentSnapshot) ViewGroup(android.view.ViewGroup) MainActivity(com.example.mobileterm.MainActivity) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) QuerySnapshot(com.google.firebase.firestore.QuerySnapshot) AdapterView(android.widget.AdapterView) Nullable(androidx.annotation.Nullable)

Aggregations

ViewGroup (android.view.ViewGroup)4 MainActivity (com.example.mobileterm.MainActivity)4 View (android.view.View)3 TextView (android.widget.TextView)3 Nullable (androidx.annotation.Nullable)2 CalendarDay (com.prolificinteractive.materialcalendarview.CalendarDay)2 MaterialCalendarView (com.prolificinteractive.materialcalendarview.MaterialCalendarView)2 OnDateSelectedListener (com.prolificinteractive.materialcalendarview.OnDateSelectedListener)2 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 QueryDocumentSnapshot (com.google.firebase.firestore.QueryDocumentSnapshot)1 QuerySnapshot (com.google.firebase.firestore.QuerySnapshot)1