Skip to content

Commit

Permalink
#171 modify cardAdapter & tourEventModel
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1994 committed Dec 1, 2018
1 parent ac50c15 commit 5dc62f5
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 45 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ dependencies {
implementation 'com.amazonaws:aws-android-sdk-cognito:2.6.+'

implementation 'id.zelory:compressor:2.1.0'

}

apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
public class CardItem {
private String mTextResource;
private String mTitleResource;
private String mHomepageUrl;
private String mTel;

public CardItem(String title, String text) {
public CardItem(String title, String text,String url,String tel) {
mTitleResource = title;
mTextResource = text;
mHomepageUrl = url;
mTel = tel;
}

public String getText() {
Expand All @@ -16,4 +20,12 @@ public String getText() {
public String getTitle() {
return mTitleResource;
}

public String getmHomepageUrl() {
return mHomepageUrl;
}

public String getmTel() {
return mTel;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.depromeet.hanriver.hanrivermeetup.fragment.meeting.map;

import android.content.Context;
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.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.depromeet.hanriver.hanrivermeetup.R;

Expand All @@ -19,10 +22,12 @@ public class CardPagerAdapter extends PagerAdapter implements CardAdapter {
private float mBaseElevation;

public CardPagerAdapter() {

mData = new ArrayList<>();
mViews = new ArrayList<>();
}


public void addCardItem(CardItem item) {
mViews.add(null);
mData.add(item);
Expand Down Expand Up @@ -73,8 +78,13 @@ public void destroyItem(ViewGroup container, int position, Object object) {
private void bind(CardItem item, View view) {
TextView titleTextView = view.findViewById(R.id.title);
TextView addressTextView = view.findViewById(R.id.address);
TextView homePageView = view.findViewById(R.id.homepage_text);
TextView telView = view.findViewById(R.id.phone_text);

titleTextView.setText(item.getTitle());
addressTextView.setText(item.getText());
homePageView.setText(item.getmHomepageUrl());
telView.setText(item.getmTel());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.support.v4.view.ViewPager;
import android.view.Display;
Expand Down Expand Up @@ -54,12 +55,10 @@ public class TmapFragment extends Fragment {
private TextView tabname[] = new TextView[3];
private CompositeDisposable mCompositeDisposable;
private Bitmap bitmap;

private ViewPager mViewPager;
TMapMarkerItem[] cf_markerItem;
private CardPagerAdapter mCardAdapter;
private ShadowTransformer mCardShadowTransformer;
private CardFragmentPagerAdapter mFragmentCardAdapter;
private ShadowTransformer mFragmentCardShadowTransformer;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down Expand Up @@ -94,22 +93,19 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c

map.addView(mapView);

mViewPager = view.findViewById(R.id.viewPager);
mViewPager = view.findViewById(R.id.map_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()));
// mCardAdapter = new CardPagerAdapter(getContext());
// mCardAdapter.addCardItem(new CardItem("test", "hello"));
// mCardAdapter.addCardItem(new CardItem("test2", "hello2"));
// mCardAdapter.addCardItem(new CardItem("test3", "hello3"));
// mCardAdapter.addCardItem(new CardItem("test4", "hello4"));

mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter);
mFragmentCardShadowTransformer = new ShadowTransformer(mViewPager, mFragmentCardAdapter);

mViewPager.setAdapter(mCardAdapter);
mViewPager.setPageTransformer(false, mCardShadowTransformer);
mViewPager.setOffscreenPageLimit(3);
// mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter);
//
// mViewPager.setAdapter(mCardAdapter);
// mViewPager.setPageTransformer(false, mCardShadowTransformer);
// mViewPager.setOffscreenPageLimit(3);

return view;
}
Expand Down Expand Up @@ -141,6 +137,13 @@ public void onTabSelected(TabLayout.Tab tab) {
tabname[tab.getPosition()].setTextColor(getResources().getColor(R.color.clear_blue));
bind();

if(current_position==1||current_position==2){
mViewPager.setVisibility(View.GONE);
}
else{
mViewPager.setVisibility(View.VISIBLE);
}

}

@Override
Expand Down Expand Up @@ -204,30 +207,30 @@ private void unBind() {

private void setTourEventMarker(@NonNull final List<TourEventInfo> markers) {
mapView.removeAllMarkerItem();
TMapMarkerItem[] markerItem = new TMapMarkerItem[markers.size()];
cf_markerItem = new TMapMarkerItem[markers.size()];
TMapPoint mapPoint;

for (int i = 0; i < markers.size(); i++) {
markerItem[i] = new TMapMarkerItem();
cf_markerItem[i] = new TMapMarkerItem();
mapPoint = new TMapPoint(markers.get(i).getMapy(), markers.get(i).getMapx());
markerItem[i].setTMapPoint(mapPoint);
markerItem[i].setVisible(TMapMarkerItem.VISIBLE);
cf_markerItem[i].setTMapPoint(mapPoint);
cf_markerItem[i].setVisible(TMapMarkerItem.VISIBLE);
// markerItem[i].setID(markers.get(i).getMap_seq());
markerItem[i].setID(String.valueOf(i));
cf_markerItem[i].setID(String.valueOf(i));

///////////////////Marker Click logic///////////////////////

//풍선뷰 이미지 bitmap으로 저장
bitmap = BitmapFactory.decodeResource(getContext().getResources(), R.mipmap.ic_launcher);

// 풍선뷰 안의 항목 세팅
markerItem[i].setCalloutTitle(markers.get(i).getTitle());
markerItem[i].setCalloutSubTitle(markers.get(i).getTel());
markerItem[i].setCanShowCallout(true);
markerItem[i].setAutoCalloutVisible(false);
markerItem[i].setCalloutRightButtonImage(bitmap);
cf_markerItem[i].setCalloutTitle(markers.get(i).getTitle());
cf_markerItem[i].setCalloutSubTitle(markers.get(i).getTel());
cf_markerItem[i].setCanShowCallout(true);
cf_markerItem[i].setAutoCalloutVisible(false);
cf_markerItem[i].setCalloutRightButtonImage(bitmap);

mapView.addMarkerItem(markerItem[i].getID(), markerItem[i]);
mapView.addMarkerItem(cf_markerItem[i].getID(), cf_markerItem[i]);

//풍선뷰 클릭 이벤트
mapView.setOnCalloutRightButtonClickListener(new TMapView.OnCalloutRightButtonClickCallback() {
Expand All @@ -238,6 +241,8 @@ public void onCalloutRightButton(TMapMarkerItem tMapMarkerItem) {
}
});
}

setCardList(markers);
}

private void setMarker(@NonNull final List<MapMarker> markers) {
Expand Down Expand Up @@ -267,6 +272,7 @@ private void setMarker(@NonNull final List<MapMarker> markers) {
markerItem[i].setCalloutRightButtonImage(bitmap);



mapView.addMarkerItem(markerItem[i].getID(), markerItem[i]);

mapView.setOnMarkerClickEvent(new TMapView.OnCalloutMarker2ClickCallback() {
Expand All @@ -287,6 +293,40 @@ public void onCalloutRightButton(TMapMarkerItem tMapMarkerItem) {
}
}

private void setCardList(List<TourEventInfo> markers){
mCardAdapter = new CardPagerAdapter();
for(int i=0;i<markers.size();i++) {
mCardAdapter.addCardItem(new CardItem(markers.get(i).getTitle(), markers.get(i).getAddr(),markers.get(i).getHompage(),markers.get(i).getTel()));
}

mCardShadowTransformer = new ShadowTransformer(mViewPager, mCardAdapter);

mViewPager.setAdapter(mCardAdapter);
mViewPager.setPageTransformer(false, mCardShadowTransformer);
mViewPager.setOffscreenPageLimit(3);

mapView.setCenterPoint(markers.get(0).getMapx(),markers.get(0).getMapy()-0.003);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int i, float v, int i1) {

}

@Override
public void onPageSelected(int i) {
mapView.setCenterPoint(markers.get(i).getMapx(),markers.get(i).getMapy()-0.003);
mapView.setZoom(15);
cf_markerItem[i].setAutoCalloutVisible(true);
Log.d("@@@",""+markers.get(i).getMapx()+"/"+markers.get(i).getMapy());
}

@Override
public void onPageScrollStateChanged(int i) {

}
});
}

private void initTablayoutWeight(TabLayout tablayout) {
LinearLayout linearLayout = (LinearLayout) tablayout.getChildAt(0);
Display display = getActivity().getWindowManager().getDefaultDisplay();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</RelativeLayout>

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:id="@+id/map_viewPager"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="bottom"
Expand Down
36 changes: 21 additions & 15 deletions app/src/main/res/layout/tour_event_info_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,32 @@
android:layout_marginTop="10dp"
android:text="Hello World" />

<ImageView
android:id="@+id/homepage_btn"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintRight_toLeftOf="@+id/phone_btn"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginRight="20dp"
android:src="@drawable/homepage"/>
<TextView
android:id="@+id/homepage_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/address"
android:layout_marginTop="20dp"
android:text="홈페이지 주소"
android:textSize="15sp"
android:textColor="@color/white"/>

<ImageView
android:id="@+id/phone_btn"
android:layout_width="40dp"
android:layout_height="40dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/phone_number_icon"/>
<TextView
android:id="@+id/phone_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/homepage_text"
android:layout_marginTop="5dp"
android:text="홈페이지 주소"
android:textSize="15sp"
android:textColor="@color/white"/>

</android.support.constraint.ConstraintLayout>

<ImageView
android:id="@+id/mapcard_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|end"/>
Expand Down

0 comments on commit 5dc62f5

Please sign in to comment.