Activities About 'Linco'

An group purchase application
Dev by 'Android studio'
my part was developing 'Filtering system' / 'my page'

below is code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".mypage.MypageActivity">
 
 
    <LinearLayout
        android:layout_width="411dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="horizontal"
        android:paddingTop="10dp">
 
 
        <ImageButton
            android:id="@+id/left_arrow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:layout_marginLeft="16dp"
            android:background="#FFFFFF"
            app:srcCompat="@drawable/left_arrow" />
 
 
        <TextView
            android:id="@+id/mypage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="70dp"
            android:layout_marginRight="70dp"
            android:text="마이페이지"
            android:textSize="28sp" />
 
        <ImageButton
            android:id="@+id/logout_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="13dp"
            android:layout_marginEnd="13dp"
            android:background="#FFFFFF"
            app:srcCompat="@drawable/logout" />
    </LinearLayout>
 
 
    <GridLayout
        android:layout_width="match_parent"
        android:layout_height="111dp"
        android:layout_marginTop="10dp">
 
        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/profile_image"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="16dp"
            android:src="@drawable/seulgi" />
 
        <!--        <TextView-->
        <!--            android:id="@+id/nickname"-->
        <!--            android:layout_width="wrap_content"-->
        <!--            android:layout_height="wrap_content"-->
        <!--            android:layout_marginLeft="50dp"-->
        <!--            android:layout_marginTop="20dp"-->
        <!--            android:text="홍길동님"-->
        <!--            android:textColor="@color/black"-->
        <!--            android:textSize="30sp"-->
        <!--            android:textStyle="bold" />-->
        <!--        //아이디 표시를 위해 android:text를 제거할 것-->
 
        <TextView
            android:id="@+id/nickname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_row="0"
            android:layout_column="1"
            android:layout_marginLeft="50dp"
            android:layout_marginTop="14dp"
            android:text="홍길동님"
            android:textColor="@color/black"
            android:textSize="30sp"
            android:textStyle="bold" />
 
 
    </GridLayout>
 
 
    <TextView
        android:id="@+id/keyowrd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="관심키워드"
        android:textSize="20sp"
        android:textStyle="bold"
        android:textColor="@color/black"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:layout_marginBottom="10dp"/>
 
 
    <HorizontalScrollView
 
        android:id="@+id/ScrollView1"
        android:scrollbars="none"
        android:layout_width="match_parent"
        android:layout_height="70dp">
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
 
            <Button
                android:id="@+id/camping"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 캠핑" />
 
            <Button
                android:id="@+id/beauty"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 뷰티" />
 
            <Button
                android:id="@+id/wealth"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 건강" />
 
            <Button
                android:id="@+id/sports"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 스포츠" />
 
            <Button
                android:id="@+id/interior"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 인테리어" />
 
 
            <Button
                android:id="@+id/kids"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 육아" />
 
            <Button
                android:id="@+id/device"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 전자기기" />
 
            <Button
                android:id="@+id/book"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 도서" />
 
            <Button
                android:id="@+id/fashion"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 패션" />
 
 
            <Button
                android:id="@+id/reset"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:layout_marginBottom="5dp"
                android:background="@drawable/button_round"
                android:text="# 초기화" />
 
        </LinearLayout>
    </HorizontalScrollView>
 
 
 
    <TextView
        android:id="@+id/mypost"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="내가 쓴 글"
        android:textSize="20sp"
        android:textStyle="bold"
        android:textColor="@color/black"
        android:layout_marginLeft="10dp"
        android:layout_marginBottom="10dp"
        />
 
    <!--    <GridView-->
    <!--        android:id="@+id/mypost_list"-->
    <!--        android:layout_width="match_parent"-->
    <!--        android:layout_height="wrap_content"-->
    <!--        android:gravity="center"-->
    <!--        android:numColumns="2">-->
    <!--    </GridView>-->
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        app:layout_constraintTop_toBottomOf="@+id/scrollView2"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:paddingStart="20dp"
        android:paddingEnd="20dp"
        android:paddingTop="10dp"
        android:fillViewport="true"
        android:scrollbars="none"
        >
 
        <GridView
            android:id="@+id/gridView_mypost"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:horizontalSpacing="10dp"
            android:numColumns="auto_fit"
            android:scrollbars="none"
            android:verticalSpacing="10dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
 
    </ScrollView>
 
    <!--    <GridView-->
    <!--        android:id="@+id/mypost_list"-->
    <!--        android:layout_width="match_parent"-->
    <!--        android:layout_height="wrap_content"-->
    <!--        android:gravity="center"-->
    <!--        android:numColumns="2">-->
    <!--    </GridView>-->
 
 
 
 
 
 
 
</LinearLayout>
cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
package com.univ.linco.mypage;
//..
 
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
 
import com.univ.linco.mypage.database.Filter;
 
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.room.Room;
 
import com.univ.linco.MainActivity;
import com.univ.linco.R;
import com.univ.linco.mypage.database.FilterClient;
import com.univ.linco.mypage.database.FilterDao;
import com.univ.linco.posting.DetailsActivity;
import com.univ.linco.posting.database.Post;
import com.univ.linco.posting.database.PostClient;
import com.univ.linco.posting.database.PostDao;
import com.univ.linco.signin.SigninActivity;
import com.univ.linco.signup.database.User;
import com.univ.linco.signup.database.UserClient;
import com.univ.linco.signup.database.UserDao;
import com.univ.linco.thumbnail.ThumbnailAdapter;
import com.univ.linco.thumbnail.ThumbnailData;
import com.univ.linco.thumbnail.ThumbnailItem;
 
import java.util.ArrayList;
import java.util.List;
 
public class MypageActivity extends AppCompatActivity {
    TextView nickname;
    Intent intent;
    GridView gridView_mypost;
    ThumbnailData thumbnail_data;
    ArrayList<ThumbnailItem> data;
    Intent getID = getIntent();
    FilterDao db;
    Filter data_filter;
    private static final String SHARED_PREF_NAME = "mypref";
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mypage);
 
        //내부 DB 로드
        SharedPreferences pref = getSharedPreferences("login_id", MODE_PRIVATE);
        UserDao userDao = UserClient.getInstance(getApplicationContext()).getAppDatabase().userDao();
        PostDao db_post = PostClient.getInstance(getApplicationContext()).getAppDatabase().postDao();
        FilterDao filterDao = FilterClient.getInstance(getApplicationContext()).getAppDatabase().filterDao();
        User user_info = userDao.getAll().get(pref.getInt("login"0));
 
        //뷰 할당
        nickname = findViewById(R.id.nickname);
        ImageButton logout = (ImageButton)findViewById(R.id.logout_button);
        ImageButton back = (ImageButton)findViewById(R.id.left_arrow);
        Button camping = (Button) findViewById(R.id.camping);
        Button beauty = (Button) findViewById(R.id.beauty);
        Button wealth = (Button) findViewById(R.id.wealth);
        Button sports = (Button) findViewById(R.id.sports);
        Button interior = (Button) findViewById(R.id.interior);
        Button kids = (Button) findViewById(R.id.kids);
        Button device = (Button) findViewById(R.id.device);
        Button book = (Button) findViewById(R.id.book);
        Button fashion = (Button) findViewById(R.id.fashion);
        Button reset = (Button) findViewById(R.id.reset);
 
        //이름 할당
        nickname.setText(user_info.getName()+"님");
 
        //내가 쓴 글 데이터 정리
        ArrayList<Post> my_post = new ArrayList<>();
        for (int i=0; i<db_post.getAll().size(); i++){
            if(db_post.getAll().get(i).getUser_id().equals(user_info.getUser_id())){
                my_post.add(db_post.getAll().get(i));
            }
        }
        thumbnail_data = new ThumbnailData(my_post);
        data = thumbnail_data.getThumbnailData();
 
 
 
        Button[] array_btn = {camping, beauty, wealth, sports, interior, kids, device, book, fashion};
 
        data_filter = filterDao.getAll().get(filterDao.getAll().size()-1);
 
        Boolean[] array_filter = {
                data_filter.isCamping(), data_filter.isBeauty(), data_filter.isWealth(),
                data_filter.isSports(), data_filter.isInterior(), data_filter.isKids(),
                data_filter.isDevice(), data_filter.isBook(), data_filter.isFashion()
        };
 
        for (int i=0; i< array_filter.length; i++){
            if(array_filter[i]==false){
                array_btn[i].setVisibility(View.GONE);
            }
        }
 
 
        logout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
 
                intent = new Intent(getApplicationContext(), SigninActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish();
            }
        });
 
        camping.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                camping.setVisibility(View.GONE);
                data_filter.setCamping(false);
            }
        });
        beauty.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                beauty.setVisibility(View.GONE);
                data_filter.setBeauty(false);
            }
        });
        wealth.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                wealth.setVisibility(View.GONE);
                data_filter.setWealth(false);
            }
        });
        sports.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                sports.setVisibility(View.GONE);
                data_filter.setSports(false);
            }
        });
        interior.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                interior.setVisibility(View.GONE);
                data_filter.setInterior(false);
            }
        });
        kids.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                kids.setVisibility(View.GONE);
                data_filter.setDevice(false);
            }
        });
        device.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                device.setVisibility(View.GONE);
                data_filter.setBook(false);
            }
        });
 
        book.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                book.setVisibility(View.GONE);
                data_filter.setFashion(false);
            }
        });
 
        fashion.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                fashion.setVisibility(View.GONE);
                data_filter.setFashion(false);
            }
        });
 
 
        reset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                camping.setVisibility(View.VISIBLE);
                beauty.setVisibility(View.VISIBLE);
                wealth.setVisibility(View.VISIBLE);
                sports.setVisibility(View.VISIBLE);
                interior.setVisibility(View.VISIBLE);
                kids.setVisibility(View.VISIBLE);
                device.setVisibility(View.VISIBLE);
                book.setVisibility(View.VISIBLE);
                fashion.setVisibility(View.VISIBLE);
                data_filter.setCamping(true);
                data_filter.setBeauty(true);
                data_filter.setWealth(true);
                data_filter.setSports(true);
                data_filter.setInterior(true);
                data_filter.setKids(true);
                data_filter.setDevice(true);
                data_filter.setBook(true);
                data_filter.setFashion(true);
            }
        });
 
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                filterDao.updateFilter(data_filter);
                intent = new Intent(getApplicationContext(), MainActivity.class);
                startActivity(intent);
            }
        });
 
        gridView_mypost = findViewById(R.id.gridView_mypost);
        ThumbnailAdapter adapter = new ThumbnailAdapter();
 
        for (int i=0; i<data.size();i++){
            adapter.addItem(data.get(i));
        }
 
        gridView_mypost.setAdapter(adapter);
 
        gridView_mypost.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent to_detail = new Intent(getApplicationContext(), DetailsActivity.class);
                final ThumbnailItem item = (ThumbnailItem) adapter.getItem(position);
                int id_item = item.getPost_id();
                to_detail.putExtra("id", id_item);
                startActivity(to_detail);
            }
        });
 
    }
}
cs