diff --git a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardAdapter.java b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardAdapter.java new file mode 100644 index 0000000..45207b6 --- /dev/null +++ b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardAdapter.java @@ -0,0 +1,14 @@ +package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map; + +import android.support.v7.widget.CardView; + +public interface CardAdapter { + + int MAX_ELEVATION_FACTOR = 8; + + float getBaseElevation(); + + CardView getCardViewAt(int position); + + int getCount(); +} \ No newline at end of file diff --git a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardFragment.java b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardFragment.java new file mode 100644 index 0000000..027900e --- /dev/null +++ b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardFragment.java @@ -0,0 +1,30 @@ +package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v7.widget.CardView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.depromeet.hanriver.hanrivermeetup.R; + +public class CardFragment extends Fragment { + private CardView mCardView; + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.tour_event_info_card, container, false); + mCardView = view.findViewById(R.id.cardView); + mCardView.setMaxCardElevation(mCardView.getCardElevation() + * CardAdapter.MAX_ELEVATION_FACTOR); + return view; + } + + public CardView getCardView() { + return mCardView; + } +} diff --git a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardFragmentPagerAdapter.java b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardFragmentPagerAdapter.java new file mode 100644 index 0000000..90e43d4 --- /dev/null +++ b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardFragmentPagerAdapter.java @@ -0,0 +1,59 @@ +package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentStatePagerAdapter; +import android.support.v7.widget.CardView; +import android.view.View; +import android.view.ViewGroup; + +import java.util.ArrayList; +import java.util.List; + +public class CardFragmentPagerAdapter extends FragmentStatePagerAdapter implements CardAdapter { + + private List mFragments; + private float mBaseElevation; + + public CardFragmentPagerAdapter(FragmentManager fm, float baseElevation) { + super(fm); + mFragments = new ArrayList<>(); + mBaseElevation = baseElevation; + + for(int i = 0; i< 5; i++){ + addCardFragment(new CardFragment()); + } + } + + @Override + public float getBaseElevation() { + return mBaseElevation; + } + + @Override + public CardView getCardViewAt(int position) { + return mFragments.get(position).getCardView(); + } + + @Override + public int getCount() { + return mFragments.size(); + } + + @Override + public Fragment getItem(int position) { + return mFragments.get(position); + } + + @Override + public Object instantiateItem(ViewGroup container, int position) { + Object fragment = super.instantiateItem(container, position); + mFragments.set(position, (CardFragment) fragment); + return fragment; + } + + public void addCardFragment(CardFragment fragment) { + mFragments.add(fragment); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardItem.java b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardItem.java new file mode 100644 index 0000000..1ea97ff --- /dev/null +++ b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardItem.java @@ -0,0 +1,19 @@ +package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map; + +public class CardItem { + private String mTextResource; + private String mTitleResource; + + public CardItem(String title, String text) { + mTitleResource = title; + mTextResource = text; + } + + public String getText() { + return mTextResource; + } + + public String getTitle() { + return mTitleResource; + } +} diff --git a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardPagerAdapter.java b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardPagerAdapter.java new file mode 100644 index 0000000..e4f1320 --- /dev/null +++ b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/CardPagerAdapter.java @@ -0,0 +1,80 @@ +package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map; + +import android.support.v4.view.PagerAdapter; +import android.support.v7.widget.CardView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.depromeet.hanriver.hanrivermeetup.R; + +import java.util.ArrayList; +import java.util.List; + +public class CardPagerAdapter extends PagerAdapter implements CardAdapter { + + private List mViews; + private List mData; + private float mBaseElevation; + + public CardPagerAdapter() { + mData = new ArrayList<>(); + mViews = new ArrayList<>(); + } + + public void addCardItem(CardItem item) { + mViews.add(null); + mData.add(item); + } + + public float getBaseElevation() { + return mBaseElevation; + } + + @Override + public CardView getCardViewAt(int position) { + return mViews.get(position); + } + + @Override + public int getCount() { + return mData.size(); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view == object; + } + + @Override + public Object instantiateItem(ViewGroup container, int position) { + View view = LayoutInflater.from(container.getContext()) + .inflate(R.layout.tour_event_info_card, container, false); + container.addView(view); + bind(mData.get(position), view); + CardView cardView = view.findViewById(R.id.cardView); + + if (mBaseElevation == 0) { + mBaseElevation = cardView.getCardElevation(); + } + + cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR); + mViews.set(position, cardView); + return view; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object object) { + container.removeView((View) object); + mViews.set(position, null); + } + + private void bind(CardItem item, View view) { + TextView titleTextView = view.findViewById(R.id.title); + TextView addressTextView = view.findViewById(R.id.address); + titleTextView.setText(item.getTitle()); + addressTextView.setText(item.getText()); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/ShadowTransformer.java b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/ShadowTransformer.java new file mode 100644 index 0000000..431704e --- /dev/null +++ b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/ShadowTransformer.java @@ -0,0 +1,108 @@ +package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map; +import android.support.v4.view.ViewPager; +import android.support.v7.widget.CardView; +import android.view.View; + +public class ShadowTransformer implements ViewPager.OnPageChangeListener, ViewPager.PageTransformer { + + private ViewPager mViewPager; + private CardAdapter mAdapter; + private float mLastOffset; + private boolean mScalingEnabled; + + public ShadowTransformer(ViewPager viewPager, CardAdapter adapter) { + mViewPager = viewPager; + viewPager.addOnPageChangeListener(this); + mAdapter = adapter; + } + + public void enableScaling(boolean enable) { + if (mScalingEnabled && !enable) { + // shrink main card + CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem()); + if (currentCard != null) { + currentCard.animate().scaleY(1); + currentCard.animate().scaleX(1); + } + }else if(!mScalingEnabled && enable){ + // grow main card + CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem()); + if (currentCard != null) { + currentCard.animate().scaleY(1.1f); + currentCard.animate().scaleX(1.1f); + } + } + + mScalingEnabled = enable; + } + + @Override + public void transformPage(View page, float position) { + + } + + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + int realCurrentPosition; + int nextPosition; + float baseElevation = mAdapter.getBaseElevation(); + float realOffset; + boolean goingLeft = mLastOffset > positionOffset; + + // If we're going backwards, onPageScrolled receives the last position + // instead of the current one + if (goingLeft) { + realCurrentPosition = position + 1; + nextPosition = position; + realOffset = 1 - positionOffset; + } else { + nextPosition = position + 1; + realCurrentPosition = position; + realOffset = positionOffset; + } + + // Avoid crash on overscroll + if (nextPosition > mAdapter.getCount() - 1 + || realCurrentPosition > mAdapter.getCount() - 1) { + return; + } + + CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition); + + // This might be null if a fragment is being used + // and the views weren't created yet + if (currentCard != null) { + if (mScalingEnabled) { + currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset))); + currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset))); + } + currentCard.setCardElevation((baseElevation + baseElevation + * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset))); + } + + CardView nextCard = mAdapter.getCardViewAt(nextPosition); + + // We might be scrolling fast enough so that the next (or previous) card + // was already destroyed or a fragment might not have been created yet + if (nextCard != null) { + if (mScalingEnabled) { + nextCard.setScaleX((float) (1 + 0.1 * (realOffset))); + nextCard.setScaleY((float) (1 + 0.1 * (realOffset))); + } + nextCard.setCardElevation((baseElevation + baseElevation + * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset))); + } + + mLastOffset = positionOffset; + } + + @Override + public void onPageSelected(int position) { + + } + + @Override + public void onPageScrollStateChanged(int state) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/TmapFragment.java b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/TmapFragment.java index 9148fcc..b1b147f 100644 --- a/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/TmapFragment.java +++ b/app/src/main/java/com/depromeet/hanriver/hanrivermeetup/fragment/meeting/map/TmapFragment.java @@ -1,5 +1,6 @@ package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map; +import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; @@ -10,6 +11,7 @@ import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.util.Log; +import android.support.v4.view.ViewPager; import android.view.Display; import android.view.LayoutInflater; import android.view.View; @@ -53,11 +55,22 @@ public class TmapFragment extends Fragment { private CompositeDisposable mCompositeDisposable; private Bitmap bitmap; + private ViewPager mViewPager; + private CardPagerAdapter mCardAdapter; + private ShadowTransformer mCardShadowTransformer; + private CardFragmentPagerAdapter mFragmentCardAdapter; + private ShadowTransformer mFragmentCardShadowTransformer; + @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } + public static float dpToPixels(int dp, Context context) { + return dp * (context.getResources().getDisplayMetrics().density); + } + + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -81,6 +94,23 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c map.addView(mapView); + mViewPager = view.findViewById(R.id.viewPager); + + mCardAdapter = new CardPagerAdapter(); + mCardAdapter.addCardItem(new CardItem("test", "hello")); + mCardAdapter.addCardItem(new CardItem("test2", "hello2")); + mCardAdapter.addCardItem(new CardItem("test3", "hello3")); + mCardAdapter.addCardItem(new CardItem("test4", "hello4")); + mFragmentCardAdapter = new CardFragmentPagerAdapter(getActivity().getSupportFragmentManager(), + dpToPixels(2, getActivity())); + + mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter); + mFragmentCardShadowTransformer = new ShadowTransformer(mViewPager, mFragmentCardAdapter); + + mViewPager.setAdapter(mCardAdapter); + mViewPager.setPageTransformer(false, mCardShadowTransformer); + mViewPager.setOffscreenPageLimit(3); + return view; } @@ -93,6 +123,7 @@ private void setupViews(View v) { tabname[i].setTextColor(getResources().getColor(R.color.greyish)); tabLayout.addTab(tabLayout.newTab().setCustomView(tabs[i])); } + tabname[0].setText("행사정보"); tabname[1].setText("편의점"); tabname[2].setText("화장실"); @@ -224,8 +255,9 @@ private void setMarker(@NonNull final List markers) { ///////////////////Marker Click logic/////////////////////// - //풍선뷰 이미지 bitmap으로 저장 - bitmap = BitmapFactory.decodeResource(getContext().getResources(), R.mipmap.ic_launcher); + + // bitmap = BitmapFactory.decodeResource(getContext().getResources(), R.mipmap.ic_launcher); + // 풍선뷰 안의 항목 세팅 markerItem[i].setCalloutTitle(markers.get(i).getLat()); @@ -234,6 +266,7 @@ private void setMarker(@NonNull final List markers) { markerItem[i].setAutoCalloutVisible(false); markerItem[i].setCalloutRightButtonImage(bitmap); + mapView.addMarkerItem(markerItem[i].getID(), markerItem[i]); mapView.setOnMarkerClickEvent(new TMapView.OnCalloutMarker2ClickCallback() { @@ -270,4 +303,4 @@ private void initTablayoutWeight(TabLayout tablayout) { } } -} +} \ No newline at end of file diff --git a/app/src/main/res/drawable/homepage.png b/app/src/main/res/drawable/homepage.png new file mode 100644 index 0000000..66b7c49 Binary files /dev/null and b/app/src/main/res/drawable/homepage.png differ diff --git a/app/src/main/res/drawable/phone_number_icon.png b/app/src/main/res/drawable/phone_number_icon.png new file mode 100644 index 0000000..3bfe74e Binary files /dev/null and b/app/src/main/res/drawable/phone_number_icon.png differ diff --git a/app/src/main/res/layout/fragment_map.xml b/app/src/main/res/layout/fragment_map.xml index 5598fcf..cab1ab3 100644 --- a/app/src/main/res/layout/fragment_map.xml +++ b/app/src/main/res/layout/fragment_map.xml @@ -2,7 +2,6 @@ @@ -33,51 +32,6 @@ app:tabMaxWidth="0dp" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + \ No newline at end of file diff --git a/app/src/main/res/layout/tour_event_info_card.xml b/app/src/main/res/layout/tour_event_info_card.xml new file mode 100644 index 0000000..874f3eb --- /dev/null +++ b/app/src/main/res/layout/tour_event_info_card.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file