@ -0,0 +1,7 @@
|
||||
.gradle
|
||||
/local.properties
|
||||
/build
|
||||
/captures
|
||||
*.iml
|
||||
.idea
|
||||
*.apk #optional
|
@ -0,0 +1,53 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 31
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.travelor"
|
||||
minSdk 24
|
||||
targetSdk 31
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main{
|
||||
jniLibs.srcDirs = ['libs']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation files('libs\\AMap2DMap_6.0.0_AMapSearch_9.7.0_AMapLocation_6.4.2_20231215.jar')
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.0'
|
||||
|
||||
// todo added
|
||||
implementation files('libs/SparkChain.aar')
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-keep class com.amap.** { *; }
|
||||
-dontwarn com.amap.**
|
@ -0,0 +1,26 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.example.travelor", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.example.travelor.bean.Plans;
|
||||
import com.example.travelor.datebase.PlansDbOpenHelper;
|
||||
import com.example.travelor.util.ToastUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class AddActivity extends AppCompatActivity {
|
||||
|
||||
private EditText etMainPlan, etDetails;
|
||||
|
||||
private PlansDbOpenHelper mPlansDbOpenHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add);
|
||||
|
||||
etMainPlan = findViewById(R.id.et_name);
|
||||
etDetails = findViewById(R.id.et_describe);
|
||||
mPlansDbOpenHelper = new PlansDbOpenHelper(this);
|
||||
|
||||
etMainPlan.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
etMainPlan.setSelected(true);
|
||||
} else {
|
||||
etMainPlan.setSelected(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
etDetails.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
etDetails.setSelected(true);
|
||||
} else {
|
||||
etDetails.setSelected(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void add(View view) {
|
||||
String mainPlan = etMainPlan.getText().toString();
|
||||
String details = etDetails.getText().toString();
|
||||
if (TextUtils.isEmpty(mainPlan)) {
|
||||
ToastUtil.toastShort(this, "活动名称不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
Plans plan = new Plans();
|
||||
|
||||
plan.setMainPlan(mainPlan);
|
||||
plan.setDetails(details);
|
||||
plan.setCreateTime(getCurrentTimeFormat());
|
||||
long row = mPlansDbOpenHelper.insertData(plan);
|
||||
if (row != -1) {
|
||||
ToastUtil.toastShort(this, "添加成功!");
|
||||
this.finish();
|
||||
} else {
|
||||
ToastUtil.toastShort(this, "添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentTimeFormat() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
|
||||
Date date = new Date();
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelor.adapter.AttractionCltAdapter;
|
||||
import com.example.travelor.adapter.HotelAdapter;
|
||||
import com.example.travelor.bean.Attractions;
|
||||
import com.example.travelor.datebase.AttrCltDbOpenHelper;
|
||||
import com.example.travelor.util.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AttractionCollectActivity extends AppCompatActivity {
|
||||
private TextView vtManage;
|
||||
private TextView vtBack;
|
||||
private ViewGroup llDelete;
|
||||
private TextView chooseAll;
|
||||
private Button btDelete;
|
||||
private Boolean isChooseAll = false;
|
||||
private Boolean managed = false;
|
||||
|
||||
private List<Attractions> mAttraction;
|
||||
private AttrCltDbOpenHelper mAttrCltDbOpenHelper;
|
||||
private AttractionCltAdapter mAttractionCltAdapter;
|
||||
private RecyclerView collectRecycler;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.attraction_collect_layout);
|
||||
|
||||
vtManage = findViewById(R.id.vt_manage);
|
||||
vtBack = findViewById(R.id.back);
|
||||
llDelete = findViewById(R.id.ll_delete);
|
||||
btDelete = findViewById(R.id.bt_delete);
|
||||
chooseAll = findViewById(R.id.choose_all);
|
||||
|
||||
collectRecycler = findViewById(R.id.collect_rlv);
|
||||
mAttrCltDbOpenHelper = new AttrCltDbOpenHelper(this);
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
vtManage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(managed == false) {
|
||||
vtManage.setText("完成");
|
||||
managed = true;
|
||||
llDelete.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else{
|
||||
vtManage.setText("管理");
|
||||
managed = false;
|
||||
llDelete.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
mAttractionCltAdapter.setCheckBoxStatus(managed);
|
||||
|
||||
deleteManage();
|
||||
}
|
||||
});
|
||||
|
||||
vtBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void deleteManage() {
|
||||
chooseAll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(isChooseAll == false) {
|
||||
isChooseAll = true;
|
||||
mAttractionCltAdapter.chooseAll();
|
||||
chooseAll.setText("取消");
|
||||
}
|
||||
else {
|
||||
isChooseAll = false;
|
||||
mAttractionCltAdapter.cancelAll();
|
||||
chooseAll.setText("全选");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btDelete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAttractionCltAdapter.deleteChosen();
|
||||
ToastUtil.toastShort(AttractionCollectActivity.this, "删除成功!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
llDelete.setVisibility(View.INVISIBLE); // 初始是看不见的
|
||||
|
||||
mAttraction = mAttrCltDbOpenHelper.queryAllFromDb();
|
||||
mAttractionCltAdapter = new AttractionCltAdapter(this, mAttraction);
|
||||
collectRecycler.setAdapter(mAttractionCltAdapter);
|
||||
|
||||
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
||||
collectRecycler.setLayoutManager(linearLayoutManager); // 创建布局管理器
|
||||
mAttractionCltAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.example.travelor.adapter.HotelAdapter;
|
||||
import com.example.travelor.adapter.ImagePagerAdapter;
|
||||
import com.example.travelor.bean.Attractions;
|
||||
import com.example.travelor.bean.Hotels;
|
||||
import com.example.travelor.bean.Plans;
|
||||
import com.example.travelor.datebase.AttrCltDbOpenHelper;
|
||||
import com.example.travelor.datebase.HotelDbOpenHelper;
|
||||
import com.example.travelor.fragment.FrontPageFragment;
|
||||
import com.example.travelor.util.SpfUtil;
|
||||
import com.example.travelor.util.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DetailsPageActivity extends AppCompatActivity {
|
||||
private ViewPager viewPager;
|
||||
private List<Integer> imageList;
|
||||
private ArrayList<View> dots = new ArrayList<>();
|
||||
private Attractions mAttraction;
|
||||
|
||||
private TextView tvName;
|
||||
private TextView tvRank;
|
||||
private TextView tvLocation;
|
||||
private List<ImageView> imageViews = new ArrayList<>();
|
||||
private TextView tvPrice;
|
||||
private TextView tvIntroduce;
|
||||
private TextView back;
|
||||
|
||||
private VideoView videoView;
|
||||
private Button btnToggle;
|
||||
private int currentPosition = 1;
|
||||
private boolean isPlaying = false;
|
||||
|
||||
private Context mContext;
|
||||
private View likeItIcon;
|
||||
private View locationIcon;
|
||||
public static final String KEY_COLLECTED = "collected";
|
||||
|
||||
private RecyclerView hotelRecycler;
|
||||
private List<Hotels> mHotels;
|
||||
private HotelAdapter mHotelAdapter;
|
||||
private HotelDbOpenHelper mHotelDbOpenHelper;
|
||||
|
||||
private Button btCollect;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.details_page_layout);
|
||||
mContext = this;
|
||||
|
||||
tvName = findViewById(R.id.name);
|
||||
tvRank = findViewById(R.id.rank);
|
||||
tvPrice = findViewById(R.id.price);
|
||||
tvIntroduce = findViewById(R.id.introduce);
|
||||
tvLocation = findViewById(R.id.location);
|
||||
btCollect = findViewById(R.id.buy_now);
|
||||
imageViews.add((ImageView)findViewById(R.id.photo1));
|
||||
imageViews.add((ImageView)findViewById(R.id.photo2));
|
||||
imageViews.add((ImageView)findViewById(R.id.photo3));
|
||||
|
||||
hotelRecycler = findViewById(R.id.hotel_rl);
|
||||
mHotels = new ArrayList<>();
|
||||
mHotelDbOpenHelper = new HotelDbOpenHelper(this);
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
imageSwitch();
|
||||
videoPlayer();
|
||||
setLikeIt();
|
||||
viewRoute();
|
||||
backEvent();
|
||||
collect();
|
||||
}
|
||||
|
||||
private void collect() {
|
||||
btCollect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AttrCltDbOpenHelper attractionCollectDbOpenHelper = new AttrCltDbOpenHelper(mContext);
|
||||
long row = attractionCollectDbOpenHelper.insertData(mAttraction);
|
||||
if (row != -1) {
|
||||
ToastUtil.toastShort(mContext, "收藏成功!");
|
||||
} else {
|
||||
ToastUtil.toastShort(mContext, "已收藏!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void backEvent() {
|
||||
back = findViewById(R.id.turn_back);
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查看路线
|
||||
private void viewRoute() {
|
||||
locationIcon = findViewById(R.id.location_icon);
|
||||
locationIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(DetailsPageActivity.this, GaodeMapActivity.class);
|
||||
intent.putExtra("attraction", mAttraction);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 设置收藏点亮
|
||||
private void setLikeIt() {
|
||||
likeItIcon = findViewById(R.id.likeIt_icon);
|
||||
|
||||
likeItIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Boolean isCollected = SpfUtil.getBoolean(DetailsPageActivity.this, KEY_COLLECTED);
|
||||
if(isCollected) {
|
||||
likeItIcon.setSelected(false);
|
||||
SpfUtil.saveBoolean(DetailsPageActivity.this, KEY_COLLECTED, false);
|
||||
}
|
||||
else {
|
||||
likeItIcon.setSelected(true);
|
||||
SpfUtil.saveBoolean(DetailsPageActivity.this, KEY_COLLECTED, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 风景图设置
|
||||
private void setImages(String imagesString) {
|
||||
String[] imageNames = imagesString.split("#");
|
||||
|
||||
for (int i = 0; i < imageNames.length; i++) {
|
||||
int id = getResources().getIdentifier(imageNames[i], "drawable", getPackageName());
|
||||
imageViews.get(i).setImageResource(id);
|
||||
}
|
||||
}
|
||||
|
||||
// 接收数据并初始化
|
||||
private void initData() {
|
||||
Intent intent = getIntent();
|
||||
mAttraction = (Attractions) intent.getSerializableExtra("attraction");
|
||||
if (mAttraction != null) {
|
||||
tvName.setText(mAttraction.getName());
|
||||
tvRank.setText(mAttraction.getRank());
|
||||
tvIntroduce.setText(" " + mAttraction.getIntroduce());
|
||||
tvLocation.setText("地理位置: "+mAttraction.getLocation());
|
||||
tvPrice.setText("¥ " + mAttraction.getPrice());
|
||||
setImages(mAttraction.getImages());
|
||||
}
|
||||
|
||||
initHotel(mAttraction.getName());
|
||||
}
|
||||
|
||||
// 处理酒店视图
|
||||
private void initHotel(String mAttraction) {
|
||||
mHotels = mHotelDbOpenHelper.queryFromDbByAttraction("杭州西湖"); // todo 动态景点名称
|
||||
mHotelAdapter = new HotelAdapter(this, mHotels);
|
||||
hotelRecycler.setAdapter(mHotelAdapter);
|
||||
|
||||
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
|
||||
hotelRecycler.setLayoutManager(linearLayoutManager); // 创建布局管理器
|
||||
mHotelAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
//视频播放
|
||||
private void videoPlayer() {
|
||||
videoView = findViewById(R.id.videoView);
|
||||
btnToggle = findViewById(R.id.btnToggle);
|
||||
|
||||
String videoPath = "android.resource://" + getPackageName() + "/" + R.raw.west_lack;
|
||||
Uri uri = Uri.parse(videoPath);
|
||||
videoView.setVideoURI(uri);
|
||||
videoView.requestFocus();
|
||||
videoView.seekTo(currentPosition);
|
||||
|
||||
btnToggle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(!isPlaying) {
|
||||
videoView.seekTo(currentPosition); // 设置播放位置
|
||||
videoView.start();
|
||||
isPlaying = true;
|
||||
btnToggle.setSelected(true);
|
||||
btnToggle.setVisibility(View.INVISIBLE);
|
||||
setBtnVisible();
|
||||
}
|
||||
else { // 如果正在播放,则停止播放
|
||||
videoView.pause();
|
||||
currentPosition = videoView.getCurrentPosition(); // 记录当前播放位置;
|
||||
isPlaying = false;
|
||||
btnToggle.setSelected(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 开始停止播放逻辑
|
||||
private void setBtnVisible() {
|
||||
videoView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(btnToggle.getVisibility() == View.INVISIBLE)
|
||||
btnToggle.setVisibility(View.VISIBLE);
|
||||
else btnToggle.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 图片轮回切换
|
||||
private void imageSwitch() {
|
||||
viewPager = findViewById(R.id.viewPager);
|
||||
imageList = new ArrayList<>(); // 存储图片资源的列表
|
||||
final int[] position = {0}; // 当前显示的图片索引
|
||||
|
||||
// 添加图片资源到列表
|
||||
imageList.add(R.drawable.west_lake1);
|
||||
imageList.add(R.drawable.west_lake2);
|
||||
imageList.add(R.drawable.west_lake3);
|
||||
|
||||
dots.add(findViewById(R.id.p1));
|
||||
dots.add(findViewById(R.id.p2));
|
||||
dots.add(findViewById(R.id.p3));
|
||||
|
||||
// 创建适配器并设置给ViewPager
|
||||
ImagePagerAdapter adapter = new ImagePagerAdapter(imageList);
|
||||
viewPager.setAdapter(adapter);
|
||||
|
||||
// 设置自动切换
|
||||
Handler handler = new Handler();
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int oldPosition = position[0];
|
||||
position[0] = (position[0] + 1) % imageList.size();
|
||||
|
||||
viewPager.setCurrentItem(position[0], true);
|
||||
dots.get(oldPosition).setBackgroundResource(R.drawable.dot_normal);
|
||||
dots.get(position[0]).setBackgroundResource(R.drawable.dot_focus);
|
||||
|
||||
handler.postDelayed(this, 1000); // 设置延时时间(单位:毫秒)
|
||||
}
|
||||
};
|
||||
|
||||
// 启动自动切换
|
||||
handler.postDelayed(runnable, 1000); // 设置初始延时时间(单位:毫秒)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelor.bean.Plans;
|
||||
import com.example.travelor.datebase.PlansDbOpenHelper;
|
||||
import com.example.travelor.util.ToastUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class EditPlanActivity extends AppCompatActivity {
|
||||
private TextView et_mainPlan;
|
||||
private TextView et_details;
|
||||
private TextView createTime;
|
||||
private Plans mPlan;
|
||||
private PlansDbOpenHelper mPlansDbOpenHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_edit_plan);
|
||||
|
||||
et_mainPlan = findViewById(R.id.et_name);
|
||||
et_details = findViewById(R.id.et_describe);
|
||||
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Intent intent = getIntent();
|
||||
mPlan = (Plans) intent.getSerializableExtra("plan");
|
||||
if (mPlan != null) {
|
||||
et_mainPlan.setText(mPlan.getMainPlan());
|
||||
et_details.setText(mPlan.getDetails());
|
||||
}
|
||||
mPlansDbOpenHelper = new PlansDbOpenHelper(this);
|
||||
}
|
||||
|
||||
public void save(View view) {
|
||||
String mainPlan = et_mainPlan.getText().toString();
|
||||
String details = et_details.getText().toString();
|
||||
if (TextUtils.isEmpty(mainPlan)) {
|
||||
ToastUtil.toastShort(this, "标题不能为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
mPlan.setMainPlan(mainPlan);
|
||||
mPlan.setDetails(details);
|
||||
mPlan.setCreateTime(getCurrentTimeFormat());
|
||||
long rowId = mPlansDbOpenHelper.updateData(mPlan);
|
||||
if (rowId != -1) {
|
||||
ToastUtil.toastShort(this, "修改成功!");
|
||||
this.finish();
|
||||
}else{
|
||||
ToastUtil.toastShort(this, "修改失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getCurrentTimeFormat() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd日 HH:mm:ss");
|
||||
Date date = new Date();
|
||||
return sdf.format(date);
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.travelor.util.SpfUtil;
|
||||
|
||||
import com.example.travelor.datebase.UsersDbOpenHelper;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private EditText etAccount, etPassword;
|
||||
private Button btnLogin;
|
||||
private TextView etSignIn;
|
||||
private CheckBox cbRememberMe;
|
||||
|
||||
private UsersDbOpenHelper mUsersDbOpenHelper;
|
||||
|
||||
public static final String KEY_ACCOUNT = "account";
|
||||
public static final String KEY_PASSWORD = "password";
|
||||
public static final String KEY_REMEMBER_CHECK = "remember_check";
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.login_layout);
|
||||
|
||||
etAccount = findViewById(R.id.account);
|
||||
etPassword = findViewById(R.id.password);
|
||||
btnLogin = findViewById(R.id.buttonLogin);
|
||||
etSignIn = findViewById(R.id.sign_new_account);
|
||||
cbRememberMe = findViewById(R.id.checkbox);
|
||||
|
||||
// 自动填充记录
|
||||
String rmAccount = SpfUtil.getString(this, KEY_ACCOUNT);
|
||||
String rmPassword = SpfUtil.getString(this, KEY_PASSWORD);
|
||||
Boolean rmCheck = SpfUtil.getBoolean(this, KEY_REMEMBER_CHECK);
|
||||
etAccount.setText(rmAccount);
|
||||
etPassword.setText(rmPassword);
|
||||
cbRememberMe.setChecked(rmCheck);
|
||||
|
||||
btnLogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String account = etAccount.getText().toString();
|
||||
String password = etPassword.getText().toString();
|
||||
|
||||
// 进行登录验证逻辑
|
||||
if (isValidCredentials(account, password)) {
|
||||
rememberMe(account, password);
|
||||
|
||||
// 登录成功,跳转到主界面或其他目标界面
|
||||
Intent intent = new Intent(LoginActivity.this, PageJumpActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
// 登录失败,显示错误消息
|
||||
Toast.makeText(LoginActivity.this, "账号或密码错误!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
etSignIn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(LoginActivity.this, SignInActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void rememberMe(String account, String password) {
|
||||
boolean isChecked = cbRememberMe.isChecked();
|
||||
if(isChecked) {
|
||||
SpfUtil.saveString(this, KEY_ACCOUNT, account);
|
||||
SpfUtil.saveString(this, KEY_PASSWORD, password);
|
||||
SpfUtil.saveBoolean(this, KEY_REMEMBER_CHECK, true);
|
||||
}
|
||||
else {
|
||||
SpfUtil.saveString(this, KEY_ACCOUNT, "");
|
||||
SpfUtil.saveString(this, KEY_PASSWORD, "");
|
||||
SpfUtil.saveBoolean(this, KEY_REMEMBER_CHECK, false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidCredentials(String account, String password) {
|
||||
mUsersDbOpenHelper = new UsersDbOpenHelper(this);
|
||||
String realPassword = mUsersDbOpenHelper.queryFromDbByAccount(account);
|
||||
if(realPassword.equals("") || !realPassword.equals(password))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.example.travelor.fragment.FrontPageFragment;
|
||||
|
||||
import com.example.travelor.fragment.MineFragment;
|
||||
import com.example.travelor.fragment.PlanFragment;
|
||||
import com.example.travelor.fragment.SparkAiFragment;
|
||||
|
||||
public class PageJumpActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main_page_layout);
|
||||
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
FragmentTransaction ft = fm.beginTransaction();
|
||||
FrontPageFragment fgm_front_page = new FrontPageFragment();
|
||||
ft.replace(R.id.main_fragment, fgm_front_page);
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
public void page_jump(View view) {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
FragmentTransaction ft = fm.beginTransaction();
|
||||
|
||||
FrontPageFragment fgm_front_page = new FrontPageFragment();
|
||||
PlanFragment fgm_plan_page = new PlanFragment();
|
||||
MineFragment fgm_mine_page = new MineFragment();
|
||||
SparkAiFragment fgm_spark_page = new SparkAiFragment();
|
||||
|
||||
switch (view.getId()){
|
||||
case R.id.front_page:
|
||||
ft.replace(R.id.main_fragment, fgm_front_page);
|
||||
break;
|
||||
case R.id.plan:
|
||||
ft.replace(R.id.main_fragment, fgm_plan_page);
|
||||
break;
|
||||
case R.id.mine:
|
||||
ft.replace(R.id.main_fragment, fgm_mine_page);
|
||||
break;
|
||||
case R.id.spark:
|
||||
ft.replace(R.id.main_fragment, fgm_spark_page);
|
||||
break;
|
||||
}
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
package com.example.travelor;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.travelor.bean.Users;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
import com.example.travelor.datebase.UsersDbOpenHelper;
|
||||
|
||||
public class SignInActivity extends AppCompatActivity {
|
||||
private EditText etAccount;
|
||||
private EditText etPassword;
|
||||
private EditText etConfirmPwd;
|
||||
private EditText etUserName;
|
||||
private EditText etVerifyCode;
|
||||
private Button btnSignIn;
|
||||
private Button btnVerify;
|
||||
private TextView tvAgree;
|
||||
private TextView tvLogin;
|
||||
private CheckBox ckAgree;
|
||||
private UsersDbOpenHelper mUsersDbOpenHelper;
|
||||
|
||||
private String verification_code = "";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.sign_in_layout);
|
||||
|
||||
etAccount = findViewById(R.id.sign_account);
|
||||
etPassword = findViewById(R.id.new_password);
|
||||
etConfirmPwd = findViewById(R.id.confirm_password);
|
||||
etVerifyCode = findViewById(R.id.verification_code);
|
||||
etUserName = findViewById(R.id.username);
|
||||
btnSignIn = findViewById(R.id.buttonSignIn);
|
||||
btnVerify = findViewById(R.id.sent_VerifyCode);
|
||||
tvAgree = findViewById(R.id.agree_pact);
|
||||
tvLogin = findViewById(R.id.tvlogin);
|
||||
ckAgree = findViewById(R.id.agree_check);
|
||||
mUsersDbOpenHelper = new UsersDbOpenHelper(this);
|
||||
|
||||
//发送验证码
|
||||
btnVerify.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Random random = new Random();
|
||||
int randomNumber = 1000 + random.nextInt(9000);
|
||||
verification_code = String.valueOf(randomNumber);
|
||||
|
||||
Toast.makeText(SignInActivity.this, verification_code, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
// 注册按钮
|
||||
btnSignIn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String mAccount = etAccount.getText().toString();
|
||||
String mPassword = etPassword.getText().toString();
|
||||
String mConfirmPwd = etConfirmPwd.getText().toString();
|
||||
String mVerifyCode = etVerifyCode.getText().toString();
|
||||
String UserName = etUserName.getText().toString();
|
||||
|
||||
Boolean is_OK = isValidAccount(mAccount, mPassword, mConfirmPwd, mVerifyCode, UserName);
|
||||
if(is_OK) {
|
||||
saveDate(mAccount, mPassword, UserName);
|
||||
Toast.makeText(SignInActivity.this, "注册成功!", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Intent intent = new Intent(SignInActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tvAgree.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(SignInActivity.this);
|
||||
builder.setTitle("安全协议");
|
||||
builder.setMessage("xxxxxxxxx\nxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxx");
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton("同意", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ckAgree.setChecked(true);
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
});
|
||||
|
||||
tvLogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(SignInActivity.this, LoginActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 获取当前时间
|
||||
private String getCurrentTimeFormat() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
|
||||
Date date = new Date();
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
|
||||
// 将新用户保存到数据库
|
||||
private void saveDate(String mAccount, String mPassword, String userName) {
|
||||
Users newUser = new Users();
|
||||
|
||||
newUser.setAccount(mAccount);
|
||||
newUser.setUserName(userName);
|
||||
newUser.setPassword(mPassword);
|
||||
newUser.setCreatedTime(getCurrentTimeFormat());
|
||||
|
||||
mUsersDbOpenHelper.insertData(newUser);
|
||||
}
|
||||
|
||||
// 判断新用户设置是否合法
|
||||
private Boolean isValidAccount(String mAccount, String mPassword, String mConfirmPwd, String mVerifyCode, String userName) {
|
||||
String regex = "^1[3456789]\\d{9}$";
|
||||
if(!mAccount.matches(regex)) {
|
||||
Toast.makeText(SignInActivity.this, "账号不合法!", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
if(!mUsersDbOpenHelper.queryFromDbByAccount(mAccount).equals("")) {
|
||||
Toast.makeText(SignInActivity.this, "此账号已经存在,请登录!", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
if(mPassword.length() < 6) {
|
||||
Toast.makeText(SignInActivity.this, "密码太短!", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
if(!mConfirmPwd.equals(mPassword)) {
|
||||
Toast.makeText(SignInActivity.this, "密码确认有误!", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
if(verification_code.equals("") || !mVerifyCode.equals(verification_code)) {
|
||||
Toast.makeText(SignInActivity.this, "验证码错误!", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
if(!ckAgree.isChecked()) {
|
||||
Toast.makeText(SignInActivity.this, "请同意协议!", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.example.travelor.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelor.DetailsPageActivity;
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.bean.Attractions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.travelor.datebase.AttractionDbOpenHelper;
|
||||
|
||||
public class AttractionCardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private List<Attractions> mAttractionList;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
|
||||
private AttractionDbOpenHelper mAttractionDbOpenHelper;
|
||||
|
||||
public AttractionCardAdapter(Context context, List<Attractions> mAttractionList){
|
||||
this.mAttractionList = mAttractionList;
|
||||
this.mContext = context;
|
||||
mLayoutInflater = LayoutInflater.from(mContext);
|
||||
mAttractionDbOpenHelper = new AttractionDbOpenHelper(mContext);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mLayoutInflater.inflate(R.layout.attraction_card, parent, false);
|
||||
MyViewHolder myViewHolder = new MyViewHolder(view);
|
||||
|
||||
return myViewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
bindViewHolder((MyViewHolder) holder, position);
|
||||
}
|
||||
|
||||
private void bindViewHolder(MyViewHolder holder, int position) {
|
||||
Attractions attraction = mAttractionList.get(position);
|
||||
holder.mAttrName.setText(attraction.getName());
|
||||
holder.mAttrRank.setText(attraction.getRank());
|
||||
holder.mAttrLocation.setText(attraction.getLocation());
|
||||
|
||||
// holder.mAttrImage.setImageResource(R.drawable.circular_image);
|
||||
// 动态设置图片
|
||||
holder.mAttrImage.setImageResource(getResourceId(attraction.getImages()));
|
||||
|
||||
holder.mCardContain.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
Intent intent = new Intent(mContext, DetailsPageActivity.class);
|
||||
intent.putExtra("attraction", attraction);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getResourceId(String fileNames) {
|
||||
String[] imageNames = fileNames.split("#");
|
||||
String resourceName = imageNames[0];
|
||||
String resourceType = "drawable";
|
||||
String packageName = mContext.getPackageName();
|
||||
return mContext.getResources().getIdentifier(resourceName, resourceType, packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mAttractionList.size();
|
||||
}
|
||||
|
||||
public void refreshData(List<Attractions> mAttractions) {
|
||||
this.mAttractionList = mAttractions;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
// 用于保存 list_item.xml 中的视图组件
|
||||
class MyViewHolder extends RecyclerView.ViewHolder{
|
||||
ImageView mAttrImage;
|
||||
TextView mAttrName;
|
||||
TextView mAttrRank;
|
||||
TextView mAttrLocation;
|
||||
ViewGroup mCardContain;
|
||||
|
||||
public MyViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.mAttrImage = itemView.findViewById(R.id.attraction_image);
|
||||
this.mAttrName = itemView.findViewById(R.id.attraction_name);
|
||||
this.mAttrRank = itemView.findViewById(R.id.rank);
|
||||
this.mAttrLocation = itemView.findViewById(R.id.location);
|
||||
this.mCardContain = itemView.findViewById(R.id.card_contain);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
package com.example.travelor.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelor.DetailsPageActivity;
|
||||
import com.example.travelor.LoginActivity;
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.SignInActivity;
|
||||
import com.example.travelor.bean.Attractions;
|
||||
import com.example.travelor.datebase.AttrCltDbOpenHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AttractionCltAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private List<Attractions> mAttractionList;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
private Boolean checkboxVisible = false;
|
||||
private Boolean mChooseAll = false;
|
||||
private AttrCltDbOpenHelper mAttrCltDbOpenHelper;
|
||||
private boolean mCancelAll = false;
|
||||
private boolean[] checkedPositions; // 跟踪复选框的选中状态
|
||||
|
||||
public AttractionCltAdapter(Context context, List<Attractions> mAttraction) {
|
||||
this.mAttractionList = mAttraction;
|
||||
this.mContext = context;
|
||||
mLayoutInflater = LayoutInflater.from(mContext);
|
||||
mAttrCltDbOpenHelper = new AttrCltDbOpenHelper(mContext);
|
||||
checkedPositions = new boolean[mAttraction.size()];
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mLayoutInflater.inflate(R.layout.attraction_collect_card, parent, false);
|
||||
AttractionCltAdapter.MyViewHolder myViewHolder = new AttractionCltAdapter.MyViewHolder(view);
|
||||
|
||||
return myViewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
bindViewHolder((AttractionCltAdapter.MyViewHolder) holder, position);
|
||||
}
|
||||
|
||||
private void bindViewHolder(AttractionCltAdapter.MyViewHolder holder, int position) {
|
||||
Attractions attraction = mAttractionList.get(position);
|
||||
holder.mAttrName.setText(attraction.getName());
|
||||
holder.mAttrLocation.setText(attraction.getLocation());
|
||||
// holder.mAttrImage.setImageResource(R.drawable.west_lake1); // todo
|
||||
|
||||
// 动态设置图片
|
||||
holder.mAttrImage.setImageResource(getResourceId(attraction.getImages()));
|
||||
String introduce = attraction.getIntroduce();
|
||||
// 卡片简介不能太长
|
||||
holder.mAttrIntroduce.setText("简介:" + introduce.substring(0, Math.min(introduce.length(), 15)));
|
||||
|
||||
if (checkboxVisible) {
|
||||
holder.mChoice.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.mChoice.setVisibility(View.INVISIBLE);
|
||||
checkedPositions[position] = false;
|
||||
}
|
||||
|
||||
holder.mChoice.setChecked(checkedPositions[position]);
|
||||
holder.mChoice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
checkedPositions[position] = isChecked; // 更新选中状态
|
||||
}
|
||||
});
|
||||
|
||||
holder.mDetails.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mContext, DetailsPageActivity.class);
|
||||
intent.putExtra("attraction", attraction);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int getResourceId(String fileNames) {
|
||||
String[] imageNames = fileNames.split("#");
|
||||
String resourceName = imageNames[0];
|
||||
String resourceType = "drawable";
|
||||
String packageName = mContext.getPackageName();
|
||||
return mContext.getResources().getIdentifier(resourceName, resourceType, packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mAttractionList.size();
|
||||
}
|
||||
|
||||
public void refreshData(List<Attractions> mAttractions) {
|
||||
this.mAttractionList = mAttractions;
|
||||
for (int i = 0; i < mAttractionList.size(); i++)
|
||||
checkedPositions[i] = false;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setCheckBoxStatus(Boolean managed) {
|
||||
this.checkboxVisible = managed;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void chooseAll() {
|
||||
for (int i = 0; i < mAttractionList.size(); i++)
|
||||
checkedPositions[i] = true;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void deleteChosen() {
|
||||
List<Attractions> newAttractionList = new ArrayList<>();
|
||||
for (int i = 0; i < mAttractionList.size(); i++) {
|
||||
if (checkedPositions[i])
|
||||
mAttrCltDbOpenHelper.deleteFromDbByName(mAttractionList.get(i).getName());
|
||||
else newAttractionList.add(mAttractionList.get(i));
|
||||
}
|
||||
refreshData(newAttractionList);
|
||||
}
|
||||
|
||||
public void cancelAll() {
|
||||
for (int i = 0; i < mAttractionList.size(); i++)
|
||||
checkedPositions[i] = false;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder{
|
||||
ImageView mAttrImage;
|
||||
TextView mAttrName;
|
||||
TextView mAttrLocation;
|
||||
TextView mAttrIntroduce;
|
||||
TextView mDetails;
|
||||
CheckBox mChoice;
|
||||
ViewGroup mCardContain;
|
||||
|
||||
public MyViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.mAttrImage = itemView.findViewById(R.id.image);
|
||||
this.mAttrName = itemView.findViewById(R.id.name);
|
||||
this.mAttrLocation = itemView.findViewById(R.id.location);
|
||||
this.mAttrIntroduce = itemView.findViewById(R.id.introduce);
|
||||
this.mCardContain = itemView.findViewById(R.id.card_contain);
|
||||
this.mDetails = itemView.findViewById(R.id.details);
|
||||
this.mChoice = itemView.findViewById(R.id.cb_choice);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.example.travelor.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.bean.Chats;
|
||||
import com.example.travelor.datebase.ChatDbOpenHelper;
|
||||
import com.example.travelor.datebase.PlansDbOpenHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChatAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
|
||||
private List<Chats> mChatsList;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
private ChatDbOpenHelper mChatDbOpenHelper;
|
||||
|
||||
private int viewType;
|
||||
|
||||
public static int TYPE_AI_LAYOUT = 0;
|
||||
public static int TYPE_USER_LAYOUT = 1;
|
||||
|
||||
public ChatAdapter(Context context, List<Chats> mChatsList){
|
||||
this.mChatsList = mChatsList;
|
||||
this.mContext = context;
|
||||
mLayoutInflater = LayoutInflater.from(mContext);
|
||||
mChatDbOpenHelper = new ChatDbOpenHelper(mContext); // 创建数据库管理对象
|
||||
}
|
||||
|
||||
public int getItemViewType(int position) {
|
||||
String identity = mChatsList.get(position).getIdentity();
|
||||
if (identity.equals("ai")) viewType = TYPE_AI_LAYOUT;
|
||||
else viewType = TYPE_USER_LAYOUT;
|
||||
return viewType;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if(viewType == TYPE_AI_LAYOUT){
|
||||
View view = mLayoutInflater.inflate(R.layout.ai_response_item, parent, false);
|
||||
AiViewHolder aiViewHolder = new AiViewHolder(view);
|
||||
return aiViewHolder;
|
||||
}else if(viewType == TYPE_USER_LAYOUT){
|
||||
View view = mLayoutInflater.inflate(R.layout.user_ask_item, parent, false);
|
||||
UserViewHolder myGridViewHolder = new UserViewHolder(view);
|
||||
return myGridViewHolder;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder == null) {
|
||||
return;
|
||||
}
|
||||
if(holder instanceof AiViewHolder){ // 判断holder的类型
|
||||
bindAiViewHolder((AiViewHolder) holder, position);
|
||||
} else if (holder instanceof UserViewHolder) {
|
||||
bindUserViewHolder((UserViewHolder) holder, position);
|
||||
}
|
||||
}
|
||||
|
||||
private void bindUserViewHolder(UserViewHolder holder, int position) {
|
||||
Chats chat = mChatsList.get(position);
|
||||
|
||||
holder.userContent.setText(chat.getContent());
|
||||
// todo 头像
|
||||
}
|
||||
|
||||
private void bindAiViewHolder(AiViewHolder holder, int position) {
|
||||
Chats chat = mChatsList.get(position);
|
||||
holder.aiContent.setText(chat.getContent());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mChatsList.size();
|
||||
}
|
||||
|
||||
// 刷新数据
|
||||
public void refreshData(List<Chats> chats) {
|
||||
this.mChatsList = chats;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class AiViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView aiContent;
|
||||
public AiViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.aiContent = itemView.findViewById(R.id.ai_content);
|
||||
}
|
||||
}
|
||||
class UserViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView userContent;
|
||||
ViewGroup chatContain;
|
||||
|
||||
public UserViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.userContent = itemView.findViewById(R.id.user_content);
|
||||
this.chatContain = itemView.findViewById(R.id.user_contain);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.example.travelor.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.bean.Hotels;
|
||||
import com.example.travelor.datebase.HotelDbOpenHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HotelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private List<Hotels> mHotelList;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
|
||||
public HotelAdapter(Context context, List<Hotels> mHotelList){
|
||||
this.mHotelList = mHotelList;
|
||||
this.mContext = context;
|
||||
mLayoutInflater = LayoutInflater.from(mContext);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mLayoutInflater.inflate(R.layout.hotel_item_layout, parent, false);
|
||||
HtViewHolder htViewHolder = new HtViewHolder(view);
|
||||
|
||||
return htViewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
bindViewHolder((HtViewHolder) holder, position);
|
||||
}
|
||||
|
||||
private void bindViewHolder(HtViewHolder holder, int position) {
|
||||
Hotels hotel = mHotelList.get(position);
|
||||
|
||||
holder.mHotelName.setText(hotel.getHotelName());
|
||||
holder.mHotelPrice.setText(hotel.getHotelPrice());
|
||||
holder.mHotelScore.setText(hotel.getHotelScore());
|
||||
holder.mHotelRank.setText(hotel.getHotelRank());
|
||||
holder.mHotelLocation.setText(hotel.getHotelLocation());
|
||||
|
||||
holder.mCardContain.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// todo 收藏
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mHotelList.size();
|
||||
}
|
||||
|
||||
public void refreshData(List<Hotels> mHotels) {
|
||||
this.mHotelList = mHotels;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class HtViewHolder extends RecyclerView.ViewHolder{
|
||||
ImageView mHotelImage;
|
||||
TextView mHotelName;
|
||||
TextView mHotelRank;
|
||||
TextView mHotelLocation;
|
||||
TextView mHotelScore;
|
||||
TextView mHotelPrice;
|
||||
ViewGroup mCardContain;
|
||||
|
||||
public HtViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.mHotelName = itemView.findViewById(R.id.hotel_name);
|
||||
this.mHotelImage = itemView.findViewById(R.id.hotel_image);
|
||||
this.mHotelLocation = itemView.findViewById(R.id.hotel_location);
|
||||
this.mHotelRank = itemView.findViewById(R.id.hotel_rank);
|
||||
this.mHotelScore = itemView.findViewById(R.id.hotel_score);
|
||||
this.mHotelPrice = itemView.findViewById(R.id.hotel_price);
|
||||
this.mCardContain = itemView.findViewById(R.id.hotel_card);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.example.travelor.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImagePagerAdapter extends PagerAdapter {
|
||||
private List<Integer> imageList;
|
||||
|
||||
public ImagePagerAdapter(List<Integer> imageList) {
|
||||
this.imageList = imageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return imageList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||
ImageView imageView = new ImageView(container.getContext());
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
imageView.setImageResource(imageList.get(position));
|
||||
container.addView(imageView);
|
||||
return imageView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||
container.removeView((View) object);
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package com.example.travelor.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.travelor.EditPlanActivity;
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.bean.Plans;
|
||||
import com.example.travelor.datebase.PlansDbOpenHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlanAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
private List<Plans> mPlansList;
|
||||
private LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
private boolean isSwipeActive = false;
|
||||
private final int SWIPE_THRESHOLD = 4;
|
||||
private float startX;
|
||||
private PlansDbOpenHelper mPlansDbOpenHelper;
|
||||
|
||||
public PlanAdapter(Context context, List<Plans> mPlansList){
|
||||
this.mPlansList = mPlansList;
|
||||
this.mContext = context;
|
||||
mLayoutInflater = LayoutInflater.from(mContext);
|
||||
mPlansDbOpenHelper = new PlansDbOpenHelper(mContext); // 创建数据库管理对象
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mLayoutInflater.inflate(R.layout.one_plan, parent, false);
|
||||
PlanAdapter.MyViewHolder myViewHolder = new PlanAdapter.MyViewHolder(view);
|
||||
return myViewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
bindViewHolder((PlanAdapter.MyViewHolder) holder, position);
|
||||
}
|
||||
|
||||
private void bindViewHolder(PlanAdapter.MyViewHolder holder, int position) {
|
||||
Plans plan = mPlansList.get(position);
|
||||
|
||||
holder.planIndex.setText(Integer.toString(position + 1));
|
||||
holder.mainPlan.setText(plan.getMainPlan());
|
||||
holder.planDetails.setText(plan.getDetails());
|
||||
holder.createTime.setText(plan.getCreateTime());
|
||||
|
||||
holder.planContain.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
startX = event.getX();
|
||||
isSwipeActive = false;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
float distanceX = event.getX() - startX;
|
||||
if (distanceX < SWIPE_THRESHOLD) {
|
||||
isSwipeActive = true;
|
||||
holder.handleContain.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else if(distanceX > SWIPE_THRESHOLD) {
|
||||
isSwipeActive = false;
|
||||
holder.handleContain.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
holder.deleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int row = mPlansDbOpenHelper.deleteFromDbById(plan.getId());
|
||||
if (row > 0) {
|
||||
removeData(position);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.editButton.setOnClickListener((new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mContext, EditPlanActivity.class);
|
||||
intent.putExtra("plan", plan);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private void removeData(int position) {
|
||||
mPlansList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mPlansList.size();
|
||||
}
|
||||
|
||||
public void refreshData(List<Plans> mPlansList) {
|
||||
this.mPlansList = mPlansList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class MyViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView planIndex;
|
||||
TextView mainPlan;
|
||||
TextView planDetails;
|
||||
TextView createTime;
|
||||
ViewGroup planContain;
|
||||
ViewGroup handleContain;
|
||||
ImageButton editButton;
|
||||
ImageButton deleteButton;
|
||||
|
||||
public MyViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.planIndex = itemView.findViewById(R.id.plan_index);
|
||||
this.mainPlan = itemView.findViewById(R.id.main_plan);
|
||||
this.planDetails = itemView.findViewById(R.id.details);
|
||||
this.createTime = itemView.findViewById(R.id.create_time);
|
||||
this.planContain = itemView.findViewById(R.id.plan_contain);
|
||||
this.handleContain = itemView.findViewById(R.id.handle_buttons);
|
||||
this.editButton = itemView.findViewById(R.id.edit_button);
|
||||
this.deleteButton = itemView.findViewById(R.id.delete_button);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.example.travelor.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class Attractions implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String location;
|
||||
private String introduce;
|
||||
private String hotels;
|
||||
private String images;
|
||||
private String video;
|
||||
private String price;
|
||||
private String rank;
|
||||
private String category;
|
||||
|
||||
public String getId() { return id; }
|
||||
|
||||
public void setId(String id) { this.id = id; }
|
||||
|
||||
public void setCategory(String category) { this.category = category; }
|
||||
|
||||
public String getCategory() { return category; }
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void setIntroduce(String introduce) {
|
||||
this.introduce = introduce;
|
||||
}
|
||||
|
||||
public void setHotels(String hotels) {
|
||||
this.hotels = hotels;
|
||||
}
|
||||
|
||||
public void setImages(String images) {
|
||||
this.images = images;
|
||||
}
|
||||
|
||||
public void setVideo(String video) {
|
||||
this.video = video;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public void setRank(String rank) {
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getIntroduce() {
|
||||
return introduce;
|
||||
}
|
||||
|
||||
public String getHotels() {
|
||||
return hotels;
|
||||
}
|
||||
|
||||
public String getImages() {
|
||||
return images;
|
||||
}
|
||||
|
||||
public String getVideo() {
|
||||
return video;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public String getRank() {
|
||||
return rank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Attractions{" +
|
||||
"id='" + id + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", location='" + location + '\'' +
|
||||
", introduce='" + introduce + '\'' +
|
||||
", hotels='" + hotels + '\'' +
|
||||
", images='" + images + '\'' +
|
||||
", video='" + video + '\'' +
|
||||
", price='" + price + '\'' +
|
||||
", rank='" + rank + '\'' +
|
||||
", category='" + category + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.example.travelor.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Chats implements Serializable {
|
||||
private String id;
|
||||
private String identity;
|
||||
private String content;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public void setIdentity(String identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "chats{" +
|
||||
"id='" + id + '\'' +
|
||||
", identity='" + identity + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.example.travelor.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Hotels implements Serializable {
|
||||
private String hotelName;
|
||||
private String hotelLocation;
|
||||
private String hotelImage;
|
||||
private String hotelRank;
|
||||
private String hotelScore;
|
||||
private String hotelPrice;
|
||||
|
||||
public String getHotelName() {
|
||||
return hotelName;
|
||||
}
|
||||
|
||||
public void setHotelName(String hotelName) {
|
||||
this.hotelName = hotelName;
|
||||
}
|
||||
|
||||
public String getHotelLocation() {
|
||||
return hotelLocation;
|
||||
}
|
||||
|
||||
public void setHotelLocation(String hotelLocation) {
|
||||
this.hotelLocation = hotelLocation;
|
||||
}
|
||||
|
||||
public String getHotelImage() {
|
||||
return hotelImage;
|
||||
}
|
||||
|
||||
public void setHotelImage(String hotelImage) {
|
||||
this.hotelImage = hotelImage;
|
||||
}
|
||||
|
||||
public String getHotelRank() {
|
||||
return hotelRank;
|
||||
}
|
||||
|
||||
public void setHotelRank(String hotelRank) {
|
||||
this.hotelRank = hotelRank;
|
||||
}
|
||||
|
||||
public String getHotelScore() {
|
||||
return hotelScore;
|
||||
}
|
||||
|
||||
public void setHotelScore(String hotelScore) {
|
||||
this.hotelScore = hotelScore;
|
||||
}
|
||||
|
||||
public String getHotelPrice() {
|
||||
return hotelPrice;
|
||||
}
|
||||
|
||||
public void setHotelPrice(String hotelPrice) {
|
||||
this.hotelPrice = hotelPrice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Hotels{" +
|
||||
"hotelName='" + hotelName + '\'' +
|
||||
", hotelLocation='" + hotelLocation + '\'' +
|
||||
", hotelImage='" + hotelImage + '\'' +
|
||||
", hotelRank='" + hotelRank + '\'' +
|
||||
", hotelScore='" + hotelScore + '\'' +
|
||||
", hotelPrice='" + hotelPrice + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.example.travelor.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Plans implements Serializable {
|
||||
private String mainPlan;
|
||||
private String details;
|
||||
private String createTime;
|
||||
private String id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMainPlan() {
|
||||
return mainPlan;
|
||||
}
|
||||
|
||||
public void setMainPlan(String main_plan) {
|
||||
this.mainPlan = main_plan;
|
||||
}
|
||||
|
||||
public String getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(String details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String create_time) {
|
||||
this.createTime = create_time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "plans{" +
|
||||
"main_plan='" + mainPlan + '\'' +
|
||||
", details='" + details + '\'' +
|
||||
", create_time='" + createTime + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.example.travelor.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Users implements Serializable {
|
||||
|
||||
private String account;
|
||||
private String password;
|
||||
private String username;
|
||||
private String createdTime;
|
||||
private String id;
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.username = userName;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setCreatedTime(String createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public String getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Users{" +
|
||||
"account='" + account + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", createdTime='" + createdTime + '\'' +
|
||||
", userName='" + username + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.example.travelor.datebase;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.example.travelor.bean.Attractions;
|
||||
import com.example.travelor.bean.Hotels;
|
||||
import com.example.travelor.bean.Plans;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HotelCollectDbOpenHelper extends SQLiteOpenHelper {
|
||||
private static final String DB_NAME = "hotelCollectSQLite.db";
|
||||
private static final String TABLE_NAME_NOTE = "hotel_collect";
|
||||
|
||||
|
||||
private static final String CREATE_TABLE_SQL = "create table " + TABLE_NAME_NOTE + " (id integer primary key autoincrement," +
|
||||
"name text UNIQUE, location text, image text, rank text, score text, price text, attraction text)";
|
||||
|
||||
public HotelCollectDbOpenHelper(Context context) {
|
||||
super(context, DB_NAME, null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(CREATE_TABLE_SQL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
|
||||
public int deleteFromDbById(String id) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
return db.delete(TABLE_NAME_NOTE, "id = ?", new String[]{id}); // 创建包含单个元素的字符串数组
|
||||
}
|
||||
|
||||
public long insertData(Hotels hotel) {
|
||||
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("name", hotel.getHotelName());
|
||||
values.put("location", hotel.getHotelLocation());
|
||||
values.put("image", hotel.getHotelImage());
|
||||
values.put("rank", hotel.getHotelRank());
|
||||
values.put("score", hotel.getHotelScore());
|
||||
values.put("price", hotel.getHotelPrice());
|
||||
|
||||
return db.insert(TABLE_NAME_NOTE, null, values);
|
||||
}
|
||||
|
||||
@SuppressLint("Range")
|
||||
public List<Hotels> queryAllFromDb() {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
List<Hotels> hotelList = new ArrayList<>();
|
||||
|
||||
Cursor cursor = db.query(TABLE_NAME_NOTE, null, null, null, null, null, null);
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String hotelName = cursor.getString(cursor.getColumnIndex("name"));
|
||||
String hotelRank = cursor.getString(cursor.getColumnIndex("rank"));
|
||||
String hotelImage = cursor.getString(cursor.getColumnIndex("image"));
|
||||
String hotelLocation = cursor.getString(cursor.getColumnIndex("location"));
|
||||
String hotelPrice = cursor.getString(cursor.getColumnIndex("price"));
|
||||
String hotelScore = cursor.getString(cursor.getColumnIndex("score"));
|
||||
|
||||
Hotels hotel = new Hotels();
|
||||
hotel.setHotelName(hotelName);
|
||||
hotel.setHotelImage(hotelImage);
|
||||
hotel.setHotelLocation(hotelLocation);
|
||||
hotel.setHotelPrice(hotelPrice);
|
||||
hotel.setHotelScore(hotelScore);
|
||||
hotel.setHotelRank(hotelRank);
|
||||
|
||||
hotelList.add(hotel);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return hotelList;
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.example.travelor.datebase;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import com.example.travelor.bean.Users;
|
||||
|
||||
public class UsersDbOpenHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final String DB_NAME = "usersSQLite.db";
|
||||
private static final String TABLE_NAME_NOTE = "users";
|
||||
|
||||
private static final String CREATE_TABLE_SQL = "create table " + TABLE_NAME_NOTE + " (id integer primary key autoincrement, account text, password text, username text, create_time text)";
|
||||
|
||||
|
||||
public UsersDbOpenHelper(Context context) {
|
||||
super(context, DB_NAME, null, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(CREATE_TABLE_SQL);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
|
||||
public long insertData(Users users) {
|
||||
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("account", users.getAccount());
|
||||
values.put("password", users.getPassword());
|
||||
values.put("username", users.getUserName());
|
||||
values.put("create_time", users.getCreatedTime());
|
||||
|
||||
return db.insert(TABLE_NAME_NOTE, null, values);
|
||||
}
|
||||
|
||||
public int deleteFromDbById(String id) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
// return db.delete(TABLE_NAME_NOTE, "id = ?", new String[]{id});
|
||||
// return db.delete(TABLE_NAME_NOTE, "id is ?", new String[]{id});
|
||||
return db.delete(TABLE_NAME_NOTE, "id like ?", new String[]{id}); // 创建包含单个元素的字符串数组
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public int updateData(Note note) {
|
||||
//
|
||||
// SQLiteDatabase db = getWritableDatabase();
|
||||
//
|
||||
// ContentValues values = new ContentValues();
|
||||
// values.put("title", note.getTitle());
|
||||
// values.put("content", note.getContent());
|
||||
// values.put("create_time", note.getCreatedTime());
|
||||
// // 返回整数值 表示受影响的行数
|
||||
// return db.update(TABLE_NAME_NOTE, values, "id like ?", new String[]{note.getId()});
|
||||
// }
|
||||
|
||||
// public List<Note> queryAllFromDb() {
|
||||
//
|
||||
// SQLiteDatabase db = getWritableDatabase();
|
||||
// List<Note> noteList = new ArrayList<>();
|
||||
//
|
||||
// Cursor cursor = db.query(TABLE_NAME_NOTE, null, null, null, null, null, null);
|
||||
// if (cursor != null) {
|
||||
// while (cursor.moveToNext()) {
|
||||
// String id = cursor.getString(cursor.getColumnIndex("id"));
|
||||
// String title = cursor.getString(cursor.getColumnIndex("title"));
|
||||
// String content = cursor.getString(cursor.getColumnIndex("content"));
|
||||
// String createTime = cursor.getString(cursor.getColumnIndex("create_time"));
|
||||
//
|
||||
// Note note = new Note();
|
||||
// note.setId(id);
|
||||
// note.setTitle(title);
|
||||
// note.setContent(content);
|
||||
// note.setCreatedTime(createTime);
|
||||
//
|
||||
// noteList.add(note);
|
||||
// }
|
||||
// cursor.close();
|
||||
// }
|
||||
//
|
||||
// return noteList;
|
||||
//
|
||||
// }
|
||||
//
|
||||
@SuppressLint("Range")
|
||||
public String queryFromDbByAccount(String account) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
String password = "";
|
||||
|
||||
Cursor cursor = db.query(TABLE_NAME_NOTE, null, "account=?", new String[]{account}, null, null, null);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
password = cursor.getString(cursor.getColumnIndex("password"));
|
||||
cursor.close();
|
||||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
package com.example.travelor.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.adapter.AttractionCardAdapter;
|
||||
import com.example.travelor.bean.Attractions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.example.travelor.datebase.AttractionDbOpenHelper;
|
||||
|
||||
public class FrontPageFragment extends Fragment{
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private List<Attractions> mAttractions;
|
||||
private AttractionCardAdapter mAttrAdapter;
|
||||
private SearchView searchView;
|
||||
private TextView showAttraction;
|
||||
private TextView showAll;
|
||||
private TextView showHumanity;
|
||||
private TextView showNature;
|
||||
|
||||
private AttractionDbOpenHelper mAttractionDbOpenHelper;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.front_page_layout, container, false);
|
||||
initView(rootView);
|
||||
initData();
|
||||
initEvent();
|
||||
|
||||
// 搜索框
|
||||
searchView = rootView.findViewById(R.id.searchView);
|
||||
showAttraction = rootView.findViewById(R.id.show_attraction);
|
||||
showAll = rootView.findViewById(R.id.show_all);
|
||||
showNature = rootView.findViewById(R.id.show_nature);
|
||||
showHumanity = rootView.findViewById(R.id.show_humanity);
|
||||
|
||||
search();
|
||||
categoryAct();
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
// 按类别查询
|
||||
private void categoryAct() {
|
||||
showAll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAttractions = mAttractionDbOpenHelper.queryAllFromDb();
|
||||
mAttrAdapter.refreshData(mAttractions);
|
||||
setLayout();
|
||||
}
|
||||
});
|
||||
|
||||
showAttraction.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAttractions = mAttractionDbOpenHelper.queryFromDbByCategory("风景");
|
||||
mAttrAdapter.refreshData(mAttractions);
|
||||
setLayout();
|
||||
}
|
||||
});
|
||||
|
||||
showNature.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAttractions = mAttractionDbOpenHelper.queryFromDbByCategory("自然");
|
||||
mAttrAdapter.refreshData(mAttractions);
|
||||
setLayout();
|
||||
}
|
||||
});
|
||||
|
||||
showHumanity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
mAttractions = mAttractionDbOpenHelper.queryFromDbByCategory("人文");
|
||||
mAttrAdapter.refreshData(mAttractions);
|
||||
setLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 景点名搜索
|
||||
private void search() {
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
performSearch(newText);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void performSearch(String query) {
|
||||
mAttractions = mAttractionDbOpenHelper.queryFromDbByName(query);
|
||||
mAttrAdapter.refreshData(mAttractions);
|
||||
setLayout();
|
||||
}
|
||||
|
||||
// 回溯
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
refreshDataFromDb();
|
||||
setLayout();
|
||||
}
|
||||
|
||||
// 更新视图
|
||||
private void setLayout() {
|
||||
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false);
|
||||
mRecyclerView.setLayoutManager(linearLayoutManager); // 创建布局管理器
|
||||
mAttrAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void refreshDataFromDb() {
|
||||
mAttractions = getDataFromDB();
|
||||
mAttrAdapter.refreshData(mAttractions);
|
||||
}
|
||||
|
||||
private List<Attractions> getDataFromDB() {
|
||||
return mAttractionDbOpenHelper.queryAllFromDb();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
mAttrAdapter = new AttractionCardAdapter(requireContext(), mAttractions);
|
||||
mRecyclerView.setAdapter(mAttrAdapter);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
mAttractions = new ArrayList<>();
|
||||
mAttractionDbOpenHelper = new AttractionDbOpenHelper(requireContext());
|
||||
}
|
||||
|
||||
private void initView(View rootView) {
|
||||
mRecyclerView = rootView.findViewById(R.id.rlv);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.example.travelor.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.travelor.AttractionCollectActivity;
|
||||
import com.example.travelor.LoginActivity;
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.SignInActivity;
|
||||
|
||||
public class MineFragment extends Fragment {
|
||||
private Button btLogout;
|
||||
public ViewGroup vgCollect;
|
||||
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_mine, container, false);
|
||||
|
||||
btLogout = rootView.findViewById(R.id.logout);
|
||||
vgCollect = rootView.findViewById(R.id.mine_collect);
|
||||
|
||||
initEvent();
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
btLogout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), LoginActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
vgCollect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), AttractionCollectActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.example.travelor.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelor.AddActivity;
|
||||
import com.example.travelor.DetailsPageActivity;
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.adapter.PlanAdapter;
|
||||
import com.example.travelor.bean.Plans;
|
||||
import com.example.travelor.datebase.PlansDbOpenHelper;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class PlanFragment extends Fragment {
|
||||
private RecyclerView mRecyclerView;
|
||||
private List<Plans> mPlans;
|
||||
private PlanAdapter mPlanAdapter;
|
||||
private FloatingActionButton addButton;
|
||||
private PlansDbOpenHelper mPlansDbOpenHelper;
|
||||
private TextView mDate;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.plan_layout, container, false);
|
||||
|
||||
addButton = rootView.findViewById(R.id.btn_add);
|
||||
mDate = rootView.findViewById(R.id.date);
|
||||
|
||||
initView(rootView);
|
||||
initData();
|
||||
initEvent();
|
||||
add();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
refreshDataFromDb();
|
||||
setLayout();
|
||||
}
|
||||
|
||||
// 更新视图
|
||||
private void setLayout() {
|
||||
mPlanAdapter.notifyDataSetChanged();
|
||||
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false);
|
||||
mRecyclerView.setLayoutManager(linearLayoutManager); // 创建布局管理器
|
||||
}
|
||||
|
||||
private void refreshDataFromDb() {
|
||||
mPlans = getDataFromDB();
|
||||
mPlanAdapter.refreshData(mPlans);
|
||||
}
|
||||
|
||||
private List<Plans> getDataFromDB() {
|
||||
return mPlansDbOpenHelper.queryAllFromDb();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
mPlanAdapter = new PlanAdapter(requireContext(), mPlans);
|
||||
mRecyclerView.setAdapter(mPlanAdapter);
|
||||
mDate.setText(getCurrentTimeFormat());
|
||||
}
|
||||
|
||||
private String getCurrentTimeFormat() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd");
|
||||
Date date = new Date();
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
mPlans = new ArrayList<>();
|
||||
mPlansDbOpenHelper = new PlansDbOpenHelper(requireContext());
|
||||
}
|
||||
|
||||
private void initView(View rootView) {
|
||||
mRecyclerView = rootView.findViewById(R.id.plan_rlv);
|
||||
}
|
||||
|
||||
public void add() {
|
||||
addButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), AddActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.example.travelor.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.travelor.LoginActivity;
|
||||
import com.example.travelor.PageJumpActivity;
|
||||
import com.example.travelor.R;
|
||||
import com.example.travelor.SparkAiActivity;
|
||||
|
||||
public class SparkAiFragment extends Fragment {
|
||||
|
||||
private TextView tvStart;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_spark_ai, container, false);
|
||||
tvStart = rootView.findViewById(R.id.start);
|
||||
initEvent();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
tvStart.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), SparkAiActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.example.travelor.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class SpfUtil {
|
||||
|
||||
private static String SPF_NAME = "noteSpf";
|
||||
|
||||
public static void saveString(Context context, String key, String value) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = spf.edit();
|
||||
edit.putString(key, value);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static String getString(Context context, String key) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
return spf.getString(key, "");
|
||||
}
|
||||
|
||||
public static void saveBoolean(Context context, String key, boolean value) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = spf.edit();
|
||||
edit.putBoolean(key, value);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static Boolean getBoolean(Context context, String key) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
return spf.getBoolean(key, false);
|
||||
}
|
||||
|
||||
public static void saveInt(Context context, String key, int value) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor edit = spf.edit();
|
||||
edit.putInt(key, value);
|
||||
edit.apply();
|
||||
}
|
||||
|
||||
public static int getInt(Context context, String key) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
return spf.getInt(key, -1);
|
||||
}
|
||||
|
||||
public static int getIntWithDefault(Context context, String key, int defValue) {
|
||||
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
|
||||
return spf.getInt(key, defValue);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.example.travelor.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ToastUtil {
|
||||
|
||||
public static void toastShort(Context context, String msg) {
|
||||
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void toastLong(Context context, String msg) {
|
||||
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
@ -0,0 +1,20 @@
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!--阴影-->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#1F7F7F7F" />
|
||||
<corners android:radius="100dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<!--前景-->
|
||||
<item
|
||||
android:bottom="5dp"
|
||||
android:left="5dp"
|
||||
android:right="5dp"
|
||||
android:top="5dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/white"/>
|
||||
<corners android:radius="100dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 27 KiB |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/main_style_green" /> <!-- 设置填充颜色 -->
|
||||
<corners android:radius="5dp" /> <!-- 设置圆角半径 -->
|
||||
</shape>
|
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/btn_start" android:state_selected="false" />
|
||||
<item android:drawable="@drawable/btn_stop" android:state_selected="true" />
|
||||
</selector>
|
@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/green_700" /> <!-- 设置填充颜色 -->
|
||||
<corners android:radius="50dp" /> <!-- 设置圆角半径 -->
|
||||
</shape>
|
@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#E3DDD5" /> <!-- 替换为您想要的背景颜色 -->
|
||||
<corners android:radius="1000dp" />
|
||||
</shape>
|
@ -0,0 +1,6 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="80dp" />
|
||||
<stroke android:width="1dp"
|
||||
android:color="#7F7F7F" />
|
||||
</shape>
|
After Width: | Height: | Size: 372 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 2.4 KiB |
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#0a8c8c8c" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:left="2px"
|
||||
android:right="2px"
|
||||
android:top="2px" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#0fd7d7d7" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:left="2px"
|
||||
android:right="2px"
|
||||
android:top="2px" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#14c7c7c7" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:left="2px"
|
||||
android:right="2px"
|
||||
android:top="2px" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#19c1c1c1" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:left="2px"
|
||||
android:right="2px"
|
||||
android:top="2px" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#1ec6c6c6" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:left="2px"
|
||||
android:right="2px"
|
||||
android:top="2px" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#23b7b7b7" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:right="2px"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#28aeaeae" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:right="2px"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<solid android:color="#2d9e9e9e" />
|
||||
<corners android:radius="30dp" />
|
||||
<padding android:bottom="5px"
|
||||
android:right="2px"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle" >
|
||||
<corners android:radius="30dp" />
|
||||
<solid android:color="@color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1,8 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#575757"
|
||||
android:dashWidth="4dp"
|
||||
android:dashGap="5dp"
|
||||
/>
|
||||
</shape>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="oval"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="5dp"/>
|
||||
<solid android:color="@color/white"/>
|
||||
</shape>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="oval"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="5dp"/>
|
||||
<solid android:color="@color/black"/>
|
||||
</shape>
|
@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke android:width="1dp" android:color="#324C4E"/>
|
||||
</shape>
|
@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke android:width="2dp" android:color="#007693"/>
|
||||
</shape>
|
@ -0,0 +1,6 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@android:color/transparent" /> <!-- 设置背景为透明色 -->
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#5B5A5A" /> <!-- 设置边框颜色 -->
|
||||
</shape>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/edit_text_bg" android:state_selected="false" />
|
||||
<item android:drawable="@drawable/edit_text_bg_focus" android:state_selected="true" />
|
||||
</selector>
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,7 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:type="linear"
|
||||
android:startColor="#48A57A"
|
||||
android:endColor="#3CAEA9"
|
||||
android:angle="135" />
|
||||
</shape>
|
After Width: | Height: | Size: 655 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 161 KiB |
After Width: | Height: | Size: 129 KiB |
After Width: | Height: | Size: 396 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 9.8 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#4D4D4D" /> <!-- 设置填充颜色 -->
|
||||
<corners android:radius="5dp" /> <!-- 设置圆角半径 -->
|
||||
</shape>
|
After Width: | Height: | Size: 2.1 KiB |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/like" android:state_selected="false" />
|
||||
<item android:drawable="@drawable/liked" android:state_selected="true" />
|
||||
</selector>
|