신기성

bottom dooderge

This diff is collapsed. Click to expand it.
1 +#-*- coding: utf-8 -*-
2 +from datetime import datetime, timedelta
3 +import json
4 +import re
5 +
6 +'''
7 +def dday_calculate(date):
8 + y_m_d = date.split("-")
9 + return (datetime.now() - datetime(int(y_m_d[0]), int(y_m_d[1]), int(y_m_d[2]))).days
10 +
11 +
12 +def date_calculate(url):
13 + dates = re.findall(r'[0-9]{2,4}[.|-][0-9]{1,2}[.|-][0-9]{1,2}|~', url)
14 +
15 + for i in range(len(dates)):
16 + dates[i] = dates[i].replace(".", "-")
17 +
18 + # 날짜가 없는 경우
19 + if len(dates) == 0:
20 + return "상시"
21 +
22 + # XXX ~
23 + if dates[-1] == "~":
24 + dday = dday_calculate(dates[0])
25 + if dday > 0:
26 + return "진행중"
27 + else:
28 + return "준비중"
29 +
30 + # ~ XXX and XXX ~ XXX
31 + if dates[-1] != "~":
32 + dday = dday_calculate(dates[-1])
33 + if dday < 0:
34 + return "D"+str(dday)
35 + else:
36 + return "종료"
37 +
38 + # except
39 + return "상 시"
40 +'''
41 +
42 +
43 +with open('d.json', 'rt', encoding='utf-8') as json_file:
44 + json_data = json.load(json_file)
45 +
46 +
47 +for js in json_data:
48 + for key, value in js.items():
49 + if type(value) != str and key != 'View':
50 + js[key] = str(value)
51 + if key == "Link" and value[0] == '[':
52 + js[key] = value[1:-1]
53 +# if key == "Date":
54 +# js[key] = date_calculate(value)
55 +
56 +
57 +with open('result.json', 'w', encoding='utf-8') as make_file:
58 + make_file.write('[')
59 + for i, js in enumerate(json_data):
60 + #make_file.write(json.dumps(js, indent="\t",ensure_ascii=False))
61 + json.dump(js, make_file, indent="\t", ensure_ascii=False)
62 + if i != len(json_data) - 1:
63 + make_file.write(',')
64 + make_file.write(']')
This diff is collapsed. Click to expand it.
...@@ -9,7 +9,7 @@ android { ...@@ -9,7 +9,7 @@ android {
9 buildToolsVersion "29.0.2" 9 buildToolsVersion "29.0.2"
10 defaultConfig { 10 defaultConfig {
11 applicationId "com.example.vip" 11 applicationId "com.example.vip"
12 - minSdkVersion 23 12 + minSdkVersion 26
13 targetSdkVersion 29 13 targetSdkVersion 29
14 versionCode 1 14 versionCode 1
15 versionName "1.0" 15 versionName "1.0"
......
...@@ -24,10 +24,30 @@ import kotlinx.android.synthetic.main.activity_recommend.toolbar ...@@ -24,10 +24,30 @@ import kotlinx.android.synthetic.main.activity_recommend.toolbar
24 import kotlinx.android.synthetic.main.activity_signin.* 24 import kotlinx.android.synthetic.main.activity_signin.*
25 25
26 data class MemoItemFavor( 26 data class MemoItemFavor(
27 - val Target : String = "",
28 val Policy : String = "", 27 val Policy : String = "",
29 val Content : String = "", 28 val Content : String = "",
30 - val Link : String = "" 29 + val Link : String = "",
30 + val View : Int = 0,
31 + val Keyword : String = "",
32 + val Date : String = "",
33 + val Review : String = "",
34 + val Score : Float = 0.toFloat(),
35 + val Category1 : String = "",
36 + val Category2 : String = "",
37 + val Category3 : String = "",
38 + val Category4 : String = "",
39 + val Category5 : String = "",
40 + val Category6 : String = "",
41 + val Category7 : String = "",
42 + val Category8 : String = "",
43 + val Category9 : String = "",
44 + val Category10 : String = "",
45 + val Category11 : String = "",
46 + val Category12 : String = "",
47 + val Category13 : String = "",
48 + val Category14 : String = "",
49 + val Category15 : String = "",
50 + val Category16 : String = ""
31 ) 51 )
32 52
33 class FavoritesActivity : AppCompatActivity() { 53 class FavoritesActivity : AppCompatActivity() {
...@@ -71,10 +91,29 @@ class FavoritesActivity : AppCompatActivity() { ...@@ -71,10 +91,29 @@ class FavoritesActivity : AppCompatActivity() {
71 PolicyItem( 91 PolicyItem(
72 ContextCompat.getDrawable(this@FavoritesActivity, R.drawable.image01)!!, 92 ContextCompat.getDrawable(this@FavoritesActivity, R.drawable.image01)!!,
73 memo!!.Policy, 93 memo!!.Policy,
74 - memo!!.Policy, 94 + memo.Content,
75 - memo!!.Policy, 95 + memo.Link,
76 - 4.toFloat(), 96 + memo.View,
77 - " " 97 + memo.Keyword,
98 + memo.Date,
99 + memo.Review,
100 + memo.Score,
101 + memo.Category1,
102 + memo.Category2,
103 + memo.Category3,
104 + memo.Category4,
105 + memo.Category5,
106 + memo.Category6,
107 + memo.Category7,
108 + memo.Category8,
109 + memo.Category9,
110 + memo.Category10,
111 + memo.Category11,
112 + memo.Category12,
113 + memo.Category13,
114 + memo.Category14,
115 + memo.Category15,
116 + memo.Category16
78 ) 117 )
79 ) 118 )
80 } 119 }
...@@ -85,17 +124,6 @@ class FavoritesActivity : AppCompatActivity() { ...@@ -85,17 +124,6 @@ class FavoritesActivity : AppCompatActivity() {
85 }) 124 })
86 } 125 }
87 126
88 - /* if (intent.hasExtra("key")) {
89 - //textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임
90 -
91 - } else {
92 - Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show()
93 - }
94 -
95 - */
96 -
97 -
98 -
99 // 1. 툴바 사용 설정 127 // 1. 툴바 사용 설정
100 setSupportActionBar(toolbar) 128 setSupportActionBar(toolbar)
101 129
......
...@@ -11,6 +11,11 @@ import android.widget.Toast ...@@ -11,6 +11,11 @@ import android.widget.Toast
11 import androidx.recyclerview.widget.RecyclerView 11 import androidx.recyclerview.widget.RecyclerView
12 import kotlinx.android.synthetic.main.item_policy.view.* 12 import kotlinx.android.synthetic.main.item_policy.view.*
13 import kotlinx.android.synthetic.main.item_policyfield.view.* 13 import kotlinx.android.synthetic.main.item_policyfield.view.*
14 +import java.time.LocalDate
15 +import java.text.ParseException
16 +import java.text.SimpleDateFormat
17 +import java.time.format.DateTimeFormatter
18 +
14 19
15 class PolicyAdapter(private val items: ArrayList<PolicyItem>) : 20 class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
16 RecyclerView.Adapter<PolicyAdapter.ViewHolder>() { 21 RecyclerView.Adapter<PolicyAdapter.ViewHolder>() {
...@@ -41,26 +46,56 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -41,26 +46,56 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
41 val editor: SharedPreferences.Editor=prof.edit() 46 val editor: SharedPreferences.Editor=prof.edit()
42 47
43 48
49 +/*
50 + fun dday_calculate(date : String) : Long {
51 +
52 + var now = LocalDate.now()
53 + var Strnow = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
54 + var calDateDays : Long = 0.toLong()
55 +
56 + try { // String Type을 Date Type으로 캐스팅하면서 생기는 예외로 인해 여기서 예외처리 해주지 않으면 컴파일러에서 에러가 발생해서 컴파일을 할 수 없다.
57 + val format = SimpleDateFormat("yyyy-mm-dd")
58 + // date1, date2 두 날짜를 parse()를 통해 Date형으로 변환.
59 + val Date = format.parse(date)
60 + val nowDate = format.parse(Strnow)
61 +
62 + // Date로 변환된 두 날짜를 계산한 뒤 그 리턴값으로 long type 변수를 초기화 하고 있다.
63 + // 연산결과 -950400000. long type 으로 return 된다.
64 + val calDate = nowDate.getTime() - Date.getTime()
65 +
66 + // Date.getTime() 은 해당날짜를 기준으로1970년 00:00:00 부터 몇 초가 흘렀는지를 반환해준다.
67 + // 이제 24*60*60*1000(각 시간값에 따른 차이점) 을 나눠주면 일수가 나온다.
68 + calDateDays = calDate / (24 * 60 * 60 * 1000)
69 + } catch (e: ParseException) {
70 + calDateDays = 0
71 + }
72 + return calDateDays
73 + }
74 +
75 + fun date_calculate(dday : String) {
76 + val matchResult : Sequence<MatchResult> = Regex.findAll("abcd")
77 + return
78 + }*/
44 fun bind(item: PolicyItem) { 79 fun bind(item: PolicyItem) {
45 view.policyImage.setImageDrawable(item.policyItemImage) 80 view.policyImage.setImageDrawable(item.policyItemImage)
46 - view.policyDday.text = item.policyItemDday 81 + if (item.policyItemDate == "") { item.policyItemDate = "상시" }
47 - view.policyHost.text = item.policyItemHost 82 + view.policyDday.text = item.policyItemDate
48 - view.policyTitle.text = item.policyItemTitle 83 + view.policyHost.text = item.policyItemKeyword
49 - view.policyScore.rating= item.policyItemScore 84 + view.policyTitle.text = item.policyItemPolicy
50 - view.policyFavor.text=item.policyItemFavor 85 + view.policyScore.rating= item.policyScore
86 +
51 87
52 88
53 - if(item.policyItemTitle in prof.getString("favorstringlist","")!!.split("@").toMutableSet()){ 89 + if(item.policyItemPolicy in prof.getString("favorstringlist","")!!.split("@").toMutableSet()){
54 view.policyFavor.isChecked=true 90 view.policyFavor.isChecked=true
55 }else{ 91 }else{
56 - view.policyFavor.isChecked=false
57 } 92 }
58 view.setOnClickListener{ 93 view.setOnClickListener{
59 94
60 val intent=Intent(view.context, DetailActivity::class.java) 95 val intent=Intent(view.context, DetailActivity::class.java)
61 //putExtraStart 96 //putExtraStart
62 - intent.putExtra("key",item.policyItemTitle) 97 + intent.putExtra("key",item.policyItemPolicy)
63 - //putExtraEnd 98 + //putExtraEnd0
64 view.context.startActivity(intent) 99 view.context.startActivity(intent)
65 } 100 }
66 101
...@@ -75,7 +110,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -75,7 +110,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
75 editor.commit() 110 editor.commit()
76 Toast.makeText( 111 Toast.makeText(
77 view.context, 112 view.context,
78 - "찜목록 추가 완료! : " + view.policyTitle.text.toString(), 113 + "찜목록 추가 완료!",
79 Toast.LENGTH_SHORT 114 Toast.LENGTH_SHORT
80 ).show() 115 ).show()
81 Log.d("asdf1",prof.getString("favorstringlist","none")) 116 Log.d("asdf1",prof.getString("favorstringlist","none"))
...@@ -85,7 +120,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) : ...@@ -85,7 +120,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
85 editor.commit() 120 editor.commit()
86 Toast.makeText( 121 Toast.makeText(
87 view.context, 122 view.context,
88 - "찜목록 제거 완료! : " + view.policyTitle.text.toString(), 123 + "찜목록 제거 완료!",
89 Toast.LENGTH_SHORT 124 Toast.LENGTH_SHORT
90 ).show() 125 ).show()
91 Log.d("asdf2",prof.getString("favorstringlist","none")) 126 Log.d("asdf2",prof.getString("favorstringlist","none"))
......
...@@ -3,8 +3,28 @@ package com.example.vip ...@@ -3,8 +3,28 @@ package com.example.vip
3 import android.graphics.drawable.Drawable 3 import android.graphics.drawable.Drawable
4 4
5 class PolicyItem(val policyItemImage: Drawable, 5 class PolicyItem(val policyItemImage: Drawable,
6 - val policyItemDday: String,
7 - val policyItemHost: String,
8 - val policyItemTitle: String,
9 - val policyItemScore: Float,
10 - val policyItemFavor: String)
...\ No newline at end of file ...\ No newline at end of file
6 + val policyItemPolicy: String,
7 + val policyItemContents: String,
8 + val policyItemLink: String,
9 + val policyItemView: Int,
10 + val policyItemKeyword: String,
11 + var policyItemDate: String,
12 + val policyReview : String,
13 + val policyScore : Float,
14 + val policyCategory1: String,
15 + val policyCategory2: String,
16 + val policyCategory3: String,
17 + val policyCategory4: String,
18 + val policyCategory5: String,
19 + val policyCategory6: String,
20 + val policyCategory7: String,
21 + val policyCategory8: String,
22 + val policyCategory9: String,
23 + val policyCategory10: String,
24 + val policyCategory11: String,
25 + val policyCategory12: String,
26 + val policyCategory13: String,
27 + val policyCategory14: String,
28 + val policyCategory15: String,
29 + val policyCategory16: String
30 +) {}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -33,12 +33,31 @@ import androidx.core.content.ContextCompat.getSystemService ...@@ -33,12 +33,31 @@ import androidx.core.content.ContextCompat.getSystemService
33 import android.icu.lang.UCharacter.GraphemeClusterBreak.T 33 import android.icu.lang.UCharacter.GraphemeClusterBreak.T
34 import androidx.core.view.size 34 import androidx.core.view.size
35 35
36 -
37 data class MemoItemRecom( 36 data class MemoItemRecom(
38 - val Target : String = "",
39 val Policy : String = "", 37 val Policy : String = "",
40 val Content : String = "", 38 val Content : String = "",
41 - val Link : String = "" 39 + val Link : String = "",
40 + val View : Int = 0,
41 + val Keyword : String = "",
42 + val Date : String = "",
43 + val Review : String = "",
44 + val Score : Float = 0.toFloat(),
45 + val Category1 : String = "",
46 + val Category2 : String = "",
47 + val Category3 : String = "",
48 + val Category4 : String = "",
49 + val Category5 : String = "",
50 + val Category6 : String = "",
51 + val Category7 : String = "",
52 + val Category8 : String = "",
53 + val Category9 : String = "",
54 + val Category10 : String = "",
55 + val Category11 : String = "",
56 + val Category12 : String = "",
57 + val Category13 : String = "",
58 + val Category14 : String = "",
59 + val Category15 : String = "",
60 + val Category16 : String = ""
42 ) 61 )
43 62
44 class RecommendActivity : AppCompatActivity() { 63 class RecommendActivity : AppCompatActivity() {
...@@ -74,11 +93,30 @@ class RecommendActivity : AppCompatActivity() { ...@@ -74,11 +93,30 @@ class RecommendActivity : AppCompatActivity() {
74 policyList.add( 93 policyList.add(
75 PolicyItem( 94 PolicyItem(
76 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!, 95 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!,
77 - "상시",
78 memo!!.Policy, 96 memo!!.Policy,
79 - memo.Policy, 97 + memo.Content,
80 - 4.toFloat(), 98 + memo.Link,
81 - "" 99 + memo.View,
100 + memo.Keyword,
101 + memo.Date,
102 + memo.Review,
103 + memo.Score,
104 + memo.Category1,
105 + memo.Category2,
106 + memo.Category3,
107 + memo.Category4,
108 + memo.Category5,
109 + memo.Category6,
110 + memo.Category7,
111 + memo.Category8,
112 + memo.Category9,
113 + memo.Category10,
114 + memo.Category11,
115 + memo.Category12,
116 + memo.Category13,
117 + memo.Category14,
118 + memo.Category15,
119 + memo.Category16
82 ) 120 )
83 ) 121 )
84 } 122 }
...@@ -102,14 +140,32 @@ class RecommendActivity : AppCompatActivity() { ...@@ -102,14 +140,32 @@ class RecommendActivity : AppCompatActivity() {
102 policyList.add( 140 policyList.add(
103 PolicyItem( 141 PolicyItem(
104 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!, 142 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!,
105 - "상시",
106 memo!!.Policy, 143 memo!!.Policy,
107 - memo.Policy, 144 + memo!!.Content,
108 - 4.toFloat(), 145 + memo!!.Link,
109 - "" 146 + memo!!.View,
147 + memo!!.Keyword,
148 + memo!!.Date,
149 + memo!!.Review,
150 + memo!!.Score,
151 + memo!!.Category1,
152 + memo!!.Category2,
153 + memo!!.Category3,
154 + memo!!.Category4,
155 + memo!!.Category5,
156 + memo!!.Category6,
157 + memo!!.Category7,
158 + memo!!.Category8,
159 + memo!!.Category9,
160 + memo!!.Category10,
161 + memo!!.Category11,
162 + memo!!.Category12,
163 + memo!!.Category13,
164 + memo!!.Category14,
165 + memo!!.Category15,
166 + memo!!.Category16
110 ) 167 )
111 ) 168 )
112 - //Toast.makeText(this@RecommendActivity, memo.View.toString(), Toast.LENGTH_SHORT).show()
113 } 169 }
114 val adapter = PolicyAdapter(policyList) 170 val adapter = PolicyAdapter(policyList)
115 policyRecyclerView.adapter = adapter 171 policyRecyclerView.adapter = adapter
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
6 <!-- 로고 --> 6 <!-- 로고 -->
7 <item> 7 <item>
8 <bitmap 8 <bitmap
9 - android:gravity="center" 9 + android:gravity="bottom"
10 - android:src="@drawable/final_splash"/> 10 + android:src="@drawable/final_splash" />
11 </item> 11 </item>
12 </layer-list> 12 </layer-list>
......
...@@ -60,8 +60,11 @@ ...@@ -60,8 +60,11 @@
60 android:layout_width="match_parent" 60 android:layout_width="match_parent"
61 android:layout_height="10dp" 61 android:layout_height="10dp"
62 android:layout_marginLeft="14dp" 62 android:layout_marginLeft="14dp"
63 + android:layout_marginRight="12dp"
63 android:layout_weight="0.7" 64 android:layout_weight="0.7"
65 + android:ellipsize="end"
64 android:gravity="bottom|left|center_vertical" 66 android:gravity="bottom|left|center_vertical"
67 + android:maxLines="1"
65 android:text="TextView" 68 android:text="TextView"
66 android:textColor="#C04A4A4A" 69 android:textColor="#C04A4A4A"
67 android:textSize="13dp" /> 70 android:textSize="13dp" />
...@@ -71,8 +74,11 @@ ...@@ -71,8 +74,11 @@
71 android:layout_width="match_parent" 74 android:layout_width="match_parent"
72 android:layout_height="10dp" 75 android:layout_height="10dp"
73 android:layout_marginLeft="11dp" 76 android:layout_marginLeft="11dp"
77 + android:layout_marginRight="10dp"
74 android:layout_weight="1" 78 android:layout_weight="1"
79 + android:ellipsize="end"
75 android:gravity="left|center_vertical" 80 android:gravity="left|center_vertical"
81 + android:maxLines="1"
76 android:text="TextView" 82 android:text="TextView"
77 android:textColor="#000" 83 android:textColor="#000"
78 android:textSize="18dp" /> 84 android:textSize="18dp" />
......