Commit e8975bec authored by fengruiyu's avatar fengruiyu

VR的免费专区和精选体验数据库bean类创建

五星展示的功能已完成
parent 76d889c6
...@@ -21,8 +21,8 @@ import me.tatarka.bindingcollectionadapter2.ItemBinding ...@@ -21,8 +21,8 @@ import me.tatarka.bindingcollectionadapter2.ItemBinding
/** /**
* Created by 冯瑞雨 on 2021/7/9. * Created by 冯瑞雨 on 2021/7/9.
*/ */
class EnterDestinationAdapter(val context: Context, val list :String): class EnterDestinationAdapter(val context: Context):
AbstractVLayoutBaseAdapter<EnterDestinationAdapterBinding, String>(context,list,1) { AbstractVLayoutBaseAdapter<EnterDestinationAdapterBinding, Any>(context,null,1) {
private var vLayout: VirtualLayoutManager? = null private var vLayout: VirtualLayoutManager? = null
...@@ -37,7 +37,7 @@ class EnterDestinationAdapter(val context: Context, val list :String): ...@@ -37,7 +37,7 @@ class EnterDestinationAdapter(val context: Context, val list :String):
holder.binding.listView.layoutManager = vLayout holder.binding.listView.layoutManager = vLayout
holder.binding.listView.adapter = mAdapter holder.binding.listView.adapter = mAdapter
mAdapter?.addAdapter(ItemEnterDestinationAdapter(context,"",true)) mAdapter?.addAdapter(ItemEnterDestinationAdapter(context,true))
} }
......
...@@ -17,8 +17,8 @@ import me.goldze.mvvmhabit.utils.KLog ...@@ -17,8 +17,8 @@ import me.goldze.mvvmhabit.utils.KLog
* Created by 冯瑞雨 on 2021/7/9. * Created by 冯瑞雨 on 2021/7/9.
* @param isMultipleLayout 是否是多布局 * @param isMultipleLayout 是否是多布局
*/ */
class ItemEnterDestinationAdapter(val context: Context,string:String,val isMultipleLayout:Boolean) class ItemEnterDestinationAdapter(val context: Context,val isMultipleLayout:Boolean)
:AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding,String>(context,string,1) { :AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding,Any>(context,null,1) {
override fun onBindViewHolder( override fun onBindViewHolder(
holder: BindingViewHolder<ItemEnterDestinationAdapterBinding>, holder: BindingViewHolder<ItemEnterDestinationAdapterBinding>,
position: Int position: Int
......
...@@ -10,4 +10,6 @@ import androidx.room.Query ...@@ -10,4 +10,6 @@ import androidx.room.Query
interface ScenicSpotDao { interface ScenicSpotDao {
@Query("SELECT * FROM scenic_spot") @Query("SELECT * FROM scenic_spot")
fun getAll(): List<ScenicSpotBean> fun getAll(): List<ScenicSpotBean>
} }
\ No newline at end of file
package com.mints.street.db package com.mints.street.db
import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
/** /**
* Created by 冯瑞雨 on 2021/7/20. * Created by 冯瑞雨 on 2021/7/20.
* 景区表 * VR景区表
*/ */
@Entity(tableName = "scenic_spot") @Entity(tableName = "vr_scenic_spot")
class ScenicSpotBean( class ScenicSpotBean(
//主键 自增 //主键 自增
@PrimaryKey(autoGenerate = true) var id: Int = 0, @PrimaryKey(autoGenerate = true)
//景区 类型 1=境内热门景区 2=境内免费专区 3=首页的景区 var id: Int = 0,
var type :Int = 0,
//景区 经度 //景区 经度
var longitude :Double?=null, var longitude :Double?=null,
//景区 纬度 //景区 纬度
...@@ -20,7 +20,23 @@ class ScenicSpotBean( ...@@ -20,7 +20,23 @@ class ScenicSpotBean(
//景区 名称 //景区 名称
var name :String? = null, var name :String? = null,
//景区 图片 //景区 图片
var images : List<String>? = null, var images : String? = null,
//景区 星级 默认0-5 //景区 星级 默认0-5
@ColumnInfo(name="star_rating")
var starRating : Int? = null var starRating : Int? = null
)
@Entity(tableName = "foreign_scenic_spots")
class ForeignScenicSpots(
//主键 自增
@PrimaryKey(autoGenerate = true)
var id: Int = 0,
//景区 经度
var longitude :Double?=null,
//景区 纬度
var latitude :Double?=null,
//景区 名称
var name :String? = null,
//景区 图片
var images : List<String>? = null
) )
\ No newline at end of file
...@@ -40,6 +40,6 @@ class FeaturedExperienceFragment:BaseFragment<FragmentFeaturedExperienceBinding ...@@ -40,6 +40,6 @@ class FeaturedExperienceFragment:BaseFragment<FragmentFeaturedExperienceBinding
binding.listView.layoutManager = vLayout binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter binding.listView.adapter = mAdapter
mAdapter?.addAdapter(ItemEnterDestinationAdapter(context!!, "",false)) mAdapter?.addAdapter(ItemEnterDestinationAdapter(context!!, false))
} }
} }
\ No newline at end of file
...@@ -48,7 +48,7 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel ...@@ -48,7 +48,7 @@ class FreeZoneFragment : BaseFragment<FragmentFreeZoneBinding, FreeZoneViewModel
binding.listView.layoutManager = vLayout binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter binding.listView.adapter = mAdapter
mAdapter?.addAdapter(EnterDestinationAdapter(context!!, "")) mAdapter?.addAdapter(EnterDestinationAdapter(context!! ))
} }
......
package com.mints.street.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.mints.street.R;
import androidx.annotation.Nullable;
/**
* Created by 冯瑞雨 on 2021/7/21.
*/
public class RatingStar extends View {
private int normalId;
private Bitmap normalImg;
private Bitmap focusImg;
private int number;
private int w1;
private int h1;
private int marginLeft;
private int marginTop;
private int marginBottom;
private int marginRight;
private int height;
private int width;
private int p;
private float w0;
private int i0;
private int mGrade;
public RatingStar(Context context) {
this(context,null);
}
public RatingStar(Context context, @Nullable AttributeSet attrs) {
this(context, attrs,0);
}
public RatingStar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RatingStar);
normalId = array.getResourceId(R.styleable.RatingStar_starNormal,0);
normalImg = BitmapFactory.decodeResource(getResources(), normalId);
number = array.getInteger(R.styleable.RatingStar_starNumber,5);
array.recycle();
i0 = -1;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
w1 = normalImg.getWidth();
h1 = normalImg.getHeight();
//中间间隔
p = 10;
// marginTop = 20;
// marginBottom = 20;
// marginLeft = 20;
// marginRight = 20;
height = h1 + marginTop + marginBottom;
width = w1 *number+(number-1)*p +marginLeft+marginRight;
setMeasuredDimension(width, height);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
for (int i = 0; i < number; i++) {
if (i <= i0){
canvas.drawBitmap(focusImg,i*w1+marginLeft+i*p,marginTop,null);
mGrade = i+1;
}else{
canvas.drawBitmap(normalImg,i*w1+marginLeft+i*p,marginTop,null);
}
}
// Log.e("msg","我被调用了!");
}
}
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<LinearLayout <LinearLayout
android:layout_margin="15dp" android:layout_margin="15dp"
android:id="@+id/bg" android:id="@+id/bg"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="230dp" android:layout_height="230dp"
android:background="@drawable/shape_bg_vrdata" android:background="@drawable/shape_bg_vrdata"
android:elevation="5dp" android:elevation="5dp"
...@@ -40,6 +40,12 @@ ...@@ -40,6 +40,12 @@
android:orientation="horizontal"> android:orientation="horizontal">
</LinearLayout> </LinearLayout>
<com.mints.street.widget.RatingStar
android:layout_width="60dp"
android:layout_height="10dp"
app:starNormal="@mipmap/star_icon"
app:starNumber="5"
/>
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
...@@ -16,4 +16,9 @@ ...@@ -16,4 +16,9 @@
<attr name="HorizontalselectedViewTextColor" format="color|reference"></attr> <attr name="HorizontalselectedViewTextColor" format="color|reference"></attr>
</declare-styleable> </declare-styleable>
<declare-styleable name="RatingStar">
<attr name="starNormal" format="reference"/>
<attr name="starFocus" format="reference"/>
<attr name="starNumber" format="integer"/>
</declare-styleable>
</resources> </resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment