修改功能

This commit is contained in:
fengjignqi
2026-11-14 09:42:57 +08:00
parent dae233e651
commit 673eb7e59c
139 changed files with 9742 additions and 6235 deletions

View File

@@ -152,6 +152,15 @@
android:name=".food.AllGoodsActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".food.FoodDetailActivity"
android:exported="false" />
<activity
android:name=".shop.ProductDetailActivity"
android:exported="false" />
<activity
android:name=".message.MessageCenterActivity"
android:exported="false" />
<activity
android:name=".device.BltDeviceListActivity"
android:exported="false"

View File

@@ -12,7 +12,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.gson.Gson;
import com.ckkj.griddle.fate.util.LunarDateLoader;
import com.ckkj.griddle.login.entity.LoginEntity;
import com.ckkj.griddle.network.NetWorkManager;
import com.ckkj.griddle.utils.dataUtil.SharePreUtil;
@@ -64,8 +63,6 @@ public class MyApplication extends Application {
super.onCreate();
instance = this;
context = getApplicationContext();
// 异步预加载农历数据缓存
LunarDateLoader.preloadLunarJson(this);
boolean isUserAgreed = SharePreUtil.getBoolean(ConstantUtil.SHARE_PRE_NAME,context,ConstantUtil.PRIVACY_POLICY_AGREED);
if(isUserAgreed){

View File

@@ -20,6 +20,7 @@ import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.utils.show.ToastUtil;
import com.gyf.immersionbar.ImmersionBar;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -31,6 +32,8 @@ import butterknife.OnClick;
/** 新版购物车:普通与管理共用商品列表,底部切换结算和批量删除。 */
public class CartManageActivity extends BaseActivity<CartManageLayoutBinding, CartPresenter>
implements CartContract.CartView {
/** 商城详情加购入口;仅首次创建时消费,旋转恢复不重复增加数量。 */
public static final String EXTRA_ADD_GOODS = "cart_add_goods";
private static final String STATE_MANAGING = "cart_managing";
private static final String STATE_GOODS = "cart_goods";
@@ -64,7 +67,9 @@ public class CartManageActivity extends BaseActivity<CartManageLayoutBinding, Ca
savedInstanceState.getSerializable(STATE_GOODS);
mPresenter.restoreCart(goods);
} else {
mPresenter.getCart();
Serializable extra = savedInstanceState == null
? getIntent().getSerializableExtra(EXTRA_ADD_GOODS) : null;
mPresenter.getCart(extra instanceof CartGoodsEntity ? (CartGoodsEntity) extra : null);
}
}

View File

@@ -16,10 +16,16 @@ public class CartPresenter extends BasePresenter<CartContract.CartView> {
}
public void getCart() {
getCart(null);
}
/** 等购物车数据加载完成后再合并带入商品,后续改为异步接口也不会被响应覆盖。 */
public void getCart(CartGoodsEntity incoming) {
impl.getCart(new CartContract.CallBack<List<CartGoodsEntity>>() {
@Override
public void success(List<CartGoodsEntity> data) {
restoreCart(data);
if (incoming != null) addItem(incoming);
}
@Override
@@ -44,6 +50,25 @@ public class CartPresenter extends BasePresenter<CartContract.CartView> {
return result;
}
/** 合并商城带入的本地演示商品,同款累计数量,上限与购物车操作保持一致。 */
public void addItem(CartGoodsEntity incoming) {
if (incoming == null) return;
for (CartGoodsEntity item : goods) {
if (item.id.equals(incoming.id)) {
item.quantity = Math.min(CartGoodsEntity.MAX_QUANTITY,
item.quantity + Math.max(1, incoming.quantity));
item.selected = true;
renderCart();
return;
}
}
CartGoodsEntity added = incoming.copy();
added.quantity = Math.max(1, Math.min(CartGoodsEntity.MAX_QUANTITY, added.quantity));
added.selected = true;
goods.add(added);
renderCart();
}
public void toggleItem(String id) {
for (CartGoodsEntity item : goods) {
if (item.id.equals(id)) item.selected = !item.selected;

View File

@@ -26,12 +26,14 @@ import com.ckkj.griddle.device.entity.HomeDeviceEntity;
import com.ckkj.griddle.device.mvp.DeviceContract;
import com.ckkj.griddle.device.mvp.DeviceImpl;
import com.ckkj.griddle.device.mvp.DevicePresenter;
import com.ckkj.griddle.message.MessageCenterActivity;
import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.utils.show.ToastUtil;
import java.util.ArrayList;
import java.util.List;
import butterknife.OnClick;
import pub.devrel.easypermissions.EasyPermissions;
/**
@@ -100,6 +102,17 @@ public class DeviceFragment extends BaseFragment<DeviceIndexFragmentBinding, Dev
viewBinding.llHomeLocation.setOnClickListener(v -> requestHomeLocationPermission());
}
@OnClick({R.id.iv_notifications})
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_notifications:
goTo(mContext, MessageCenterActivity.class, null);
break;
default:
break;
}
}
/** 仅供首页展示:三台在线、一台离线;后续接口接入时替换此方法中的数据来源。 */
private void initDemoDevices() {
HomeDeviceAdapter adapter = new HomeDeviceAdapter();

View File

@@ -1,52 +0,0 @@
package com.ckkj.griddle.fate.adapter;
import android.content.Context;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.fate.entity.FateHistoryEntity;
import com.ckkj.griddle.utils.color.FateDataUtil;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/7/24
* @description TODO: 描述该类的作用
*/
public class FateHistoryAdapter extends BaseQuickAdapter<FateHistoryEntity.HistoryList, BaseViewHolder> {
private Context mContext;
public FateHistoryAdapter(Context context,int layoutResId, @Nullable List<FateHistoryEntity.HistoryList> data) {
super(layoutResId, data);
this.mContext = context;
}
@Override
protected void convert(BaseViewHolder holder, FateHistoryEntity.HistoryList item) {
holder.setText(R.id.tv_date,item.getRecordDate());
holder.setText(R.id.tv_week,item.getDayOfWeek());
if(item.isToday()){
holder.setVisible(R.id.tv_today,true);
}else{
holder.setVisible(R.id.tv_today,false);
}
holder.setText(R.id.tv_name,item.getName());
holder.setText(R.id.tv_location,item.getCurrentPlace());
holder.setText(R.id.tv_weather,item.getWeatherCondition());
holder.setText(R.id.tv_star,item.getConstellation());
holder.setText(R.id.tv_score,item.getOverallScore() + "");
holder.setText(R.id.tv_syy_score,item.getCareerScore() + "");
holder.setText(R.id.tv_gqy_score,item.getLoveScore() + "");
holder.setText(R.id.tv_jky_score,item.getHealthScore() + "");
holder.setText(R.id.tv_cfy_score,item.getWealthScore() + "");
holder.setTextColor(R.id.tv_score, FateDataUtil.getScoreColor(item.getOverallScore()));
holder.setTextColor(R.id.tv_syy_score, FateDataUtil.getScoreColor(item.getCareerScore()));
holder.setTextColor(R.id.tv_gqy_score, FateDataUtil.getScoreColor(item.getLoveScore()));
holder.setTextColor(R.id.tv_jky_score, FateDataUtil.getScoreColor(item.getHealthScore()));
holder.setTextColor(R.id.tv_cfy_score, FateDataUtil.getScoreColor(item.getWealthScore()));
}
}

View File

@@ -1,50 +0,0 @@
package com.ckkj.griddle.fate.adapter;
import android.content.Context;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.fate.entity.CityDataEntity;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/7/18
* @description TODO: 描述该类的作用
*/
public class SelectCityAdapter extends BaseQuickAdapter<CityDataEntity, BaseViewHolder> {
private Context mContext;
private int mSelPos = -1;
public SelectCityAdapter(Context context,int layoutResId, @Nullable List<CityDataEntity> data) {
super(layoutResId, data);
this.mContext = context;
}
@Override
protected void convert(BaseViewHolder helper, CityDataEntity item) {
helper.setText(R.id.tv_city_name,item.getCityName());
if(mSelPos == helper.getLayoutPosition()){
helper.setVisible(R.id.img_select,true);
}else{
helper.setVisible(R.id.img_select,false);
}
}
public void setSelPos(int pos){
this.mSelPos = pos;
notifyDataSetChanged();
}
public int getmSelPos() {
return mSelPos;
}
public void setmSelPos(int mSelPos) {
this.mSelPos = mSelPos;
}
}

View File

@@ -1,203 +0,0 @@
package com.ckkj.griddle.fate.entity;
import java.io.Serializable;
/**
* @author fengxiaoyang
* @date 2025/7/18
* @description TODO: 描述该类的作用
*/
public class CityDataEntity implements Serializable {
private int id;
private String cityCode;
private String cityName;
private String cityNameEn;
private String provinceCode;
private String provinceName;
private int cityLevel;
private String cityType;
private double longitude;
private double latitude;
private String population;
private String area;
private String gdp;
private String zipCode;
private String phoneCode;
private int isCapital;
private int isActive;
private int sortOrder;
private String remark;
private String createdTime;
private String updatedTime;
private String capitalCity;
public String getCapitalCity() {
return capitalCity;
}
public void setCapitalCity(String capitalCity) {
this.capitalCity = capitalCity;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getCityNameEn() {
return cityNameEn;
}
public void setCityNameEn(String cityNameEn) {
this.cityNameEn = cityNameEn;
}
public String getProvinceCode() {
return provinceCode;
}
public void setProvinceCode(String provinceCode) {
this.provinceCode = provinceCode;
}
public String getProvinceName() {
return provinceName;
}
public void setProvinceName(String provinceName) {
this.provinceName = provinceName;
}
public int getCityLevel() {
return cityLevel;
}
public void setCityLevel(int cityLevel) {
this.cityLevel = cityLevel;
}
public String getCityType() {
return cityType;
}
public void setCityType(String cityType) {
this.cityType = cityType;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public String getPopulation() {
return population;
}
public void setPopulation(String population) {
this.population = population;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getGdp() {
return gdp;
}
public void setGdp(String gdp) {
this.gdp = gdp;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String getPhoneCode() {
return phoneCode;
}
public void setPhoneCode(String phoneCode) {
this.phoneCode = phoneCode;
}
public int getIsCapital() {
return isCapital;
}
public void setIsCapital(int isCapital) {
this.isCapital = isCapital;
}
public int getIsActive() {
return isActive;
}
public void setIsActive(int isActive) {
this.isActive = isActive;
}
public int getSortOrder() {
return sortOrder;
}
public void setSortOrder(int sortOrder) {
this.sortOrder = sortOrder;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public void setCreatedTime(String createdTime) {
this.createdTime = createdTime;
}
public void setUpdatedTime(String updatedTime) {
this.updatedTime = updatedTime;
}
}

View File

@@ -1,139 +0,0 @@
package com.ckkj.griddle.fate.entity;
import java.io.Serializable;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/7/25
* @description TODO: 描述该类的作用
*/
public class FateHistoryEntity {
private List<HistoryList> list;
private int total;
public void setList(List<HistoryList> list) {
this.list = list;
}
public List<HistoryList> getList() {
return list;
}
public void setTotal(int total) {
this.total = total;
}
public int getTotal() {
return total;
}
public static class HistoryList implements Serializable{
private String recordDate;
private String dayOfWeek;
private String name;
private String currentPlace;
private String weatherCondition;
private String constellation;
private int overallScore;
private int careerScore;
private int loveScore;
private int healthScore;
private int wealthScore;
private boolean isToday;
public String getRecordDate() {
return recordDate;
}
public void setRecordDate(String recordDate) {
this.recordDate = recordDate;
}
public String getDayOfWeek() {
return dayOfWeek;
}
public void setDayOfWeek(String dayOfWeek) {
this.dayOfWeek = dayOfWeek;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCurrentPlace() {
return currentPlace;
}
public void setCurrentPlace(String currentPlace) {
this.currentPlace = currentPlace;
}
public String getWeatherCondition() {
return weatherCondition;
}
public void setWeatherCondition(String weatherCondition) {
this.weatherCondition = weatherCondition;
}
public String getConstellation() {
return constellation;
}
public void setConstellation(String constellation) {
this.constellation = constellation;
}
public int getOverallScore() {
return overallScore;
}
public void setOverallScore(int overallScore) {
this.overallScore = overallScore;
}
public int getCareerScore() {
return careerScore;
}
public void setCareerScore(int careerScore) {
this.careerScore = careerScore;
}
public int getLoveScore() {
return loveScore;
}
public void setLoveScore(int loveScore) {
this.loveScore = loveScore;
}
public int getHealthScore() {
return healthScore;
}
public void setHealthScore(int healthScore) {
this.healthScore = healthScore;
}
public int getWealthScore() {
return wealthScore;
}
public void setWealthScore(int wealthScore) {
this.wealthScore = wealthScore;
}
public boolean isToday() {
return isToday;
}
public void setToday(boolean today) {
isToday = today;
}
}
}

View File

@@ -1,66 +0,0 @@
package com.ckkj.griddle.fate.entity;
import java.io.Serializable;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/7/16
* @description TODO: 描述该类的作用
*/
public class LunarYearEntity implements Serializable {
public String year; // 年份
public List<LunarMonth> month; // 月份列表
// Gson需要无参构造
public LunarYearEntity() {}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public List<LunarMonth> getMonth() {
return month;
}
public void setMonth(List<LunarMonth> month) {
this.month = month;
}
public static class LunarMonth implements Serializable{
public String name; // 月份数字(字符串形式)
public int isRun; // 是否闰月(0=否,1=是)
public int isAllDay; // 是否包含三十(0=29天,1=30天)
// Gson需要无参构造
public LunarMonth() {}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIsRun() {
return isRun;
}
public void setIsRun(int isRun) {
this.isRun = isRun;
}
public int getIsAllDay() {
return isAllDay;
}
public void setIsAllDay(int isAllDay) {
this.isAllDay = isAllDay;
}
}
}

View File

@@ -1,526 +0,0 @@
package com.ckkj.griddle.fate.entity;
import com.ckkj.griddle.base.entity.UserInfoEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/7/21
* @description TODO: 描述该类的作用
*/
public class TodayFateEntity implements Serializable {
private FortuneAnalysis fortuneAnalysis;
private UserInfoEntity userInfo;
private TodayInfo todayInfo;
private String weatherCondition;
private String weatherTemperature;
private int todayVisitCount;
private int totalVisitDays;
public void setFortuneAnalysis(FortuneAnalysis fortuneAnalysis) {
this.fortuneAnalysis = fortuneAnalysis;
}
public FortuneAnalysis getFortuneAnalysis() {
return fortuneAnalysis;
}
public void setUserInfo(UserInfoEntity userInfo) {
this.userInfo = userInfo;
}
public UserInfoEntity getUserInfo() {
return userInfo;
}
public void setTodayInfo(TodayInfo todayInfo) {
this.todayInfo = todayInfo;
}
public TodayInfo getTodayInfo() {
return todayInfo;
}
public void setWeatherCondition(String weatherCondition) {
this.weatherCondition = weatherCondition;
}
public String getWeatherCondition() {
return weatherCondition;
}
public void setWeatherTemperature(String weatherTemperature) {
this.weatherTemperature = weatherTemperature;
}
public String getWeatherTemperature() {
return weatherTemperature;
}
public void setTodayVisitCount(int todayVisitCount) {
this.todayVisitCount = todayVisitCount;
}
public int getTodayVisitCount() {
return todayVisitCount;
}
public void setTotalVisitDays(int totalVisitDays) {
this.totalVisitDays = totalVisitDays;
}
public int getTotalVisitDays() {
return totalVisitDays;
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class TodayInfo implements Serializable{
private Date date;
private String weekDay;
private int year;
private int month;
private int day;
public void setDate(Date date) {
this.date = date;
}
public Date getDate() {
return date;
}
public void setWeekDay(String weekDay) {
this.weekDay = weekDay;
}
public String getWeekDay() {
return weekDay;
}
public void setYear(int year) {
this.year = year;
}
public int getYear() {
return year;
}
public void setMonth(int month) {
this.month = month;
}
public int getMonth() {
return month;
}
public void setDay(int day) {
this.day = day;
}
public int getDay() {
return day;
}
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class FortuneAnalysis implements Serializable{
private int overallScore;
private String overallDescription;
private String destiny;
private String todayGanzhi;
private BaziAnalysis baziAnalysis;
private Weather weather;
private AstrologyInfluence astrologyInfluence;
private LuckyInfo luckyInfo;
private int careerScore;
private String careerDescription;
private int loveScore;
private String loveDescription;
private int healthScore;
private String healthDescription;
private int wealthScore;
private String wealthDescription;
private Suggestions suggestions;
private String fiveElementsAnalysis;
public void setOverallScore(int overallScore) {
this.overallScore = overallScore;
}
public int getOverallScore() {
return overallScore;
}
public void setOverallDescription(String overallDescription) {
this.overallDescription = overallDescription;
}
public String getOverallDescription() {
return overallDescription;
}
public void setDestiny(String destiny) {
this.destiny = destiny;
}
public String getDestiny() {
return destiny;
}
public void setTodayGanzhi(String todayGanzhi) {
this.todayGanzhi = todayGanzhi;
}
public String getTodayGanzhi() {
return todayGanzhi;
}
public void setBaziAnalysis(BaziAnalysis baziAnalysis) {
this.baziAnalysis = baziAnalysis;
}
public BaziAnalysis getBaziAnalysis() {
return baziAnalysis;
}
public void setWeather(Weather weather) {
this.weather = weather;
}
public Weather getWeather() {
return weather;
}
public void setAstrologyInfluence(AstrologyInfluence astrologyInfluence) {
this.astrologyInfluence = astrologyInfluence;
}
public AstrologyInfluence getAstrologyInfluence() {
return astrologyInfluence;
}
public void setLuckyInfo(LuckyInfo luckyInfo) {
this.luckyInfo = luckyInfo;
}
public LuckyInfo getLuckyInfo() {
return luckyInfo;
}
public void setCareerScore(int careerScore) {
this.careerScore = careerScore;
}
public int getCareerScore() {
return careerScore;
}
public void setCareerDescription(String careerDescription) {
this.careerDescription = careerDescription;
}
public String getCareerDescription() {
return careerDescription;
}
public void setLoveScore(int loveScore) {
this.loveScore = loveScore;
}
public int getLoveScore() {
return loveScore;
}
public void setLoveDescription(String loveDescription) {
this.loveDescription = loveDescription;
}
public String getLoveDescription() {
return loveDescription;
}
public void setHealthScore(int healthScore) {
this.healthScore = healthScore;
}
public int getHealthScore() {
return healthScore;
}
public void setHealthDescription(String healthDescription) {
this.healthDescription = healthDescription;
}
public String getHealthDescription() {
return healthDescription;
}
public void setWealthScore(int wealthScore) {
this.wealthScore = wealthScore;
}
public int getWealthScore() {
return wealthScore;
}
public void setWealthDescription(String wealthDescription) {
this.wealthDescription = wealthDescription;
}
public String getWealthDescription() {
return wealthDescription;
}
public void setSuggestions(Suggestions suggestions) {
this.suggestions = suggestions;
}
public Suggestions getSuggestions() {
return suggestions;
}
public void setFiveElementsAnalysis(String fiveElementsAnalysis) {
this.fiveElementsAnalysis = fiveElementsAnalysis;
}
public String getFiveElementsAnalysis() {
return fiveElementsAnalysis;
}
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class Suggestions implements Serializable{
private String positive;
private String negative;
public void setPositive(String positive) {
this.positive = positive;
}
public String getPositive() {
return positive;
}
public void setNegative(String negative) {
this.negative = negative;
}
public String getNegative() {
return negative;
}
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class LuckyInfo implements Serializable{
private String[] numbers;
private String color;
private String direction;
private List<LuckyTimes> luckyTimes;
private String flower;
private String food;
public String[] getNumbers() {
return numbers;
}
public void setNumbers(String[] numbers) {
this.numbers = numbers;
}
public void setColor(String color) {
this.color = color;
}
public String getColor() {
return color;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getDirection() {
return direction;
}
public void setLuckyTimes(List<LuckyTimes> luckyTimes) {
this.luckyTimes = luckyTimes;
}
public List<LuckyTimes> getLuckyTimes() {
return luckyTimes;
}
public void setFlower(String flower) {
this.flower = flower;
}
public String getFlower() {
return flower;
}
public void setFood(String food) {
this.food = food;
}
public String getFood() {
return food;
}
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class LuckyTimes implements Serializable{
private String time;
private String description;
public void setTime(String time) {
this.time = time;
}
public String getTime() {
return time;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class AstrologyInfluence implements Serializable{
private String constellation;
private String value;
private String description;
public void setConstellation(String constellation) {
this.constellation = constellation;
}
public String getConstellation() {
return constellation;
}
public void setValue(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class Weather implements Serializable{
private String condition;
private String temperature;
public void setCondition(String condition) {
this.condition = condition;
}
public String getCondition() {
return condition;
}
public void setTemperature(String temperature) {
this.temperature = temperature;
}
public String getTemperature() {
return temperature;
}
}
/**
* Copyright 2025 bejson.com
*/
/**
* Auto-generated: 2025-07-21 17:23:17
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
public static class BaziAnalysis implements Serializable{
private String nianzhu;
private String yuezhu;
private String rizhu;
private String shizhu;
private String todayInfluence;
public void setNianzhu(String nianzhu) {
this.nianzhu = nianzhu;
}
public String getNianzhu() {
return nianzhu;
}
public void setYuezhu(String yuezhu) {
this.yuezhu = yuezhu;
}
public String getYuezhu() {
return yuezhu;
}
public void setRizhu(String rizhu) {
this.rizhu = rizhu;
}
public String getRizhu() {
return rizhu;
}
public void setShizhu(String shizhu) {
this.shizhu = shizhu;
}
public String getShizhu() {
return shizhu;
}
public void setTodayInfluence(String todayInfluence) {
this.todayInfluence = todayInfluence;
}
public String getTodayInfluence() {
return todayInfluence;
}
}
}

View File

@@ -1,58 +0,0 @@
package com.ckkj.griddle.fate.mvp;
import com.ckkj.griddle.base.IView;
import com.ckkj.griddle.base.entity.MineUserInfoBean;
import com.ckkj.griddle.fate.entity.CityDataEntity;
import com.ckkj.griddle.fate.entity.FateHistoryEntity;
import com.ckkj.griddle.fate.entity.TodayFateEntity;
import com.ckkj.griddle.network.BaseBean;
import org.json.JSONObject;
import java.util.List;
import java.util.Map;
/**
* @author fengxiaoyang
* @date 2025/7/15
* @description TODO: 描述该类的作用
*/
public class FateContract {
public interface CallBack<T> {
void success(T msg);
void fail(String msg);
}
public interface DataModel{
//查询所有城市
void getAllCityDatas(Map<String,Object> map, CallBack callBack);
//保存用户生日信息
void saveUserBirthInfo(JSONObject json, CallBack callBack);
//用户修改生日信息
void saveUserEditBirthInfo(JSONObject json, CallBack callBack);
//查询用户今日运势
void getUserTodayFateDatas(Map<String,Object> map, CallBack callBack);
//查询历史运势
void getUserFateHistory(Map<String,Object> map, CallBack callBack);
//提交举报反馈
void commitReport(Map<String,Object> map, CallBack callBack);
}
public interface FateView extends IView{
//查询所有城市成功
void getAllCitySuccess(List<CityDataEntity> list);
//获取今日运势成功
void getUserTodayFateDataSuccess(TodayFateEntity entity);
//获取历史运势成功
void getFateHistorySuccess(FateHistoryEntity entity);
//用户保存生辰八字成功
void userSaveBirthInfoSuccess(TodayFateEntity bean);
//用户信息
void getUserInfoSuccess(MineUserInfoBean bean);
//提交举报反馈成功
void commitReportSuccess(BaseBean bean);
}
}

View File

@@ -1,273 +0,0 @@
package com.ckkj.griddle.fate.mvp;
import com.ckkj.griddle.fate.entity.CityDataEntity;
import com.ckkj.griddle.fate.entity.FateHistoryEntity;
import com.ckkj.griddle.fate.entity.TodayFateEntity;
import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.network.NetWorkManager;
import org.json.JSONObject;
import java.util.List;
import java.util.Map;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* @author fengxiaoyang
* @date 2025/7/15
* @description TODO: 描述该类的作用
*/
public class FateImpl implements FateContract.DataModel{
/**
* 所有城市
* @param map
* @param callBack
*/
@Override
public void getAllCityDatas(Map<String, Object> map, FateContract.CallBack callBack) {
try {
NetWorkManager.getRequest().getCityDatas(NetWorkManager.getToken(),map)
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseBean<List<CityDataEntity>>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseBean<List<CityDataEntity>> bean) {
if(bean.getCode() == 200){
callBack.success(bean.getData());
}else{
callBack.fail(bean.getMessage());
}
}
@Override
public void onError(@NonNull Throwable e) {
callBack.fail(e.getMessage());
}
@Override
public void onComplete() {
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 保存用户生辰信息
* @param json
* @param callBack
*/
@Override
public void saveUserBirthInfo(JSONObject json, FateContract.CallBack callBack) {
try {
NetWorkManager.getRequest().saveUserBirthInfo(NetWorkManager.getToken(),NetWorkManager.toRequestBody(json))
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseBean bean) {
if(bean.getCode() == 200){
callBack.success(bean);
}else{
callBack.fail(bean.getMessage());
}
}
@Override
public void onError(@NonNull Throwable e) {
callBack.fail(e.getMessage());
}
@Override
public void onComplete() {
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 用户修改生辰八字
* @param json
* @param callBack
*/
@Override
public void saveUserEditBirthInfo(JSONObject json, FateContract.CallBack callBack) {
try {
NetWorkManager.getRequest().saveUserEditBirthInfo(NetWorkManager.getToken(),NetWorkManager.toRequestBody(json))
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseBean<TodayFateEntity>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseBean<TodayFateEntity> bean) {
if(bean.getCode() == 200){
callBack.success(bean.getData());
}else{
callBack.fail(bean.getMessage());
}
}
@Override
public void onError(@NonNull Throwable e) {
callBack.fail(e.getMessage());
}
@Override
public void onComplete() {
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取今日运势
* @param map
* @param callBack
*/
@Override
public void getUserTodayFateDatas(Map<String, Object> map, FateContract.CallBack callBack) {
try {
NetWorkManager.getRequest().getUserTodayFateDatas(NetWorkManager.getToken())
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseBean<TodayFateEntity>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseBean<TodayFateEntity> bean) {
if(bean.getCode() == 200){
callBack.success(bean.getData());
}else{
callBack.fail(bean.getMessage());
}
}
@Override
public void onError(@NonNull Throwable e) {
callBack.fail(e.getMessage());
}
@Override
public void onComplete() {
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取历史数据
* @param map
* @param callBack
*/
@Override
public void getUserFateHistory(Map<String, Object> map, FateContract.CallBack callBack) {
try {
NetWorkManager.getRequest().getUserFateHistory(NetWorkManager.getToken())
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseBean<FateHistoryEntity>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseBean<FateHistoryEntity> bean) {
if(bean.getCode() == 200){
callBack.success(bean.getData());
}else{
callBack.fail(bean.getMessage());
}
}
@Override
public void onError(@NonNull Throwable e) {
callBack.fail(e.getMessage());
}
@Override
public void onComplete() {
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 举报反馈
* @param map
* @param callBack
*/
@Override
public void commitReport(Map<String, Object> map, FateContract.CallBack callBack) {
try {
NetWorkManager.getRequest().commitReporting(NetWorkManager.getToken(), map)
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseBean bean) {
if (bean.getCode() == 200) {
callBack.success(bean);
} else {
callBack.fail(bean.getMessage());
}
}
@Override
public void onError(@NonNull Throwable e) {
callBack.fail(e.getMessage());
}
@Override
public void onComplete() {
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -1,190 +0,0 @@
package com.ckkj.griddle.fate.mvp;
import com.ckkj.griddle.base.BasePresenter;
import com.ckkj.griddle.base.entity.MineUserInfoBean;
import com.ckkj.griddle.fate.entity.CityDataEntity;
import com.ckkj.griddle.fate.entity.FateHistoryEntity;
import com.ckkj.griddle.fate.entity.TodayFateEntity;
import com.ckkj.griddle.login.mvp.LoginContract;
import com.ckkj.griddle.main.MainPresenter;
import com.ckkj.griddle.base.repository.UserInfoRepository;
import com.ckkj.griddle.network.BaseBean;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author fengxiaoyang
* @date 2025/7/15
* @description TODO: 描述该类的作用
*/
public class FatePresenter extends BasePresenter<FateContract.FateView> {
private FateImpl impl;
public FatePresenter(FateImpl impl) {
this.impl = impl;
}
/**
* 获取城市列表
*/
public void getCityDatas() {
Map<String, Object> map = new HashMap<>();
impl.getAllCityDatas(map, new FateContract.CallBack<List<CityDataEntity>>() {
@Override
public void success(List<CityDataEntity> list) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().getAllCitySuccess(list);
}
}
@Override
public void fail(String msg) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().showError(msg);
}
}
});
}
/**
* 保存用户生辰
* @param json
*/
public void saveUserBirthInfo(JSONObject json) {
impl.saveUserBirthInfo(json, new FateContract.CallBack<BaseBean>() {
@Override
public void success(BaseBean bean) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().userSaveBirthInfoSuccess(null);
}
}
@Override
public void fail(String msg) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().showError(msg);
}
}
});
}
/**
* 获取今日运势
*/
public void getTodayFateDatas() {
impl.getUserTodayFateDatas(new HashMap<>(), new FateContract.CallBack<TodayFateEntity>() {
@Override
public void success(TodayFateEntity bean) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().getUserTodayFateDataSuccess(bean);
}
}
@Override
public void fail(String msg) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().showError(msg);
}
}
});
}
/**
* 获取历史运势
* @param page
*/
public void getHistoryDatas(int page) {
Map<String, Object> map = new HashMap<>();
map.put("pageNum", page);
map.put("pageSize", 10);
impl.getUserFateHistory(map, new FateContract.CallBack<FateHistoryEntity>() {
@Override
public void success(FateHistoryEntity entity) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().getFateHistorySuccess(entity);
}
}
@Override
public void fail(String msg) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().showError(msg);
}
}
});
}
/**
* 用户修改的生辰八字保存
* @param json
*/
public void saveEditBirthInfo(JSONObject json) {
impl.saveUserEditBirthInfo(json, new FateContract.CallBack<TodayFateEntity>() {
@Override
public void success(TodayFateEntity bean) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().userSaveBirthInfoSuccess(bean);
}
}
@Override
public void fail(String msg) {
if(FatePresenter.this.getView() != null){
FatePresenter.this.getView().showError(msg);
}
}
});
}
/**
* 获取个人信息
*/
public void getUserInfo() {
Map<String,Object> map = new HashMap<>();
new UserInfoRepository().getUserInfo(map, new LoginContract.CallBack<MineUserInfoBean>() {
@Override
public void success(MineUserInfoBean bean) {
if( FatePresenter.this.getView() != null){
FatePresenter.this.getView().getUserInfoSuccess(bean);
}
}
@Override
public void fail(String msg) {
if( FatePresenter.this.getView() != null){
FatePresenter.this.getView().showError(msg);
}
}
});
}
/**
* 举报
* @param reason
*/
public void commitReport(String reason) {
Map<String, Object> map = new HashMap<>();
map.put("content", reason);
impl.commitReport(map, new FateContract.CallBack<BaseBean>() {
@Override
public void success(BaseBean bean) {
if (FatePresenter.this.getView() != null) {
FatePresenter.this.getView().commitReportSuccess(bean);
}
}
@Override
public void fail(String msg) {
if (FatePresenter.this.getView() != null) {
FatePresenter.this.getView().showError(msg);
}
}
});
}
}

View File

@@ -1,75 +0,0 @@
package com.ckkj.griddle.fate.util;
import android.content.Context;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
public class LunarDateLoader {
// 缓存静态变量
private static JSONArray cachedLunarJsonArray = null;
/**
* 初始化缓存(异步调用,建议在 Application 中调用)
*/
public static void preloadLunarJson(final Context context) {
if (cachedLunarJsonArray != null) return; // 已加载过则跳过
new Thread(() -> {
try {
InputStream inputStream = context.getAssets().open("lunar_1899_2099.json");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, len);
}
inputStream.close();
String jsonStr = outputStream.toString("UTF-8");
cachedLunarJsonArray = new JSONArray(jsonStr);
} catch (Exception e) {
e.printStackTrace();
}
}).start();
}
/**
* 获取缓存的农历 JSON 数据(同步获取)
* 可在页面中直接调用
*/
@Nullable
public static JSONArray getCachedLunarJson() {
return cachedLunarJsonArray;
}
/**
* 同步加载(兜底)
*/
@Nullable
public static JSONArray loadJsonFromAssets(Context context, String fileName) {
try {
InputStream inputStream = context.getAssets().open(fileName);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, len);
}
inputStream.close();
String jsonStr = outputStream.toString("UTF-8");
return new JSONArray(jsonStr);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View File

@@ -1,96 +0,0 @@
package com.ckkj.griddle.fate.util;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ckkj.griddle.fate.entity.LunarYearEntity;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
public class LunarDatePicker {
private List<LunarYearEntity> lunarYears; // 所有年份数据
private List<LunarYearEntity.LunarMonth> currentYearMonths; // 当前选中年的月份数据
// 月份名称映射(数字->中文)
private static final String[] MONTH_NAMES = {
"正月", "二月", "三月", "四月", "五月", "六月",
"七月", "八月", "九月", "十月", "冬月", "腊月"
};
// 日期名称列表(初一到三十)
private static final String[] DAY_NAMES = {
"初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十",
"十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
"廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"
};
public LunarDatePicker(String jsonData) {
// 解析JSON数据
parseLunarData(jsonData);
}
// 解析JSON数据
private void parseLunarData(String jsonData) {
Gson gson = new Gson();
Type type = new TypeToken<List<LunarYearEntity>>(){}.getType();
lunarYears = gson.fromJson(jsonData, type);
}
// 获取年份列表(用于年的WheelView)
public List<String> getYearList() {
List<String> years = new ArrayList<>();
for (LunarYearEntity year : lunarYears) {
years.add(year.getYear());
}
return years;
}
// 根据选中的年份索引获取月份列表(用于月的WheelView)
public List<String> getMonthList(int yearIndex) {
if (yearIndex < 0 || yearIndex >= lunarYears.size()) {
return new ArrayList<>();
}
LunarYearEntity selectedYear = lunarYears.get(yearIndex);
currentYearMonths = selectedYear.getMonth(); // 保存当前年的月份数据
List<String> monthList = new ArrayList<>();
for (LunarYearEntity.LunarMonth month : selectedYear.month) {
int monthNum = Integer.parseInt(month.name);
String monthName = MONTH_NAMES[monthNum - 1]; // 数组索引从0开始
// 处理闰月
if (month.isRun == 1) {
monthName = "闰" + monthName;
}
monthList.add(monthName);
}
return monthList;
}
// 根据选中的月份索引获取日期列表(用于日的WheelView)
public List<String> getDayList(int monthIndex) {
if (currentYearMonths == null || monthIndex < 0 || monthIndex >= currentYearMonths.size()) {
return new ArrayList<>();
}
LunarYearEntity.LunarMonth selectedMonth = currentYearMonths.get(monthIndex);
int days = selectedMonth.isAllDay == 1 ? 30 : 29; // 确定天数
List<String> dayList = new ArrayList<>();
for (int i = 0; i < days; i++) {
dayList.add(DAY_NAMES[i]);
}
return dayList;
}
// 获取选中的完整日期(年、月、日索引)
public String getSelectedDate(int yearIndex, int monthIndex, int dayIndex) {
String year = lunarYears.get(yearIndex).year + "年";
String month = getMonthList(yearIndex).get(monthIndex);
String day = getDayList(monthIndex).get(dayIndex);
return year + month + day;
}
}

View File

@@ -1,844 +0,0 @@
package com.ckkj.griddle.fate.view;
import static android.app.Activity.RESULT_OK;
import static com.qweather.sdk.QWeather.instance;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
//import com.amap.api.location.AMapLocation;
//import com.amap.api.location.AMapLocationClient;
//import com.amap.api.location.AMapLocationClientOption;
//import com.amap.api.location.AMapLocationListener;
import com.amap.api.services.core.AMapException;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.geocoder.GeocodeAddress;
import com.amap.api.services.geocoder.GeocodeQuery;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.google.android.material.progressindicator.CircularProgressIndicator;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.ckkj.griddle.AppConfig;
import com.ckkj.griddle.ConstantUtil;
import com.ckkj.griddle.EventMessage;
import com.ckkj.griddle.R;
import com.ckkj.griddle.base.BaseFragment;
import com.ckkj.griddle.base.entity.MineUserInfoBean;
import com.ckkj.griddle.custom.view.CustomRefreshHeader;
import com.ckkj.griddle.databinding.FateLayoutBinding;
import com.ckkj.griddle.dialog.ContentReportDialog;
import com.ckkj.griddle.fate.entity.CityDataEntity;
import com.ckkj.griddle.fate.entity.FateHistoryEntity;
import com.ckkj.griddle.fate.entity.TodayFateEntity;
import com.ckkj.griddle.fate.mvp.FateContract;
import com.ckkj.griddle.fate.mvp.FateImpl;
import com.ckkj.griddle.fate.mvp.FatePresenter;
import com.ckkj.griddle.login.LoginActivity;
import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.utils.WeatherIconUtil;
import com.ckkj.griddle.utils.click.ClickUtil;
import com.ckkj.griddle.utils.color.FateDataUtil;
import com.ckkj.griddle.utils.dataUtil.SharePreUtil;
import com.ckkj.griddle.utils.manager.MingDengUserInfoManager;
import com.ckkj.griddle.utils.number.NumberDecimalFilter;
import com.ckkj.griddle.utils.show.ToastUtil;
import com.ckkj.griddle.utils.time.ZYTimeUtils;
import com.qweather.sdk.Callback;
import com.qweather.sdk.JWTGenerator;
import com.qweather.sdk.QWeather;
import com.qweather.sdk.basic.Lang;
import com.qweather.sdk.basic.Unit;
import com.qweather.sdk.parameter.weather.WeatherParameter;
import com.qweather.sdk.response.error.ErrorResponse;
import com.qweather.sdk.response.geo.GeoPoiResponse;
import com.qweather.sdk.response.weather.WeatherNowResponse;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.layout.api.RefreshHeader;
import java.util.List;
import java.util.Calendar;
import android.os.Handler;
import android.os.Looper;
import butterknife.OnClick;
import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;
import pub.devrel.easypermissions.EasyPermissions;
/**
* @author fengxiaoyang
* @date 2025/7/7
* @description TODO: 描述该类的作用
*/
public class FateFragment extends BaseFragment<FateLayoutBinding, FatePresenter>
implements FateContract.FateView , EasyPermissions.PermissionCallbacks{
private TodayFateEntity mTodayEntity;
//声明AMapLocationClient类对象
// public AMapLocationClient mLocationClient = null;
//声明AMapLocationClientOption对象
// public AMapLocationClientOption mLocationOption = null;
// 添加动画执行标志位
private boolean isCareerAnimPlayed = false;
private boolean isLoveAnimPlayed = false;
private boolean isHealthAnimPlayed = false;
private boolean isWealthAnimPlayed = false;
private boolean isOverallAnimPlayed = false;
//是否已经加载过
private boolean hasLoaded = false;
// 添加Toast相关的成员变量
private Handler toastHandler = new Handler(Looper.getMainLooper());
private Runnable toastRunnable;
private boolean isToastTaskRunning = false;
private int currentToastIndex = 0;
private String[] toastMessages = {
"正在查看您的今日能量值",
"让我帮你看看今天的星座运势",
"正在生成您的幸运元素",
"别着急,让我来想想今天的事宜"
};
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
}
@Override
protected void onResumeInitData() {
super.onResumeInitData();
// 确保在Fragment可见时检查动画
viewBinding.getRoot().postDelayed(() -> {
checkAndAnimateProgressBars();
}, 300);
if(AppConfig.USER_LOGIN){
mPresenter.getUserInfo();
}else{
viewBinding.llInput.setVisibility(View.VISIBLE);
}
if (getUserVisibleHint() && !hasLoaded) {
if(AppConfig.USER_LOGIN){
showLoadingDialog();
// 调用接口并启动延迟Toast任务
startFateDataRequest();
hasLoaded = true;
}
}
}
@Override
public void initData(Bundle state) {
//请求定位权限
// String permission = Manifest.permission.ACCESS_FINE_LOCATION;
// if(!hasRecordPermission(permission)){
// getPermissionRequst(permission,"定位权限申请","叮叮车需要您的授权,获取您当前所在的城市",REQUEST_EVENT_CODE_10002);
// }else{
// AMapLocationClient.updatePrivacyAgree(mContext, true);
// initLocationInfo();
// }
// AMapLocationClient.updatePrivacyAgree(mContext, true);
// AMapLocationClient.updatePrivacyShow(mContext, true,true);
// 设置当前日期和星期几
setCurrentDate();
//和风天气 init
try {
JWTGenerator jwt = new JWTGenerator(
"-----BEGIN PRIVATE KEY-----\n" +
"MC4CAQAwBQYDK2VwBCIEIFH+qB/0rER1mEpgAIwpBiAShW9pnSAj8OipGY/eFLRb\n" +
"-----END PRIVATE KEY-----",//密钥
"2A89MF5WVU",//项目 ID
"K5PU3M4P2A");//凭据 ID
instance = QWeather.getInstance(mContext, "mr3597qqpv.re.qweatherapi.com")
.setTokenGenerator(jwt)
.setLogEnable(true);
Log.d(TAG,"和风天气初始化成功");
} catch (Throwable e) {
Log.d(TAG,"和风天气初始化异常");
throw new RuntimeException(e);
}
// 添加视图可见性监听
setupProgressAnimations();
ClickUtil.addClickPart(viewBinding.imgHistory,60);
// 设置自定义刷新头
RefreshHeader header = new CustomRefreshHeader(mContext);
viewBinding.refresh.setRefreshHeader(header);
// viewBinding.refresh.setRefreshFooter(new ClassicsFooter(mContext));
viewBinding.refresh.setOnRefreshListener(layout -> {
if(AppConfig.USER_LOGIN){
showLoadingDialog();
// 调用接口并启动延迟Toast任务
startFateDataRequest();
hasLoaded = true;
}
});
}
/**
* 设置当前日期和星期几
*/
private void setCurrentDate() {
Calendar calendar = Calendar.getInstance();
int month = calendar.get(Calendar.MONTH) + 1; // Calendar.MONTH 从0开始,所以要+1
int day = calendar.get(Calendar.DAY_OF_MONTH);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
// 将数字星期转换为中文
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
String weekDayStr = weekDays[dayOfWeek - 1]; // Calendar.DAY_OF_WEEK 从1开始(星期日=1)
// 格式化日期字符串:例如 "9 月 9 日 星期三"
String dateStr = month + " 月 " + day + " 日 " + weekDayStr;
// 设置到TextView
viewBinding.tvDate.setText(dateStr);
}
private void setupProgressAnimations() {
// 监听父滚动视图(假设外层是NestedScrollView)
View scrollView = viewBinding.getRoot().findViewById(R.id.nesd_scrollview); // 替换为你的NestedScrollView id
if (scrollView != null) {
scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
checkAndAnimateProgressBars();
});
}
// 初始检查(如果视图已经可见)
viewBinding.getRoot().postDelayed(() -> {
checkAndAnimateProgressBars();
}, 300); // 延迟300ms确保布局完成
}
private void checkAndAnimateProgressBars() {
if(mTodayEntity == null){
return;
}
// 圆形进度条(运势分数)
if (isViewVisible(viewBinding.includedTodayFateDatas.progressIndicator) && !isOverallAnimPlayed) {
animateCircularProgress(
viewBinding.includedTodayFateDatas.progressIndicator,
mTodayEntity.getFortuneAnalysis().getOverallScore()
);
isOverallAnimPlayed = true;
}
// 检查每个进度条是否需要执行动画
if (isViewVisible(viewBinding.includedSyy.proSyy) && !isCareerAnimPlayed) {
animateProgress(viewBinding.includedSyy.proSyy,
mTodayEntity.getFortuneAnalysis().getCareerScore());
isCareerAnimPlayed = true;
}
if (isViewVisible(viewBinding.includedSyy.proGqy) && !isLoveAnimPlayed) {
animateProgress(viewBinding.includedSyy.proGqy,
mTodayEntity.getFortuneAnalysis().getLoveScore());
isLoveAnimPlayed = true;
}
if (isViewVisible(viewBinding.includedSyy.proJky) && !isHealthAnimPlayed) {
animateProgress(viewBinding.includedSyy.proJky,
mTodayEntity.getFortuneAnalysis().getHealthScore());
isHealthAnimPlayed = true;
}
if (isViewVisible(viewBinding.includedSyy.proCfy) && !isWealthAnimPlayed) {
animateProgress(viewBinding.includedSyy.proCfy,
mTodayEntity.getFortuneAnalysis().getWealthScore());
isWealthAnimPlayed = true;
}
}
// 判断视图是否可见
private boolean isViewVisible(View view) {
if (view == null) return false;
Rect scrollBounds = new Rect();
View scrollView = viewBinding.getRoot().findViewById(R.id.nesd_scrollview);
if (scrollView != null) {
scrollView.getHitRect(scrollBounds);
return view.getLocalVisibleRect(scrollBounds);
}
return false;
}
// 执行进度条动画
private void animateProgress(LinearProgressIndicator progressBar, int targetProgress) {
// 保存原始进度值
final int originalProgress = progressBar.getProgress();
// 先重置为0
progressBar.setProgress(0);
// 创建动画
ObjectAnimator animator = ObjectAnimator.ofInt(progressBar, "progress", 0, targetProgress);
animator.setDuration(800); // 动画时长800ms
animator.setInterpolator(new AccelerateDecelerateInterpolator());
// 添加脉冲效果
animator.addUpdateListener(animation -> {
float fraction = animation.getAnimatedFraction();
float scale = 1 + 0.2f * (float) Math.sin(fraction * Math.PI);
progressBar.setScaleX(scale);
progressBar.setScaleY(scale);
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// 恢复原始大小
progressBar.animate()
.scaleX(1f)
.scaleY(1f)
.setDuration(200)
.start();
}
});
animator.start();
}
// 执行圆形进度条动画(带旋转效果)
private void animateCircularProgress(CircularProgressIndicator progressBar, int targetProgress) {
// 保存原始进度值
final int originalProgress = progressBar.getProgress();
// 先重置为0
progressBar.setProgress(0);
// 创建进度动画
ValueAnimator progressAnimator = ValueAnimator.ofInt(0, targetProgress);
progressAnimator.setDuration(1000); // 动画时长1000ms
progressAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
// 创建旋转动画
ObjectAnimator rotationAnimator = ObjectAnimator.ofFloat(progressBar, "rotation", 0f, 360f);
rotationAnimator.setDuration(800);
rotationAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
// 组合动画
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(progressAnimator, rotationAnimator);
// 添加脉冲缩放效果
progressAnimator.addUpdateListener(animation -> {
int progress = (int) animation.getAnimatedValue();
progressBar.setProgress(progress);
// 脉冲效果:在动画过程中轻微缩放
float fraction = animation.getAnimatedFraction();
float scale = 1 + 0.12f * (float) Math.sin(fraction * Math.PI);
progressBar.setScaleX(scale);
progressBar.setScaleY(scale);
});
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// 恢复原始大小
progressBar.animate()
.scaleX(1f)
.scaleY(1f)
.setDuration(200)
.start();
}
});
animatorSet.start();
}
@Override
public FatePresenter createPresenter() {
return new FatePresenter(new FateImpl());
}
@OnClick({R.id.tv_input,R.id.tv_input_new,R.id.img_history,R.id.img_jb})
public void onClick(View v) {
switch (v.getId()) {
case R.id.img_jb:
ContentReportDialog cancelDialog = new ContentReportDialog(mContext,R.layout.dialog_report_reason,"");
cancelDialog.show();
cancelDialog.setOnDialogListener(new ContentReportDialog.DialogListener() {
@Override
public void callBackDatas(String reason) {
showLoadingDialog();
//举报
mPresenter.commitReport(reason);
}
});
break;
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(data != null){
if(resultCode == RESULT_OK){
switch (requestCode){
case REQUEST_EVENT_CODE_10002:
break;
case REQUEST_EVENT_CODE_10001:
break;
}
}
}
}
@Subscribe(threadMode = ThreadMode.MainThread)
public void onGetMessage(EventMessage message) {
switch (message.msg){
case EventMessage.DATA_REFRESH_EVENT:
showLoadingDialog();
startFateDataRequest();
break;
case EventMessage.USER_LOGIN_SUCCESS:
startFateDataRequest();
break;
}
}
/**
* 启动今日运势数据请求并开始延迟Toast任务
*/
private void startFateDataRequest() {
// 停止之前的Toast任务(如果有的话)
stopToastTask();
// 调用接口
mPresenter.getTodayFateDatas();
// 启动延迟Toast任务
startDelayedToastTask();
}
/**
* 启动延迟Toast任务
*/
private void startDelayedToastTask() {
// 5秒后开始显示Toast
toastHandler.postDelayed(() -> {
if (!isToastTaskRunning) {
isToastTaskRunning = true;
currentToastIndex = 0;
startToastLoop();
}
}, 5000);
}
/**
* 开始Toast循环显示
*/
private void startToastLoop() {
if (!isToastTaskRunning) {
return;
}
toastRunnable = new Runnable() {
@Override
public void run() {
if (isToastTaskRunning && currentToastIndex < toastMessages.length) {
// 显示当前Toast
ToastUtil.showLong(mContext, toastMessages[currentToastIndex]);
currentToastIndex++;
// 如果还有下一条消息,5秒后显示
if (currentToastIndex < toastMessages.length && isToastTaskRunning) {
toastHandler.postDelayed(this, 5000);
} else {
// 所有消息显示完毕,重新开始循环
if (isToastTaskRunning) {
currentToastIndex = 0;
toastHandler.postDelayed(this, 5000);
}
}
}
}
};
// 立即执行第一次
toastRunnable.run();
}
/**
* 停止Toast任务
*/
private void stopToastTask() {
isToastTaskRunning = false;
if (toastRunnable != null) {
toastHandler.removeCallbacks(toastRunnable);
}
// 移除所有待执行的任务
toastHandler.removeCallbacksAndMessages(null);
}
/**
* 今日运势请求成功
* @param entity
*/
@Override
public void getUserTodayFateDataSuccess(TodayFateEntity entity) {
// 立即停止Toast任务
stopToastTask();
hideDialogLoading();
if (entity == null || entity.getUserInfo() == null) {
viewBinding.refresh.finishRefresh(300);
ToastUtil.showShort(mContext, "今日运势数据为空,请稍后重试");
return;
}
mTodayEntity = entity;
getLatLngByCityName(entity.getUserInfo().getCurrentPlace());
setDataShow();
viewBinding.refresh.finishRefresh(300);
}
@Override
public void getFateHistorySuccess(FateHistoryEntity entity) {
}
@Override
public void userSaveBirthInfoSuccess(TodayFateEntity bean) {
}
@Override
public void getUserInfoSuccess(MineUserInfoBean bean) {
if(bean != null && bean.getUserInfo() != null){
MingDengUserInfoManager.getInstance().setUserInfo(bean.getUserInfo());
SharePreUtil.putBoolean(ConstantUtil.SHARE_PRE_NAME,mContext,ConstantUtil.USER_HAS_SET_BIRTH,bean.isHasEightCharacters());
AppConfig.USER_SET_BIRTH_INFO = bean.isHasEightCharacters();
//是否设置过生辰
if(AppConfig.USER_SET_BIRTH_INFO){
viewBinding.llInput.setVisibility(View.GONE);
viewBinding.refresh.setVisibility(View.VISIBLE);
}else{
viewBinding.llInput.setVisibility(View.VISIBLE);
viewBinding.refresh.setVisibility(View.GONE);
}
}
}
/**
* 提交举报成功
* @param bean
*/
@Override
public void commitReportSuccess(BaseBean bean) {
ToastUtil.showShort(mContext, "星语明灯感谢您的反馈");
hideDialogLoading();
}
/**
* 设置显示内容
*/
private void setDataShow() {
//出生日期
String birthDay = mTodayEntity.getUserInfo().getBirthTime();
viewBinding.includedBirthInfo.tvBirthdayTime.setText(ZYTimeUtils.formatDateString(birthDay));
//真太阳时
String realSunTime = mTodayEntity.getUserInfo().getTrueSolarTime();
viewBinding.includedBirthInfo.tvZhentaiyangValue.setText(TextUtils.isEmpty(realSunTime) ?
"未知":ZYTimeUtils.formatToChineseDate(realSunTime));
//命格
viewBinding.includedBirthInfo.tvMingge.setText(TextUtils.isEmpty(mTodayEntity.getFortuneAnalysis().getDestiny()) ?
"未知": mTodayEntity.getFortuneAnalysis().getDestiny());
//经纬度
String lng = NumberDecimalFilter.truncateToTwoDecimal(Double.parseDouble(mTodayEntity.getUserInfo().getLongitude()));
String lat = NumberDecimalFilter.truncateToTwoDecimal(Double.parseDouble(mTodayEntity.getUserInfo().getLatitude()));
viewBinding.includedBirthInfo.tvLonglat.setText(lng + "," + lat);
//出生地
viewBinding.includedBirthInfo.tvBirthAddress.setText(mTodayEntity.getUserInfo().getBirthPlace());
//星座
viewBinding.includedBirthInfo.tvXingzuo.setText(mTodayEntity.getUserInfo().getConstellation());
//运势分数
int todayScore = mTodayEntity.getFortuneAnalysis().getOverallScore();
int color = FateDataUtil.getScoreColor(todayScore);
viewBinding.includedTodayFateDatas.progressIndicator.setIndicatorColor(color);
// viewBinding.includedTodayFateDatas.progressIndicator.setProgress(todayScore,true);
viewBinding.includedTodayFateDatas.tvFeenValue.setText(String.valueOf(todayScore));
viewBinding.includedTodayFateDatas.tvFeenValue.setTextColor(color);
//运势内容
viewBinding.includedTodayFateDatas.tvYunshiContent.setText(TextUtils.isEmpty(mTodayEntity.getFortuneAnalysis().getOverallDescription())?
"暂无内容" : mTodayEntity.getFortuneAnalysis().getOverallDescription());
//今日吉时
viewBinding.includedTodayFateDatas.tvTimeZc.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getLuckyTimes().get(0).getTime());
viewBinding.includedTodayFateDatas.tvThingZc.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getLuckyTimes().get(0).getDescription());
viewBinding.includedTodayFateDatas.tvTimeZw.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getLuckyTimes().get(1).getTime());
viewBinding.includedTodayFateDatas.tvThingZw.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getLuckyTimes().get(1).getDescription());
viewBinding.includedTodayFateDatas.tvTimeXw.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getLuckyTimes().get(2).getTime());
viewBinding.includedTodayFateDatas.tvThingXw.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getLuckyTimes().get(2).getDescription());
//天象星座
viewBinding.includedXingzuo.tvXingzuo.setText(mTodayEntity.getUserInfo().getConstellation());
viewBinding.includedXingzuo.tvWendu.setText(mTodayEntity.getWeatherTemperature());
viewBinding.includedXingzuo.tvTianqi.setText(mTodayEntity.getWeatherCondition());
viewBinding.includedXingzuo.tvXzType.setText(FateDataUtil.getConstellationType(mTodayEntity.getUserInfo().getConstellation()));
viewBinding.includedXingzuo.tvXingzuoYingxiang.setText(mTodayEntity.getFortuneAnalysis().getAstrologyInfluence().getDescription());
//事业运
viewBinding.includedSyy.tvSyyScore.setText(String.valueOf(mTodayEntity.getFortuneAnalysis().getCareerScore()));
// viewBinding.includedSyy.proSyy.setProgress(mTodayEntity.getFortuneAnalysis().getCareerScore());
viewBinding.includedSyy.tvSyyContent.setText(mTodayEntity.getFortuneAnalysis().getCareerDescription());
//事业运
viewBinding.includedSyy.tvGqyScore.setText(String.valueOf(mTodayEntity.getFortuneAnalysis().getLoveScore()));
// viewBinding.includedSyy.proGqy.setProgress(mTodayEntity.getFortuneAnalysis().getLoveScore());
viewBinding.includedSyy.tvGqyContent.setText(mTodayEntity.getFortuneAnalysis().getLoveDescription());
//事业运
viewBinding.includedSyy.tvJkyScore.setText(String.valueOf(mTodayEntity.getFortuneAnalysis().getHealthScore()));
// viewBinding.includedSyy.proJky.setProgress(mTodayEntity.getFortuneAnalysis().getHealthScore());
viewBinding.includedSyy.tvJkyContent.setText(mTodayEntity.getFortuneAnalysis().getHealthDescription());
//事业运
viewBinding.includedSyy.tvCfyScore.setText(String.valueOf(mTodayEntity.getFortuneAnalysis().getWealthScore()));
// viewBinding.includedSyy.proCfy.setProgress(mTodayEntity.getFortuneAnalysis().getWealthScore());
viewBinding.includedSyy.tvCfyContent.setText(mTodayEntity.getFortuneAnalysis().getWealthDescription());
//幸运数字
String [] numbers = mTodayEntity.getFortuneAnalysis().getLuckyInfo().getNumbers();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < numbers.length; i++) {
sb.append(numbers[i]);
if (i < numbers.length - 1) {
sb.append("、");
}
}
viewBinding.includeXingyun.tvLuckNum.setText(sb.toString());
//幸运颜色
viewBinding.includeXingyun.tvLuckColor.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getColor());
//幸运方位
viewBinding.includeXingyun.tvLuckFw.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getDirection());
//幸运时间
viewBinding.includeXingyun. tvLuckTime.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getLuckyTimes().get(0).getTime());
//幸运花卉
viewBinding.includeXingyun.tvLuckFlower.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getFlower());
//幸运方位
viewBinding.includeXingyun.tvLuckFood.setText(mTodayEntity.getFortuneAnalysis().getLuckyInfo().getFood());
//宜 忌
String positive = mTodayEntity.getFortuneAnalysis().getSuggestions().getPositive();
String negative = mTodayEntity.getFortuneAnalysis().getSuggestions().getNegative();
viewBinding.includeYsjy.tvPositive.setText(positive);
viewBinding.includeYsjy.tvNegative.setText(negative);
//五行分析
viewBinding.includeYsjy.tvFive.setText(mTodayEntity.getFortuneAnalysis().getFiveElementsAnalysis());
// 重置动画标志位
resetAnimationFlags();
}
/**
* 通过城市逆地理编码,获取经纬度
* @param cityName
*/
private void getLatLngByCityName(String cityName) {
try {
GeocodeSearch geocodeSearch = new GeocodeSearch(mContext);
geocodeSearch.setOnGeocodeSearchListener(new GeocodeSearch.OnGeocodeSearchListener() {
@Override
public void onRegeocodeSearched(com.amap.api.services.geocoder.RegeocodeResult regeocodeResult, int i) {
// Not used here
}
@Override
public void onGeocodeSearched(GeocodeResult geocodeResult, int rCode) {
if (rCode == AMapException.CODE_AMAP_SUCCESS) {
List<GeocodeAddress> addressList = geocodeResult.getGeocodeAddressList();
if (addressList != null && !addressList.isEmpty()) {
GeocodeAddress address = addressList.get(0);
LatLonPoint latLonPoint = address.getLatLonPoint();
String lat = String.valueOf(NumberDecimalFilter.roundToTwoDecimalPlaces(latLonPoint.getLatitude()));
String lng = String.valueOf(NumberDecimalFilter.roundToTwoDecimalPlaces(latLonPoint.getLongitude()));
WeatherParameter parameter = new WeatherParameter(lng + "," + lat)
.lang(Lang.ZH_HANS)
.unit(Unit.METRIC);
instance.weatherNow(parameter, new Callback<WeatherNowResponse>() {
@Override
public void onSuccess(WeatherNowResponse response) {
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
WeatherIconUtil.loadWeatherIcon(mContext,viewBinding.includedBirthInfo.imgWeather,response.getNow().getIcon());
viewBinding.includedBirthInfo.tvTianqi.setText(response.getNow().getText() + " " +response.getNow().getTemp() + "℃");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
}
@Override
public void onFailure(ErrorResponse errorResponse) {
Log.d(TAG,"调用和风 API--onFailure" + errorResponse.toString());
}
@Override
public void onException(Throwable e) {
Log.d(TAG,"调用和风 API--onException" + e.getMessage());
e.printStackTrace();
}
});
} else {
Log.d("GeoUtil", "未找到城市: " + cityName);
}
} else {
Log.e("GeoUtil", "查询失败,错误码: " + rCode);
}
}
});
// 创建 GeocodeQuery,第一个参数是城市名,第二个参数可指定省份(可选)
GeocodeQuery query = new GeocodeQuery(cityName, null);
geocodeSearch.getFromLocationNameAsyn(query); // 异步查询
} catch (AMapException e) {
throw new RuntimeException(e);
}
}
// 重置动画标志位
private void resetAnimationFlags() {
isOverallAnimPlayed = false;
isCareerAnimPlayed = false;
isLoveAnimPlayed = false;
isHealthAnimPlayed = false;
isWealthAnimPlayed = false;
}
@Override
public void onPause() {
super.onPause();
// 停止Toast任务
stopToastTask();
// 重置标志位以便下次可见时重新动画
resetAnimationFlags();
}
@Override
public void onDestroy() {
super.onDestroy();
// 清理资源
stopToastTask();
}
@Override
public void onNetChange(int netModel) {
}
@Override
public void showError(String message) {
// 停止Toast任务
stopToastTask();
hideDialogLoading();
ToastUtil.showShort(mContext,message);
}
@Override
public void logOut(BaseBean bean) {
}
@Override
public void getAllCitySuccess(List<CityDataEntity> list) {
}
/* 高德定位依赖已移除
private void initLocationInfo() {
try {
// 初始化高德地图SDK
AMapLocationClient.setApiKey(AppConfig.GAODE_MAP_APP_KEY);
//高德要求,更新隐私合规
AMapLocationClient.updatePrivacyShow(mContext, true, true);
//初始化定位
mLocationClient = new AMapLocationClient(mContext);
//设置定位回调监听
mLocationClient.setLocationListener(locationListener);
//初始化AMapLocationClientOption对象
mLocationOption = new AMapLocationClientOption();
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
//该方法默认为false。单次定位
mLocationOption.setOnceLocation(true);
//获取最近3s内精度最高的一次定位结果:
//设置setOnceLocationLatest(boolean b)接口为true,启动定位时SDK会返回最近3s内精度最高的一次定位结果。
// 如果设置其为true,setOnceLocation(boolean b)接口也会被设置为true,反之不会,默认为false
mLocationOption.setOnceLocationLatest(true);
//设置是否返回地址信息(默认返回地址信息)
mLocationOption.setNeedAddress(true);
//设置是否允许模拟位置,默认为true,允许模拟位置
mLocationOption.setMockEnable(true);
//单位是毫秒,默认30000毫秒,建议超时时间不要低于8000毫秒。
mLocationOption.setHttpTimeOut(20000);
//给定位客户端对象设置定位参数
mLocationClient.setLocationOption(mLocationOption);
//启动定位
mLocationClient.startLocation();
} catch (Exception e) {
e.printStackTrace();
}
}
*/
/* 高德定位依赖已移除
AMapLocationListener locationListener = new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if(aMapLocation != null){
hideDialogLoading();
if(aMapLocation.getErrorCode() == 0){
}
}
}
};
*/
private void getCurrentCityWeather(GeoPoiResponse response) {
}
@Override
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
// AMapLocationClient.updatePrivacyAgree(mContext, true);
// initLocationInfo();
}
@Override
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
hidePermissionDialog();
if(requestCode == REQUEST_EVENT_CODE_10002){
if(grantResults[0] == 0){
ToastUtil.showShort(mContext,"定位获取成功");
}
}
}
}

View File

@@ -15,6 +15,7 @@ import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.food.adapter.ShopFoodAdapter;
import com.ckkj.griddle.food.entity.ShopBannerEntity;
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
import com.ckkj.griddle.food.entity.ShopGoodsEntity;
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
import com.ckkj.griddle.food.mock.FoodMockData;
import com.ckkj.griddle.food.mvp.ShopContract;
@@ -73,6 +74,8 @@ public class AllGoodsActivity extends BaseActivity<AllGoodsLayoutBinding, ShopPr
/** 美食页使用独立卡片样式,保留商城 Tab 原有的商品卡片。 */
private void initGoodsList() {
goodsAdapter = new ShopFoodAdapter(R.layout.food_recommend_item);
goodsAdapter.setOnItemClickListener((adapter, view, position) ->
openFoodDetail(goodsAdapter.getItem(position)));
viewBinding.rvAllGoods.setLayoutManager(new StaggeredGridLayoutManager(
2, StaggeredGridLayoutManager.VERTICAL));
viewBinding.rvAllGoods.setItemAnimator(null);
@@ -82,6 +85,14 @@ public class AllGoodsActivity extends BaseActivity<AllGoodsLayoutBinding, ShopPr
oldLeft, oldTop, oldRight, oldBottom) -> updateRecipeColumns(right - left));
}
/** 通过父类统一路由传递所选美食,返回时保留当前列表和分页位置。 */
private void openFoodDetail(ShopGoodsEntity food) {
if (food == null) {
return;
}
goTo(mContext, FoodDetailActivity.class, FoodDetailActivity.createBundle(food));
}
/** 根据列表实际可用宽度更新列数,适配折叠展开、横屏及分屏。 */
private void updateRecipeColumns(int widthPx) {
if (widthPx <= 0 || viewBinding == null) {

View File

@@ -0,0 +1,144 @@
package com.ckkj.griddle.food;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.bumptech.glide.Glide;
import com.ckkj.griddle.R;
import com.ckkj.griddle.base.BaseActivity;
import com.ckkj.griddle.databinding.FoodDetailLayoutBinding;
import com.ckkj.griddle.food.adapter.FoodIngredientAdapter;
import com.ckkj.griddle.food.entity.FoodDetailEntity;
import com.ckkj.griddle.food.entity.ShopGoodsEntity;
import com.ckkj.griddle.food.mvp.FoodDetailContract;
import com.ckkj.griddle.food.mvp.FoodDetailImpl;
import com.ckkj.griddle.food.mvp.FoodDetailPresenter;
import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.utils.show.ToastUtil;
import com.gyf.immersionbar.ImmersionBar;
import java.io.Serializable;
import java.util.ArrayList;
import butterknife.OnClick;
/** 美食详情:展示封面、完整名称、简介及动态食材列表。 */
public class FoodDetailActivity extends BaseActivity<FoodDetailLayoutBinding, FoodDetailPresenter>
implements FoodDetailContract.DetailView {
private static final String EXTRA_FOOD = "food_detail_food";
private FoodIngredientAdapter ingredientAdapter;
private ShopGoodsEntity selectedFood;
/** 首页及全部美食列表复用同一参数,保留所点条目的 ID、名称和封面。 */
public static Bundle createBundle(ShopGoodsEntity food) {
Bundle bundle = new Bundle();
bundle.putSerializable(EXTRA_FOOD, food);
return bundle;
}
@Override
public FoodDetailPresenter createPresenter() {
return new FoodDetailPresenter(new FoodDetailImpl());
}
@Override
public int getLayoutResId(Bundle savedInstanceState) {
return R.layout.food_detail_layout;
}
@Override
public void initData(Bundle savedInstanceState) {
super.initData(savedInstanceState);
// 页面、标题栏与系统状态栏保持相同底色,避免出现颜色分层。
ImmersionBar.with(this)
.statusBarColor(R.color.f9f9f9)
.statusBarDarkFont(true)
.navigationBarColor(R.color.f9f9f9)
.init();
initIngredients();
Serializable extra = getIntent().getSerializableExtra(EXTRA_FOOD);
if (extra instanceof ShopGoodsEntity) {
selectedFood = (ShopGoodsEntity) extra;
}
mPresenter.getFoodDetail(selectedFood);
}
private void initIngredients() {
ingredientAdapter = new FoodIngredientAdapter();
viewBinding.rvFoodIngredients.setLayoutManager(new LinearLayoutManager(this));
viewBinding.rvFoodIngredients.setNestedScrollingEnabled(false);
viewBinding.rvFoodIngredients.setItemAnimator(null);
viewBinding.rvFoodIngredients.setAdapter(ingredientAdapter);
}
@Override
public void showFoodDetail(FoodDetailEntity detail) {
if (detail == null) {
showError(null);
return;
}
String name = TextUtils.isEmpty(detail.getName())
? getString(R.string.food_detail_title) : detail.getName();
viewBinding.tvFoodDetailTitle.setText(name);
viewBinding.tvFoodDetailName.setText(name);
viewBinding.ivFoodDetailCover.setContentDescription(name);
setTitle(name);
String cover = detail.getCover();
Glide.with(this)
.load(TextUtils.isEmpty(cover) ? null : cover.trim())
.placeholder(R.drawable.food_cover_placeholder)
.fallback(R.drawable.food_cover_placeholder)
.error(R.drawable.food_cover_placeholder)
.centerCrop()
.into(viewBinding.ivFoodDetailCover);
// 设计稿简介区域没有正文;接口返回内容时再显示,不预留空白正文高度。
viewBinding.tvFoodDetailDescription.setText(detail.getDescription());
viewBinding.tvFoodDetailDescription.setVisibility(
TextUtils.isEmpty(detail.getDescription()) ? View.GONE : View.VISIBLE);
ingredientAdapter.setNewData(new ArrayList<>(detail.getIngredients()));
viewBinding.tvFoodDetailState.setVisibility(View.GONE);
viewBinding.scrollFoodDetail.setVisibility(View.VISIBLE);
}
@OnClick({R.id.iv_food_detail_back, R.id.tv_food_detail_state})
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_food_detail_back:
finish();
break;
case R.id.tv_food_detail_state:
mPresenter.getFoodDetail(selectedFood);
break;
default:
break;
}
}
@Override
public void showError(String message) {
String error = TextUtils.isEmpty(message)
? getString(R.string.food_detail_unavailable) : message;
viewBinding.scrollFoodDetail.setVisibility(View.GONE);
viewBinding.tvFoodDetailState.setText(error);
viewBinding.tvFoodDetailState.setVisibility(View.VISIBLE);
ToastUtil.showShort(mContext, error);
}
@Override
public void logOut(BaseBean bean) {
// 登录失效沿用父类统一处理。
}
@Override
protected void onDestroy() {
viewBinding.rvFoodIngredients.setAdapter(null);
super.onDestroy();
}
}

View File

@@ -153,6 +153,10 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
});
breakfastAdapter = new ShopFoodAdapter(R.layout.food_breakfast_item);
recommendationAdapter = new ShopFoodAdapter(R.layout.food_recommend_item);
breakfastAdapter.setOnItemClickListener((adapter, view, position) ->
openFoodDetail(breakfastAdapter.getItem(position)));
recommendationAdapter.setOnItemClickListener((adapter, view, position) ->
openFoodDetail(recommendationAdapter.getItem(position)));
viewBinding.rvFoodCategories.setAdapter(categoryAdapter);
viewBinding.rvFoodBreakfast.setAdapter(breakfastAdapter);
viewBinding.rvFoodRecommend.setAdapter(recommendationAdapter);
@@ -161,6 +165,14 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
oldLeft, oldTop, oldRight, oldBottom) -> updateRecommendationColumns(right - left));
}
/** 首页分类区和推荐区统一进入同一详情页。 */
private void openFoodDetail(ShopGoodsEntity food) {
if (food == null) {
return;
}
goTo(mContext, FoodDetailActivity.class, FoodDetailActivity.createBundle(food));
}
private void updateRecommendationColumns(int widthPx) {
if (widthPx <= 0 || viewBinding == null) {
return;

View File

@@ -0,0 +1,18 @@
package com.ckkj.griddle.food.adapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
/** 食材条目按数据动态排列,长文案自然换行。 */
public class FoodIngredientAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public FoodIngredientAdapter() {
super(R.layout.item_food_ingredient);
}
@Override
protected void convert(BaseViewHolder helper, String item) {
helper.setText(R.id.tv_food_ingredient, item);
}
}

View File

@@ -0,0 +1,45 @@
package com.ckkj.griddle.food.entity;
import java.util.Collections;
import java.util.List;
/** 美食详情,名称、封面、简介和食材均由数据层提供。 */
public class FoodDetailEntity {
private String name;
private String cover;
private String description;
private List<String> ingredients;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<String> getIngredients() {
return ingredients == null ? Collections.emptyList() : ingredients;
}
public void setIngredients(List<String> ingredients) {
this.ingredients = ingredients;
}
}

View File

@@ -1,16 +1,20 @@
package com.ckkj.griddle.food.mock;
import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.ArrayRes;
import androidx.annotation.StringRes;
import com.ckkj.griddle.R;
import com.ckkj.griddle.food.entity.FoodDetailEntity;
import com.ckkj.griddle.food.entity.ShopBannerEntity;
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
import com.ckkj.griddle.food.entity.ShopGoodsEntity;
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -106,6 +110,32 @@ public final class FoodMockData {
return paginate(goods, page, pageSize);
}
/**
* 临时详情沿用列表条目的名称及封面,食材按展示菜品分组填充。
* TODO 接入详情接口时与本类其他模拟数据一并删除。
*/
public static FoodDetailEntity getDetail(Context context, ShopGoodsEntity food) {
FoodDetailEntity detail = new FoodDetailEntity();
detail.setName(food.getGoodsName());
detail.setCover(food.getGoodsImg());
// 设计稿的简介区仅展示标题和分隔线,暂不添加设计稿之外的模拟正文。
detail.setDescription("");
String image = TextUtils.isEmpty(food.getGoodsImg()) ? "" : food.getGoodsImg();
@ArrayRes int ingredientsRes = R.array.food_mock_ingredients_main;
if (image.contains("noodles") || image.contains("pasta")) {
ingredientsRes = R.array.food_mock_ingredients_noodles;
} else if (image.contains("fried_rice")) {
ingredientsRes = R.array.food_mock_ingredients_rice;
} else if (image.contains("egg_tart")) {
ingredientsRes = R.array.food_mock_ingredients_pastry;
} else if (image.contains("fruit_drinks")) {
ingredientsRes = R.array.food_mock_ingredients_drinks;
}
detail.setIngredients(new ArrayList<>(Arrays.asList(
context.getResources().getStringArray(ingredientsRes))));
return detail;
}
/** 总数始终为完整数据量,越界页返回空列表,避免反复加载相同数据。 */
private static ShopGoodsPageEntity paginate(List<ShopGoodsEntity> goods,
int page, int pageSize) {

View File

@@ -0,0 +1,20 @@
package com.ckkj.griddle.food.mvp;
import com.ckkj.griddle.base.IView;
import com.ckkj.griddle.food.entity.FoodDetailEntity;
import com.ckkj.griddle.food.entity.ShopGoodsEntity;
/** 美食详情页面与数据层的基础协议。 */
public final class FoodDetailContract {
private FoodDetailContract() {
}
public interface DataModel {
void getFoodDetail(ShopGoodsEntity food, ShopContract.CallBack<FoodDetailEntity> callback);
}
public interface DetailView extends IView {
void showFoodDetail(FoodDetailEntity detail);
}
}

View File

@@ -0,0 +1,27 @@
package com.ckkj.griddle.food.mvp;
import android.content.Context;
import com.ckkj.griddle.MyApplication;
import com.ckkj.griddle.R;
import com.ckkj.griddle.food.entity.FoodDetailEntity;
import com.ckkj.griddle.food.entity.ShopGoodsEntity;
import com.ckkj.griddle.food.mock.FoodMockData;
import com.ckkj.griddle.utils.AppLanguageUtil;
/** 详情暂用本地模拟数据,后续联调在此替换为详情接口。 */
public class FoodDetailImpl implements FoodDetailContract.DataModel {
@Override
public void getFoodDetail(ShopGoodsEntity food,
ShopContract.CallBack<FoodDetailEntity> callback) {
// 数据层不持有 Activity,读取资源时使用应用当前选择的语言。
Context context = AppLanguageUtil.wrap(MyApplication.getContext());
if (food == null) {
callback.fail(context.getString(R.string.food_detail_unavailable));
return;
}
// TODO 美食接口联调时,改用 food.getId() 查询详情并删除此模拟数据调用。
callback.success(FoodMockData.getDetail(context, food));
}
}

View File

@@ -0,0 +1,33 @@
package com.ckkj.griddle.food.mvp;
import com.ckkj.griddle.base.BasePresenter;
import com.ckkj.griddle.food.entity.FoodDetailEntity;
import com.ckkj.griddle.food.entity.ShopGoodsEntity;
/** 美食详情协调层,页面沿用项目现有 MVP 关联方式。 */
public class FoodDetailPresenter extends BasePresenter<FoodDetailContract.DetailView> {
private final FoodDetailContract.DataModel impl;
public FoodDetailPresenter(FoodDetailContract.DataModel impl) {
this.impl = impl;
}
public void getFoodDetail(ShopGoodsEntity food) {
impl.getFoodDetail(food, new ShopContract.CallBack<FoodDetailEntity>() {
@Override
public void success(FoodDetailEntity detail) {
if (getView() != null) {
getView().showFoodDetail(detail);
}
}
@Override
public void fail(String message) {
if (getView() != null) {
getView().showError(message);
}
}
});
}
}

View File

@@ -94,7 +94,7 @@ public class LaunchActivity extends BaseActivity<GuideLayoutBinding, MainPresent
if(AppConfig.USER_LOGIN && !TextUtils.isEmpty(AppConfig.USER_TOKEN)){
goTo(mContext, MainActivity.class, null);
}else{
Intent intent = new Intent(mContext, MainActivity.class);
Intent intent = new Intent(mContext, LoginActivity.class);
startActivity(intent);
}
finish();

View File

@@ -22,7 +22,6 @@ import com.ckkj.griddle.base.BaseActivity;
import com.ckkj.griddle.base.entity.MineUserInfoBean;
import com.ckkj.griddle.databinding.MainActivityLayoutBinding;
import com.ckkj.griddle.dialog.DialogAppUpdate;
import com.ckkj.griddle.food.AllGoodsFragment;
import com.ckkj.griddle.main.MainContract;
import com.ckkj.griddle.main.MainImpl;
import com.ckkj.griddle.main.MainPresenter;
@@ -123,7 +122,8 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
mFragmentList.clear();
mFragmentList.add(new DeviceFragment());
mFragmentList.add(new ShopFragment());
mFragmentList.add(new AllGoodsFragment());
// 美食继续使用 food.ShopFragment,商城独立使用 shop 模块。
mFragmentList.add(new com.ckkj.griddle.shop.ShopFragment());
mFragmentList.add(new MineFragment());
// 重新设置适配器
@@ -196,6 +196,9 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
if (selected == TAB_FOOD) {
return R.color.food_page_background;
}
if (selected == TAB_SHOP) {
return R.color.shop_mall_background;
}
return R.color.f9f9f9;
}

View File

@@ -0,0 +1,148 @@
package com.ckkj.griddle.message;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.ckkj.griddle.R;
import com.ckkj.griddle.base.BaseActivity;
import com.ckkj.griddle.base.BaseFragment;
import com.ckkj.griddle.databinding.MessageCenterLayoutBinding;
import com.ckkj.griddle.message.adapter.MessageAdapter;
import com.ckkj.griddle.message.entity.MessageEntity;
import com.ckkj.griddle.message.mvp.MessageContract;
import com.ckkj.griddle.message.mvp.MessageImpl;
import com.ckkj.griddle.message.mvp.MessagePresenter;
import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.utils.show.ToastUtil;
import com.gyf.immersionbar.ImmersionBar;
import java.util.ArrayList;
import java.util.List;
import butterknife.OnClick;
/** 消息中心:常规浅色标题栏,支持查看通知及全部标记已读。 */
public class MessageCenterActivity extends BaseActivity<MessageCenterLayoutBinding, MessagePresenter>
implements MessageContract.MessageView {
private MessageAdapter adapter;
@Override
public MessagePresenter createPresenter() {
return new MessagePresenter(new MessageImpl());
}
@Override
public int getLayoutResId(Bundle savedInstanceState) {
return R.layout.message_center_layout;
}
@Override
public void initData(Bundle savedInstanceState) {
super.initData(savedInstanceState);
// 根布局处理系统边距,状态栏和常规标题栏保持白底深色文字。
ImmersionBar.with(this).statusBarColor(R.color.white).statusBarDarkFont(true)
.navigationBarColor(R.color.message_center_background).navigationBarDarkIcon(true).init();
adapter = new MessageAdapter();
viewBinding.rvMessageCenter.setLayoutManager(new LinearLayoutManager(this));
viewBinding.rvMessageCenter.setItemAnimator(null);
viewBinding.rvMessageCenter.setAdapter(adapter);
final int gap = Math.round(12 * getResources().getDisplayMetrics().density);
viewBinding.rvMessageCenter.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
@NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
outRect.set(0, parent.getChildAdapterPosition(view) > 0 ? gap : 0, 0, 0);
}
});
adapter.setOnItemClickListener((baseAdapter, view, position) -> openMessage(position));
mPresenter.getMessages();
}
@OnClick({R.id.iv_message_center_back, R.id.tv_message_center_read_all, R.id.tv_message_center_state})
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_message_center_back:
finish();
break;
case R.id.tv_message_center_read_all:
mPresenter.markAllRead();
break;
case R.id.tv_message_center_state:
mPresenter.getMessages();
break;
default:
break;
}
}
private void openMessage(int position) {
if (position < 0 || position >= adapter.getData().size()
|| (dialog != null && dialog.isShowing())) return;
MessageEntity item = adapter.getItem(position);
if (item == null) return;
// 当前稿未提供详情页,复用父类弹窗查看完整通知,不扩展新的 Activity。
if (!item.read) mPresenter.markRead(item.id);
showDialogtext(null, false, false, true,
getString(item.titleRes), getString(item.contentRes), null,
getString(R.string.message_center_close), new BaseFragment.OnDialogClick() {
@Override
public void onCancelClick() {
// 关闭弹窗,保留消息列表。
}
@Override
public void onConfirmClick() {
// 已读记录由数据层维护,无需重复更新。
}
});
// 父类只在双按钮都有文案时赋值,单按钮弹窗在此补齐本地化文字。
TextView closeButton = dialog.findViewById(R.id.btnRight);
if (closeButton != null) closeButton.setText(R.string.message_center_close);
}
@Override
public void showMessages(List<MessageEntity> messages) {
List<MessageEntity> data = messages == null ? new ArrayList<>() : new ArrayList<>(messages);
adapter.setNewData(data);
viewBinding.tvMessageCenterState.setText(R.string.message_center_empty);
viewBinding.tvMessageCenterState.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
boolean hasUnread = false;
for (MessageEntity item : data) {
if (!item.read) {
hasUnread = true;
break;
}
}
viewBinding.tvMessageCenterReadAll.setEnabled(hasUnread);
viewBinding.tvMessageCenterReadAll.setAlpha(hasUnread ? 1f : 0.45f);
}
@Override
public void showError(String message) {
String error = TextUtils.isEmpty(message) ? getString(R.string.message_center_load_failed) : message;
if (adapter != null && adapter.getData().isEmpty()) {
viewBinding.tvMessageCenterState.setText(error);
viewBinding.tvMessageCenterState.setVisibility(View.VISIBLE);
}
ToastUtil.showShort(mContext, error);
}
@Override
public void logOut(BaseBean bean) {
// 登录失效沿用父类统一处理。
}
@Override
protected void onDestroy() {
viewBinding.rvMessageCenter.setAdapter(null);
if (dialog != null && dialog.isShowing()) dialog.dismiss();
super.onDestroy();
}
}

View File

@@ -0,0 +1,25 @@
package com.ckkj.griddle.message.adapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.message.entity.MessageEntity;
/** 消息卡片:摘要最多两行,完整内容在点击后展示。 */
public class MessageAdapter extends BaseQuickAdapter<MessageEntity, BaseViewHolder> {
public MessageAdapter() {
super(R.layout.item_message_center);
}
@Override
protected void convert(BaseViewHolder helper, MessageEntity item) {
helper.setText(R.id.tv_message_item_title, mContext.getString(item.titleRes));
helper.setText(R.id.tv_message_item_content, mContext.getString(item.contentRes));
helper.setText(R.id.tv_message_item_time, mContext.getString(item.timeRes));
// 已读不额外添加设计稿之外的角标,通过辅助描述提供状态信息。
helper.itemView.setContentDescription(mContext.getString(R.string.message_center_item_description,
mContext.getString(item.titleRes),
mContext.getString(item.read ? R.string.message_center_read : R.string.message_center_unread),
mContext.getString(item.contentRes)));
}
}

View File

@@ -0,0 +1,18 @@
package com.ckkj.griddle.message.entity;
/** 消息列表条目;本地示例文案通过资源 ID 随应用语言切换。 */
public class MessageEntity {
public final String id;
public final int titleRes;
public final int contentRes;
public final int timeRes;
public final boolean read;
public MessageEntity(String id, int titleRes, int contentRes, int timeRes, boolean read) {
this.id = id;
this.titleRes = titleRes;
this.contentRes = contentRes;
this.timeRes = timeRes;
this.read = read;
}
}

View File

@@ -0,0 +1,29 @@
package com.ckkj.griddle.message.mvp;
import com.ckkj.griddle.base.IView;
import com.ckkj.griddle.message.entity.MessageEntity;
import java.util.List;
/** 消息中心基础协议,页面不直接维护数据来源及已读记录。 */
public final class MessageContract {
private MessageContract() { }
public interface CallBack<T> {
void success(T data);
void fail(String message);
}
public interface DataModel {
void getMessages(CallBack<List<MessageEntity>> callback);
void markRead(String id, CallBack<List<MessageEntity>> callback);
void markAllRead(CallBack<List<MessageEntity>> callback);
}
public interface MessageView extends IView {
void showMessages(List<MessageEntity> messages);
}
}

View File

@@ -0,0 +1,47 @@
package com.ckkj.griddle.message.mvp;
import android.content.Context;
import android.content.SharedPreferences;
import com.ckkj.griddle.MyApplication;
import com.ckkj.griddle.R;
import com.ckkj.griddle.message.entity.MessageEntity;
import java.util.ArrayList;
import java.util.List;
/** 消息数据层:暂用设计稿示例,接口联调时统一替换此处。 */
public class MessageImpl implements MessageContract.DataModel {
private static final String DEMO_MESSAGE_ID = "demo_system_maintenance";
private static final String PREVIEW_READ_STATE = "message_center_preview_read_state";
private SharedPreferences getReadState() {
// 仅保存模拟消息已读状态,单独命名,避免与后续服务端消息记录混用。
return MyApplication.getContext().getSharedPreferences(PREVIEW_READ_STATE, Context.MODE_PRIVATE);
}
@Override
public void getMessages(MessageContract.CallBack<List<MessageEntity>> callback) {
List<MessageEntity> messages = new ArrayList<>();
messages.add(new MessageEntity(DEMO_MESSAGE_ID, R.string.message_center_system_notice,
R.string.message_center_demo_content, R.string.message_center_demo_time,
getReadState().getBoolean(DEMO_MESSAGE_ID, false)));
callback.success(messages);
}
@Override
public void markRead(String id, MessageContract.CallBack<List<MessageEntity>> callback) {
if (!DEMO_MESSAGE_ID.equals(id)) {
callback.fail(null);
return;
}
getReadState().edit().putBoolean(id, true).apply();
getMessages(callback);
}
@Override
public void markAllRead(MessageContract.CallBack<List<MessageEntity>> callback) {
getReadState().edit().putBoolean(DEMO_MESSAGE_ID, true).apply();
getMessages(callback);
}
}

View File

@@ -0,0 +1,41 @@
package com.ckkj.griddle.message.mvp;
import com.ckkj.griddle.base.BasePresenter;
import com.ckkj.griddle.message.entity.MessageEntity;
import java.util.List;
/** 消息中心协调层,加载、单条已读和全部已读共用列表回显。 */
public class MessagePresenter extends BasePresenter<MessageContract.MessageView> {
private final MessageContract.DataModel impl;
public MessagePresenter(MessageContract.DataModel impl) {
this.impl = impl;
}
public void getMessages() {
impl.getMessages(createCallback());
}
public void markRead(String id) {
impl.markRead(id, createCallback());
}
public void markAllRead() {
impl.markAllRead(createCallback());
}
private MessageContract.CallBack<List<MessageEntity>> createCallback() {
return new MessageContract.CallBack<List<MessageEntity>>() {
@Override
public void success(List<MessageEntity> messages) {
if (getView() != null) getView().showMessages(messages);
}
@Override
public void fail(String message) {
if (getView() != null) getView().showError(message);
}
};
}
}

View File

@@ -3,14 +3,8 @@ package com.ckkj.griddle.network;
import com.ckkj.griddle.base.entity.MineUserInfoBean;
import com.ckkj.griddle.fate.entity.CityDataEntity;
import com.ckkj.griddle.fate.entity.FateHistoryEntity;
import com.ckkj.griddle.fate.entity.TodayFateEntity;
import com.ckkj.griddle.login.entity.LoginEntity;
import com.ckkj.griddle.main.entity.CheckVersionEntity;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.plate.entity.BaziSaveSuccessEntity;
import com.ckkj.griddle.plate.entity.PaipanHistoryEntity;
import com.ckkj.griddle.food.entity.ShopBannerEntity;
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
@@ -46,15 +40,6 @@ public interface Request {
//版本检测更新
@POST("mine/api/versionNum")
Observable<BaseBean<CheckVersionEntity>> getVersionCheck(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
//获取城市列表
@GET("mobile/chinaCites")
Observable<BaseBean<List<CityDataEntity>>> getCityDatas(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
//保存用户的生辰八字
@POST("mobile/yourhoroscope")
Observable<BaseBean> saveUserBirthInfo(@HeaderMap Map<String, String> headMap,@Body RequestBody requestBody);
//修改用户的生辰八字
@POST("mobile/yourhoroscope/modify")
Observable<BaseBean<TodayFateEntity>> saveUserEditBirthInfo(@HeaderMap Map<String, String> headMap,@Body RequestBody requestBody);
//发送验证码
@POST("mobile/sendCode")
Observable<BaseBean> sendPhoneCode(@HeaderMap Map<String, String> headMap,@Body RequestBody requestBody);
@@ -73,30 +58,6 @@ public interface Request {
//获取个人信息
@GET("mobile/userInfo")
Observable<BaseBean<MineUserInfoBean>> getMineUserInfo(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
//获取今日运势
@POST("mobile/yourhoroscope/today")
Observable<BaseBean<TodayFateEntity>> getUserTodayFateDatas(@HeaderMap Map<String, String> headMap);
//获取运势历史列表
@GET("mobile/yourhoroscope/history")
Observable<BaseBean<FateHistoryEntity>> getUserFateHistory(@HeaderMap Map<String, String> headMap);
//保存排盘结果
@POST("mobile/paiPan")
Observable<BaseBean<BaziSaveSuccessEntity>> startPaipan(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
//AI解析排盘结果
@POST("mobile/paiPan/ai")
Observable<BaseBean> aiParesBaziResult(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
//开始排盘
@POST("https://api.yuanfenju.com/index.php/v1/Bazi/jingpan")
Observable<BaseYfjApiBean<BaziResultBean>> startPaipanByYfj(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
//获取运势历史列表
@GET("mobile/paiPan/records")
Observable<BaseBean<PaipanHistoryEntity>> getPaipanHistoryList(@HeaderMap Map<String, String> headMap);
//删除历史记录
@POST("mobile/paiPan/record")
Observable<BaseBean> deletePaipanRecordById(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
//问题反馈
@POST("mobile/reporting")
Observable<BaseBean> commitReporting(@HeaderMap Map<String, String> headMap,@QueryMap Map<String, Object> map);
/**
* 获取商城顶部轮播商品,接口最多返回三个在售商品。
*/

View File

@@ -1,40 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import android.graphics.Color;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.utils.helper.FiveElementsHelper;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/6
* @description TODO: 描述该类的作用
*/
public class CangGanAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
private Context mContext;
private List<String> mDzGodList;
public CangGanAdapter(Context context, int layoutResId, @Nullable List<String> data,List<String> dzGodList) {
super(layoutResId, data);
this.mContext = context;
this.mDzGodList = dzGodList;
}
public void setmDzGodList(List<String> mDzGodList) {
this.mDzGodList = mDzGodList;
}
@Override
protected void convert(BaseViewHolder holder, String item) {
holder.setText(R.id.tv_cg_gan,item);
holder.setTextColor(R.id.tv_cg_gan, Color.parseColor(FiveElementsHelper.getElementInfo(item).get("color")));
holder.setText(R.id.tv_cg_shishen,mDzGodList.get(holder.getLayoutPosition()));
}
}

View File

@@ -1,77 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.utils.helper.ShiShen;
import com.ckkj.griddle.utils.helper.ShiShenCalculator;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/5
* @description TODO: 描述该类的作用
*/
public class DayunAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO, BaseViewHolder> {
private Context mContext;
private int mSelPos = -1;
public DayunAdapter(Context context,int layoutResId, @Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO> data,
BaziResultBean.DetailInfoDTO.SizhuInfoDTO sizhuInfoDTO) {
super(layoutResId, data);
this.mContext = context;
}
public int getmSelPos() {
return mSelPos;
}
@Override
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO item) {
holder.setText(R.id.tv_year,item.getDayunStartYear() + "");
if(holder.getLayoutPosition() != 0){
holder.setText(R.id.tv_age,item.getDayunStartAge() + "岁");
holder.setText(R.id.tv_gan_value,ShiShenCalculator.getAbbreviation(item.getDayunShishen()));
holder.setText(R.id.tv_zhi_value,ShiShenCalculator.getAbbreviation(item.getDayunYearDzGod().get(0)));
holder.setGone(R.id.tv_gan_value,true);
holder.setGone(R.id.tv_zhi_value,true);
holder.setGone(R.id.tv_zhi_key,true);
holder.setText(R.id.tv_gan_key,item.getDayunYearTg());
holder.setText(R.id.tv_zhi_key,item.getDayunYearDz());
}else{
int dyStart = item.getDayunStartYear();
int dyEnd = item.getDayunEndYear();
if(dyStart > dyEnd){
holder.setText(R.id.tv_age,"0岁");
}else if(dyStart == dyEnd){
holder.setText(R.id.tv_age,"1岁");
}else{
holder.setText(R.id.tv_age,item.getDayunStartAge() + "-" + item.getDayunEndAge() + "岁");
}
holder.setGone(R.id.tv_gan_value,false);
holder.setGone(R.id.tv_zhi_value,false);
holder.setText(R.id.tv_gan_key,item.getDayunTongxian());
holder.setGone(R.id.tv_zhi_key,false);
holder.setGone(R.id.tv_zhi_value,false);
}
if(holder.getLayoutPosition() == mSelPos){
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.divider));
}else{
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.white));
}
}
public void setSelPostion(int pos){
this.mSelPos = pos;
notifyDataSetChanged();
}
}

View File

@@ -1,167 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.utils.helper.FiveElementsHelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/6
* @description 大运、流年、流月柱状图适配器
*/
public class DayunColumnAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO, BaseViewHolder> {
private Context mContext;
private int mDayunTypeCode = 100;
private CangGanAdapter mCangganAdapter;
private ShenshaAdapter mShenshaAdapter;
private int mSelectXiaoyunPos = -1;
public DayunColumnAdapter(Context context, int layoutResId,
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO> data,
int typeCode) {
super(layoutResId, data);
this.mContext = context;
this.mDayunTypeCode = typeCode;
}
@Override
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO item) {
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
holder.setGone(R.id.viewline,true);
switch (mDayunTypeCode) {
case 100: // 大运
// 第一个item(bornBean)童限 的特殊处理
holder.setText(R.id.tv_shishen, item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunShishen() : item.getDayunShishen());
holder.setText(R.id.tv_tg, item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunYearTg() : item.getDayunYearTg());
holder.setText(R.id.tv_dz, item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunYearDz() : item.getDayunYearDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo
(item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunYearTg() : item.getDayunYearTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo
(item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunYearTg() : item.getDayunYearTg()).get("color")));
holder.setText(R.id.tv_xingyun, item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunDzStarCs() : item.getDayunDzStarCs());
holder.setText(R.id.tv_zizuo, item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunDzSelfCs() : item.getDayunDzSelfCs());
holder.setText(R.id.tv_kongwang, item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunKongwang() : item.getDayunKongwang());
holder.setText(R.id.tv_nayin, item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunNayin() : item.getDayunNayin());
// bornBean可能没有藏干和神煞数据,需要特殊处理
if (mCangganAdapter == null) {
mCangganAdapter = new CangGanAdapter(mContext,
R.layout.paipan_canggan_item,
item.isTongXian() ? item.getXiaoyunInfo().get(0).getXiaoyunYearCg() : item.getDayunYearCg(),
item.isTongXian() ? item.getXiaoyunInfo().get(0).getXiaoyunDzGod() : item.getDayunYearDzGod());
rvDatas.setAdapter(mCangganAdapter);
} else {
mCangganAdapter.setNewData(item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunYearCg() : item.getDayunYearCg());
mCangganAdapter.setmDzGodList(item.isTongXian() ?
item.getXiaoyunInfo().get(0).getXiaoyunDzGod() : item.getDayunYearDzGod());
}
List<String> shenshaList = new ArrayList<>();
if (item.isTongXian()) {
String shensha = item.getXiaoyunInfo().get(0).getXiaoyunShensha();
if (!TextUtils.isEmpty(shensha)) {
shenshaList = Arrays.asList(shensha.split(" "));
}
} else {
String shensha = item.getDayunShensha();
if (!TextUtils.isEmpty(shensha)) {
shenshaList = Arrays.asList(shensha.split(" "));
}
}
if (mShenshaAdapter == null) {
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, shenshaList);
rvShenShaData.setAdapter(mShenshaAdapter);
} else {
mShenshaAdapter.setNewData(shenshaList);
}
break;
case 200: // 流年
BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO xiaoyunEntity = item.getXiaoyunInfo().get(mSelectXiaoyunPos);
// 第一个item(bornBean)的特殊处理
holder.setText(R.id.tv_shishen, xiaoyunEntity.getXiaoyunShishen());
holder.setText(R.id.tv_tg, xiaoyunEntity.getXiaoyunYearTg());
holder.setText(R.id.tv_dz, xiaoyunEntity.getXiaoyunYearDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(xiaoyunEntity.getXiaoyunYearTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(xiaoyunEntity.getXiaoyunYearDz()).get("color")));
holder.setText(R.id.tv_xingyun, xiaoyunEntity.getXiaoyunDzStarCs());
holder.setText(R.id.tv_zizuo, xiaoyunEntity.getXiaoyunDzSelfCs());
holder.setText(R.id.tv_kongwang, xiaoyunEntity.getXiaoyunKongwang());
holder.setText(R.id.tv_nayin, xiaoyunEntity.getXiaoyunNayin());
// bornBean的流年数据可能为空,需要特殊处理
if (mCangganAdapter == null) {
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
xiaoyunEntity.getXiaoyunYearCg(), xiaoyunEntity.getXiaoyunDzGod());
rvDatas.setAdapter(mCangganAdapter);
}else{
mCangganAdapter.setNewData(xiaoyunEntity.getXiaoyunYearCg());
mCangganAdapter.setmDzGodList(xiaoyunEntity.getXiaoyunDzGod());
}
if (mShenshaAdapter == null) {
String shensha = xiaoyunEntity.getXiaoyunShensha();
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList(shensha.split(" ")));
rvShenShaData.setAdapter(mShenshaAdapter);
}else{
String shensha = xiaoyunEntity.getXiaoyunShensha();
mShenshaAdapter.setNewData(Arrays.asList(shensha.split(" ")));
}
break;
case 300: // 流月
// 第一个item(bornBean)的特殊处理
holder.setText(R.id.tv_shishen, "小运");
holder.setText(R.id.tv_tg, item.getDayunYearTg());
holder.setText(R.id.tv_dz, item.getDayunYearDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDayunYearTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDayunYearDz()).get("color")));
holder.setText(R.id.tv_xingyun, "");
holder.setText(R.id.tv_zizuo, "");
holder.setText(R.id.tv_kongwang, "");
holder.setText(R.id.tv_nayin, "");
// bornBean的流月数据可能为空,需要特殊处理
if (mCangganAdapter == null) {
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
Arrays.asList(), Arrays.asList());
rvDatas.setAdapter(mCangganAdapter);
}
if (mShenshaAdapter == null) {
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList());
rvShenShaData.setAdapter(mShenshaAdapter);
}
break;
}
}
public void setColumnCode(int code,int xiaoyunPos) {
mDayunTypeCode = code;
mSelectXiaoyunPos = xiaoyunPos;
notifyDataSetChanged();
}
}

View File

@@ -1,77 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import android.graphics.Color;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.utils.helper.FiveElementsHelper;
import java.util.Arrays;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/7
* @description TODO: 描述该类的作用
*/
public class LiuNianColumnAdapter extends BaseQuickAdapter
<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO, BaseViewHolder> {
private CangGanAdapter mCangganAdapter;
private ShenshaAdapter mShenshaAdapter;
private Context mContext;
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo;
public LiuNianColumnAdapter(Context context, int layoutResId,
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO> data,
List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo) {
super(layoutResId, data);
this.mContext = context;
this.xiaoyunInfo = xiaoyunInfo;
}
@Override
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO item) {
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
// 第一个item(bornBean)的特殊处理
holder.setText(R.id.tv_shishen, item.getLiunianShishen());
holder.setText(R.id.tv_tg, item.getLiunianYearTg());
holder.setText(R.id.tv_dz, item.getLiunianYearDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiunianYearTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiunianYearDz()).get("color")));
holder.setText(R.id.tv_xingyun, item.getLiunianDzStarCs());
holder.setText(R.id.tv_zizuo, item.getLiunianDzSelfCs());
holder.setText(R.id.tv_kongwang, item.getLiunianKongwang());
holder.setText(R.id.tv_nayin, item.getLiunianNayin());
// bornBean的流年数据可能为空,需要特殊处理
if (mCangganAdapter == null) {
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
item.getLiunianYearCg(), item.getLiunianDzGod());
rvDatas.setAdapter(mCangganAdapter);
}else{
mCangganAdapter.setNewData(item.getLiunianYearCg());
mCangganAdapter.setmDzGodList(item.getLiunianDzGod());
}
if (mShenshaAdapter == null) {
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList(item.getLiunianShensha().split(" ")));
rvShenShaData.setAdapter(mShenshaAdapter);
}else{
String shensha = item.getLiunianShensha();
mShenshaAdapter.setNewData(Arrays.asList(shensha.split(" ")));
}
}
public void setXiaoyunDatas(List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfoDTOList) {
this.xiaoyunInfo = xiaoyunInfoDTOList;
}
}

View File

@@ -1,75 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import android.graphics.Color;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.utils.helper.FiveElementsHelper;
import java.util.Arrays;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/7
* @description TODO: 描述该类的作用
*/
public class LiuYueColumnAdapter extends BaseQuickAdapter
<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO, BaseViewHolder> {
private CangGanAdapter mCangganAdapter;
private ShenshaAdapter mShenshaAdapter;
private Context mContext;
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo;
public LiuYueColumnAdapter(Context context, int layoutResId,
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO> data) {
super(layoutResId, data);
this.mContext = context;
}
@Override
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO item) {
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
// 第一个item(bornBean)的特殊处理
holder.setText(R.id.tv_shishen, item.getLiuyueShishen());
holder.setText(R.id.tv_tg, item.getLiuyueMonthTg());
holder.setText(R.id.tv_dz, item.getLiuyueMonthDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiuyueMonthTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiuyueMonthDz()).get("color")));
holder.setText(R.id.tv_xingyun, item.getLiuyueDzStarCs());
holder.setText(R.id.tv_zizuo, item.getLiuyueDzSelfCs());
holder.setText(R.id.tv_kongwang, item.getLiuyueKongwang());
holder.setText(R.id.tv_nayin, item.getLiuyueNayin());
// bornBean的流年数据可能为空,需要特殊处理
if (mCangganAdapter == null) {
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
item.getLiuyueMonthCg(), item.getLiuyueMonthDzGod());
rvDatas.setAdapter(mCangganAdapter);
}else{
mCangganAdapter.setNewData(item.getLiuyueMonthCg());
mCangganAdapter.setmDzGodList(item.getLiuyueMonthDzGod());
}
if (mShenshaAdapter == null) {
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList(item.getLiuyueShensha().split(" ")));
rvShenShaData.setAdapter(mShenshaAdapter);
}else{
String shensha = item.getLiuyueShensha();
mShenshaAdapter.setNewData(Arrays.asList(shensha.split(" ")));
}
}
// public void setXiaoyunDatas(List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfoDTOList) {
// this.xiaoyunInfo = xiaoyunInfoDTOList;
// }
}

View File

@@ -1,63 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.utils.helper.ShiShenCalculator;
import java.util.ArrayList;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/6
* @description TODO: 描述该类的作用
*/
public class LiunianAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO, BaseViewHolder> {
private Context mContext;
private int mSelPos = -1;
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunList =
new ArrayList<>();
public LiunianAdapter(Context context, int layoutResId,
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO> data,
List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo) {
super(layoutResId, data);
this.mContext = context;
this.xiaoyunList = xiaoyunInfo;
}
@Override
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO item) {
holder.setText(R.id.tv_year,item.getLiunianYear() + "");
holder.setGone(R.id.tv_age,false);
holder.setText(R.id.tv_gan_value, ShiShenCalculator.getAbbreviation(item.getLiunianTgGod()));
holder.setText(R.id.tv_zhi_value,ShiShenCalculator.getAbbreviation(item.getLiunianDzGod().get(0)));
holder.setText(R.id.tv_gan_key,item.getLiunianYearTg());
holder.setText(R.id.tv_zhi_key,item.getLiunianYearDz());
holder.setGone(R.id.tv_xiaoyun,true);
holder.setText(R.id.tv_xiaoyun,xiaoyunList.get(holder.getLayoutPosition()).getXiaoyunGanzhi());
if(holder.getLayoutPosition() == mSelPos){
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.divider));
}else{
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.white));
}
}
public void setSelPostion(int pos){
this.mSelPos = pos;
notifyDataSetChanged();
}
public int getmSelPos() {
return mSelPos;
}
}

View File

@@ -1,64 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.utils.helper.ShiShenCalculator;
import com.ckkj.griddle.utils.time.ZYTimeUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/6
* @description TODO: 描述该类的作用
*/
public class LiuyueAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO.
LiunianInfoDTO.LiuyueInfoDTO, BaseViewHolder> {
private Context mContext;
private int mSelPos = -1;
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiunianJieqiDTO> jieqiList =
new ArrayList<>();
public LiuyueAdapter(Context context,int layoutResId, @Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO> data,
List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiunianJieqiDTO> jieqiList) {
super(layoutResId, data);
this.mContext = context;
this.jieqiList = jieqiList;
}
@Override
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO item) {
holder.setText(R.id.tv_year,jieqiList.get(holder.getLayoutPosition()).getJieqiName());
holder.setGone(R.id.tv_age,true);
//节气日期转换
String jieqiDate = ZYTimeUtils.formatToMonthDay(jieqiList.get(holder.getLayoutPosition()).getJieqiSolarYmdhms());
holder.setText(R.id.tv_age, jieqiDate);
holder.setText(R.id.tv_gan_value, ShiShenCalculator.getAbbreviation(item.getLiuyueMonthTgGod()));
holder.setText(R.id.tv_zhi_value,ShiShenCalculator.getAbbreviation(item.getLiuyueMonthDzGod().get(0)));
holder.setText(R.id.tv_gan_key,item.getLiuyueMonthTg());
holder.setText(R.id.tv_zhi_key,item.getLiuyueMonthDz());
holder.setGone(R.id.tv_xiaoyun,false);
if(holder.getLayoutPosition() == mSelPos){
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.divider));
}else{
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.white));
}
}
public void setSelPostion(int pos){
this.mSelPos = pos;
notifyDataSetChanged();
}
public int getmSelPos() {
return mSelPos;
}
}

View File

@@ -1,60 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import android.graphics.Color;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.PaipanHistoryEntity;
import com.ckkj.griddle.utils.click.ClickUtil;
import com.ckkj.griddle.utils.helper.FiveElementsHelper;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/9
* @description TODO: 描述该类的作用
*/
public class PaipanHistoryAdapter extends BaseQuickAdapter<PaipanHistoryEntity.RecordsDTO, BaseViewHolder> {
private Context mContext;
public PaipanHistoryAdapter(Context context,int layoutResId, @Nullable List<PaipanHistoryEntity.RecordsDTO> data) {
super(layoutResId, data);
this.mContext = context;
}
@Override
protected void convert(BaseViewHolder holder, PaipanHistoryEntity.RecordsDTO item) {
String []nianArr = item.getNianZhu().split(",");
String []yueArr = item.getYueZhu().split(",");
String []riArr = item.getRiZhu().split(",");
String []shiArr = item.getShiZhu().split(",");
holder.setText(R.id.tv_nian_tg,nianArr[0]);
holder.setText(R.id.tv_nian_dz,nianArr[1]);
holder.setText(R.id.tv_yue_tg,yueArr[0]);
holder.setText(R.id.tv_yue_dz,yueArr[1]);
holder.setText(R.id.tv_ri_tg,riArr[0]);
holder.setText(R.id.tv_ri_dz,riArr[1]);
holder.setText(R.id.tv_shi_tg,shiArr[0]);
holder.setText(R.id.tv_shi_dz,shiArr[1]);
holder.setTextColor(R.id.tv_nian_tg, Color.parseColor(FiveElementsHelper.getElementInfo(nianArr[0]).get("color")));
holder.setTextColor(R.id.tv_nian_dz, Color.parseColor(FiveElementsHelper.getElementInfo(nianArr[1]).get("color")));
holder.setTextColor(R.id.tv_yue_tg, Color.parseColor(FiveElementsHelper.getElementInfo(yueArr[0]).get("color")));
holder.setTextColor(R.id.tv_yue_dz, Color.parseColor(FiveElementsHelper.getElementInfo(yueArr[1]).get("color")));
holder.setTextColor(R.id.tv_ri_tg, Color.parseColor(FiveElementsHelper.getElementInfo(riArr[0]).get("color")));
holder.setTextColor(R.id.tv_ri_dz, Color.parseColor(FiveElementsHelper.getElementInfo(riArr[1]).get("color")));
holder.setTextColor(R.id.tv_shi_tg, Color.parseColor(FiveElementsHelper.getElementInfo(shiArr[0]).get("color")));
holder.setTextColor(R.id.tv_shi_dz, Color.parseColor(FiveElementsHelper.getElementInfo(shiArr[1]).get("color")));
holder.setText(R.id.tv_user_name,item.getName());
holder.setText(R.id.tv_user_sex,Integer.parseInt(item.getGender()) == 0 ? "男":"女");
holder.setText(R.id.tv_user_birthtime,Integer.parseInt(item.getBirthType()) == 1 ?
"公历:" + item.getYangLiBirthTime():
"农历:" + item.getYinLiBirthTime());
ClickUtil.addClickPart(holder.getView(R.id.img_delete),80);
holder.addOnClickListener(R.id.img_delete);
}
}

View File

@@ -1,30 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/6
* @description TODO: 描述该类的作用
*/
public class ShenshaAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
private Context mContext;
public ShenshaAdapter(Context context,int layoutResId, @Nullable List<String> data) {
super(layoutResId, data);
this.mContext = context;
}
@Override
protected void convert(BaseViewHolder helper, String item) {
helper.setText(R.id.tv_shensha_value,item);
}
}

View File

@@ -1,128 +0,0 @@
package com.ckkj.griddle.plate.adapter;
import android.content.Context;
import android.graphics.Color;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.plate.entity.BaziResultBean;
import com.ckkj.griddle.utils.helper.FiveElementsHelper;
import java.util.Arrays;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/6
* @description TODO: 描述该类的作用
*/
public class SizhuAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.SizhuInfoDTO, BaseViewHolder> {
private Context mContext;
private int mSizhuTypeCode = 100;
private CangGanAdapter mCangganAdapter;
private ShenshaAdapter mShenshaAdapter;
public SizhuAdapter(Context context,int layoutResId,
@Nullable List<BaziResultBean.DetailInfoDTO.SizhuInfoDTO> data,
int typeCode) {
super(layoutResId, data);
this.mContext = context;
this.mSizhuTypeCode = typeCode;
}
@Override
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.SizhuInfoDTO item) {
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
switch (mSizhuTypeCode){
case 100: // 年柱
holder.setText(R.id.tv_shishen,item.getYear().getTgGod());
holder.setText(R.id.tv_tg,item.getYear().getTg());
holder.setText(R.id.tv_dz,item.getYear().getDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getYear().getTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getYear().getDz()).get("color")));
holder.setText(R.id.tv_xingyun,item.getYear().getDzStarCs());
holder.setText(R.id.tv_zizuo,item.getYear().getDzSelfCs());
holder.setText(R.id.tv_kongwang,item.getYear().getKw());
holder.setText(R.id.tv_nayin,item.getYear().getNy());
if(mCangganAdapter == null){
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
item.getYear().getCg(), item.getYear().getDzGod());
rvDatas.setAdapter(mCangganAdapter);
}
if(mShenshaAdapter == null){
List<String> shenshaList = Arrays.asList(item.getYear().getShensha().split(" "));
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
rvShenShaData.setAdapter(mShenshaAdapter);
}
break;
case 200: // 月柱
holder.setText(R.id.tv_shishen,item.getMonth().getTgGod());
holder.setText(R.id.tv_tg,item.getMonth().getTg());
holder.setText(R.id.tv_dz,item.getMonth().getDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getMonth().getTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getMonth().getDz()).get("color")));
holder.setText(R.id.tv_xingyun,item.getMonth().getDzStarCs());
holder.setText(R.id.tv_zizuo,item.getMonth().getDzSelfCs());
holder.setText(R.id.tv_kongwang,item.getMonth().getKw());
holder.setText(R.id.tv_nayin,item.getMonth().getNy());
if(mCangganAdapter == null){
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
item.getMonth().getCg(), item.getMonth().getDzGod());
rvDatas.setAdapter(mCangganAdapter);
}
if(mShenshaAdapter == null){
List<String> shenshaList = Arrays.asList(item.getMonth().getShensha().split(" "));
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
rvShenShaData.setAdapter(mShenshaAdapter);
}
break;
case 300: // 日柱
holder.setText(R.id.tv_shishen,item.getDay().getTgGod());
holder.setText(R.id.tv_tg,item.getDay().getTg());
holder.setText(R.id.tv_dz,item.getDay().getDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDay().getTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDay().getDz()).get("color")));
holder.setText(R.id.tv_xingyun,item.getDay().getDzStarCs());
holder.setText(R.id.tv_zizuo,item.getDay().getDzSelfCs());
holder.setText(R.id.tv_kongwang,item.getDay().getKw());
holder.setText(R.id.tv_nayin,item.getDay().getNy());
if(mCangganAdapter == null){
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
item.getDay().getCg(), item.getDay().getDzGod());
rvDatas.setAdapter(mCangganAdapter);
}
if(mShenshaAdapter == null){
List<String> shenshaList = Arrays.asList(item.getDay().getShensha().split(" "));
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
rvShenShaData.setAdapter(mShenshaAdapter);
}
break;
case 400: // 时柱
holder.setText(R.id.tv_shishen,item.getHour().getTgGod());
holder.setText(R.id.tv_tg,item.getHour().getTg());
holder.setText(R.id.tv_dz,item.getHour().getDz());
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getHour().getTg()).get("color")));
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getHour().getDz()).get("color")));
holder.setText(R.id.tv_xingyun,item.getHour().getDzStarCs());
holder.setText(R.id.tv_zizuo,item.getHour().getDzSelfCs());
holder.setText(R.id.tv_kongwang,item.getHour().getKw());
holder.setText(R.id.tv_nayin,item.getHour().getNy());
if(mCangganAdapter == null){
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
item.getHour().getCg(), item.getHour().getDzGod());
rvDatas.setAdapter(mCangganAdapter);
}
if(mShenshaAdapter == null){
List<String> shenshaList = Arrays.asList(item.getHour().getShensha().split(" "));
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
rvShenShaData.setAdapter(mShenshaAdapter);
}
break;
}
}
}

View File

@@ -1,661 +0,0 @@
package com.ckkj.griddle.plate.entity;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author fengxiaoyang
* @date 2025/8/5
* @description TODO: 描述该类的作用
*/
@NoArgsConstructor
@Data
public class BaziResultBean implements Serializable {
@SerializedName("base_info")
private BaseInfoDTO baseInfo;
@SerializedName("detail_info")
private DetailInfoDTO detailInfo;
@NoArgsConstructor
@Data
public static class BaseInfoDTO implements Serializable {
@SerializedName("sex")
private String sex;
@SerializedName("name")
private String name;
@SerializedName("gongli")
private String gongli;
@SerializedName("nongli")
private String nongli;
@SerializedName("qiyun")
private String qiyun;
@SerializedName("jiaoyun")
private String jiaoyun;
@SerializedName("taiyuan")
private String taiyuan;
@SerializedName("taiyuan_nayin")
private String taiyuanNayin;
@SerializedName("taixi")
private String taixi;
@SerializedName("taixi_nayin")
private String taixiNayin;
@SerializedName("minggong")
private String minggong;
@SerializedName("minggong_nayin")
private String minggongNayin;
@SerializedName("shengong")
private String shengong;
@SerializedName("shengong_nayin")
private String shengongNayin;
@SerializedName("shengxiao")
private String shengxiao;
@SerializedName("xingzuo")
private String xingzuo;
@SerializedName("siling")
private String siling;
@SerializedName("jiaoyun_mang")
private String jiaoyunMang;
@SerializedName("xingxiu")
private String xingxiu;
@SerializedName("minggua")
private MingguaDTO minggua;
@SerializedName("wuxing_wangdu")
private String wuxingWangdu;
@SerializedName("tiangan_liuyi")
private String tianganLiuyi;
@SerializedName("dizhi_liuyi")
private String dizhiLiuyi;
@SerializedName("zhengge")
private String zhengge;
@SerializedName("xiyongshen")
private XiyongshenDTO xiyongshen;
@SerializedName("wuxing_xiji")
private String wuxingXiji;
@NoArgsConstructor
@Data
public static class MingguaDTO implements Serializable {
@SerializedName("minggua_name")
private String mingguaName;
@SerializedName("minggua_fangwei")
private String mingguaFangwei;
}
@NoArgsConstructor
@Data
public static class XiyongshenDTO implements Serializable {
@SerializedName("qiangruo")
private String qiangruo;
@SerializedName("xiyongshen")
private String xiyongshen;
@SerializedName("jishen")
private String jishen;
@SerializedName("xiyongshen_desc")
private String xiyongshenDesc;
@SerializedName("jin_number")
private Integer jinNumber;
@SerializedName("mu_number")
private Integer muNumber;
@SerializedName("shui_number")
private Integer shuiNumber;
@SerializedName("huo_number")
private Integer huoNumber;
@SerializedName("tu_number")
private Integer tuNumber;
@SerializedName("zidang")
private Integer zidang;
@SerializedName("yidang")
private Integer yidang;
@SerializedName("zidang_percent")
private String zidangPercent;
@SerializedName("yidang_percent")
private String yidangPercent;
@SerializedName("tonglei")
private String tonglei;
@SerializedName("yilei")
private String yilei;
@SerializedName("rizhu_tiangan")
private String rizhuTiangan;
@SerializedName("jin_score")
private Integer jinScore;
@SerializedName("mu_score")
private Integer muScore;
@SerializedName("shui_score")
private Integer shuiScore;
@SerializedName("huo_score")
private Integer huoScore;
@SerializedName("tu_score")
private Integer tuScore;
@SerializedName("jin_score_percent")
private String jinScorePercent;
@SerializedName("mu_score_percent")
private String muScorePercent;
@SerializedName("shui_score_percent")
private String shuiScorePercent;
@SerializedName("huo_score_percent")
private String huoScorePercent;
@SerializedName("tu_score_percent")
private String tuScorePercent;
@SerializedName("yinyang")
private String yinyang;
}
}
@NoArgsConstructor
@Data
public static class DetailInfoDTO implements Serializable {
@SerializedName("dayun_info")
private List<DayunInfoDTO> dayunInfo;
@SerializedName("dayun_born_info")
private DayunInfoDTO dayunBornInfo;
@SerializedName("sizhu_info")
private SizhuInfoDTO sizhuInfo;
@SerializedName("taishen_info")
private TaishenInfoDTO taishenInfo;
@NoArgsConstructor
@Data
public static class SizhuInfoDTO implements Serializable {
@SerializedName("year")
private YearDTO year;
@SerializedName("month")
private MonthDTO month;
@SerializedName("day")
private DayDTO day;
@SerializedName("hour")
private HourDTO hour;
@NoArgsConstructor
@Data
public static class YearDTO implements Serializable {
@SerializedName("tg_god")
private String tgGod;
@SerializedName("tg")
private String tg;
@SerializedName("dz")
private String dz;
@SerializedName("cg")
private List<String> cg;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("kw")
private String kw;
@SerializedName("ny")
private String ny;
@SerializedName("wx")
private String wx;
@SerializedName("xun")
private String xun;
@SerializedName("shensha")
private String shensha;
}
@NoArgsConstructor
@Data
public static class MonthDTO implements Serializable {
@SerializedName("tg_god")
private String tgGod;
@SerializedName("tg")
private String tg;
@SerializedName("dz")
private String dz;
@SerializedName("cg")
private List<String> cg;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("kw")
private String kw;
@SerializedName("ny")
private String ny;
@SerializedName("wx")
private String wx;
@SerializedName("xun")
private String xun;
@SerializedName("shensha")
private String shensha;
}
@NoArgsConstructor
@Data
public static class DayDTO implements Serializable {
@SerializedName("tg_god")
private String tgGod;
@SerializedName("tg")
private String tg;
@SerializedName("dz")
private String dz;
@SerializedName("cg")
private List<String> cg;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("kw")
private String kw;
@SerializedName("ny")
private String ny;
@SerializedName("wx")
private String wx;
@SerializedName("xun")
private String xun;
@SerializedName("shensha")
private String shensha;
}
@NoArgsConstructor
@Data
public static class HourDTO implements Serializable {
@SerializedName("tg_god")
private String tgGod;
@SerializedName("tg")
private String tg;
@SerializedName("dz")
private String dz;
@SerializedName("cg")
private List<String> cg;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("kw")
private String kw;
@SerializedName("ny")
private String ny;
@SerializedName("wx")
private String wx;
@SerializedName("xun")
private String xun;
@SerializedName("shensha")
private String shensha;
}
}
@NoArgsConstructor
@Data
public static class TaishenInfoDTO implements Serializable {
@SerializedName("taiyuan")
private TaiyuanDTO taiyuan;
@SerializedName("taixi")
private TaixiDTO taixi;
@SerializedName("minggong")
private MinggongDTO minggong;
@SerializedName("shengong")
private ShengongDTO shengong;
@NoArgsConstructor
@Data
public static class TaiyuanDTO implements Serializable {
@SerializedName("ganzhi")
private String ganzhi;
@SerializedName("xun")
private String xun;
@SerializedName("kongwang")
private String kongwang;
@SerializedName("changsheng")
private String changsheng;
@SerializedName("gan")
private String gan;
@SerializedName("zhi")
private String zhi;
@SerializedName("dz_cg")
private List<String> dzCg;
@SerializedName("tg_god")
private String tgGod;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("nayin")
private String nayin;
@SerializedName("wuxing")
private String wuxing;
@SerializedName("tg_liuyi")
private String tgLiuyi;
@SerializedName("dz_liuyi")
private String dzLiuyi;
@SerializedName("shensha")
private String shensha;
}
@NoArgsConstructor
@Data
public static class TaixiDTO implements Serializable {
@SerializedName("ganzhi")
private String ganzhi;
@SerializedName("xun")
private String xun;
@SerializedName("kongwang")
private String kongwang;
@SerializedName("changsheng")
private String changsheng;
@SerializedName("gan")
private String gan;
@SerializedName("zhi")
private String zhi;
@SerializedName("dz_cg")
private List<String> dzCg;
@SerializedName("tg_god")
private String tgGod;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("nayin")
private String nayin;
@SerializedName("wuxing")
private String wuxing;
@SerializedName("tg_liuyi")
private String tgLiuyi;
@SerializedName("dz_liuyi")
private String dzLiuyi;
@SerializedName("shensha")
private String shensha;
}
@NoArgsConstructor
@Data
public static class MinggongDTO implements Serializable {
@SerializedName("ganzhi")
private String ganzhi;
@SerializedName("xun")
private String xun;
@SerializedName("kongwang")
private String kongwang;
@SerializedName("changsheng")
private String changsheng;
@SerializedName("gan")
private String gan;
@SerializedName("zhi")
private String zhi;
@SerializedName("dz_cg")
private List<String> dzCg;
@SerializedName("tg_god")
private String tgGod;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("nayin")
private String nayin;
@SerializedName("wuxing")
private String wuxing;
@SerializedName("tg_liuyi")
private String tgLiuyi;
@SerializedName("dz_liuyi")
private String dzLiuyi;
@SerializedName("shensha")
private String shensha;
}
@NoArgsConstructor
@Data
public static class ShengongDTO implements Serializable {
@SerializedName("ganzhi")
private String ganzhi;
@SerializedName("xun")
private String xun;
@SerializedName("kongwang")
private String kongwang;
@SerializedName("changsheng")
private String changsheng;
@SerializedName("gan")
private String gan;
@SerializedName("zhi")
private String zhi;
@SerializedName("dz_cg")
private List<String> dzCg;
@SerializedName("tg_god")
private String tgGod;
@SerializedName("dz_god")
private List<String> dzGod;
@SerializedName("dz_star_cs")
private String dzStarCs;
@SerializedName("dz_self_cs")
private String dzSelfCs;
@SerializedName("nayin")
private String nayin;
@SerializedName("wuxing")
private String wuxing;
@SerializedName("tg_liuyi")
private String tgLiuyi;
@SerializedName("dz_liuyi")
private String dzLiuyi;
@SerializedName("shensha")
private String shensha;
}
}
@NoArgsConstructor
@Data
public static class DayunInfoDTO implements Serializable {
@SerializedName("dayun_is_tongxian")
private boolean isTongXian = false;
@SerializedName("dayun_tongxian")
private String dayunTongxian;
@SerializedName("dayun_index")
private Integer dayunIndex;
@SerializedName("dayun_start_year")
private Integer dayunStartYear;
@SerializedName("dayun_start_age")
private Integer dayunStartAge;
@SerializedName("dayun_end_year")
private Integer dayunEndYear;
@SerializedName("dayun_end_age")
private Integer dayunEndAge;
@SerializedName("dayun_start_ganzhi")
private String dayunStartGanzhi;
@SerializedName("dayun_xun")
private String dayunXun;
@SerializedName("dayun_kongwang")
private String dayunKongwang;
@SerializedName("dayun_shishen")
private String dayunShishen;
@SerializedName("dayun_changsheng")
private String dayunChangsheng;
@SerializedName("dayun_year_tg")
private String dayunYearTg;
@SerializedName("dayun_year_dz")
private String dayunYearDz;
@SerializedName("dayun_year_cg")
private List<String> dayunYearCg;
@SerializedName("dayun_year_tg_god")
private String dayunYearTgGod;
@SerializedName("dayun_year_dz_god")
private List<String> dayunYearDzGod;
@SerializedName("dayun_dz_star_cs")
private String dayunDzStarCs;
@SerializedName("dayun_dz_self_cs")
private String dayunDzSelfCs;
@SerializedName("dayun_nayin")
private String dayunNayin;
@SerializedName("dayun_wuxing")
private String dayunWuxing;
@SerializedName("dayun_tg_liuyi")
private String dayunTgLiuyi;
@SerializedName("dayun_dz_liuyi")
private String dayunDzLiuyi;
@SerializedName("liunian_info")
private List<LiunianInfoDTO> liunianInfo;
@SerializedName("xiaoyun_info")
private List<XiaoyunInfoDTO> xiaoyunInfo;
@SerializedName("dayun_shensha")
private String dayunShensha;
@NoArgsConstructor
@Data
public static class LiunianInfoDTO implements Serializable {
@SerializedName("liunian_index")
private Integer liunianIndex;
@SerializedName("liunian_year")
private Integer liunianYear;
@SerializedName("liunian_age")
private Integer liunianAge;
@SerializedName("liunian_ganzhi")
private String liunianGanzhi;
@SerializedName("liunian_xun")
private String liunianXun;
@SerializedName("liunian_kongwang")
private String liunianKongwang;
@SerializedName("liunian_shishen")
private String liunianShishen;
@SerializedName("liunian_changsheng")
private String liunianChangsheng;
@SerializedName("liunian_jieqi")
private List<LiunianJieqiDTO> liunianJieqi;
@SerializedName("liunian_year_tg")
private String liunianYearTg;
@SerializedName("liunian_year_dz")
private String liunianYearDz;
@SerializedName("liunian_year_cg")
private List<String> liunianYearCg;
@SerializedName("liunian_tg_god")
private String liunianTgGod;
@SerializedName("liunian_dz_god")
private List<String> liunianDzGod;
@SerializedName("liunian_dz_star_cs")
private String liunianDzStarCs;
@SerializedName("liunian_dz_self_cs")
private String liunianDzSelfCs;
@SerializedName("liunian_nayin")
private String liunianNayin;
@SerializedName("liunian_wuxing")
private String liunianWuxing;
@SerializedName("liunian_tg_liuyi")
private String liunianTgLiuyi;
@SerializedName("liunian_dz_liuyi")
private String liunianDzLiuyi;
@SerializedName("liunian_shensha")
private String liunianShensha;
@SerializedName("liuyue_info")
private List<LiuyueInfoDTO> liuyueInfo;
@NoArgsConstructor
@Data
public static class LiunianJieqiDTO implements Serializable {
@SerializedName("jieqi_name")
private String jieqiName;
@SerializedName("jieqi_solar_ymdhms")
private String jieqiSolarYmdhms;
@SerializedName("jieqi_lunar_ymdhms_isleap")
private String jieqiLunarYmdhmsIsleap;
@SerializedName("jieqi_lunar_ymdhms")
private String jieqiLunarYmdhms;
}
@NoArgsConstructor
@Data
public static class LiuyueInfoDTO implements Serializable {
@SerializedName("liuyue_index")
private Integer liuyueIndex;
@SerializedName("liuyue_month")
private String liuyueMonth;
@SerializedName("liuyue_ganzhi")
private String liuyueGanzhi;
@SerializedName("liuyue_xun")
private String liuyueXun;
@SerializedName("liuyue_kongwang")
private String liuyueKongwang;
@SerializedName("liuyue_shishen")
private String liuyueShishen;
@SerializedName("liuyue_changsheng")
private String liuyueChangsheng;
@SerializedName("liuyue_month_tg")
private String liuyueMonthTg;
@SerializedName("liuyue_month_dz")
private String liuyueMonthDz;
@SerializedName("liuyue_month_cg")
private List<String> liuyueMonthCg;
@SerializedName("liuyue_month_tg_god")
private String liuyueMonthTgGod;
@SerializedName("liuyue_month_dz_god")
private List<String> liuyueMonthDzGod;
@SerializedName("liuyue_dz_star_cs")
private String liuyueDzStarCs;
@SerializedName("liuyue_dz_self_cs")
private String liuyueDzSelfCs;
@SerializedName("liuyue_nayin")
private String liuyueNayin;
@SerializedName("liuyue_wuxing")
private String liuyueWuxing;
@SerializedName("liuyue_tg_liuyi")
private String liuyueTgLiuyi;
@SerializedName("liuyue_dz_liuyi")
private String liuyueDzLiuyi;
@SerializedName("liuyue_shensha")
private String liuyueShensha;
}
}
@NoArgsConstructor
@Data
public static class XiaoyunInfoDTO implements Serializable {
@SerializedName("xiaoyun_index")
private Integer xiaoyunIndex;
@SerializedName("xiaoyun_year")
private Integer xiaoyunYear;
@SerializedName("xiaoyun_age")
private Integer xiaoyunAge;
@SerializedName("xiaoyun_ganzhi")
private String xiaoyunGanzhi;
@SerializedName("xiaoyun_xun")
private String xiaoyunXun;
@SerializedName("xiaoyun_kongwang")
private String xiaoyunKongwang;
@SerializedName("xiaoyun_shishen")
private String xiaoyunShishen;
@SerializedName("xiaoyun_changsheng")
private String xiaoyunChangsheng;
@SerializedName("xiaoyun_year_tg")
private String xiaoyunYearTg;
@SerializedName("xiaoyun_year_dz")
private String xiaoyunYearDz;
@SerializedName("xiaoyun_year_cg")
private List<String> xiaoyunYearCg;
@SerializedName("xiaoyun_tg_god")
private String xiaoyunTgGod;
@SerializedName("xiaoyun_dz_god")
private List<String> xiaoyunDzGod;
@SerializedName("xiaoyun_dz_star_cs")
private String xiaoyunDzStarCs;
@SerializedName("xiaoyun_dz_self_cs")
private String xiaoyunDzSelfCs;
@SerializedName("xiaoyun_nayin")
private String xiaoyunNayin;
@SerializedName("xiaoyun_wuxing")
private String xiaoyunWuxing;
@SerializedName("xiaoyun_tg_liuyi")
private String xiaoyunTgLiuyi;
@SerializedName("xiaoyun_dz_liuyi")
private String xiaoyunDzLiuyi;
@SerializedName("xiaoyun_shensha")
private String xiaoyunShensha;
}
}
}
}

View File

@@ -1,62 +0,0 @@
package com.ckkj.griddle.plate.entity;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author fengxiaoyang
* @date 2025/8/11
* @description TODO: 描述该类的作用
*/
@NoArgsConstructor
@Data
public class BaziSaveSuccessEntity implements Serializable {
@SerializedName("recordId")
private String recordId;
@SerializedName("savedData")
private SavedDataDTO savedData;
@SerializedName("message")
private String message;
@SerializedName("saveTime")
private String saveTime;
@NoArgsConstructor
@Data
public static class SavedDataDTO {
@SerializedName("recordId")
private String recordId;
@SerializedName("birthPlace")
private String birthPlace;
@SerializedName("gender")
private String gender;
@SerializedName("yinLiBirthTime")
private String yinLiBirthTime;
@SerializedName("siZhu")
private SiZhuDTO siZhu;
@SerializedName("name")
private String name;
@SerializedName("yangLiBirthTime")
private String yangLiBirthTime;
@SerializedName("openSolarTime")
private String openSolarTime;
@NoArgsConstructor
@Data
public static class SiZhuDTO {
@SerializedName("yueZhu")
private String yueZhu;
@SerializedName("shiZhu")
private String shiZhu;
@SerializedName("riZhu")
private String riZhu;
@SerializedName("nianZhu")
private String nianZhu;
}
}
}

View File

@@ -1,17 +0,0 @@
package com.ckkj.griddle.plate.entity;
public class PaipanCache {
private static BaziResultBean cachedResult;
public static void set(BaziResultBean result) {
cachedResult = result;
}
public static BaziResultBean get() {
return cachedResult;
}
public static void clear() {
cachedResult = null;
}
}

View File

@@ -1,76 +0,0 @@
package com.ckkj.griddle.plate.entity;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author fengxiaoyang
* @date 2025/8/9
* @description TODO: 描述该类的作用
*/
@NoArgsConstructor
@Data
public class PaipanHistoryEntity implements Serializable {
@SerializedName("total")
private Integer total;
@SerializedName("pages")
private Integer pages;
@SerializedName("records")
private List<RecordsDTO> records;
@SerializedName("hasNextPage")
private Boolean hasNextPage;
@SerializedName("pageSize")
private Integer pageSize;
@SerializedName("hasPreviousPage")
private Boolean hasPreviousPage;
@SerializedName("userId")
private Long userId;
@SerializedName("pageNum")
private Integer pageNum;
@NoArgsConstructor
@Data
public static class RecordsDTO implements Serializable{
@SerializedName("id")
private String id;
@SerializedName("userId")
private Long userId;
@SerializedName("name")
private String name;
@SerializedName("gender")
private String gender;
@SerializedName("birthType")
private String birthType;
@SerializedName("yangLiBirthTime")
private String yangLiBirthTime;
@SerializedName("yinLiBirthTime")
private String yinLiBirthTime;
@SerializedName("birthPlace")
private String birthPlace;
@SerializedName("openSolarTime")
private String openSolarTime;
@SerializedName("nianZhu")
private String nianZhu;
@SerializedName("yueZhu")
private String yueZhu;
@SerializedName("riZhu")
private String riZhu;
@SerializedName("shiZhu")
private String shiZhu;
@SerializedName("apiStatus")
private Integer apiStatus;
@SerializedName("apiMessage")
private String apiMessage;
@SerializedName("requestIp")
private String requestIp;
@SerializedName("remark")
private Object remark;
}
}

View File

@@ -0,0 +1,252 @@
package com.ckkj.griddle.shop;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.widget.ImageViewCompat;
import androidx.viewpager2.widget.ViewPager2;
import com.bumptech.glide.Glide;
import com.ckkj.griddle.R;
import com.ckkj.griddle.base.BaseActivity;
import com.ckkj.griddle.base.BaseFragment;
import com.ckkj.griddle.cart.CartManageActivity;
import com.ckkj.griddle.cart.CheckoutActivity;
import com.ckkj.griddle.cart.entity.CartGoodsEntity;
import com.ckkj.griddle.databinding.ShopProductDetailLayoutBinding;
import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.shop.adapter.ProductImageAdapter;
import com.ckkj.griddle.shop.entity.ProductEntity;
import com.ckkj.griddle.shop.mvp.ShopContract;
import com.ckkj.griddle.shop.mvp.ShopImpl;
import com.ckkj.griddle.shop.mvp.ShopPresenter;
import com.ckkj.griddle.utils.show.ToastUtil;
import com.gyf.immersionbar.ImmersionBar;
import java.util.ArrayList;
import butterknife.OnClick;
/** 商品详情:图片、商品说明和店铺信息共用一页,底部关联现有购物车及下单流程。 */
public class ProductDetailActivity extends BaseActivity<ShopProductDetailLayoutBinding, ShopPresenter>
implements ShopContract.DetailView {
private static final String EXTRA_PRODUCT_ID = "shop_product_id";
private static final String STATE_IMAGE_INDEX = "shop_image_index";
private ProductEntity product;
private int restoredImageIndex;
private boolean toolbarCollapsed;
private final ViewPager2.OnPageChangeCallback imageCallback =
new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageSelected(int position) {
renderImageCounter(position);
}
};
public static Bundle createBundle(String productId) {
Bundle bundle = new Bundle();
bundle.putString(EXTRA_PRODUCT_ID, productId);
return bundle;
}
@Override
public ShopPresenter createPresenter() {
return new ShopPresenter(new ShopImpl());
}
@Override
public int getLayoutResId(Bundle savedInstanceState) {
return R.layout.shop_product_detail_layout;
}
@Override
public void initData(Bundle savedInstanceState) {
super.initData(savedInstanceState);
// 状态栏和标题栏覆盖在主图上;滚动离开主图后同步切换为白底深色文字。
ImmersionBar.with(this)
.transparentStatusBar()
.statusBarView(viewBinding.shopDetailStatusBar)
.statusBarDarkFont(false)
.navigationBarColor(R.color.white)
.init();
restoredImageIndex = savedInstanceState == null ? 0
: savedInstanceState.getInt(STATE_IMAGE_INDEX, 0);
viewBinding.vpShopProductImages.registerOnPageChangeCallback(imageCallback);
viewBinding.scrollShopDetail.setOnScrollChangeListener(
(androidx.core.widget.NestedScrollView.OnScrollChangeListener)
(v, scrollX, scrollY, oldScrollX, oldScrollY) -> updateToolbar(scrollY));
setProductActionsEnabled(false);
mPresenter.getProduct(getIntent().getStringExtra(EXTRA_PRODUCT_ID));
}
@Override
public void showProduct(ProductEntity data) {
if (data == null) {
showError(null);
return;
}
product = data;
viewBinding.tvShopDetailName.setText(data.nameRes);
viewBinding.tvShopDetailPrice.setText(ShopPriceFormatter.format(this, data.cashCents));
viewBinding.tvShopDetailSold.setText(getString(R.string.shop_mall_sold, data.sold));
viewBinding.tvShopDetailDescription.setText(data.descriptionRes);
int[] images = data.getImages();
viewBinding.vpShopProductImages.setAdapter(new ProductImageAdapter(Glide.with(this), images));
int page = Math.max(0, Math.min(restoredImageIndex, images.length - 1));
viewBinding.vpShopProductImages.setCurrentItem(page, false);
renderImageCounter(page);
viewBinding.tvShopDetailState.setVisibility(View.GONE);
viewBinding.scrollShopDetail.setVisibility(View.VISIBLE);
setProductActionsEnabled(true);
viewBinding.scrollShopDetail.post(() -> updateToolbar(viewBinding.scrollShopDetail.getScrollY()));
}
private void renderImageCounter(int position) {
if (product == null) return;
viewBinding.tvShopImageCounter.setText(getString(R.string.shop_mall_image_counter,
position + 1, product.getImages().length));
}
private void setProductActionsEnabled(boolean enabled) {
viewBinding.tvShopAddCart.setEnabled(enabled);
viewBinding.tvShopBuyNow.setEnabled(enabled);
viewBinding.tvShopAddCart.setAlpha(enabled ? 1f : 0.5f);
viewBinding.tvShopBuyNow.setAlpha(enabled ? 1f : 0.5f);
}
private void updateToolbar(int scrollY) {
boolean collapsed = viewBinding.shopDetailHero.getHeight() > 0
&& scrollY >= viewBinding.shopDetailHero.getHeight() - viewBinding.shopDetailToolbar.getHeight();
if (toolbarCollapsed == collapsed) return;
toolbarCollapsed = collapsed;
int foreground = collapsed ? ContextCompat.getColor(this, R.color.shop_mall_text) : Color.WHITE;
viewBinding.shopDetailToolbar.setBackgroundColor(collapsed ? Color.WHITE : Color.TRANSPARENT);
viewBinding.tvShopDetailTitle.setTextColor(foreground);
ImageViewCompat.setImageTintList(viewBinding.ivShopDetailBack, ColorStateList.valueOf(foreground));
ImmersionBar.with(this).statusBarDarkFont(collapsed).init();
}
@OnClick({R.id.iv_shop_detail_back, R.id.ll_shop_detail_cart, R.id.tv_shop_add_cart,
R.id.tv_shop_buy_now, R.id.ll_shop_store, R.id.ll_shop_store_phone, R.id.tv_shop_detail_state})
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_shop_detail_back:
finish();
break;
case R.id.ll_shop_detail_cart:
goTo(mContext, CartManageActivity.class, null);
break;
case R.id.tv_shop_add_cart:
addToCart();
break;
case R.id.tv_shop_buy_now:
buyNow();
break;
case R.id.ll_shop_store_phone:
dialStore();
break;
case R.id.ll_shop_store:
showStoreInfo();
break;
case R.id.tv_shop_detail_state:
mPresenter.getProduct(getIntent().getStringExtra(EXTRA_PRODUCT_ID));
break;
default:
break;
}
}
/** 本地演示阶段将所选商品传入购物车,正式加购接口联调时替换此入口。 */
private void addToCart() {
if (product == null) return;
Bundle bundle = new Bundle();
bundle.putSerializable(CartManageActivity.EXTRA_ADD_GOODS, product.toCartGoods());
goTo(mContext, CartManageActivity.class, bundle);
}
private void buyNow() {
if (product == null) return;
ArrayList<CartGoodsEntity> goods = new ArrayList<>();
goods.add(product.toCartGoods());
Bundle bundle = new Bundle();
bundle.putSerializable(CheckoutActivity.EXTRA_GOODS, goods);
goTo(mContext, CheckoutActivity.class, bundle);
}
private void dialStore() {
// 调起系统拨号盘,不直接拨打,因此无需申请电话权限。
try {
startActivity(new Intent(Intent.ACTION_DIAL,
Uri.fromParts("tel", getString(R.string.shop_mall_store_phone), null)));
} catch (ActivityNotFoundException e) {
ToastUtil.showShort(mContext, getString(R.string.shop_mall_no_dialer));
}
}
private void showStoreInfo() {
if (dialog != null && dialog.isShowing()) return;
String content = getString(R.string.shop_mall_store_name) + "\n"
+ getString(R.string.shop_mall_store_phone) + "\n"
+ getString(R.string.shop_mall_store_address);
showDialogtext(null, false, false, false,
getString(R.string.shop_mall_store_title), content,
getString(android.R.string.cancel), getString(R.string.shop_mall_call),
new BaseFragment.OnDialogClick() {
@Override
public void onCancelClick() {
// 关闭后继续浏览商品。
}
@Override
public void onConfirmClick() {
dialStore();
}
});
}
@Override
public void showError(String message) {
setProductActionsEnabled(false);
viewBinding.scrollShopDetail.setVisibility(View.GONE);
viewBinding.tvShopDetailState.setText(TextUtils.isEmpty(message)
? getString(R.string.shop_mall_detail_failed) : message);
viewBinding.tvShopDetailState.setVisibility(View.VISIBLE);
// 异常页面没有主图承托标题,使用同一白色背景保证可读性。
toolbarCollapsed = true;
viewBinding.shopDetailToolbar.setBackgroundColor(Color.WHITE);
viewBinding.tvShopDetailTitle.setTextColor(ContextCompat.getColor(this, R.color.shop_mall_text));
ImageViewCompat.setImageTintList(viewBinding.ivShopDetailBack,
ColorStateList.valueOf(ContextCompat.getColor(this, R.color.shop_mall_text)));
ImmersionBar.with(this).statusBarDarkFont(true).init();
}
@Override
public void logOut(BaseBean bean) {
// 登录失效沿用父类统一处理。
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
outState.putInt(STATE_IMAGE_INDEX, viewBinding.vpShopProductImages.getCurrentItem());
super.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
viewBinding.vpShopProductImages.unregisterOnPageChangeCallback(imageCallback);
viewBinding.vpShopProductImages.setAdapter(null);
viewBinding.scrollShopDetail.setOnScrollChangeListener(
(androidx.core.widget.NestedScrollView.OnScrollChangeListener) null);
super.onDestroy();
}
}

View File

@@ -0,0 +1,140 @@
package com.ckkj.griddle.shop;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.ckkj.griddle.R;
import com.ckkj.griddle.base.BaseFragment;
import com.ckkj.griddle.databinding.ShopMallFragmentBinding;
import com.ckkj.griddle.network.BaseBean;
import com.ckkj.griddle.shop.adapter.ShopProductAdapter;
import com.ckkj.griddle.shop.entity.ProductEntity;
import com.ckkj.griddle.shop.mvp.ShopContract;
import com.ckkj.griddle.shop.mvp.ShopImpl;
import com.ckkj.griddle.shop.mvp.ShopPresenter;
import java.util.ArrayList;
import java.util.List;
import butterknife.OnClick;
/** 主页面商城入口,与美食模块分离;普通手机三列,宽窗口按可用宽度增加列数。 */
public class ShopFragment extends BaseFragment<ShopMallFragmentBinding, ShopPresenter>
implements ShopContract.ListView {
private ShopProductAdapter adapter;
private GridLayoutManager layoutManager;
private boolean viewReady;
private final View.OnLayoutChangeListener widthListener =
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
if (right - left != oldRight - oldLeft) updateColumns(right - left);
};
@Override
public ShopPresenter createPresenter() {
return new ShopPresenter(new ShopImpl());
}
@Override
public void initData(Bundle savedInstanceState) {
viewReady = true;
adapter = new ShopProductAdapter();
layoutManager = new GridLayoutManager(mContext, 3);
viewBinding.rvShopProducts.setLayoutManager(layoutManager);
viewBinding.rvShopProducts.setItemAnimator(null);
viewBinding.rvShopProducts.setAdapter(adapter);
viewBinding.rvShopProducts.addOnLayoutChangeListener(widthListener);
viewBinding.rvShopProducts.addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
@NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
if (position == RecyclerView.NO_POSITION) return;
int count = layoutManager.getSpanCount();
int column = position % count;
int gap = dp(10);
outRect.left = column * gap / count;
outRect.right = gap - (column + 1) * gap / count;
outRect.bottom = gap;
}
});
adapter.setOnItemClickListener((baseAdapter, view, position) -> openProduct(position));
adapter.setOnItemChildClickListener((baseAdapter, view, position) -> openProduct(position));
mPresenter.getProducts();
}
/** 按列表实际宽度计算,折叠屏、分屏和旋转后重新排版,不依赖物理屏幕宽度。 */
private void updateColumns(int width) {
if (!viewReady || width <= 0) return;
int available = width - viewBinding.rvShopProducts.getPaddingLeft()
- viewBinding.rvShopProducts.getPaddingRight();
int columns = Math.max(2, Math.min(6, (available + dp(10)) / dp(118)));
if (layoutManager.getSpanCount() != columns) {
layoutManager.setSpanCount(columns);
viewBinding.rvShopProducts.invalidateItemDecorations();
}
}
private int dp(int value) {
return Math.round(value * getResources().getDisplayMetrics().density);
}
private void openProduct(int position) {
if (position < 0 || position >= adapter.getData().size()) return;
ProductEntity product = adapter.getItem(position);
if (product != null) {
goTo(mContext, ProductDetailActivity.class, ProductDetailActivity.createBundle(product.id));
}
}
@Override
public void showProducts(List<ProductEntity> products) {
if (!viewReady) return;
adapter.setNewData(products == null ? new ArrayList<>() : new ArrayList<>(products));
viewBinding.tvShopMallState.setText(R.string.shop_mall_empty);
viewBinding.tvShopMallState.setVisibility(adapter.getData().isEmpty() ? View.VISIBLE : View.GONE);
}
@OnClick(R.id.tv_shop_mall_state)
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_shop_mall_state:
mPresenter.getProducts();
break;
default:
break;
}
}
@Override
public void showError(String message) {
if (!viewReady) return;
viewBinding.tvShopMallState.setText(TextUtils.isEmpty(message)
? getString(R.string.shop_mall_load_failed) : message);
viewBinding.tvShopMallState.setVisibility(View.VISIBLE);
}
@Override
public void onNetChange(int netModel) {
// 模拟阶段不因网络变化重新加载,避免打断列表浏览。
}
@Override
public void logOut(BaseBean bean) {
// 登录失效沿用父类处理。
}
@Override
public void onDestroyView() {
viewReady = false;
viewBinding.rvShopProducts.removeOnLayoutChangeListener(widthListener);
viewBinding.rvShopProducts.setAdapter(null);
super.onDestroyView();
}
}

View File

@@ -0,0 +1,22 @@
package com.ckkj.griddle.shop;
import android.content.Context;
import com.ckkj.griddle.R;
import java.math.BigDecimal;
import java.text.NumberFormat;
/** 列表和详情统一格式化现金价格,避免使用浮点数。 */
public final class ShopPriceFormatter {
private ShopPriceFormatter() { }
public static String format(Context context, long cashCents) {
NumberFormat format = NumberFormat.getNumberInstance(
context.getResources().getConfiguration().getLocales().get(0));
format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(2);
return context.getString(R.string.shop_mall_price,
format.format(BigDecimal.valueOf(cashCents, 2)));
}
}

View File

@@ -0,0 +1,59 @@
package com.ckkj.griddle.shop.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.RequestManager;
import com.ckkj.griddle.R;
/** 详情图片轮播,页数来自真实图片集合,不固定显示设计稿中的五张。 */
public class ProductImageAdapter extends RecyclerView.Adapter<ProductImageAdapter.ImageHolder> {
private final RequestManager requestManager;
private final int[] images;
public ProductImageAdapter(@NonNull RequestManager requestManager, int[] images) {
// 由页面在生命周期有效时传入,加载和回收始终复用同一个请求管理器。
this.requestManager = requestManager;
this.images = images.clone();
}
@NonNull
@Override
public ImageHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ImageHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_shop_product_image, parent, false));
}
@Override
public void onBindViewHolder(@NonNull ImageHolder holder, int position) {
holder.image.setContentDescription(holder.itemView.getContext()
.getString(R.string.shop_mall_image_description, position + 1, images.length));
requestManager.load(images[position]).centerCrop().into(holder.image);
}
@Override
public int getItemCount() {
return images.length;
}
@Override
public void onViewRecycled(@NonNull ImageHolder holder) {
// Activity 销毁时也会回收图片,不能在此通过 View 重新获取 Glide 管理器。
requestManager.clear(holder.image);
super.onViewRecycled(holder);
}
static class ImageHolder extends RecyclerView.ViewHolder {
final ImageView image;
ImageHolder(View view) {
super(view);
image = view.findViewById(R.id.iv_shop_gallery_image);
}
}
}

View File

@@ -0,0 +1,29 @@
package com.ckkj.griddle.shop.adapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ckkj.griddle.R;
import com.ckkj.griddle.shop.ShopPriceFormatter;
import com.ckkj.griddle.shop.entity.ProductEntity;
/** 三列商品卡片;标题最多四行,长名称省略,按钮交由页面统一路由。 */
public class ShopProductAdapter extends BaseQuickAdapter<ProductEntity, BaseViewHolder> {
public ShopProductAdapter() {
super(R.layout.item_shop_product);
}
@Override
protected void convert(BaseViewHolder helper, ProductEntity item) {
helper.setText(R.id.tv_shop_product_name, mContext.getString(item.nameRes));
helper.setText(R.id.tv_shop_product_sold, mContext.getString(R.string.shop_mall_sold, item.sold));
helper.setText(R.id.tv_shop_product_price, ShopPriceFormatter.format(mContext, item.cashCents));
ImageView cover = helper.getView(R.id.iv_shop_product_cover);
cover.setContentDescription(mContext.getString(item.nameRes));
Glide.with(cover).load(item.coverRes).centerCrop().into(cover);
helper.addOnClickListener(R.id.tv_shop_product_redeem);
}
}

View File

@@ -0,0 +1,38 @@
package com.ckkj.griddle.shop.entity;
import com.ckkj.griddle.cart.entity.CartGoodsEntity;
import java.io.Serializable;
/** 商城商品演示模型;金额以分保存,商品 ID 在列表、详情和下单之间保持一致。 */
public class ProductEntity implements Serializable {
private static final long serialVersionUID = 1L;
public final String id;
public final int nameRes;
public final int coverRes;
public final int descriptionRes;
public final long cashCents;
public final int sold;
private final int[] images;
public ProductEntity(String id, int nameRes, int coverRes, int descriptionRes,
long cashCents, int sold, int[] images) {
this.id = id;
this.nameRes = nameRes;
this.coverRes = coverRes;
this.descriptionRes = descriptionRes;
this.cashCents = cashCents;
this.sold = sold;
this.images = images == null ? new int[0] : images.clone();
}
public int[] getImages() {
return images.length == 0 ? new int[]{coverRes} : images.clone();
}
/** 复用现有购物车与结算模型,不另外维护一套金额、数量计算。 */
public CartGoodsEntity toCartGoods() {
return new CartGoodsEntity(id, nameRes, coverRes, 0, cashCents, 1, true);
}
}

View File

@@ -0,0 +1,33 @@
package com.ckkj.griddle.shop.mvp;
import com.ckkj.griddle.base.IView;
import com.ckkj.griddle.shop.entity.ProductEntity;
import java.util.List;
/** 商城列表与商品详情共用的数据协议。 */
public final class ShopContract {
private ShopContract() { }
public interface CallBack<T> {
void success(T data);
void fail(String message);
}
public interface DataModel {
void getProducts(CallBack<List<ProductEntity>> callback);
void getProduct(String productId, CallBack<ProductEntity> callback);
}
public interface ShopView extends IView { }
public interface ListView extends ShopView {
void showProducts(List<ProductEntity> products);
}
public interface DetailView extends ShopView {
void showProduct(ProductEntity product);
}
}

View File

@@ -0,0 +1,39 @@
package com.ckkj.griddle.shop.mvp;
import com.ckkj.griddle.R;
import com.ckkj.griddle.shop.entity.ProductEntity;
import java.util.ArrayList;
import java.util.List;
/** 商城数据层:暂用本地模拟数据,联调时统一替换此处,不在页面拼装接口数据。 */
public class ShopImpl implements ShopContract.DataModel {
private List<ProductEntity> createProducts() {
List<ProductEntity> products = new ArrayList<>();
for (int i = 0; i < 12; i++) {
// 原稿沿用同款商品演示;每项 ID 独立,照片仅使用实际准备的本地预览图。
products.add(new ProductEntity("shop_demo_" + (i + 1),
R.string.shop_mall_product_name, R.drawable.shop_product_preview,
R.string.shop_mall_product_description, 20800, i == 0 ? 1000 : 0,
new int[]{R.drawable.shop_detail_preview, R.drawable.shop_product_preview}));
}
return products;
}
@Override
public void getProducts(ShopContract.CallBack<List<ProductEntity>> callback) {
callback.success(createProducts());
}
@Override
public void getProduct(String productId, ShopContract.CallBack<ProductEntity> callback) {
for (ProductEntity product : createProducts()) {
if (product.id.equals(productId)) {
callback.success(product);
return;
}
}
callback.fail(null);
}
}

View File

@@ -0,0 +1,47 @@
package com.ckkj.griddle.shop.mvp;
import com.ckkj.griddle.base.BasePresenter;
import com.ckkj.griddle.shop.entity.ProductEntity;
import java.util.List;
/** 商城协调层;分别向列表和详情派发数据,沿用项目 attachView 生命周期。 */
public class ShopPresenter extends BasePresenter<ShopContract.ShopView> {
private final ShopContract.DataModel impl;
public ShopPresenter(ShopContract.DataModel impl) {
this.impl = impl;
}
public void getProducts() {
impl.getProducts(new ShopContract.CallBack<List<ProductEntity>>() {
@Override
public void success(List<ProductEntity> data) {
if (getView() instanceof ShopContract.ListView) {
((ShopContract.ListView) getView()).showProducts(data);
}
}
@Override
public void fail(String message) {
if (getView() != null) getView().showError(message);
}
});
}
public void getProduct(String productId) {
impl.getProduct(productId, new ShopContract.CallBack<ProductEntity>() {
@Override
public void success(ProductEntity data) {
if (getView() instanceof ShopContract.DetailView) {
((ShopContract.DetailView) getView()).showProduct(data);
}
}
@Override
public void fail(String message) {
if (getView() != null) getView().showError(message);
}
});
}
}

View File

@@ -1,171 +0,0 @@
package com.ckkj.griddle.utils;
import android.content.Context;
import android.util.Log;
import com.ckkj.griddle.fate.entity.CityDataEntity;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
* @author fengxiaoyang
* @date 2025/8/11
* @description 城市信息JSON处理工具类
*/
public class YfjJsonHadnlerUtil {
private static final String TAG = "YfjJsonHadnlerUtil";
private static final String CITY_INFO_FILE = "yfj_city_info.json";
private static JSONObject cityInfoJson = null;
/**
* 初始化城市信息数据
* @param context 上下文
*/
public static void initCityInfo(Context context) {
if (cityInfoJson == null) {
cityInfoJson = loadCityInfoFromAssets(context);
}
}
/**
* 从assets文件夹加载城市信息JSON文件
* @param context 上下文
* @return JSONObject 城市信息数据
*/
private static JSONObject loadCityInfoFromAssets(Context context) {
try {
InputStream inputStream = context.getAssets().open(CITY_INFO_FILE);
int size = inputStream.available();
byte[] buffer = new byte[size];
inputStream.read(buffer);
inputStream.close();
String jsonString = new String(buffer, StandardCharsets.UTF_8);
return new JSONObject(jsonString);
} catch (IOException | JSONException e) {
Log.e(TAG, "加载城市信息文件失败: " + e.getMessage());
return null;
}
}
/**
* 根据城市名称查找匹配的城市信息
* @param cityEntity 城市名称,如"济宁市"、"北京市"、"XX地区"
* @return 匹配的城市名称,如果找不到则返回空字符串
*/
public static String findCityByName(CityDataEntity cityEntity) {
String cityResult = "";
if (cityInfoJson == null) {
Log.e(TAG, "城市信息未初始化,请先调用initCityInfo方法");
return "";
}
if (cityEntity == null || cityEntity.getCityName().trim().isEmpty()) {
return "";
}
try {
// 遍历所有省份/直辖市
JSONArray provinceNames = cityInfoJson.names();
if (provinceNames != null) {
for (int i = 0; i < provinceNames.length(); i++) {
String provinceName = provinceNames.getString(i);
// 检查省份名称是否包含城市名称
if (cityEntity.getCityName().contains(provinceName) || provinceName.contains(cityEntity.getCityName())) {
String proName = provinceName.replace("市","");
return proName;
}else if(cityEntity.getCityType().equals("特别行政区")){
}
if(cityEntity.getProvinceName().equals(provinceName)){
// 获取该省份下的城市列表
JSONArray cityList = cityInfoJson.getJSONArray(provinceName);
if (cityList != null) {
for (int j = 0; j < cityList.length(); j++) {
String city = cityList.getString(j);
// 检查城市名称是否包含城市名称参数,或者城市名称参数是否包含城市名称
if ((cityEntity.getCityName().contains(city) || city.contains(cityEntity.getCityName()))
&& cityEntity.getProvinceName().equals(provinceName)) {
cityResult = city;
return cityResult;
}else{
cityResult = cityEntity.getCapitalCity();
}
}
}
}
}
}
} catch (JSONException e) {
Log.e(TAG, "解析城市信息失败: " + e.getMessage());
}
return cityResult;
}
/**
* 获取所有省份名称
* @return 省份名称列表
*/
public static List<String> getAllProvinces() {
List<String> provinces = new ArrayList<>();
if (cityInfoJson == null) {
return provinces;
}
try {
JSONArray provinceNames = cityInfoJson.names();
if (provinceNames != null) {
for (int i = 0; i < provinceNames.length(); i++) {
provinces.add(provinceNames.getString(i));
}
}
} catch (JSONException e) {
Log.e(TAG, "获取省份列表失败: " + e.getMessage());
}
return provinces;
}
/**
* 根据省份名称获取该省份下的城市列表
* @param provinceName 省份名称
* @return 城市列表
*/
public static List<String> getCitiesByProvince(String provinceName) {
List<String> cities = new ArrayList<>();
if (cityInfoJson == null || provinceName == null || provinceName.trim().isEmpty()) {
return cities;
}
try {
if (cityInfoJson.has(provinceName)) {
JSONArray cityList = cityInfoJson.getJSONArray(provinceName);
if (cityList != null) {
for (int i = 0; i < cityList.length(); i++) {
cities.add(cityList.getString(i));
}
}
}
} catch (JSONException e) {
Log.e(TAG, "获取城市列表失败: " + e.getMessage());
}
return cities;
}
}

View File

@@ -1,69 +0,0 @@
package com.ckkj.griddle.wxapi;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import com.ckkj.griddle.AppConfig;
import com.ckkj.griddle.EventMessage;
import com.ckkj.griddle.utils.show.ToastUtil;
//import com.tencent.mm.opensdk.constants.ConstantsAPI;
//import com.tencent.mm.opensdk.modelbase.BaseReq;
//import com.tencent.mm.opensdk.modelbase.BaseResp;
//import com.tencent.mm.opensdk.openapi.IWXAPI;
//import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
//import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import de.greenrobot.event.EventBus;
public class WXPayEntryActivity extends Activity {
// private IWXAPI api;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 微信 SDK 依赖已移除
// api = WXAPIFactory.createWXAPI(this, AppConfig.WX_APPID);
// api.handleIntent(getIntent(), this);
finish();
}
/* 微信 SDK 依赖已移除
@Override
public void onReq(BaseReq baseReq) {
if(baseReq != null){
}
}
@Override
public void onResp(BaseResp baseResp) {
if (baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
int code = baseResp.errCode;
switch (code){
case 0://支付成功
EventBus.getDefault().post(new EventMessage(EventMessage.WX_PAY_SUCCESS));
finish();
break;
case -2:
ToastUtil.showShort(WXPayEntryActivity.this,"取消支付");
finish();
break;
case -1:
ToastUtil.showShort(WXPayEntryActivity.this,"参数错误");
finish();
break;
}
}
}
*/
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
// api.handleIntent(intent, this);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/food_detail_accent" />
</shape>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<corners android:radius="16dp" />
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#24FFFFFF">
<item>
<shape>
<solid android:color="@color/shop_mall_light_orange" />
<corners android:radius="12dp" />
</shape>
</item>
</ripple>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#24FFFFFF">
<item>
<shape>
<solid android:color="@color/shop_mall_orange" />
<corners android:radius="12dp" />
</shape>
</item>
</ripple>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<corners android:radius="10dp" />
</shape>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#CC000000" />
<corners android:radius="36dp" />
</shape>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#24FFFFFF">
<item>
<shape>
<solid android:color="@color/shop_mall_orange" />
<corners android:radius="24dp" />
</shape>
</item>
</ripple>

View File

@@ -68,6 +68,8 @@
android:layout_height="38dp"
android:layout_gravity="center"
android:background="@drawable/home_index_action_background"
android:clickable="true"
android:focusable="true"
android:elevation="5dp"
android:outlineProvider="background"
android:contentDescription="@string/device_home_notifications"

View File

@@ -0,0 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 美食详情:原稿为 393dp 宽,宽窗口居中限宽,正文及食材随内容自然增高。 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/f9f9f9"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".food.FoodDetailActivity">
<!-- 长名称只在标题栏中单行省略,正文名称完整展示。 -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/f9f9f9">
<TextView
android:id="@+id/tv_food_detail_title"
style="@style/FoodDetailSectionTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="87dp"
android:layout_marginEnd="88dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="@string/food_detail_title"
android:textSize="18sp"
tools:text="YeShinbera Asa Wot (Ethiopian Chickpea Fish Stew)" />
<ImageView
android:id="@+id/iv_food_detail_back"
android:layout_width="44dp"
android:layout_height="match_parent"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="14dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/food_detail_back"
android:focusable="true"
android:padding="11dp"
android:scaleType="centerInside"
android:src="@mipmap/img_back_black" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_food_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none"
android:visibility="gone"
tools:visibility="visible">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:orientation="vertical"
android:paddingStart="28dp"
android:paddingTop="10dp"
android:paddingEnd="27dp"
android:paddingBottom="36dp"
app:maxContentWidth="720dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/iv_food_detail_cover"
android:layout_width="0dp"
android:layout_height="0dp"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:src="@drawable/food_cover_placeholder"
app:layout_constraintDimensionRatio="338:220"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:riv_corner_radius="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_food_detail_name"
style="@style/FoodDetailText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif"
android:lineSpacingExtra="4dp"
android:textSize="20sp"
android:textStyle="bold"
tools:text="YeShinbera Asa Wot (Ethiopian Chickpea Fish Stew)" />
<TextView
style="@style/FoodDetailSectionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:minHeight="19dp"
android:text="@string/food_detail_description" />
<TextView
android:id="@+id/tv_food_detail_description"
style="@style/FoodDetailText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="gone" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="12dp"
android:background="@color/food_detail_divider" />
<TextView
style="@style/FoodDetailSectionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:minHeight="19dp"
android:text="@string/food_detail_ingredients" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_ingredients"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never"
tools:itemCount="11"
tools:listitem="@layout/item_food_ingredient" />
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
</FrameLayout>
</androidx.core.widget.NestedScrollView>
<TextView
android:id="@+id/tv_food_detail_state"
style="@style/FoodDetailText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:padding="24dp"
android:visibility="gone" />
</FrameLayout>
</LinearLayout>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 普通行至少 33dp;食材文案过长时增加行高,不裁切内容。 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="33dp"
android:orientation="horizontal"
android:paddingVertical="7dp">
<View
android:layout_width="7dp"
android:layout_height="7dp"
android:layout_marginEnd="11dp"
android:background="@drawable/food_detail_ingredient_dot"
android:importantForAccessibility="no" />
<TextView
android:id="@+id/tv_food_ingredient"
style="@style/FoodDetailText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="19dp"
tools:text="4 cups of Shiro Mitten (spiced chickpeas flour)" />
</LinearLayout>

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/message_center_card_bg"
android:elevation="1dp"
android:foreground="?attr/selectableItemBackground"
android:minHeight="95dp"
android:padding="16dp">
<ImageView
android:layout_width="52dp"
android:layout_height="52dp"
android:contentDescription="@null"
android:src="@mipmap/icon_message_system_notice"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- 52dp 图标加 14dp 间距;文本不使用固定宽度,兼容折叠窗口变化。 -->
<TextView
android:id="@+id/tv_message_item_time"
style="@style/MessageCenterText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:maxLines="1"
android:textColor="@color/message_center_secondary"
android:textSize="11sp"
app:layout_constraintBaseline_toBaselineOf="@id/tv_message_item_title"
app:layout_constraintEnd_toEndOf="parent"
tools:text="@string/message_center_demo_time" />
<TextView
android:id="@+id/tv_message_item_title"
style="@style/MessageCenterText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="66dp"
android:ellipsize="end"
android:maxLines="1"
android:textSize="13.279999732971191sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/tv_message_item_time"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/message_center_system_notice" />
<TextView
android:id="@+id/tv_message_item_content"
style="@style/MessageCenterText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="66dp"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:lineSpacingExtra="5dp"
android:maxLines="2"
android:textColor="@color/message_center_secondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_message_item_title"
app:layout_constraintVertical_bias="0"
tools:text="@string/message_center_demo_content" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shop_mall_card_bg"
android:clipToOutline="true"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_shop_product_cover"
android:layout_width="match_parent"
android:layout_height="75dp"
android:contentDescription="@null"
android:scaleType="centerCrop"
tools:src="@drawable/shop_product_preview" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="@+id/tv_shop_product_name"
style="@style/ShopMallText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="sans-serif-medium"
android:gravity="top"
android:maxLines="4"
android:minLines="4"
tools:text="@string/shop_mall_product_name" />
<TextView
android:id="@+id/tv_shop_product_sold"
style="@style/ShopMallText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/shop_mall_secondary"
android:textSize="12sp"
tools:text="Sold: 0" />
<TextView
android:id="@+id/tv_shop_product_price"
style="@style/ShopMallText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:maxLines="1"
android:textColor="@color/shop_mall_price"
android:textStyle="bold"
tools:text="¥208.00" />
<TextView
android:id="@+id/tv_shop_product_redeem"
style="@style/ShopMallAction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@drawable/shop_mall_redeem_bg"
android:minHeight="33dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="@string/shop_mall_redeem"
android:textSize="14sp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ViewPager2 的页面必须占满父容器,图片只裁剪自身,不裁剪标题栏。 -->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/iv_shop_gallery_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="centerCrop" />

View File

@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 采用常规白色标题栏;系统栏边距由根布局统一处理,不叠加状态栏占位。 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".message.MessageCenterActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@android:color/white">
<ImageView
android:id="@+id/iv_message_center_back"
android:layout_width="44dp"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/message_center_back"
android:focusable="true"
android:padding="13dp"
android:scaleType="centerInside"
android:src="@mipmap/icon_cart_back"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_message_center_read_all"
style="@style/MessageCenterText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:enabled="false"
android:focusable="true"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:maxWidth="120dp"
android:paddingStart="12dp"
android:paddingEnd="16dp"
android:text="@string/message_center_read_all"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- 两侧按右侧操作区最大宽度对称留白,标题始终相对整个标题栏居中。 -->
<TextView
style="@style/MessageCenterText"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="120dp"
android:layout_marginEnd="120dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:text="@string/message_center_title"
android:textSize="18sp"
android:textStyle="bold"
app:autoSizeMaxTextSize="18sp"
app:autoSizeMinTextSize="14sp"
app:autoSizeStepGranularity="1sp"
app:autoSizeTextType="uniform"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/message_center_background">
<!-- 列表独立滚动,展开屏居中限宽,卡片高度随字体及内容自然增高。 -->
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|center_horizontal"
android:orientation="vertical"
app:maxContentWidth="720dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_message_center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingStart="28dp"
android:paddingTop="22dp"
android:paddingEnd="27dp"
android:paddingBottom="24dp"
android:scrollbars="none"
tools:itemCount="1"
tools:listitem="@layout/item_message_center" />
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
<TextView
android:id="@+id/tv_message_center_state"
style="@style/MessageCenterText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:padding="24dp"
android:textColor="@color/message_center_secondary"
android:textSize="14sp"
android:visibility="gone" />
</FrameLayout>
</LinearLayout>

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 状态栏和底部导航由 MainActivity 管理,商城内容不重复处理系统栏高度。 -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/shop_mall_background"
tools:context=".shop.ShopFragment">
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|center_horizontal"
android:orientation="vertical"
app:maxContentWidth="1000dp">
<TextView
style="@style/ShopMallText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="48dp"
android:text="@string/shop_mall_title"
android:textSize="26sp"
android:textStyle="bold" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!-- 手机按设计稿三列,实际列数由 Fragment 按窗口宽度调整。 -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_shop_products"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingBottom="12dp"
android:scrollbars="none"
tools:itemCount="12"
tools:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/item_shop_product"
tools:spanCount="3" />
<TextView
android:id="@+id/tv_shop_mall_state"
style="@style/ShopMallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:padding="24dp"
android:visibility="gone" />
</FrameLayout>
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
</FrameLayout>

View File

@@ -0,0 +1,384 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 详情内容居中限宽;底部操作固定,长说明和大字体均可滚动展示。 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/shop_mall_background"
android:orientation="vertical"
tools:context=".shop.ProductDetailActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll_shop_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:orientation="vertical"
app:maxContentWidth="720dp">
<FrameLayout
android:id="@+id/shop_detail_hero"
android:layout_width="match_parent"
android:layout_height="360dp">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp_shop_product_images"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/tv_shop_image_counter"
style="@style/ShopMallText"
android:layout_width="wrap_content"
android:layout_height="29dp"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/shop_mall_counter_bg"
android:gravity="center"
android:minWidth="50dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:textColor="@android:color/white"
android:textSize="12sp"
tools:text="1/2" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@android:color/white"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/tv_shop_detail_name"
style="@style/ShopMallSectionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
tools:text="@string/shop_mall_product_name" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_shop_detail_price"
style="@style/ShopMallText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/shop_mall_price"
android:textSize="16sp"
android:textStyle="bold"
tools:text="¥208.00" />
<TextView
android:id="@+id/tv_shop_detail_sold"
style="@style/ShopMallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:textColor="@color/shop_mall_secondary"
tools:text="Sold: 1000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@android:color/white"
android:orientation="vertical"
android:padding="16dp">
<TextView
style="@style/ShopMallSectionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/shop_mall_description_title" />
<TextView
android:id="@+id/tv_shop_detail_description"
style="@style/ShopMallText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:lineSpacingExtra="7dp"
tools:text="@string/shop_mall_product_description" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="4dp"
android:background="@android:color/white"
android:orientation="vertical"
android:padding="16dp">
<TextView
style="@style/ShopMallSectionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/shop_mall_store_title" />
<LinearLayout
android:id="@+id/ll_shop_store"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:src="@mipmap/icon_pickup_store_avatar"
app:riv_oval="true" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
style="@style/ShopMallText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/shop_mall_store_name" />
<LinearLayout
android:id="@+id/ll_shop_store_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:minHeight="18dp"
android:orientation="horizontal">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:contentDescription="@null"
android:src="@mipmap/icon_shop_phone" />
<TextView
style="@style/ShopMallText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_weight="1"
android:text="@string/shop_mall_store_phone"
android:textColor="@color/shop_mall_secondary"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:contentDescription="@null"
android:src="@mipmap/icon_shop_location" />
<TextView
style="@style/ShopMallText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_weight="1"
android:text="@string/shop_mall_store_address"
android:textColor="@color/shop_mall_secondary"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="7dp"
android:layout_height="12dp"
android:layout_marginStart="8dp"
android:contentDescription="@null"
android:src="@mipmap/icon_device_preview_arrow" />
</LinearLayout>
</LinearLayout>
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
</FrameLayout>
</androidx.core.widget.NestedScrollView>
<!-- 状态栏占位与标题作为一个整体同步背景,避免出现不同颜色的横条。 -->
<LinearLayout
android:id="@+id/shop_detail_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:id="@+id/shop_detail_status_bar"
android:layout_width="match_parent"
android:layout_height="0dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="48dp">
<TextView
android:id="@+id/tv_shop_detail_title"
style="@style/ShopMallSectionTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="60dp"
android:layout_marginEnd="60dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="@string/shop_mall_detail_title"
android:textColor="@android:color/white"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_shop_detail_back"
android:layout_width="44dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginStart="5dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/shop_mall_back"
android:focusable="true"
android:padding="11dp"
android:scaleType="centerInside"
android:src="@mipmap/img_back_black"
app:tint="@android:color/white" />
</FrameLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_shop_detail_state"
style="@style/ShopMallText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:padding="24dp"
android:visibility="gone" />
</FrameLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/shop_mall_divider" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white">
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingTop="10dp"
android:paddingEnd="16dp"
android:paddingBottom="7dp"
app:maxContentWidth="720dp">
<LinearLayout
android:id="@+id/ll_shop_detail_cart"
android:layout_width="63dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:minHeight="52dp"
android:orientation="vertical">
<ImageView
android:layout_width="22dp"
android:layout_height="22dp"
android:contentDescription="@null"
android:src="@mipmap/icon_shop_cart" />
<TextView
style="@style/ShopMallText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="@string/shop_mall_cart"
android:textColor="@color/shop_mall_secondary"
android:textSize="10sp" />
</LinearLayout>
<TextView
android:id="@+id/tv_shop_add_cart"
style="@style/ShopMallAction"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/shop_mall_add_bg"
android:minHeight="52dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="@string/shop_mall_add_cart" />
<TextView
android:id="@+id/tv_shop_buy_now"
style="@style/ShopMallAction"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:background="@drawable/shop_mall_buy_bg"
android:minHeight="52dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="@string/shop_mall_buy_now" />
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
</FrameLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="food_detail_title">Food Details</string>
<string name="food_detail_back">Back</string>
<string name="food_detail_description">Description</string>
<string name="food_detail_ingredients">Ingredients</string>
<string name="food_detail_unavailable">Food details are unavailable. Tap to retry.</string>
</resources>

View File

@@ -26,4 +26,65 @@
<string name="food_mock_pasta_bowl">Vegetable Pasta Snack</string>
<string name="food_mock_beef_bowl">Spicy Beef Bowl</string>
<string name="food_mock_noodle_bowl">Refreshing Noodle Bowl</string>
<!-- Temporary detail ingredients; remove together with FoodMockData during API integration. -->
<string-array name="food_mock_ingredients_noodles">
<item>200 g of noodles or pasta</item>
<item>2 tomatoes</item>
<item>Half an onion, finely chopped</item>
<item>150 g of beef or vegetables, depending on the selected dish</item>
<item>1 tbsp of vegetable oil</item>
<item>1 tsp of minced garlic</item>
<item>1 tbsp of light soy sauce</item>
<item>500 ml of water</item>
<item>Half a tsp of minced ginger</item>
<item>A quarter tsp of black pepper</item>
<item>Salt to taste</item>
</string-array>
<string-array name="food_mock_ingredients_rice">
<item>2 bowls of cooked rice</item>
<item>100 g of minced meat</item>
<item>4 mushrooms, finely diced</item>
<item>2 eggs</item>
<item>Half a carrot</item>
<item>50 g of green peas</item>
<item>1 tbsp of vegetable oil</item>
<item>1 tbsp of light soy sauce</item>
<item>1 tbsp of chopped spring onion</item>
<item>A quarter tsp of black pepper</item>
<item>Salt to taste</item>
</string-array>
<string-array name="food_mock_ingredients_main">
<item>300 g of meat or mushrooms, depending on the selected dish</item>
<item>1 red onion, finely chopped</item>
<item>150 g of seasonal vegetables</item>
<item>1 tbsp of vegetable oil</item>
<item>1 tsp of minced garlic</item>
<item>Half a tsp of minced ginger</item>
<item>1 tbsp of light soy sauce</item>
<item>200 ml of water</item>
<item>Half a tsp of mixed spices</item>
<item>A quarter tsp of black pepper</item>
<item>Salt to taste</item>
</string-array>
<string-array name="food_mock_ingredients_pastry">
<item>6 egg tart shells</item>
<item>2 eggs</item>
<item>100 ml of milk</item>
<item>80 ml of cream</item>
<item>25 g of caster sugar</item>
<item>5 g of cake flour</item>
<item>A few drops of vanilla extract</item>
</string-array>
<string-array name="food_mock_ingredients_drinks">
<item>200 ml of fresh orange or berry juice</item>
<item>100 ml of drinking water</item>
<item>1 tsp of honey</item>
<item>2 lemon slices</item>
<item>Ice cubes as needed</item>
</string-array>
</resources>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="message_center_title">Message Center</string>
<string name="message_center_back">Back</string>
<string name="message_center_read_all">Mark All as Read</string>
<string name="message_center_system_notice">System Notice</string>
<string name="message_center_demo_time">Yesterday</string>
<string name="message_center_demo_content">Platform will undergo system maintenance. Some features may be temporarily unavailable during maintenance.</string>
<string name="message_center_empty">No messages yet.</string>
<string name="message_center_load_failed">Could not load messages. Tap to retry.</string>
<string name="message_center_close">Close</string>
<string name="message_center_read">Read</string>
<string name="message_center_unread">Unread</string>
<string name="message_center_item_description">%1$s, %2$s, %3$s</string>
</resources>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="shop_mall_title">Points Mall</string>
<string name="shop_mall_detail_title">Product Details</string>
<string name="shop_mall_redeem">Redeem</string>
<string name="shop_mall_sold">Sold: %1$d</string>
<string name="shop_mall_price">¥%1$s</string>
<string name="shop_mall_description_title">Product Description</string>
<string name="shop_mall_store_title">Shop Information</string>
<string name="shop_mall_cart">Shopping Cart</string>
<string name="shop_mall_add_cart">Add to Cart</string>
<string name="shop_mall_buy_now">Buy Now</string>
<string name="shop_mall_back">Back</string>
<string name="shop_mall_empty">No products yet. Tap to refresh.</string>
<string name="shop_mall_load_failed">Could not load products. Tap to retry.</string>
<string name="shop_mall_detail_failed">This product is unavailable. Tap to retry.</string>
<string name="shop_mall_no_dialer">No dialer is available on this device.</string>
<string name="shop_mall_call">Call Shop</string>
<string name="shop_mall_image_counter">%1$d/%2$d</string>
<string name="shop_mall_image_description">Product image %1$d of %2$d</string>
<string name="shop_mall_product_name">Charcoal Grilled Air-dried Beef Gift Box 320g (80g x 4)</string>
<string name="shop_mall_product_description">An authentic Yunnan flavor made with the classic Kunming technique — crafted from premium beef, traditionally marinated, air-dried, and flame-grilled for a rich meaty taste.</string>
<string name="shop_mall_store_name">Huadong Youxuan Electrical</string>
<string name="shop_mall_store_phone">+251123981908</string>
<string name="shop_mall_store_address">Addis Ababa……</string>
</resources>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="food_detail_title">美食详情</string>
<string name="food_detail_back">返回</string>
<string name="food_detail_description">简介</string>
<string name="food_detail_ingredients">食材</string>
<string name="food_detail_unavailable">暂无该美食详情,点击重试</string>
</resources>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="food_detail_body_text">#1F2329</color>
<color name="food_detail_heading_text">#252529</color>
<color name="food_detail_divider">#EDEFF2</color>
<color name="food_detail_accent">#FF6900</color>
<style name="FoodDetailText" parent="LoginDesignText">
<item name="android:textColor">@color/food_detail_body_text</item>
<item name="android:textSize">14sp</item>
<item name="android:gravity">start|center_vertical</item>
<item name="android:breakStrategy">simple</item>
<item name="android:hyphenationFrequency">none</item>
</style>
<style name="FoodDetailSectionTitle" parent="FoodDetailText">
<item name="android:textColor">@color/food_detail_heading_text</item>
<item name="android:textStyle">bold</item>
</style>
</resources>

View File

@@ -26,4 +26,65 @@
<string name="food_mock_pasta_bowl">蔬菜意面小食</string>
<string name="food_mock_beef_bowl">香辣牛肉小碗</string>
<string name="food_mock_noodle_bowl">爽口凉面小碗</string>
<!-- 详情页临时食材数据,与界面正式标签分开维护,便于联调时整体删除。 -->
<string-array name="food_mock_ingredients_noodles">
<item>面条或意面 200 克</item>
<item>番茄 2 个</item>
<item>洋葱半个,切成细丁</item>
<item>牛肉或蔬菜 150 克(按所选菜品准备)</item>
<item>食用油 1 汤匙</item>
<item>蒜末 1 茶匙</item>
<item>生抽 1 汤匙</item>
<item>清水 500 毫升</item>
<item>姜末半茶匙</item>
<item>黑胡椒四分之一茶匙</item>
<item>盐适量</item>
</string-array>
<string-array name="food_mock_ingredients_rice">
<item>熟米饭 2 碗</item>
<item>肉末 100 克</item>
<item>香菇 4 朵,切成小丁</item>
<item>鸡蛋 2 个</item>
<item>胡萝卜半根</item>
<item>青豆 50 克</item>
<item>食用油 1 汤匙</item>
<item>生抽 1 汤匙</item>
<item>葱花 1 汤匙</item>
<item>黑胡椒四分之一茶匙</item>
<item>盐适量</item>
</string-array>
<string-array name="food_mock_ingredients_main">
<item>肉类或菌菇 300 克(按所选菜品准备)</item>
<item>红洋葱 1 个,切成细丁</item>
<item>时令蔬菜 150 克</item>
<item>食用油 1 汤匙</item>
<item>蒜末 1 茶匙</item>
<item>姜末半茶匙</item>
<item>生抽 1 汤匙</item>
<item>清水 200 毫升</item>
<item>香料粉半茶匙</item>
<item>黑胡椒四分之一茶匙</item>
<item>盐适量</item>
</string-array>
<string-array name="food_mock_ingredients_pastry">
<item>蛋挞皮 6 个</item>
<item>鸡蛋 2 个</item>
<item>牛奶 100 毫升</item>
<item>淡奶油 80 毫升</item>
<item>细砂糖 25 克</item>
<item>低筋面粉 5 克</item>
<item>香草精少许</item>
</string-array>
<string-array name="food_mock_ingredients_drinks">
<item>鲜榨橙汁或莓果汁 200 毫升</item>
<item>饮用水 100 毫升</item>
<item>蜂蜜 1 茶匙</item>
<item>柠檬片 2 片</item>
<item>冰块适量</item>
</string-array>
</resources>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="message_center_background">#F8F8F8</color>
<color name="message_center_text">#252529</color>
<color name="message_center_secondary">#9AA0A6</color>
<style name="MessageCenterText">
<item name="android:fontFamily">sans-serif</item>
<item name="android:includeFontPadding">false</item>
<item name="android:textColor">@color/message_center_text</item>
<item name="android:textSize">12sp</item>
</style>
</resources>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="message_center_title">消息中心</string>
<string name="message_center_back">返回</string>
<string name="message_center_read_all">全部已读</string>
<string name="message_center_system_notice">系统通知</string>
<string name="message_center_demo_time">昨天</string>
<string name="message_center_demo_content">平台将进行系统维护,维护期间部分功能可能暂时无法使用,请提前做好安排。</string>
<string name="message_center_empty">暂无消息</string>
<string name="message_center_load_failed">消息加载失败,点击重试</string>
<string name="message_center_close">关闭</string>
<string name="message_center_read">已读</string>
<string name="message_center_unread">未读</string>
<string name="message_center_item_description">%1$s,%2$s,%3$s</string>
</resources>

Some files were not shown because too many files have changed in this diff Show More