-
Notifications
You must be signed in to change notification settings - Fork 21
검색 시작 년도 및 마지막 년도 설정 기능 추가 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.example.yeseul.movieapp.view.main; | ||
|
|
||
| import android.app.AlertDialog; | ||
| import android.app.Dialog; | ||
| import android.content.DialogInterface; | ||
| import android.databinding.DataBindingUtil; | ||
| import android.os.Bundle; | ||
| import android.support.annotation.NonNull; | ||
| import android.support.annotation.Nullable; | ||
| import android.support.v4.app.DialogFragment; | ||
| import android.view.LayoutInflater; | ||
| import android.widget.NumberPicker; | ||
|
|
||
| import com.example.yeseul.movieapp.R; | ||
| import com.example.yeseul.movieapp.databinding.YearDialogBinding; | ||
| import com.example.yeseul.movieapp.utils.BindingUtil; | ||
|
|
||
| public class NumberPickerDialog extends DialogFragment { | ||
| private MainContract.Presenter listener; | ||
| private YearDialogBinding binding; | ||
| @NonNull | ||
| @Override | ||
| public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { | ||
| binding= DataBindingUtil.inflate(LayoutInflater.from(getContext()),R.layout.year_dialog,null,false); | ||
| binding.setDialog(this); | ||
| LayoutInflater inflater =getActivity().getLayoutInflater(); | ||
| AlertDialog.Builder builder=new AlertDialog.Builder(getActivity()); | ||
| builder.setTitle("제작년도 설정"); | ||
| builder.setView(binding.getRoot()) | ||
| .setPositiveButton("OK",((dialog, which) -> listener.onYearButtonClicked(binding.yearFrom.getValue(),binding.yearTo.getValue()))) | ||
| .setNegativeButton("Cancel", ((dialog, which) ->listener.onYearButtonClicked(0,0))); | ||
| binding.yearFrom.setMinValue(1990); | ||
| binding.yearFrom.setMaxValue(2019); | ||
| binding.yearFrom.setValue(2019); | ||
| binding.yearTo.setMinValue(1990); | ||
| binding.yearTo.setMaxValue(2019); | ||
| binding.yearTo.setValue(2019); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 최소값이 1990이 최대인가요??
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 조언 감사합니다 |
||
| binding.yearFrom.setWrapSelectorWheel(false); | ||
| binding.yearTo.setWrapSelectorWheel(false); | ||
| return builder.create(); | ||
| } | ||
|
|
||
| public MainContract.Presenter getListener(){ | ||
| return listener; | ||
| } | ||
| public void setListener(MainContract.Presenter listener){ | ||
| this.listener=listener; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <layout xmlns:tools="http://schemas.android.com/tools" | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
| <data> | ||
| <variable | ||
| name="dialog" | ||
| type="com.example.yeseul.movieapp.view.main.NumberPickerDialog"/> | ||
| </data> | ||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical"> | ||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="horizontal" | ||
| android:weightSum="1"> | ||
| <TextView | ||
| android:id="@+id/year_from_text" | ||
| android:layout_width="wrap_content" | ||
| android:gravity="center" | ||
| android:layout_height="wrap_content" | ||
| android:layout_weight="0.5" | ||
| android:text="시작년도" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| <TextView | ||
| android:id="@+id/year_to_text" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:gravity="center" | ||
| android:layout_weight="0.5" | ||
| android:text="종료년도" /> | ||
| </LinearLayout> | ||
| <LinearLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="horizontal" | ||
| android:weightSum="1"> | ||
| <NumberPicker | ||
| android:id="@+id/year_From" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_weight="0.5"> | ||
|
|
||
| </NumberPicker> | ||
|
|
||
| <NumberPicker | ||
| android:id="@+id/year_To" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_weight="0.5"> | ||
|
|
||
| </NumberPicker> | ||
| </LinearLayout> | ||
| </LinearLayout> | ||
| </layout> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그냥 Dialog 대신 DialogFragment 를 이용할 때 얻을 수 있는 장점은 무엇인가요 ?