-
Notifications
You must be signed in to change notification settings - Fork 21
영화앱 필터(장르, 국가) 선택 #4
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 1 commit
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,72 @@ | ||
| package com.example.yeseul.movieapp.view.custom; | ||
|
|
||
| import java.util.HashMap; | ||
|
|
||
| public class FilterView { | ||
|
|
||
| static HashMap<String,String> genreMap = null; | ||
| static HashMap<String,String> countryMap = null; | ||
|
|
||
| public synchronized static HashMap<String,String> getGenreMap() { | ||
|
|
||
| if( genreMap == null) { | ||
|
|
||
| genreMap = new HashMap<>(); | ||
|
|
||
| genreMap.put("전체", "0"); | ||
| genreMap.put("드라마", "1"); | ||
| genreMap.put("판타지", "2"); | ||
| genreMap.put("서부", "3"); | ||
| genreMap.put("공포", "4"); | ||
| genreMap.put("로맨스", "5"); | ||
| genreMap.put("모험", "6"); | ||
| genreMap.put("스릴러", "7"); | ||
| genreMap.put("느와르", "8"); | ||
| genreMap.put("컬트", "9"); | ||
| genreMap.put("다큐멘터리", "10"); | ||
| genreMap.put("코미디", "11"); | ||
| genreMap.put("가족", "12"); | ||
| genreMap.put("미스터리", "13"); | ||
| genreMap.put("전쟁", "14"); | ||
| genreMap.put("애니메이션", "15"); | ||
| genreMap.put("범죄", "16"); | ||
| genreMap.put("뮤지컬", "17"); | ||
| genreMap.put("SF", "18"); | ||
| genreMap.put("액션", "19"); | ||
| genreMap.put("무협", "20"); | ||
| genreMap.put("에로", "21"); | ||
| genreMap.put("서스펜스", "22"); | ||
| genreMap.put("서사", "23"); | ||
| genreMap.put("블랙코미디", "24"); | ||
| genreMap.put("실험", "25"); | ||
| genreMap.put("영화카툰", "26"); | ||
| genreMap.put("영화음악", "27"); | ||
| genreMap.put("영화패러디포스터", "28"); | ||
|
|
||
| } | ||
|
|
||
| return genreMap; | ||
| } | ||
|
|
||
|
|
||
| public synchronized static HashMap<String,String> getCountryMap() { | ||
|
|
||
| if( countryMap == null) { | ||
|
|
||
| countryMap = new HashMap<>(); | ||
|
|
||
| countryMap.put("전체", ""); | ||
| countryMap.put("한국", "KR"); | ||
| countryMap.put("일본", "JP"); | ||
| countryMap.put("미국", "US"); | ||
| countryMap.put("홍콩", "HK"); | ||
| countryMap.put("영국", "GB"); | ||
| countryMap.put("프랑스", "FR"); | ||
| countryMap.put("기타", "ETC"); | ||
|
|
||
| } | ||
|
|
||
| return countryMap; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,32 @@ | ||
| package com.example.yeseul.movieapp.view.main; | ||
|
|
||
| import android.content.DialogInterface; | ||
| import android.net.Uri; | ||
| import android.os.Bundle; | ||
| import android.support.annotation.NonNull; | ||
| import android.support.customtabs.CustomTabsIntent; | ||
| import android.support.v7.app.AlertDialog; | ||
| import android.support.v7.widget.DividerItemDecoration; | ||
| import android.support.v7.widget.LinearLayoutManager; | ||
| import android.support.v7.widget.RecyclerView; | ||
| import android.text.Html; | ||
| import android.text.TextUtils; | ||
| import android.view.inputmethod.EditorInfo; | ||
| import android.widget.Toast; | ||
|
|
||
| import com.example.yeseul.movieapp.R; | ||
| import com.example.yeseul.movieapp.data.source.movie.MovieRepository; | ||
| import com.example.yeseul.movieapp.databinding.ActivityMovieBinding; | ||
| import com.example.yeseul.movieapp.utils.KeyboardUtil; | ||
| import com.example.yeseul.movieapp.view.BaseActivity; | ||
|
|
||
| import java.util.HashMap; | ||
|
|
||
| public class MainActivity extends BaseActivity<ActivityMovieBinding, MainPresenter> implements MainContract.View { | ||
|
|
||
| private MovieListAdapter adapter; | ||
| private String genre; | ||
| private String country; | ||
|
|
||
|
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. |
||
| @Override | ||
| protected int getLayoutId() { | ||
|
|
@@ -44,6 +51,9 @@ protected void onCreate(Bundle savedInstanceState) { | |
| initView(); | ||
|
|
||
| presenter.onViewCreated(); | ||
|
|
||
| country = ""; | ||
|
|
||
| } | ||
|
|
||
| private void initView() { | ||
|
|
@@ -66,6 +76,7 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat | |
| } | ||
| }); | ||
|
|
||
|
|
||
| // 키보드 검색 버튼 리스너 등록 | ||
| binding.searchBox.etSearch.setOnEditorActionListener((v, actionId, event) -> { | ||
| if(actionId == EditorInfo.IME_ACTION_SEARCH){ | ||
|
|
@@ -77,6 +88,63 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat | |
|
|
||
| // 검색 버튼 리스너 등록 | ||
| binding.searchBox.btnSubmit.setOnClickListener(v -> onSearchButtonClicked()); | ||
|
|
||
| // 필터 버튼 리스터 등록 | ||
| binding.searchBox.btnFilter.setOnClickListener(v -> onFilterButtonClicked()); | ||
|
|
||
| } | ||
|
|
||
| //필터 설정 | ||
| private void onFilterButtonClicked() { | ||
|
|
||
|
|
||
| /* HashMap <String,String> countryMap = new HashMap<>(); | ||
| countryMap.put("전체",""); | ||
| countryMap.put("한국","KR"); | ||
| countryMap.put("일본","JP"); | ||
| countryMap.put("미국","US"); | ||
| countryMap.put("홍콩","HK"); | ||
| countryMap.put("영국","GB"); | ||
| countryMap.put("프랑스","FR"); | ||
| countryMap.put("기타","ETC");*/ | ||
|
|
||
|
wjddnwls918 marked this conversation as resolved.
Outdated
|
||
| //국가 선택 | ||
| AlertDialog.Builder cDialog = new AlertDialog.Builder(this); | ||
| cDialog.setTitle(R.string.country) | ||
| .setItems(R.array.country, new DialogInterface.OnClickListener() { | ||
| @Override | ||
| public void onClick(DialogInterface dialog, int which) { | ||
| //country = countryMap.get(getResources().getStringArray(R.array.country)[which]); | ||
| country = getResources().getStringArray(R.array.country)[which]; | ||
| } | ||
| }).setOnDismissListener(new DialogInterface.OnDismissListener() { | ||
|
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. 인터페이스를 람다 표현식으로 사용하는건 어떨까요?
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. 넵 참고하겠습니다 |
||
| @Override | ||
| public void onDismiss(DialogInterface dialog) { | ||
| presenter.setFilter(genre, country); | ||
| } | ||
| }); | ||
|
|
||
|
|
||
| //장르 선택 | ||
| AlertDialog.Builder gDialog = new AlertDialog.Builder(this); | ||
| gDialog.setTitle(R.string.genre) | ||
| .setItems(R.array.genre, new DialogInterface.OnClickListener() { | ||
| @Override | ||
| public void onClick(DialogInterface dialog, int which) { | ||
| //genre = Integer.toString(which); | ||
| genre = getResources().getStringArray(R.array.genre)[which]; | ||
|
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.
|
||
| } | ||
| }).setOnDismissListener(new DialogInterface.OnDismissListener() { | ||
| @Override | ||
| public void onDismiss(DialogInterface dialog) { | ||
| //orderFlag = true; | ||
| cDialog.show(); | ||
| } | ||
| }); | ||
|
|
||
| gDialog.show(); | ||
|
|
||
|
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -87,7 +155,7 @@ private void onSearchButtonClicked(){ | |
| String searchKey = binding.searchBox.etSearch.getText().toString(); | ||
|
|
||
| if(!TextUtils.isEmpty(searchKey)) { | ||
| presenter.onSearchButtonClicked(searchKey); | ||
| presenter.onSearchButtonClicked(searchKey,genre,country); | ||
| binding.recyclerMovie.scrollToPosition(0); | ||
| binding.emptyView.setText(""); | ||
| KeyboardUtil.closeKeyboard(this, binding.searchBox.etSearch); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <string-array name="genre"> | ||
|
|
||
| <item> 전체 </item> | ||
| <item> 드라마 </item> | ||
| <item> 판타지 </item> | ||
| <item> 서부 </item> | ||
| <item> 공포 </item> | ||
| <item> 로맨스 </item> | ||
| <item> 모험 </item> | ||
| <item> 스릴러 </item> | ||
| <item> 느와르 </item> | ||
| <item> 컬트 </item> | ||
| <item> 다큐멘터리 </item> | ||
| <item> 코미디 </item> | ||
| <item> 가족 </item> | ||
| <item> 미스터리 </item> | ||
| <item> 전쟁 </item> | ||
| <item> 애니메이션 </item> | ||
| <item> 범죄 </item> | ||
| <item> 뮤지컬 </item> | ||
| <item> SF </item> | ||
| <item> 액션 </item> | ||
| <item> 무협 </item> | ||
| <item> 에로 </item> | ||
| <item> 서스펜스 </item> | ||
| <item> 서사 </item> | ||
| <item> 블랙코미디 </item> | ||
| <item> 실험 </item> | ||
| <item> 영화카툰 </item> | ||
| <item> 영화음악 </item> | ||
| <item> 영화패러디포스터 </item> | ||
|
|
||
| </string-array> | ||
|
|
||
| <string-array name="country"> | ||
|
|
||
| <item> 전체 </item> | ||
| <item> 한국 </item> | ||
| <item> 일본 </item> | ||
| <item> 미국 </item> | ||
| <item> 홍콩 </item> | ||
| <item> 영국 </item> | ||
| <item> 프랑스 </item> | ||
| <item> 기타 </item> | ||
|
|
||
| </string-array> | ||
|
|
||
| </resources> | ||
|
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. 고생하셨습니다. 확실히 영화를 검색하는 것에 있어 필터를 검색하는 것은 좋은 아이디어라고 생각합니다.
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. 위에서 조언해주신대로 presenter에서 처리하는 방법을 생각해봐야겠네요 |
||
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.
com.example.yeseul.movieapp.view.custom패키지는 커스텀 뷰를 보관하는 것으로 이해하고 있습니다.FilterView는 뷰의 목적이 아닌 값을 보관하기 위한 것 같은데 해당 패키지에 있는 이유가 있나요?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.
mvp 패턴에 대해 잘 숙지하지 못해서 패키지를 어디에 분류할까 생각하다 넣었네요 .. 만약에 넣는다면 어디가 좋을까요 ??