forked from yslee94/movieApp
-
Notifications
You must be signed in to change notification settings - Fork 21
이미지 슬라이딩 및 검색 결과 count #26
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
Open
yslee94
wants to merge
2
commits into
boostcampth:master
Choose a base branch
from
yslee94:movie
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
app/src/main/java/com/example/yeseul/movieapp/view/image/ImageActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package com.example.yeseul.movieapp.view.image; | ||
|
|
||
| import android.net.Uri; | ||
| import android.os.Bundle; | ||
| import android.support.annotation.Nullable; | ||
| import android.support.customtabs.CustomTabsIntent; | ||
| import android.support.v7.widget.LinearLayoutManager; | ||
| import android.support.v7.widget.PagerSnapHelper; | ||
| import android.support.v7.widget.SnapHelper; | ||
| import android.view.WindowManager; | ||
| import android.widget.LinearLayout; | ||
|
|
||
| import com.example.yeseul.movieapp.R; | ||
| import com.example.yeseul.movieapp.data.source.movie.MovieRepository; | ||
| import com.example.yeseul.movieapp.databinding.ActivityImageBinding; | ||
| import com.example.yeseul.movieapp.view.BaseActivity; | ||
|
|
||
| public class ImageActivity extends BaseActivity<ActivityImageBinding, ImagePresenter> implements ImageContract.View { | ||
|
|
||
| public static String EXTRA_IMAGE_POSITION = "EXTRA_IMAGE_POSITION"; | ||
|
|
||
| private ImageAdapter adapter; | ||
|
|
||
| private int position; | ||
|
|
||
| @Override | ||
| protected int getLayoutId() { | ||
| return R.layout.activity_image; | ||
| } | ||
|
|
||
| @Override | ||
| protected ImagePresenter getPresenter() { | ||
| return new ImagePresenter(this, MovieRepository.getInstance()); | ||
| } | ||
|
|
||
| @Override | ||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
|
|
||
| position = getIntent().getIntExtra(EXTRA_IMAGE_POSITION, 0); | ||
|
|
||
| // 팝업창 레이아웃 크기 변경 | ||
| WindowManager.LayoutParams params = getWindow().getAttributes(); | ||
| params.width = LinearLayout.LayoutParams.MATCH_PARENT; | ||
| params.height = LinearLayout.LayoutParams.MATCH_PARENT; | ||
| getWindow().setAttributes(params); | ||
|
|
||
| // 어댑터 생성 | ||
| adapter = new ImageAdapter(this, null); | ||
|
|
||
| presenter.setAdapterView(adapter); | ||
| presenter.setAdapterModel(adapter); | ||
|
|
||
| initView(); | ||
|
|
||
| presenter.onViewCreated(); | ||
| } | ||
|
|
||
| private void initView() { | ||
|
|
||
| // 리사이클러뷰 생성 | ||
| binding.recyclerImage.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); | ||
| binding.recyclerImage.setAdapter(adapter); | ||
|
|
||
| SnapHelper snapHelper = new PagerSnapHelper(); | ||
| snapHelper.attachToRecyclerView(binding.recyclerImage); | ||
|
|
||
| // 터치 발생한 곳 position 으로 넘기기 | ||
| binding.recyclerImage.scrollToPosition(position); | ||
|
|
||
| // 닫기 버튼 리스너 등록 | ||
| binding.btnClose.setOnClickListener(v -> finish()); | ||
| } | ||
|
|
||
| /** | ||
| * 영화 상세 정보 URL 로 연결 */ | ||
| @Override | ||
| public void startMovieDetailPage(String linkUrl) { | ||
|
|
||
| CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() | ||
| .setToolbarColor(getResources().getColor(R.color.colorPrimary)) | ||
| .build(); | ||
|
|
||
| customTabsIntent.launchUrl(this, Uri.parse(linkUrl)); | ||
| } | ||
|
|
||
| } |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/example/yeseul/movieapp/view/image/ImageAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.example.yeseul.movieapp.view.image; | ||
|
|
||
| import android.content.Context; | ||
| import android.databinding.DataBindingUtil; | ||
| import android.support.annotation.NonNull; | ||
| import android.support.v7.widget.RecyclerView; | ||
| import android.util.Log; | ||
| import android.view.LayoutInflater; | ||
| import android.view.View; | ||
| import android.view.ViewGroup; | ||
|
|
||
| import com.example.yeseul.movieapp.R; | ||
| import com.example.yeseul.movieapp.databinding.HolderMovieImageBinding; | ||
| import com.example.yeseul.movieapp.pojo.Movie; | ||
| import com.example.yeseul.movieapp.view.adapter.BaseRecyclerAdapter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class ImageAdapter extends BaseRecyclerAdapter<Movie, ImageAdapter.ViewHolder> { | ||
|
|
||
| public ImageAdapter(Context context, List<Movie> itemList) { | ||
| super(context, itemList); | ||
| } | ||
|
|
||
| @Override | ||
| protected void onBindView(ViewHolder holder, int position) { | ||
| holder.binding.setItem(itemList.get(position)); | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) { | ||
| View view = LayoutInflater.from(context).inflate(R.layout.holder_movie_image, parent, false); | ||
| return new ViewHolder(view); | ||
| } | ||
|
|
||
| public class ViewHolder extends RecyclerView.ViewHolder{ | ||
|
|
||
| HolderMovieImageBinding binding; | ||
|
|
||
| public ViewHolder(@NonNull View itemView) { | ||
| super(itemView); | ||
| binding = DataBindingUtil.bind(itemView); | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/example/yeseul/movieapp/view/image/ImageContract.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.example.yeseul.movieapp.view.image; | ||
|
|
||
| import com.example.yeseul.movieapp.pojo.Movie; | ||
| import com.example.yeseul.movieapp.view.BasePresenter; | ||
| import com.example.yeseul.movieapp.view.BaseView; | ||
| import com.example.yeseul.movieapp.view.adapter.AdapterContract; | ||
|
|
||
| public interface ImageContract { | ||
|
|
||
| interface View extends BaseView { | ||
|
|
||
| void startMovieDetailPage(String linkUrl); | ||
| } | ||
|
|
||
| interface Presenter extends BasePresenter { | ||
|
|
||
| void setAdapterView(AdapterContract.View adapterView); | ||
|
|
||
| void setAdapterModel(AdapterContract.Model<Movie> adapterModel); | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
app/src/main/java/com/example/yeseul/movieapp/view/image/ImagePresenter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.example.yeseul.movieapp.view.image; | ||
|
|
||
| import com.example.yeseul.movieapp.data.source.movie.MovieRepository; | ||
| import com.example.yeseul.movieapp.pojo.Movie; | ||
| import com.example.yeseul.movieapp.view.adapter.AdapterContract; | ||
|
|
||
| public class ImagePresenter implements ImageContract.Presenter { | ||
|
|
||
| private ImageContract.View view; | ||
| private MovieRepository repository; | ||
| private AdapterContract.View adapterView; | ||
| private AdapterContract.Model<Movie> adapterModel; | ||
|
|
||
| public ImagePresenter(ImageContract.View view, MovieRepository repository) { | ||
| this.view = view; | ||
| this.repository = repository; | ||
| } | ||
|
|
||
| @Override | ||
| public void setAdapterView(AdapterContract.View adapterView) { | ||
| this.adapterView = adapterView; | ||
| this.adapterView.setOnItemClickListener(position -> { | ||
| this.view.startMovieDetailPage(this.adapterModel.getItem(position).getLinkUrl()); | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public void setAdapterModel(AdapterContract.Model<Movie> adapterModel) { | ||
| this.adapterModel = adapterModel; | ||
| } | ||
|
|
||
| @Override | ||
| public void onViewCreated() { | ||
|
|
||
| loadItems(true); | ||
| } | ||
|
|
||
| @Override | ||
| public void loadItems(boolean isRefresh) { | ||
|
|
||
| adapterModel.addItems(repository.getSavedMovieList()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <item> | ||
| <shape> | ||
| <solid android:color="@null"/> | ||
| </shape> | ||
| </item> | ||
| <item android:right="-2dp" android:left="-2dp" android:top="-2dp"> | ||
| <shape> | ||
| <solid android:color="@null"/> | ||
| <stroke android:color="@color/colorDivider" android:width="1dp"/> | ||
| </shape> | ||
| </item> | ||
| </layer-list> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <vector android:height="40dp" android:viewportHeight="24.0" | ||
| android:viewportWidth="24.0" android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <path android:fillColor="#FFFFFFFF" android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> | ||
| </vector> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
구조를 세분화 시키신 것이 인상 깊었습니다,
remoteDataSource를 한 번 더 감싸셨는데 싱글톤 패턴을 두 번 적용하신 이유가 궁금합니다