Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_street
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_street
Commits
bf04b134
Commit
bf04b134
authored
Jul 22, 2021
by
fengruiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据库数据添加
parent
e8975bec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
13 deletions
+79
-13
AppDatabase.kt
app/src/main/java/com/mints/street/db/AppDatabase.kt
+1
-1
ScenicSpotDao.kt
app/src/main/java/com/mints/street/db/ScenicSpotDao.kt
+48
-4
TableBean.kt
app/src/main/java/com/mints/street/db/TableBean.kt
+11
-1
item_grid_map_adapter.xml
app/src/main/res/layout/item_grid_map_adapter.xml
+19
-7
No files found.
app/src/main/java/com/mints/street/db/AppDatabase.kt
View file @
bf04b134
...
...
@@ -10,7 +10,7 @@ import me.goldze.mvvmhabit.utils.Utils
*/
@Database
(
entities
=
[
ScenicSpotBean
::
class
],
version
=
1
)
abstract
class
AppDatabase
:
RoomDatabase
()
{
abstract
fun
user
Dao
():
ScenicSpotDao
abstract
fun
scenicSpot
Dao
():
ScenicSpotDao
companion
object
{
private
var
_instance
:
AppDatabase
?
=
null
...
...
app/src/main/java/com/mints/street/db/ScenicSpotDao.kt
View file @
bf04b134
package
com.mints.street.db
import
androidx.room.Dao
import
androidx.room.Query
import
androidx.room.*
/**
* Created by 冯瑞雨 on 2021/7/20.
*/
@Dao
interface
ScenicSpotDao
{
@Query
(
"SELECT * FROM scenic_spot"
)
fun
getAll
():
List
<
ScenicSpotBean
>
/**
* 添加 VR 免费专区
* OnConflictStrategy.REPLACE表如已有数据,就覆盖掉。
*/
@Insert
(
onConflict
=
OnConflictStrategy
.
REPLACE
)
fun
addVRFreeZoneAll
(
list
:
List
<
ScenicSpotBean
>)
/**
* 获取 VR 免费专区
*/
@Query
(
"SELECT * FROM vr_scenic_spot"
)
fun
getVRFreeZoneAll
():
List
<
ScenicSpotBean
>
/**
* 删除 VR 免费专区
*/
@Delete
fun
deleteVRFreeZoneAll
(
list
:
List
<
ScenicSpotBean
>)
/**
* 获取 国外的 免费专区
*/
@Query
(
"SELECT * FROM foreign_scenic_spots WHERE is_free = 1"
)
fun
getForeignFreeAll
(
list
:
List
<
ForeignScenicSpots
>)
/**
* 获取 国外的 收费(精选体验)
*/
@Query
(
"SELECT * FROM foreign_scenic_spots WHERE is_free = 2"
)
fun
getForeignTollAll
(
list
:
List
<
ForeignScenicSpots
>)
/**
* 添加 VR 国外
*/
@Insert
(
onConflict
=
OnConflictStrategy
.
REPLACE
)
fun
addForeignAll
(
list
:
List
<
ForeignScenicSpots
>)
/**
* 删除 VR 国外免费
*/
@Query
(
"DELETE FROM foreign_scenic_spots WHERE is_free =1"
)
fun
deleteForeignFreeAll
()
/**
* 删除 VR 国外收费
*/
@Query
(
"DELETE FROM foreign_scenic_spots WHERE is_free =2"
)
fun
deleteForeignTollAll
()
}
\ No newline at end of file
app/src/main/java/com/mints/street/db/TableBean.kt
View file @
bf04b134
...
...
@@ -21,21 +21,31 @@ class ScenicSpotBean(
var
name
:
String
?
=
null
,
//景区 图片
var
images
:
String
?
=
null
,
//景区 url地址
var
url
:
String
?
=
null
,
//景区 星级 默认0-5
@ColumnInfo
(
name
=
"star_rating"
)
var
starRating
:
Int
?
=
null
var
starRating
:
String
?
=
null
)
@Entity
(
tableName
=
"foreign_scenic_spots"
)
class
ForeignScenicSpots
(
//主键 自增
@PrimaryKey
(
autoGenerate
=
true
)
var
id
:
Int
=
0
,
//景区 免费还是收费的 1=免费 2=收费
@ColumnInfo
(
name
=
"is_free"
)
var
isFree
:
Int
,
//景区 经度
var
longitude
:
Double
?=
null
,
//景区 纬度
var
latitude
:
Double
?=
null
,
//景区 目的地的ID
var
did
:
Int
?=
null
,
//景区 名称
var
name
:
String
?
=
null
,
//景区 人数
@ColumnInfo
(
name
=
"number_people"
)
var
numberPeople
:
Int
?
=
null
,
//景区 图片
var
images
:
List
<
String
>?
=
null
...
...
app/src/main/res/layout/item_grid_map_adapter.xml
View file @
bf04b134
...
...
@@ -28,8 +28,9 @@
android:id=
"@+id/tv_name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:padding
Start
=
"10dp"
android:text=
"测试"
android:paddingTop=
"5dp"
android:textColor=
"@color/black"
android:textSize=
"12sp"
/>
...
...
@@ -40,12 +41,23 @@
android:orientation=
"horizontal"
>
</LinearLayout>
<com.mints.street.widget.RatingStar
android:layout_width=
"60dp"
android:layout_height=
"10dp"
app:starNormal=
"@mipmap/star_icon"
app:starNumber=
"5"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
<com.mints.street.widget.RatingStar
android:layout_width=
"wrap_content"
android:layout_height=
"0dp"
android:layout_marginStart=
"10dp"
android:layout_weight=
"1"
app:starNormal=
"@mipmap/star_icon"
app:starNumber=
"5"
/>
</LinearLayout>
</LinearLayout>
</layout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment