Skip to content

Commit

Permalink
Merge pull request #45 from HanRiverMeetup/issue-44
Browse files Browse the repository at this point in the history
#44 add mypage tab2 applied meeting
  • Loading branch information
chad1994 authored Jul 27, 2018
2 parents 5f7ffda + 60ae5ee commit 5c1b633
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dependencies {

// View
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1'
implementation 'com.baoyz.swipemenulistview:library:1.3.0'

//facebook Login
implementation 'com.facebook.android:facebook-login:[4,5)'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.main.MainActivity">
<activity android:name=".activity.login.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".activity.login.LoginActivity"></activity>
<activity android:name=".activity.main.MainActivity"></activity>

<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,95 @@
package com.depromeet.hanriver.hanrivermeetup.fragment.mypage.Adapter;

public class Tab2Adapter {
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.depromeet.hanriver.hanrivermeetup.R;
import com.depromeet.hanriver.hanrivermeetup.model.mypage.Tab2VO;

import org.w3c.dom.Text;

import java.util.ArrayList;

public class Tab2Adapter extends BaseAdapter{
private LayoutInflater inflater;
ArrayList<Tab2VO> mItems;
private Context mContext;


public Tab2Adapter (ArrayList<Tab2VO> items) {
super();
mItems = items;
}



@Override
public int getCount() {
return mItems.size();
}

@Override
public Object getItem(int i) {
return mItems.get(i);
}

@Override
public long getItemId(int i) {
return 0;
}

@Override
public View getView(int i, View view, ViewGroup viewGroup) {

ViewHolder holder = new ViewHolder();

if(view == null) {
LayoutInflater inflater = (LayoutInflater)viewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.mypage_tab2_item, viewGroup, false);

holder.mTitle = (TextView) view.findViewById(R.id.title);
holder.mLocation = (TextView)view.findViewById(R.id.location);
holder.mTime = (TextView)view.findViewById(R.id.meeting_time);
holder.mCost = (TextView)view.findViewById(R.id.expected_cost);
holder.mParticipants=(TextView)view.findViewById(R.id.participants_cnt);

view.setTag(holder);
} else {
holder = (ViewHolder)view.getTag();
}

holder.mTitle.setText(mItems.get(i).getTitle());
holder.mLocation.setText(mItems.get(i).getLocation());
holder.mTime.setText(mItems.get(i).getMeeting_time());
holder.mCost.setText(String.valueOf(mItems.get(i).getExpected_cost()));
holder.mParticipants.setText(String.valueOf(mItems.get(i).getParticipants_cnt()));


return view;
}

public void addItem(String mIcon, String mStr) {
// Tab2VO item = new Tab2VO();
//
// item.set(mIcon);
// item.setStr(mStr);

// mItems.add(item);
}


public class ViewHolder {
private TextView mTitle;
private TextView mLocation;
private TextView mTime;
private TextView mCost;
private TextView mParticipants;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.depromeet.hanriver.hanrivermeetup.fragment.mypage;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CustomViewpager extends ViewPager{
public CustomViewpager(Context context) {
super(context);
}

public CustomViewpager(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
// 스와이핑되서 페이지가 바뀌는것을 막는다.
return false;
}

@Override
public boolean onTouchEvent(MotionEvent event) {
//스와이핑되서 페이가 바뀌는 것을 막는다.
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
Expand All @@ -19,7 +20,7 @@ public class MyPageFragment extends Fragment{
private TabLayout tabLayout;

@NonNull
private ViewPager viewPager;
private CustomViewpager viewPager;


@Nullable
Expand Down Expand Up @@ -55,6 +56,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
viewPager.setAdapter(pagerAdapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));


// Set TabSelectedListener
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
package com.depromeet.hanriver.hanrivermeetup.fragment.mypage;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.baoyz.swipemenulistview.SwipeMenu;
import com.baoyz.swipemenulistview.SwipeMenuCreator;
import com.baoyz.swipemenulistview.SwipeMenuItem;
import com.baoyz.swipemenulistview.SwipeMenuListView;
import com.depromeet.hanriver.hanrivermeetup.R;
import com.depromeet.hanriver.hanrivermeetup.fragment.mypage.Adapter.Tab2Adapter;
import com.depromeet.hanriver.hanrivermeetup.fragment.timeline.TestFragment;
import com.depromeet.hanriver.hanrivermeetup.model.mypage.Tab2VO;

import java.util.ArrayList;

import static com.facebook.FacebookSdk.getApplicationContext;

public class Tab2 extends Fragment {
public static TestFragment newInstance() {
Expand All @@ -30,6 +45,76 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tab2_fragment, container, false);

SwipeMenuListView listView = (SwipeMenuListView) view.findViewById(R.id.listView);

ArrayList<Tab2VO> test = new ArrayList<Tab2VO>();

test.add(new Tab2VO("test1","여의도 한강공원", "11시", 15000, 3));
test.add(new Tab2VO("test2","여의도 한강공원", "11시", 15000, 3));
test.add(new Tab2VO("test3","여의도 한강공원", "11시", 15000, 3));
test.add(new Tab2VO("test4","여의도 한강공원", "11시", 15000, 3));
test.add(new Tab2VO("test5","여의도 한강공원", "11시", 15000, 3));

Tab2Adapter adapter = new Tab2Adapter(test);
listView.setAdapter(adapter);



SwipeMenuCreator creator = new SwipeMenuCreator() {

@Override
public void create(SwipeMenu menu) {
// create "open" item
// SwipeMenuItem openItem = new SwipeMenuItem(
// getApplicationContext());
// // set item background
// openItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9,
// 0xCE)));
// // set item width
// openItem.setWidth(90);
// // set item title
// openItem.setTitle("Open");
// // set item title fontsize
// openItem.setTitleSize(18);
// // set item title font color
// openItem.setTitleColor(Color.WHITE);
// // add to menu
// menu.addMenuItem(openItem);


// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(
getApplicationContext());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.parseColor("#2186F8")));
// set item width
deleteItem.setWidth(400);
// set a icon
deleteItem.setIcon(R.drawable.ic_nagative_icon);
// add to menu
menu.addMenuItem(deleteItem);
}
};

// set creator
listView.setMenuCreator(creator);

listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch (index) {
case 0:
Toast.makeText(getActivity(), "test", Toast.LENGTH_SHORT).show();
break;
case 1:
// delete
break;
}
// false : close the menu; true : not close the menu
return false;
}
});


return view;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,50 @@

public class Tab2VO {
@NonNull
private final String mText;
private final String title;

@NonNull
private final int mImg;
private final String location;

public Tab2VO(@NonNull final String text, @NonNull final int img) {
mText = text;
mImg = img;
@NonNull
private final String meeting_time;

@NonNull
private final int expected_cost;

@NonNull
private final int participants_cnt;

public Tab2VO(@NonNull final String title, @NonNull final String location, @NonNull final String meeting_time, @NonNull final int expected_cost, @NonNull final int participants_cnt) {
this.title = title;
this.location = location;
this.meeting_time = meeting_time;
this.expected_cost = expected_cost;
this.participants_cnt = participants_cnt;
}

@NonNull
public String getTitle(){
return title;
}

@NonNull
public String getLocation() {
return location;
}

@NonNull
public String getMeeting_time() {
return meeting_time;
}

@NonNull
public String getText(){
return mText;
public int getExpected_cost(){
return expected_cost;
}

@NonNull
public int getImg() {
return mImg;
public int getParticipants_cnt(){
return participants_cnt;
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_nagative_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector android:height="24dp" android:viewportHeight="16"
android:viewportWidth="16" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00000000" android:fillType="evenOdd"
android:pathData="M2.838,1.474L13.914,12.55l-1.145,1.145L1.693,2.619l1.145,-1.145z"
android:strokeColor="#FFF" android:strokeWidth="2"/>
<path android:fillColor="#00000000" android:fillType="evenOdd"
android:pathData="M13.901,2.619L2.825,13.695 1.68,12.551 12.756,1.474l1.145,1.145z"
android:strokeColor="#FFF" android:strokeWidth="2"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/ic_positive_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<vector android:height="24dp" android:viewportHeight="16"
android:viewportWidth="16" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00000000"
android:pathData="M7.93,1.58a6,6 0,1 1,0 12,6 6,0 0,1 0,-12z"
android:strokeColor="#FFF" android:strokeWidth="2"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_mypage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:layout_centerInParent="true"
android:background="#000000"/>

<android.support.v4.view.ViewPager
<com.depromeet.hanriver.hanrivermeetup.fragment.mypage.CustomViewpager
android:id="@+id/viewpager2"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Expand Down
Loading

0 comments on commit 5c1b633

Please sign in to comment.