신기성

bottom dooderge

This diff is collapsed. Click to expand it.
#-*- coding: utf-8 -*-
from datetime import datetime, timedelta
import json
import re
'''
def dday_calculate(date):
y_m_d = date.split("-")
return (datetime.now() - datetime(int(y_m_d[0]), int(y_m_d[1]), int(y_m_d[2]))).days
def date_calculate(url):
dates = re.findall(r'[0-9]{2,4}[.|-][0-9]{1,2}[.|-][0-9]{1,2}|~', url)
for i in range(len(dates)):
dates[i] = dates[i].replace(".", "-")
# 날짜가 없는 경우
if len(dates) == 0:
return "상시"
# XXX ~
if dates[-1] == "~":
dday = dday_calculate(dates[0])
if dday > 0:
return "진행중"
else:
return "준비중"
# ~ XXX and XXX ~ XXX
if dates[-1] != "~":
dday = dday_calculate(dates[-1])
if dday < 0:
return "D"+str(dday)
else:
return "종료"
# except
return "상 시"
'''
with open('d.json', 'rt', encoding='utf-8') as json_file:
json_data = json.load(json_file)
for js in json_data:
for key, value in js.items():
if type(value) != str and key != 'View':
js[key] = str(value)
if key == "Link" and value[0] == '[':
js[key] = value[1:-1]
# if key == "Date":
# js[key] = date_calculate(value)
with open('result.json', 'w', encoding='utf-8') as make_file:
make_file.write('[')
for i, js in enumerate(json_data):
#make_file.write(json.dumps(js, indent="\t",ensure_ascii=False))
json.dump(js, make_file, indent="\t", ensure_ascii=False)
if i != len(json_data) - 1:
make_file.write(',')
make_file.write(']')
This diff is collapsed. Click to expand it.
......@@ -9,7 +9,7 @@ android {
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.vip"
minSdkVersion 23
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
......
......@@ -24,10 +24,30 @@ import kotlinx.android.synthetic.main.activity_recommend.toolbar
import kotlinx.android.synthetic.main.activity_signin.*
data class MemoItemFavor(
val Target : String = "",
val Policy : String = "",
val Content : String = "",
val Link : String = ""
val Link : String = "",
val View : Int = 0,
val Keyword : String = "",
val Date : String = "",
val Review : String = "",
val Score : Float = 0.toFloat(),
val Category1 : String = "",
val Category2 : String = "",
val Category3 : String = "",
val Category4 : String = "",
val Category5 : String = "",
val Category6 : String = "",
val Category7 : String = "",
val Category8 : String = "",
val Category9 : String = "",
val Category10 : String = "",
val Category11 : String = "",
val Category12 : String = "",
val Category13 : String = "",
val Category14 : String = "",
val Category15 : String = "",
val Category16 : String = ""
)
class FavoritesActivity : AppCompatActivity() {
......@@ -71,10 +91,29 @@ class FavoritesActivity : AppCompatActivity() {
PolicyItem(
ContextCompat.getDrawable(this@FavoritesActivity, R.drawable.image01)!!,
memo!!.Policy,
memo!!.Policy,
memo!!.Policy,
4.toFloat(),
" "
memo.Content,
memo.Link,
memo.View,
memo.Keyword,
memo.Date,
memo.Review,
memo.Score,
memo.Category1,
memo.Category2,
memo.Category3,
memo.Category4,
memo.Category5,
memo.Category6,
memo.Category7,
memo.Category8,
memo.Category9,
memo.Category10,
memo.Category11,
memo.Category12,
memo.Category13,
memo.Category14,
memo.Category15,
memo.Category16
)
)
}
......@@ -85,17 +124,6 @@ class FavoritesActivity : AppCompatActivity() {
})
}
/* if (intent.hasExtra("key")) {
//textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임
} else {
Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show()
}
*/
// 1. 툴바 사용 설정
setSupportActionBar(toolbar)
......
......@@ -11,6 +11,11 @@ import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.item_policy.view.*
import kotlinx.android.synthetic.main.item_policyfield.view.*
import java.time.LocalDate
import java.text.ParseException
import java.text.SimpleDateFormat
import java.time.format.DateTimeFormatter
class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
RecyclerView.Adapter<PolicyAdapter.ViewHolder>() {
......@@ -41,26 +46,56 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
val editor: SharedPreferences.Editor=prof.edit()
/*
fun dday_calculate(date : String) : Long {
var now = LocalDate.now()
var Strnow = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
var calDateDays : Long = 0.toLong()
try { // String Type을 Date Type으로 캐스팅하면서 생기는 예외로 인해 여기서 예외처리 해주지 않으면 컴파일러에서 에러가 발생해서 컴파일을 할 수 없다.
val format = SimpleDateFormat("yyyy-mm-dd")
// date1, date2 두 날짜를 parse()를 통해 Date형으로 변환.
val Date = format.parse(date)
val nowDate = format.parse(Strnow)
// Date로 변환된 두 날짜를 계산한 뒤 그 리턴값으로 long type 변수를 초기화 하고 있다.
// 연산결과 -950400000. long type 으로 return 된다.
val calDate = nowDate.getTime() - Date.getTime()
// Date.getTime() 은 해당날짜를 기준으로1970년 00:00:00 부터 몇 초가 흘렀는지를 반환해준다.
// 이제 24*60*60*1000(각 시간값에 따른 차이점) 을 나눠주면 일수가 나온다.
calDateDays = calDate / (24 * 60 * 60 * 1000)
} catch (e: ParseException) {
calDateDays = 0
}
return calDateDays
}
fun date_calculate(dday : String) {
val matchResult : Sequence<MatchResult> = Regex.findAll("abcd")
return
}*/
fun bind(item: PolicyItem) {
view.policyImage.setImageDrawable(item.policyItemImage)
view.policyDday.text = item.policyItemDday
view.policyHost.text = item.policyItemHost
view.policyTitle.text = item.policyItemTitle
view.policyScore.rating= item.policyItemScore
view.policyFavor.text=item.policyItemFavor
if (item.policyItemDate == "") { item.policyItemDate = "상시" }
view.policyDday.text = item.policyItemDate
view.policyHost.text = item.policyItemKeyword
view.policyTitle.text = item.policyItemPolicy
view.policyScore.rating= item.policyScore
if(item.policyItemTitle in prof.getString("favorstringlist","")!!.split("@").toMutableSet()){
if(item.policyItemPolicy in prof.getString("favorstringlist","")!!.split("@").toMutableSet()){
view.policyFavor.isChecked=true
}else{
view.policyFavor.isChecked=false
}
view.setOnClickListener{
val intent=Intent(view.context, DetailActivity::class.java)
//putExtraStart
intent.putExtra("key",item.policyItemTitle)
//putExtraEnd
intent.putExtra("key",item.policyItemPolicy)
//putExtraEnd0
view.context.startActivity(intent)
}
......@@ -75,7 +110,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
editor.commit()
Toast.makeText(
view.context,
"찜목록 추가 완료! : " + view.policyTitle.text.toString(),
"찜목록 추가 완료!",
Toast.LENGTH_SHORT
).show()
Log.d("asdf1",prof.getString("favorstringlist","none"))
......@@ -85,7 +120,7 @@ class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
editor.commit()
Toast.makeText(
view.context,
"찜목록 제거 완료! : " + view.policyTitle.text.toString(),
"찜목록 제거 완료!",
Toast.LENGTH_SHORT
).show()
Log.d("asdf2",prof.getString("favorstringlist","none"))
......
......@@ -3,8 +3,28 @@ package com.example.vip
import android.graphics.drawable.Drawable
class PolicyItem(val policyItemImage: Drawable,
val policyItemDday: String,
val policyItemHost: String,
val policyItemTitle: String,
val policyItemScore: Float,
val policyItemFavor: String)
\ No newline at end of file
val policyItemPolicy: String,
val policyItemContents: String,
val policyItemLink: String,
val policyItemView: Int,
val policyItemKeyword: String,
var policyItemDate: String,
val policyReview : String,
val policyScore : Float,
val policyCategory1: String,
val policyCategory2: String,
val policyCategory3: String,
val policyCategory4: String,
val policyCategory5: String,
val policyCategory6: String,
val policyCategory7: String,
val policyCategory8: String,
val policyCategory9: String,
val policyCategory10: String,
val policyCategory11: String,
val policyCategory12: String,
val policyCategory13: String,
val policyCategory14: String,
val policyCategory15: String,
val policyCategory16: String
) {}
\ No newline at end of file
......
......@@ -33,12 +33,31 @@ import androidx.core.content.ContextCompat.getSystemService
import android.icu.lang.UCharacter.GraphemeClusterBreak.T
import androidx.core.view.size
data class MemoItemRecom(
val Target : String = "",
val Policy : String = "",
val Content : String = "",
val Link : String = ""
val Link : String = "",
val View : Int = 0,
val Keyword : String = "",
val Date : String = "",
val Review : String = "",
val Score : Float = 0.toFloat(),
val Category1 : String = "",
val Category2 : String = "",
val Category3 : String = "",
val Category4 : String = "",
val Category5 : String = "",
val Category6 : String = "",
val Category7 : String = "",
val Category8 : String = "",
val Category9 : String = "",
val Category10 : String = "",
val Category11 : String = "",
val Category12 : String = "",
val Category13 : String = "",
val Category14 : String = "",
val Category15 : String = "",
val Category16 : String = ""
)
class RecommendActivity : AppCompatActivity() {
......@@ -74,12 +93,31 @@ class RecommendActivity : AppCompatActivity() {
policyList.add(
PolicyItem(
ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!,
"상시",
memo!!.Policy,
memo.Policy,
4.toFloat(),
""
)
memo.Content,
memo.Link,
memo.View,
memo.Keyword,
memo.Date,
memo.Review,
memo.Score,
memo.Category1,
memo.Category2,
memo.Category3,
memo.Category4,
memo.Category5,
memo.Category6,
memo.Category7,
memo.Category8,
memo.Category9,
memo.Category10,
memo.Category11,
memo.Category12,
memo.Category13,
memo.Category14,
memo.Category15,
memo.Category16
)
)
}
val adapter = PolicyAdapter(policyList)
......@@ -102,14 +140,32 @@ class RecommendActivity : AppCompatActivity() {
policyList.add(
PolicyItem(
ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!,
"상시",
memo!!.Policy,
memo.Policy,
4.toFloat(),
""
memo!!.Content,
memo!!.Link,
memo!!.View,
memo!!.Keyword,
memo!!.Date,
memo!!.Review,
memo!!.Score,
memo!!.Category1,
memo!!.Category2,
memo!!.Category3,
memo!!.Category4,
memo!!.Category5,
memo!!.Category6,
memo!!.Category7,
memo!!.Category8,
memo!!.Category9,
memo!!.Category10,
memo!!.Category11,
memo!!.Category12,
memo!!.Category13,
memo!!.Category14,
memo!!.Category15,
memo!!.Category16
)
)
//Toast.makeText(this@RecommendActivity, memo.View.toString(), Toast.LENGTH_SHORT).show()
}
val adapter = PolicyAdapter(policyList)
policyRecyclerView.adapter = adapter
......
......@@ -6,7 +6,7 @@
<!-- 로고 -->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/final_splash"/>
android:gravity="bottom"
android:src="@drawable/final_splash" />
</item>
</layer-list>
......
......@@ -60,8 +60,11 @@
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="12dp"
android:layout_weight="0.7"
android:ellipsize="end"
android:gravity="bottom|left|center_vertical"
android:maxLines="1"
android:text="TextView"
android:textColor="#C04A4A4A"
android:textSize="13dp" />
......@@ -71,8 +74,11 @@
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="left|center_vertical"
android:maxLines="1"
android:text="TextView"
android:textColor="#000"
android:textSize="18dp" />
......