更新
@@ -149,7 +149,7 @@
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".shop.AllGoodsActivity"
|
||||
android:name=".food.AllGoodsActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
@@ -264,6 +264,36 @@
|
||||
android:name=".mine.order.MyOrderActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".mine.order.MyOrderDetailActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".mine.order.AfterSalesApplyActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".review.ProductReviewActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".review.MyReviewsActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".refund.MyRefundActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".refund.RefundDetailActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".coupon.CouponManageActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
<activity
|
||||
android:name=".cart.CheckoutActivity"
|
||||
android:exported="false"
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.ckkj.griddle.coupon;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
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.coupon.adapter.CouponAdapter;
|
||||
import com.ckkj.griddle.coupon.entity.CouponEntity;
|
||||
import com.ckkj.griddle.coupon.mvp.CouponContract;
|
||||
import com.ckkj.griddle.coupon.mvp.CouponContract.Tab;
|
||||
import com.ckkj.griddle.coupon.mvp.CouponImpl;
|
||||
import com.ckkj.griddle.coupon.mvp.CouponPresenter;
|
||||
import com.ckkj.griddle.databinding.CouponManageLayoutBinding;
|
||||
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;
|
||||
|
||||
/** 我的优惠券和领取优惠券共用页面,通过 Tab 切换列表及领取入口。 */
|
||||
public class CouponManageActivity extends BaseActivity<CouponManageLayoutBinding, CouponPresenter>
|
||||
implements CouponContract.CouponView {
|
||||
private static final String STATE_TAB = "coupon_tab";
|
||||
private static final String STATE_CLAIMED_IDS = "coupon_claimed_ids";
|
||||
private final ArrayList<String> claimedIds = new ArrayList<>();
|
||||
private Tab tab = Tab.MY_COUPONS;
|
||||
private CouponAdapter adapter;
|
||||
|
||||
@Override
|
||||
public CouponPresenter createPresenter() {
|
||||
return new CouponPresenter(new CouponImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutResId(Bundle savedInstanceState) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData(Bundle savedInstanceState) {
|
||||
super.initData(savedInstanceState);
|
||||
ImmersionBar.with(this).transparentStatusBar()
|
||||
.statusBarView(viewBinding.statusBarView).statusBarDarkFont(false)
|
||||
.navigationBarColor(R.color.coupon_page_background).navigationBarDarkIcon(true).init();
|
||||
// 设计稿的系统状态栏不直接照搬,礼盒背景高度随真实状态栏同步适配。
|
||||
ViewGroup.LayoutParams headerParams = viewBinding.ivCouponHeader.getLayoutParams();
|
||||
headerParams.height = dp(168) + ImmersionBar.getStatusBarHeight(this);
|
||||
viewBinding.ivCouponHeader.setLayoutParams(headerParams);
|
||||
if (savedInstanceState != null) {
|
||||
int index = savedInstanceState.getInt(STATE_TAB, 0);
|
||||
if (index >= 0 && index < Tab.values().length) tab = Tab.values()[index];
|
||||
ArrayList<String> savedIds = savedInstanceState.getStringArrayList(STATE_CLAIMED_IDS);
|
||||
if (savedIds != null) claimedIds.addAll(savedIds);
|
||||
}
|
||||
mPresenter.restoreClaimedIds(claimedIds);
|
||||
adapter = new CouponAdapter();
|
||||
viewBinding.rvCoupons.setLayoutManager(new LinearLayoutManager(this));
|
||||
viewBinding.rvCoupons.setItemAnimator(null);
|
||||
viewBinding.rvCoupons.setAdapter(adapter);
|
||||
final int spacing = dp(16);
|
||||
viewBinding.rvCoupons.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 ? spacing : 0, 0, 0);
|
||||
}
|
||||
});
|
||||
adapter.setOnItemChildClickListener((baseAdapter, view, position) -> {
|
||||
if (view.getId() != R.id.tv_coupon_manage_claim || tab != Tab.GET_COUPONS
|
||||
|| position < 0 || position >= adapter.getData().size()) return;
|
||||
CouponEntity coupon = adapter.getItem(position);
|
||||
if (coupon != null && !coupon.owned) mPresenter.claimCoupon(coupon.id);
|
||||
});
|
||||
renderTabs();
|
||||
loadCoupons();
|
||||
}
|
||||
|
||||
@OnClick({R.id.iv_coupon_back, R.id.tv_coupon_my_tab, R.id.tv_coupon_get_tab,
|
||||
R.id.tv_coupon_retry})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_coupon_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.tv_coupon_my_tab:
|
||||
selectTab(Tab.MY_COUPONS);
|
||||
break;
|
||||
case R.id.tv_coupon_get_tab:
|
||||
selectTab(Tab.GET_COUPONS);
|
||||
break;
|
||||
case R.id.tv_coupon_retry:
|
||||
loadCoupons();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void selectTab(Tab selected) {
|
||||
if (tab == selected) return;
|
||||
tab = selected;
|
||||
renderTabs();
|
||||
adapter.setNewData(new ArrayList<>());
|
||||
viewBinding.rvCoupons.scrollToPosition(0);
|
||||
loadCoupons();
|
||||
}
|
||||
|
||||
private void renderTabs() {
|
||||
boolean mine = tab == Tab.MY_COUPONS;
|
||||
viewBinding.tvCouponMyTab.setSelected(mine);
|
||||
viewBinding.tvCouponGetTab.setSelected(!mine);
|
||||
viewBinding.tvCouponMyTab.setTypeface(null, mine ? Typeface.BOLD : Typeface.NORMAL);
|
||||
viewBinding.tvCouponGetTab.setTypeface(null, mine ? Typeface.NORMAL : Typeface.BOLD);
|
||||
viewBinding.indicatorCouponMy.setVisibility(mine ? View.VISIBLE : View.INVISIBLE);
|
||||
viewBinding.indicatorCouponGet.setVisibility(mine ? View.INVISIBLE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private void loadCoupons() {
|
||||
viewBinding.llCouponState.setVisibility(View.GONE);
|
||||
adapter.setClaimMode(tab == Tab.GET_COUPONS);
|
||||
mPresenter.getCoupons(tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCoupons(List<CouponEntity> coupons) {
|
||||
List<CouponEntity> data = coupons == null ? new ArrayList<>() : new ArrayList<>(coupons);
|
||||
adapter.setNewData(data);
|
||||
viewBinding.tvCouponState.setText(tab == Tab.MY_COUPONS
|
||||
? R.string.coupon_my_empty : R.string.coupon_get_empty);
|
||||
viewBinding.tvCouponRetry.setVisibility(View.GONE);
|
||||
viewBinding.llCouponState.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCouponClaimed(CouponEntity coupon) {
|
||||
if (coupon == null) return;
|
||||
if (!claimedIds.contains(coupon.id)) claimedIds.add(coupon.id);
|
||||
// 领取后保留当前 Tab,按钮变为已领取;切回我的优惠券即可看到新增券。
|
||||
loadCoupons();
|
||||
ToastUtil.showShort(mContext, getString(R.string.coupon_claim_preview));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String message) {
|
||||
String error = TextUtils.isEmpty(message) ? getString(R.string.coupon_load_failed) : message;
|
||||
if (adapter != null && adapter.getData().isEmpty()) {
|
||||
viewBinding.tvCouponState.setText(error);
|
||||
viewBinding.tvCouponRetry.setVisibility(View.VISIBLE);
|
||||
viewBinding.llCouponState.setVisibility(View.VISIBLE);
|
||||
}
|
||||
ToastUtil.showShort(mContext, error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut(BaseBean bean) {
|
||||
// 登录失效沿用父类统一处理。
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putInt(STATE_TAB, tab.ordinal());
|
||||
outState.putStringArrayList(STATE_CLAIMED_IDS, new ArrayList<>(claimedIds));
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
viewBinding.rvCoupons.setAdapter(null);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private int dp(int value) {
|
||||
return Math.round(value * getResources().getDisplayMetrics().density);
|
||||
}
|
||||
}
|
||||
@@ -108,9 +108,9 @@ public class DeviceFragment extends BaseFragment<DeviceIndexFragmentBinding, Dev
|
||||
goTo(mContext, DevicePreviewActivity.class, null));
|
||||
String name = getString(R.string.device_home_sample_name);
|
||||
List<HomeDeviceEntity> devices = new ArrayList<>();
|
||||
devices.add(new HomeDeviceEntity("demo-device-1", name, true, 1200, 180));
|
||||
devices.add(new HomeDeviceEntity("demo-device-2", name, true, 1000, 160));
|
||||
devices.add(new HomeDeviceEntity("demo-device-3", name, true, 800, 140));
|
||||
devices.add(new HomeDeviceEntity("demo-device-1", name, true, 1200, 180, "128.6"));
|
||||
devices.add(new HomeDeviceEntity("demo-device-2", name, true, 1000, 160, "96.4"));
|
||||
devices.add(new HomeDeviceEntity("demo-device-3", name, true, 800, 140, "64.2"));
|
||||
devices.add(new HomeDeviceEntity("demo-device-4", name, false, 0, 0));
|
||||
adapter.setNewData(devices);
|
||||
// 复用现有观察器;列表有数据时显示宫格,清空后仍可恢复原来的空状态。
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ckkj.griddle.device.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
@@ -19,16 +21,29 @@ public class HomeDeviceAdapter extends BaseQuickAdapter<HomeDeviceEntity, BaseVi
|
||||
boolean online = item.isOnline();
|
||||
helper.setText(R.id.tv_device_name, item.getName());
|
||||
helper.setText(R.id.tv_device_power, mContext.getString(
|
||||
R.string.device_home_power_value, item.getPower()));
|
||||
R.string.home_index_power, item.getPower()));
|
||||
helper.setText(R.id.tv_device_temperature, mContext.getString(
|
||||
R.string.device_home_temperature_value, item.getTemperature()));
|
||||
R.string.home_index_temperature, item.getTemperature()));
|
||||
helper.setText(R.id.tv_device_carbon, mContext.getString(
|
||||
R.string.home_index_carbon, item.getCarbonReduction()));
|
||||
// 每次绑定都重置可见性,避免离线卡片复用时残留在线功率和温度。
|
||||
helper.setGone(R.id.ll_device_online, online);
|
||||
helper.setGone(R.id.tv_device_offline, !online);
|
||||
ImageView icon = helper.getView(R.id.iv_device);
|
||||
View status = helper.getView(R.id.view_device_status);
|
||||
// 现有 selector 使用 activated=true 表示离线,图标、底色和状态点保持一致。
|
||||
icon.setActivated(!online);
|
||||
// 原切图自带绿色底色;按原图绿色通道将底色和图形映射为稿中的离线灰色。
|
||||
icon.clearColorFilter();
|
||||
if (!online) {
|
||||
float scale = (245f - 153f) / (245f - 164f);
|
||||
float offset = 245f - 245f * scale;
|
||||
ColorMatrix offline = new ColorMatrix(new float[]{
|
||||
0, scale, 0, 0, offset,
|
||||
0, scale, 0, 0, offset,
|
||||
0, scale, 0, 0, offset,
|
||||
0, 0, 0, 1, 0
|
||||
});
|
||||
icon.setColorFilter(new ColorMatrixColorFilter(offline));
|
||||
}
|
||||
status.setActivated(!online);
|
||||
status.setContentDescription(mContext.getString(online
|
||||
? R.string.device_home_online : R.string.device_home_offline));
|
||||
|
||||
@@ -35,13 +35,16 @@ public class DevicePreviewActivity extends BaseActivity<DevicePreviewBinding, De
|
||||
public void initData(Bundle savedInstanceState) {
|
||||
super.initData(savedInstanceState);
|
||||
ImmersionBar.with(this)
|
||||
.statusBarColor(R.color.device_home_background)
|
||||
.statusBarColor(R.color.white)
|
||||
.statusBarDarkFont(true)
|
||||
.init();
|
||||
// 当前沿用静态示例数据;积分环按设计稿显示 72%,不代表设备实时数据。
|
||||
findViewById(R.id.preview_points_progress).getBackground().setLevel(7200);
|
||||
}
|
||||
|
||||
@OnClick({R.id.img_back, R.id.cv_preview_device, R.id.cv_preview_carbon, R.id.ll_preview_stats,
|
||||
R.id.tv_carbon_status, R.id.ll_preview_carbon_points, R.id.tv_carbon_points})
|
||||
R.id.tv_carbon_status, R.id.ll_preview_control,
|
||||
R.id.ll_preview_carbon_points, R.id.tv_carbon_points})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.img_back:
|
||||
@@ -50,12 +53,13 @@ public class DevicePreviewActivity extends BaseActivity<DevicePreviewBinding, De
|
||||
|
||||
case R.id.cv_preview_device:
|
||||
case R.id.ll_preview_stats:
|
||||
// 设备卡片和统计入口均进入设备数据页。
|
||||
case R.id.tv_carbon_status:
|
||||
case R.id.ll_preview_control:
|
||||
// 设备卡片、统计和控制入口复用现有设备数据页。
|
||||
goTo(mContext, DeviceDataViewActivity.class, null);
|
||||
break;
|
||||
|
||||
case R.id.cv_preview_carbon:
|
||||
case R.id.tv_carbon_status:
|
||||
// 今日碳减排整张卡片进入碳排放统计页。
|
||||
goTo(mContext, CarbonActivity.class, null);
|
||||
break;
|
||||
|
||||
@@ -10,13 +10,21 @@ public class HomeDeviceEntity {
|
||||
private final int power;
|
||||
/** 当前温度,单位摄氏度。 */
|
||||
private final int temperature;
|
||||
/** 累计碳减排,单位为 kg CO₂e;使用十进制文本保留接口精度。 */
|
||||
private final String carbonReduction;
|
||||
|
||||
public HomeDeviceEntity(String id, String name, boolean online, int power, int temperature) {
|
||||
this(id, name, online, power, temperature, "0");
|
||||
}
|
||||
|
||||
public HomeDeviceEntity(String id, String name, boolean online, int power, int temperature,
|
||||
String carbonReduction) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.online = online;
|
||||
this.power = power;
|
||||
this.temperature = temperature;
|
||||
this.carbonReduction = carbonReduction;
|
||||
}
|
||||
|
||||
public String getId() { return id; }
|
||||
@@ -28,4 +36,6 @@ public class HomeDeviceEntity {
|
||||
public int getPower() { return power; }
|
||||
|
||||
public int getTemperature() { return temperature; }
|
||||
|
||||
public String getCarbonReduction() { return carbonReduction; }
|
||||
}
|
||||
|
||||
@@ -35,6 +35,12 @@ public class FaultReportImageSourceDialog implements View.OnClickListener {
|
||||
@SuppressLint("InflateParams")
|
||||
public FaultReportImageSourceDialog(Activity context,
|
||||
OnImageSourceSelectedListener listener) {
|
||||
this(context, listener, true);
|
||||
}
|
||||
|
||||
/** 仅需上传照片的业务隐藏录像入口,原有报修和售后默认行为保持一致。 */
|
||||
public FaultReportImageSourceDialog(Activity context,
|
||||
OnImageSourceSelectedListener listener, boolean allowVideo) {
|
||||
this.context = context;
|
||||
this.listener = listener;
|
||||
dialog = new Dialog(context, R.style.FaultReportImageSourceDialogStyle);
|
||||
@@ -55,6 +61,8 @@ public class FaultReportImageSourceDialog implements View.OnClickListener {
|
||||
}
|
||||
|
||||
panelView = contentView.findViewById(R.id.acl_fault_report_image_source);
|
||||
contentView.findViewById(R.id.ll_fault_report_source_video)
|
||||
.setVisibility(allowVideo ? View.VISIBLE : View.GONE);
|
||||
contentView.findViewById(R.id.fl_fault_report_image_source_root)
|
||||
.setOnClickListener(this);
|
||||
contentView.findViewById(R.id.ll_fault_report_source_camera)
|
||||
|
||||
224
app/src/main/java/com/ckkj/griddle/food/AllGoodsActivity.java
Normal file
@@ -0,0 +1,224 @@
|
||||
package com.ckkj.griddle.food;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.base.BaseActivity;
|
||||
import com.ckkj.griddle.custom.view.CustomRefreshHeader;
|
||||
import com.ckkj.griddle.databinding.AllGoodsLayoutBinding;
|
||||
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.ShopGoodsPageEntity;
|
||||
import com.ckkj.griddle.food.mock.FoodMockData;
|
||||
import com.ckkj.griddle.food.mvp.ShopContract;
|
||||
import com.ckkj.griddle.food.mvp.ShopImpl;
|
||||
import com.ckkj.griddle.food.mvp.ShopPresenter;
|
||||
import com.ckkj.griddle.utils.show.ToastUtil;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* 全部美食:复用现有商城 MVP 和分页接口,瀑布流卡片最多展示两行名称。
|
||||
*/
|
||||
public class AllGoodsActivity extends BaseActivity<AllGoodsLayoutBinding, ShopPresenter>
|
||||
implements ShopContract.ShopView {
|
||||
|
||||
private static final int PAGE_SIZE = 20;
|
||||
|
||||
private ShopFoodAdapter goodsAdapter;
|
||||
/** 只有成功后才推进页码,失败时仍可重试同一页。 */
|
||||
private int loadedPage;
|
||||
private int requestingPage;
|
||||
private boolean loading;
|
||||
private boolean requestSucceeded;
|
||||
private boolean noMoreData;
|
||||
|
||||
@Override
|
||||
public ShopPresenter createPresenter() {
|
||||
return new ShopPresenter(new ShopImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutResId(Bundle savedInstanceState) {
|
||||
return R.layout.all_goods_layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData(Bundle savedInstanceState) {
|
||||
super.initData(savedInstanceState);
|
||||
ImmersionBar.with(this)
|
||||
.statusBarColor(R.color.white)
|
||||
.statusBarDarkFont(true)
|
||||
.init();
|
||||
viewBinding.includeTitle.tvTitle.setTypeface(
|
||||
viewBinding.includeTitle.tvTitle.getTypeface(), Typeface.BOLD);
|
||||
viewBinding.includeTitle.tvTitle.setTextSize(16);
|
||||
initGoodsList();
|
||||
initRefresh();
|
||||
requestGoods(1);
|
||||
}
|
||||
|
||||
/** 美食页使用独立卡片样式,保留商城 Tab 原有的商品卡片。 */
|
||||
private void initGoodsList() {
|
||||
goodsAdapter = new ShopFoodAdapter(R.layout.food_recommend_item);
|
||||
viewBinding.rvAllGoods.setLayoutManager(new StaggeredGridLayoutManager(
|
||||
2, StaggeredGridLayoutManager.VERTICAL));
|
||||
viewBinding.rvAllGoods.setItemAnimator(null);
|
||||
viewBinding.rvAllGoods.setAdapter(goodsAdapter);
|
||||
// 间距来自卡片外边距,不再叠加普通网格的 ItemDecoration。
|
||||
viewBinding.rvAllGoods.addOnLayoutChangeListener((v, left, top, right, bottom,
|
||||
oldLeft, oldTop, oldRight, oldBottom) -> updateRecipeColumns(right - left));
|
||||
}
|
||||
|
||||
/** 根据列表实际可用宽度更新列数,适配折叠展开、横屏及分屏。 */
|
||||
private void updateRecipeColumns(int widthPx) {
|
||||
if (widthPx <= 0 || viewBinding == null) {
|
||||
return;
|
||||
}
|
||||
int availableWidth = widthPx - viewBinding.rvAllGoods.getPaddingLeft()
|
||||
- viewBinding.rvAllGoods.getPaddingRight();
|
||||
if (availableWidth <= 0) {
|
||||
return;
|
||||
}
|
||||
int widthDp = Math.round(availableWidth / getResources().getDisplayMetrics().density);
|
||||
int columns = Math.max(2, Math.min(4, widthDp / 178));
|
||||
StaggeredGridLayoutManager manager = (StaggeredGridLayoutManager)
|
||||
viewBinding.rvAllGoods.getLayoutManager();
|
||||
if (manager != null && manager.getSpanCount() != columns) {
|
||||
manager.setSpanCount(columns);
|
||||
}
|
||||
}
|
||||
|
||||
private void initRefresh() {
|
||||
viewBinding.refreshAllGoods.setRefreshHeader(new CustomRefreshHeader(mContext));
|
||||
viewBinding.refreshAllGoods.setRefreshFooter(new ClassicsFooter(mContext));
|
||||
viewBinding.refreshAllGoods.setEnableLoadMore(false);
|
||||
viewBinding.refreshAllGoods.setOnRefreshListener(refreshLayout -> requestGoods(1));
|
||||
viewBinding.refreshAllGoods.setOnLoadMoreListener(refreshLayout -> {
|
||||
if (!loading && !noMoreData) {
|
||||
requestGoods(loadedPage + 1);
|
||||
} else {
|
||||
refreshLayout.finishLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 刷新可替换正在执行的分页请求,Presenter 会丢弃旧请求的响应。 */
|
||||
private void requestGoods(int page) {
|
||||
requestingPage = page;
|
||||
loading = true;
|
||||
requestSucceeded = false;
|
||||
viewBinding.tvAllGoodsState.setVisibility(View.GONE);
|
||||
if (page == 1) {
|
||||
viewBinding.refreshAllGoods.setEnableLoadMore(false);
|
||||
viewBinding.refreshAllGoods.setNoMoreData(false);
|
||||
}
|
||||
viewBinding.progressAllGoods.setVisibility(
|
||||
goodsAdapter.getData().isEmpty() ? View.VISIBLE : View.GONE);
|
||||
// TODO 美食接口联调时恢复此请求,并删除下面的模拟数据回调。
|
||||
// mPresenter.getAllShopGoods(page, PAGE_SIZE);
|
||||
getShopGoodsSuccess(FoodMockData.getAllGoods(mContext, page, PAGE_SIZE));
|
||||
onShopRequestFinished(ShopContract.RequestType.GOODS);
|
||||
}
|
||||
|
||||
@OnClick({R.id.img_back, R.id.tv_all_goods_state})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.img_back:
|
||||
finish();
|
||||
break;
|
||||
|
||||
case R.id.tv_all_goods_state:
|
||||
if (!loading) {
|
||||
requestGoods(1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getShopGoodsSuccess(ShopGoodsPageEntity data) {
|
||||
ShopGoodsPageEntity result = data == null ? new ShopGoodsPageEntity() : data;
|
||||
if (requestingPage == 1) {
|
||||
goodsAdapter.setNewData(new ArrayList<>(result.getRows()));
|
||||
viewBinding.rvAllGoods.scrollToPosition(0);
|
||||
} else {
|
||||
goodsAdapter.addData(result.getRows());
|
||||
}
|
||||
loadedPage = requestingPage;
|
||||
requestSucceeded = true;
|
||||
// 优先依据服务端总数;空页也结束加载,避免异常总数造成反复请求。
|
||||
noMoreData = result.getRows().isEmpty()
|
||||
|| goodsAdapter.getData().size() >= result.getTotal();
|
||||
if (goodsAdapter.getData().isEmpty()) {
|
||||
showState(R.string.food_all_recipes_empty);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShopRequestFinished(ShopContract.RequestType type) {
|
||||
if (type != ShopContract.RequestType.GOODS) {
|
||||
return;
|
||||
}
|
||||
loading = false;
|
||||
viewBinding.progressAllGoods.setVisibility(View.GONE);
|
||||
if (requestingPage == 1) {
|
||||
viewBinding.refreshAllGoods.finishRefresh(requestSucceeded);
|
||||
} else {
|
||||
viewBinding.refreshAllGoods.finishLoadMore(requestSucceeded);
|
||||
}
|
||||
viewBinding.refreshAllGoods.setEnableLoadMore(!goodsAdapter.getData().isEmpty());
|
||||
viewBinding.refreshAllGoods.setNoMoreData(noMoreData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String message) {
|
||||
// 加载失败保留已有商品;首屏失败提供点击重试入口。
|
||||
if (goodsAdapter.getData().isEmpty()) {
|
||||
showState(R.string.food_all_recipes_retry);
|
||||
}
|
||||
ToastUtil.showShort(this, TextUtils.isEmpty(message)
|
||||
? getString(R.string.food_all_recipes_load_failed) : message);
|
||||
}
|
||||
|
||||
private void showState(int messageRes) {
|
||||
viewBinding.tvAllGoodsState.setText(messageRes);
|
||||
viewBinding.tvAllGoodsState.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getShopBannersSuccess(List<ShopBannerEntity> banners) {
|
||||
// 当前页面不请求轮播图,复用商城协议时无需处理此回调。
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getShopCategoriesSuccess(List<ShopCategoryEntity> categories) {
|
||||
// 当前页面展示全部商品,不请求分类。
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut(BaseBean bean) {
|
||||
// 登录失效沿用父类的统一处理。
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
viewBinding.rvAllGoods.setAdapter(null);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop;
|
||||
package com.ckkj.griddle.food;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -7,25 +7,26 @@ import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.base.BaseFragment;
|
||||
import com.ckkj.griddle.custom.view.CustomRefreshHeader;
|
||||
import com.ckkj.griddle.databinding.ShopFragmentBinding;
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.shop.adapter.ShopBannerAdapter;
|
||||
import com.ckkj.griddle.shop.adapter.ShopCategoryAdapter;
|
||||
import com.ckkj.griddle.shop.adapter.ShopFoodAdapter;
|
||||
import com.ckkj.griddle.shop.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopGoodsEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopGoodsPageEntity;
|
||||
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.food.adapter.ShopBannerAdapter;
|
||||
import com.ckkj.griddle.food.adapter.ShopCategoryAdapter;
|
||||
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;
|
||||
import com.ckkj.griddle.food.mvp.ShopImpl;
|
||||
import com.ckkj.griddle.food.mvp.ShopPresenter;
|
||||
import com.ckkj.griddle.utils.show.ToastUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -136,7 +137,9 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
|
||||
mContext, RecyclerView.HORIZONTAL, false));
|
||||
}
|
||||
if (viewBinding.rvFoodRecommend.getLayoutManager() == null) {
|
||||
viewBinding.rvFoodRecommend.setLayoutManager(new GridLayoutManager(mContext, 2));
|
||||
// 卡片根据一行或两行文案自然增高,两列分别排列,避免普通网格留下空隙。
|
||||
viewBinding.rvFoodRecommend.setLayoutManager(new StaggeredGridLayoutManager(
|
||||
2, StaggeredGridLayoutManager.VERTICAL));
|
||||
}
|
||||
|
||||
categoryAdapter = new ShopCategoryAdapter();
|
||||
@@ -163,8 +166,8 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
|
||||
return;
|
||||
}
|
||||
int widthDp = Math.round(widthPx / getResources().getDisplayMetrics().density);
|
||||
int columns = Math.max(2, Math.min(4, widthDp / 180));
|
||||
GridLayoutManager manager = (GridLayoutManager)
|
||||
int columns = Math.max(2, Math.min(4, widthDp / 178));
|
||||
StaggeredGridLayoutManager manager = (StaggeredGridLayoutManager)
|
||||
viewBinding.rvFoodRecommend.getLayoutManager();
|
||||
if (manager != null && manager.getSpanCount() != columns) {
|
||||
manager.setSpanCount(columns);
|
||||
@@ -172,7 +175,7 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
|
||||
}
|
||||
|
||||
private void initBanner() {
|
||||
// 先绑定适配器,接口返回后再提交真实的轮播商品数据。
|
||||
// 先绑定适配器,加载完成后再提交轮播数据。
|
||||
bannerAdapter = new ShopBannerAdapter();
|
||||
viewBinding.vpFoodBanner.setAdapter(bannerAdapter);
|
||||
}
|
||||
@@ -187,15 +190,20 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载 Banner 和真实分类,再由分类结果触发商品列表请求。
|
||||
* 加载轮播和分类,再由分类结果触发美食列表加载。
|
||||
*/
|
||||
private void loadShopData() {
|
||||
mPresenter.cancelGoodsRequest();
|
||||
bannersLoading = true;
|
||||
categoriesLoading = true;
|
||||
goodsLoading = false;
|
||||
mPresenter.getShopBanners();
|
||||
mPresenter.getShopCategories();
|
||||
// TODO 美食接口联调时恢复以下请求,并删除下面的模拟数据回调。
|
||||
// mPresenter.getShopBanners();
|
||||
// mPresenter.getShopCategories();
|
||||
getShopBannersSuccess(FoodMockData.getBanners(mContext));
|
||||
onShopRequestFinished(ShopContract.RequestType.BANNERS);
|
||||
getShopCategoriesSuccess(FoodMockData.getCategories(mContext));
|
||||
onShopRequestFinished(ShopContract.RequestType.CATEGORIES);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,7 +295,13 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
|
||||
viewBinding.rvFoodBreakfast.scrollToPosition(0);
|
||||
viewBinding.rvFoodRecommend.scrollToPosition(0);
|
||||
goodsLoading = true;
|
||||
mPresenter.getShopGoods(category.getId(), 1, SHOP_GOODS_PAGE_SIZE);
|
||||
// TODO 美食接口联调时恢复此请求,并删除下面的模拟数据回调。
|
||||
// mPresenter.getShopGoods(category.getId(), 1, SHOP_GOODS_PAGE_SIZE);
|
||||
getShopGoodsSuccess(FoodMockData.getCategoryGoods(
|
||||
mContext, category.getId(), 1, SHOP_GOODS_PAGE_SIZE));
|
||||
// 按设计稿分别展示当前分类和推荐区,推荐内容不随分类切换。
|
||||
recommendationAdapter.setNewData(FoodMockData.getRecommendedGoods(mContext));
|
||||
onShopRequestFinished(ShopContract.RequestType.GOODS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -315,7 +329,7 @@ public class ShopFragment extends BaseFragment<ShopFragmentBinding, ShopPresente
|
||||
}
|
||||
}
|
||||
|
||||
/** 两个展示区使用当前选中分类的同一份接口商品,不再填充模拟数据。 */
|
||||
/** 复用列表绑定逻辑;临时模拟模式下,推荐区由独立的推荐数据覆盖。 */
|
||||
private void showGoods(List<ShopGoodsEntity> goods) {
|
||||
breakfastAdapter.setNewData(goods);
|
||||
recommendationAdapter.setNewData(goods);
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop.adapter;
|
||||
package com.ckkj.griddle.food.adapter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
@@ -9,9 +9,7 @@ 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.entity.ShopBannerEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.ckkj.griddle.food.entity.ShopBannerEntity;
|
||||
|
||||
/**
|
||||
* 商城顶部轮播适配器。
|
||||
@@ -24,17 +22,11 @@ public class ShopBannerAdapter extends BaseQuickAdapter<ShopBannerEntity, BaseVi
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, ShopBannerEntity item) {
|
||||
// 接口只返回商品图、名称和价格,标题直接使用商品名称。
|
||||
// 新稿只显示轮播图片,名称继续用于无障碍描述,不再覆盖到图片上。
|
||||
String goodsName = item.getGoodsName();
|
||||
helper.setText(R.id.tv_food_banner_title, goodsName);
|
||||
ImageView cover = helper.getView(R.id.iv_food_banner);
|
||||
cover.setContentDescription(goodsName);
|
||||
|
||||
String priceText = getPriceText(helper.itemView, item);
|
||||
helper.setText(R.id.tv_food_banner_subtitle, priceText);
|
||||
helper.getView(R.id.tv_food_banner_subtitle).setVisibility(
|
||||
TextUtils.isEmpty(priceText) ? View.GONE : View.VISIBLE);
|
||||
|
||||
// 空地址也通过 Glide 替换旧请求,避免复用时显示上一件商品图。
|
||||
String goodsImg = item.getGoodsImg();
|
||||
Glide.with(cover)
|
||||
@@ -48,38 +40,6 @@ public class ShopBannerAdapter extends BaseQuickAdapter<ShopBannerEntity, BaseVi
|
||||
helper.getLayoutPosition() - getHeaderLayoutCount());
|
||||
}
|
||||
|
||||
/** 根据积分价和现金价生成展示文案。 */
|
||||
private String getPriceText(View view, ShopBannerEntity item) {
|
||||
String pointPrice = formatPrice(item.getPointPrice());
|
||||
String cashPrice = formatPrice(item.getCashPrice());
|
||||
boolean hasPointPrice = !TextUtils.isEmpty(pointPrice);
|
||||
boolean hasCashPrice = !TextUtils.isEmpty(cashPrice);
|
||||
if (hasPointPrice && hasCashPrice) {
|
||||
return view.getContext().getString(R.string.food_banner_price_both,
|
||||
pointPrice, cashPrice);
|
||||
}
|
||||
if (hasPointPrice) {
|
||||
return view.getContext().getString(R.string.food_banner_point_price, pointPrice);
|
||||
}
|
||||
if (hasCashPrice) {
|
||||
return view.getContext().getString(R.string.food_banner_cash_price, cashPrice);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/** 直接解析价格字符串,去掉多余的 0;空值或异常价格不展示。 */
|
||||
private String formatPrice(String price) {
|
||||
if (TextUtils.isEmpty(price)) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
BigDecimal value = new BigDecimal(price.trim());
|
||||
return value.signum() > 0 ? value.stripTrailingZeros().toPlainString() : "";
|
||||
} catch (NumberFormatException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** 根据 Banner 数据数量生成指示器,并高亮当前页。 */
|
||||
private void bindIndicators(LinearLayout indicators, int selectedPosition) {
|
||||
indicators.removeAllViews();
|
||||
@@ -91,8 +51,8 @@ public class ShopBannerAdapter extends BaseQuickAdapter<ShopBannerEntity, BaseVi
|
||||
indicators.setVisibility(View.VISIBLE);
|
||||
for (int index = 0; index < count; index++) {
|
||||
View indicator = new View(indicators.getContext());
|
||||
int width = dp(indicators, index == selectedPosition ? 16 : 6);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, dp(indicators, 6));
|
||||
int width = dp(indicators, index == selectedPosition ? 14 : 4);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, dp(indicators, 4));
|
||||
if (index > 0) {
|
||||
params.setMarginStart(dp(indicators, 6));
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package com.ckkj.griddle.shop.adapter;
|
||||
package com.ckkj.griddle.food.adapter;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -6,7 +9,7 @@ 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.shop.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -48,7 +51,10 @@ public class ShopCategoryAdapter extends BaseQuickAdapter<ShopCategoryEntity, Ba
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, ShopCategoryEntity item) {
|
||||
helper.setText(R.id.tv_food_category, item.getCategoryName());
|
||||
helper.itemView.setSelected(
|
||||
helper.getLayoutPosition() - getHeaderLayoutCount() == selectedPosition);
|
||||
boolean selected = helper.getLayoutPosition() - getHeaderLayoutCount() == selectedPosition;
|
||||
helper.itemView.setSelected(selected);
|
||||
// 选中分类使用中等字重,复用时同步恢复未选中的普通字重。
|
||||
TextView label = helper.getView(R.id.tv_food_category);
|
||||
label.setTypeface(Typeface.create(selected ? "sans-serif-medium" : "sans-serif", Typeface.NORMAL));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop.adapter;
|
||||
package com.ckkj.griddle.food.adapter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.widget.ImageView;
|
||||
@@ -9,7 +9,7 @@ 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.entity.ShopGoodsEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopGoodsEntity;
|
||||
|
||||
/**
|
||||
* 商城横向列表、推荐宫格和全部商品页共用的商品适配器。
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop.entity;
|
||||
package com.ckkj.griddle.food.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop.entity;
|
||||
package com.ckkj.griddle.food.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop.entity;
|
||||
package com.ckkj.griddle.food.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop.entity;
|
||||
package com.ckkj.griddle.food.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.ckkj.griddle.shop.mvp;
|
||||
package com.ckkj.griddle.food.mvp;
|
||||
|
||||
import com.ckkj.griddle.base.IView;
|
||||
import com.ckkj.griddle.shop.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopGoodsPageEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.ckkj.griddle.shop.mvp;
|
||||
package com.ckkj.griddle.food.mvp;
|
||||
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.network.NetWorkManager;
|
||||
import com.ckkj.griddle.shop.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopGoodsPageEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.ckkj.griddle.shop.mvp;
|
||||
package com.ckkj.griddle.food.mvp;
|
||||
|
||||
import com.ckkj.griddle.base.BasePresenter;
|
||||
import com.ckkj.griddle.shop.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopGoodsPageEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -3,6 +3,9 @@ package com.ckkj.griddle.main.activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.graphics.Typeface;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -11,7 +14,6 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.ckkj.griddle.AppConfig;
|
||||
import com.ckkj.griddle.BuildConfig;
|
||||
import com.ckkj.griddle.ConstantUtil;
|
||||
import com.ckkj.griddle.EventMessage;
|
||||
import com.ckkj.griddle.R;
|
||||
@@ -20,7 +22,7 @@ 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.fate.view.FateFragment;
|
||||
import com.ckkj.griddle.food.AllGoodsFragment;
|
||||
import com.ckkj.griddle.main.MainContract;
|
||||
import com.ckkj.griddle.main.MainImpl;
|
||||
import com.ckkj.griddle.main.MainPresenter;
|
||||
@@ -28,7 +30,7 @@ import com.ckkj.griddle.main.entity.CheckVersionEntity;
|
||||
import com.ckkj.griddle.mine.MineFragment;
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.device.DeviceFragment;
|
||||
import com.ckkj.griddle.shop.ShopFragment;
|
||||
import com.ckkj.griddle.food.ShopFragment;
|
||||
import com.ckkj.griddle.utils.AppInfoUtil;
|
||||
import com.ckkj.griddle.utils.dataUtil.SharePreUtil;
|
||||
import com.ckkj.griddle.utils.manager.ActivityManager;
|
||||
@@ -40,12 +42,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.OnClick;
|
||||
import de.greenrobot.event.Subscribe;
|
||||
import de.greenrobot.event.ThreadMode;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
/**
|
||||
* 主页面,BottomNavigationView + Viewpage2展示内容
|
||||
* 主页面:四个底部入口与 ViewPager2 同步,切换不播放横向滑动动画。
|
||||
*/
|
||||
public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPresenter> implements
|
||||
MainContract.MainView,EasyPermissions.PermissionCallbacks{
|
||||
@@ -54,9 +57,20 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
||||
//是否是强制更新
|
||||
private boolean isForceUpdate;
|
||||
|
||||
// 添加标记,用于区分是否是首次创建
|
||||
private boolean isFirstCreate = true;
|
||||
private static final String STATE_SELECTED_TAB = "main_selected_tab";
|
||||
// 使用新版键保存四个入口的索引,避免旧五 Tab 索引被错误恢复。
|
||||
private static final String STATE_SELECTED_TAB = "main_selected_tab_v2";
|
||||
private static final int TAB_HOME = 0;
|
||||
private static final int TAB_FOOD = 1;
|
||||
private static final int TAB_SHOP = 2;
|
||||
private static final int TAB_MINE = 3;
|
||||
|
||||
private final ViewPager2.OnPageChangeCallback pageChangeCallback =
|
||||
new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
renderTabs(position);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public MainPresenter createPresenter() {
|
||||
@@ -73,8 +87,9 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
||||
super.onCreate(savedInstanceState);
|
||||
ImmersionBar.with(this)
|
||||
.statusBarView(viewBinding.statusBarView)
|
||||
.statusBarColor(R.color.f9f9f9) // 设置状态栏颜色
|
||||
.statusBarColor(getTabStatusBarColor(viewBinding.navViewpage2.getCurrentItem()))
|
||||
.statusBarDarkFont(true) // 设置状态栏字体为黑色
|
||||
.navigationBarColor(R.color.white)
|
||||
.keyboardEnable(true)
|
||||
.init();
|
||||
}
|
||||
@@ -108,8 +123,7 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
||||
mFragmentList.clear();
|
||||
mFragmentList.add(new DeviceFragment());
|
||||
mFragmentList.add(new ShopFragment());
|
||||
mFragmentList.add(new FateFragment());
|
||||
mFragmentList.add(new Fragment(R.layout.fragment_placeholder)); // 文化页占位
|
||||
mFragmentList.add(new AllGoodsFragment());
|
||||
mFragmentList.add(new MineFragment());
|
||||
|
||||
// 重新设置适配器
|
||||
@@ -124,103 +138,82 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
||||
viewBinding.navViewpage2.setSaveEnabled(true);
|
||||
viewBinding.navViewpage2.setUserInputEnabled(false);
|
||||
|
||||
// 检查是否需要跳转到商城页(仅在首次创建时)
|
||||
if (savedInstanceState == null && isFirstCreate) {
|
||||
checkAndNavigateToShopFragment();
|
||||
isFirstCreate = false;
|
||||
viewBinding.navViewpage2.registerOnPageChangeCallback(pageChangeCallback);
|
||||
int selectedTab = savedInstanceState == null ? TAB_HOME
|
||||
: savedInstanceState.getInt(STATE_SELECTED_TAB, TAB_HOME);
|
||||
if (savedInstanceState == null && getIntent().getBooleanExtra("goto_index_fragment", false)) {
|
||||
// 兼容已有跳转参数;商城现对应新的第三个入口。
|
||||
selectedTab = TAB_SHOP;
|
||||
}
|
||||
selectTab(selectedTab);
|
||||
}
|
||||
|
||||
// ViewPager 滑动监听,切换 BottomNavigationView 选中项
|
||||
viewBinding.navViewpage2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
switch (position) {
|
||||
case 0:
|
||||
viewBinding.navView.getMenu().getItem(position).setChecked(true);
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_device);
|
||||
break;
|
||||
case 1:
|
||||
viewBinding.navView.getMenu().getItem(position).setChecked(true);
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_shop);
|
||||
break;
|
||||
case 2:
|
||||
viewBinding.navView.getMenu().getItem(position).setChecked(true);
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_fate);
|
||||
break;
|
||||
case 3:
|
||||
viewBinding.navView.getMenu().getItem(position).setChecked(true);
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_culture);
|
||||
break;
|
||||
case 4:
|
||||
viewBinding.navView.getMenu().getItem(position).setChecked(true);
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_mine);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// BottomNavigationView 点击监听,切换 ViewPager2 页面
|
||||
viewBinding.navView.setOnNavigationItemSelectedListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.navigation_device:
|
||||
viewBinding.navViewpage2.setCurrentItem(0);
|
||||
return true;
|
||||
case R.id.navigation_shop:
|
||||
viewBinding.navViewpage2.setCurrentItem(1);
|
||||
return true;
|
||||
case R.id.navigation_fate:
|
||||
viewBinding.navViewpage2.setCurrentItem(2);
|
||||
return true;
|
||||
case R.id.navigation_culture:
|
||||
viewBinding.navViewpage2.setCurrentItem(3);
|
||||
return true;
|
||||
case R.id.navigation_mine:
|
||||
viewBinding.navViewpage2.setCurrentItem(4);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
viewBinding.navView.setItemIconTintList(null);
|
||||
// 折叠展开和旋转重建后,仍停留在用户当前查看的 Tab。
|
||||
if (savedInstanceState != null) {
|
||||
int selectedTab = savedInstanceState.getInt(STATE_SELECTED_TAB, 0);
|
||||
viewBinding.navViewpage2.setCurrentItem(
|
||||
Math.max(0, Math.min(selectedTab, mFragmentList.size() - 1)), false);
|
||||
@OnClick({R.id.ll_main_tab_home, R.id.ll_main_tab_food,
|
||||
R.id.ll_main_tab_shop, R.id.ll_main_tab_mine})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.ll_main_tab_home:
|
||||
selectTab(TAB_HOME);
|
||||
break;
|
||||
case R.id.ll_main_tab_food:
|
||||
selectTab(TAB_FOOD);
|
||||
break;
|
||||
case R.id.ll_main_tab_shop:
|
||||
selectTab(TAB_SHOP);
|
||||
break;
|
||||
case R.id.ll_main_tab_mine:
|
||||
selectTab(TAB_MINE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void selectTab(int position) {
|
||||
int selected = Math.max(TAB_HOME, Math.min(position, TAB_MINE));
|
||||
if (viewBinding.navViewpage2.getCurrentItem() != selected) {
|
||||
viewBinding.navViewpage2.setCurrentItem(selected, false);
|
||||
}
|
||||
renderTabs(selected);
|
||||
}
|
||||
|
||||
/** 图标和文字独立同步 selected,文字加粗但不缩放,避免切换时跳动。 */
|
||||
private void renderTabs(int selected) {
|
||||
// 首页和美食页按各自新版底色同步状态栏。
|
||||
ImmersionBar.with(this).statusBarView(viewBinding.statusBarView)
|
||||
.statusBarColor(getTabStatusBarColor(selected))
|
||||
.statusBarDarkFont(true).init();
|
||||
renderTab(R.id.ll_main_tab_home, R.id.iv_main_tab_home, R.id.tv_main_tab_home, selected == TAB_HOME);
|
||||
renderTab(R.id.ll_main_tab_food, R.id.iv_main_tab_food, R.id.tv_main_tab_food, selected == TAB_FOOD);
|
||||
renderTab(R.id.ll_main_tab_shop, R.id.iv_main_tab_shop, R.id.tv_main_tab_shop, selected == TAB_SHOP);
|
||||
renderTab(R.id.ll_main_tab_mine, R.id.iv_main_tab_mine, R.id.tv_main_tab_mine, selected == TAB_MINE);
|
||||
}
|
||||
|
||||
private int getTabStatusBarColor(int selected) {
|
||||
if (selected == TAB_HOME) {
|
||||
return R.color.home_index_background;
|
||||
}
|
||||
if (selected == TAB_FOOD) {
|
||||
return R.color.food_page_background;
|
||||
}
|
||||
return R.color.f9f9f9;
|
||||
}
|
||||
|
||||
private void renderTab(int containerId, int iconId, int labelId, boolean selected) {
|
||||
View container = findViewById(containerId);
|
||||
container.setSelected(selected);
|
||||
findViewById(iconId).setSelected(selected);
|
||||
TextView label = findViewById(labelId);
|
||||
label.setSelected(selected);
|
||||
label.setTypeface(Typeface.DEFAULT, selected ? Typeface.BOLD : Typeface.NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理新的Intent
|
||||
*/
|
||||
private void handleNewIntent(Intent intent) {
|
||||
if (intent != null) {
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null && extras.getBoolean("goto_index_fragment", false)) {
|
||||
// 延迟执行,确保Fragment已经初始化完成
|
||||
viewBinding.navViewpage2.post(() -> {
|
||||
// 跳转到商城页(位置为1)
|
||||
viewBinding.navViewpage2.setCurrentItem(1);
|
||||
// 设置底部导航栏选中状态
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_shop);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查并跳转到商城页(仅在首次创建时)
|
||||
*/
|
||||
private void checkAndNavigateToShopFragment() {
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null && extras.getBoolean("goto_index_fragment", false)) {
|
||||
// 延迟执行,确保Fragment已经初始化完成
|
||||
viewBinding.navViewpage2.post(() -> {
|
||||
// 跳转到商城页(位置为1)
|
||||
viewBinding.navViewpage2.setCurrentItem(1);
|
||||
// 设置底部导航栏选中状态
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_shop);
|
||||
});
|
||||
if (intent != null && intent.getBooleanExtra("goto_index_fragment", false)) {
|
||||
selectTab(TAB_SHOP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,11 +239,8 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
||||
|
||||
break;
|
||||
|
||||
case EventMessage.SWITCH_TO_FATE_FRAGMENT://切换到 fateFragment
|
||||
// 切换到FateFragment(位置为2)
|
||||
viewBinding.navViewpage2.setCurrentItem(2);
|
||||
// 设置底部导航栏选中状态
|
||||
viewBinding.navView.setSelectedItemId(R.id.navigation_fate);
|
||||
case EventMessage.SWITCH_TO_FATE_FRAGMENT:
|
||||
// 旧生活指导入口已移除,历史消息不再触发错误的商城跳转。
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -281,6 +271,8 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
viewBinding.navViewpage2.unregisterOnPageChangeCallback(pageChangeCallback);
|
||||
viewBinding.navViewpage2.setAdapter(null);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.annotation.Nullable;
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.base.BaseFragment;
|
||||
import com.ckkj.griddle.cart.CartManageActivity;
|
||||
import com.ckkj.griddle.coupon.CouponManageActivity;
|
||||
import com.ckkj.griddle.base.entity.UserInfoEntity;
|
||||
import com.ckkj.griddle.databinding.MineFragmentLayoutBinding;
|
||||
import com.ckkj.griddle.fault.DeviceFaultLHistoryActivity;
|
||||
@@ -20,6 +21,8 @@ import com.ckkj.griddle.mine.order.MyOrderActivity;
|
||||
import com.ckkj.griddle.mine.share.ShareEarningsActivity;
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.point.PointsOrderActivity;
|
||||
import com.ckkj.griddle.review.MyReviewsActivity;
|
||||
import com.ckkj.griddle.refund.MyRefundActivity;
|
||||
import com.ckkj.griddle.utils.show.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -37,9 +40,19 @@ public class MineFragment extends BaseFragment<MineFragmentLayoutBinding, MinePr
|
||||
|
||||
@OnClick({R.id.cv_mine_profile, R.id.ll_mine_devices, R.id.ll_credit_history,
|
||||
R.id.ll_registration_order, R.id.ll_mine_addresses, R.id.ll_mine_shares,
|
||||
R.id.ll_mine_repairs, R.id.ll_mine_cart, R.id.ll_mine_orders})
|
||||
R.id.ll_mine_repairs, R.id.ll_mine_cart, R.id.ll_mine_orders, R.id.ll_mine_reviews,
|
||||
R.id.ll_mine_refunds, R.id.ll_mine_coupons})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.ll_mine_coupons:
|
||||
goTo(mContext, CouponManageActivity.class, null);
|
||||
break;
|
||||
case R.id.ll_mine_refunds:
|
||||
goTo(mContext, MyRefundActivity.class, null);
|
||||
break;
|
||||
case R.id.ll_mine_reviews:
|
||||
goTo(mContext, MyReviewsActivity.class, null);
|
||||
break;
|
||||
case R.id.ll_mine_orders:
|
||||
goTo(mContext, MyOrderActivity.class, null);
|
||||
break;
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.ckkj.griddle.mine.order.mvp.MyOrderContract;
|
||||
import com.ckkj.griddle.mine.order.mvp.MyOrderImpl;
|
||||
import com.ckkj.griddle.mine.order.mvp.MyOrderPresenter;
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.review.ProductReviewActivity;
|
||||
import com.ckkj.griddle.utils.show.ToastUtil;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
@@ -50,6 +51,11 @@ public class MyOrderActivity extends BaseActivity<MyOrderLayoutBinding, MyOrderP
|
||||
if (index >= 0 && index < Status.values().length) filter = Status.values()[index];
|
||||
}
|
||||
adapter = new MyOrderAdapter();
|
||||
adapter.setOnOrderClickListener(this::openOrderDetail);
|
||||
adapter.setOnItemClickListener((baseAdapter, view, position) -> {
|
||||
MyOrderEntity order = adapter.getItem(position);
|
||||
if (order != null) openOrderDetail(order);
|
||||
});
|
||||
viewBinding.rvMyOrders.setLayoutManager(new LinearLayoutManager(this));
|
||||
viewBinding.rvMyOrders.setItemAnimator(null);
|
||||
viewBinding.rvMyOrders.setAdapter(adapter);
|
||||
@@ -120,13 +126,21 @@ public class MyOrderActivity extends BaseActivity<MyOrderLayoutBinding, MyOrderP
|
||||
}
|
||||
|
||||
private void openAfterSales(MyOrderEntity order) {
|
||||
// 后续售后页面通过当前订单编号路由,不传固定示例订单。
|
||||
showError(getString(R.string.my_order_action_unavailable, order.id));
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(AfterSalesApplyActivity.EXTRA_ORDER_ID, order.id);
|
||||
goTo(mContext, AfterSalesApplyActivity.class, bundle);
|
||||
}
|
||||
|
||||
private void openOrderDetail(MyOrderEntity order) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MyOrderDetailActivity.EXTRA_ORDER_ID, order.id);
|
||||
goTo(mContext, MyOrderDetailActivity.class, bundle);
|
||||
}
|
||||
|
||||
private void openReview(MyOrderEntity order) {
|
||||
// 后续评价页面通过当前订单编号路由。
|
||||
showError(getString(R.string.my_order_action_unavailable, order.id));
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(ProductReviewActivity.EXTRA_ORDER_ID, order.id);
|
||||
goTo(mContext, ProductReviewActivity.class, bundle);
|
||||
}
|
||||
|
||||
private void confirmReceipt(MyOrderEntity order) {
|
||||
|
||||
@@ -18,6 +18,16 @@ import java.util.ArrayList;
|
||||
|
||||
/** 订单条目复用时完整刷新按钮、提货码和商品,避免不同状态串显。 */
|
||||
public class MyOrderAdapter extends BaseQuickAdapter<MyOrderEntity, BaseViewHolder> {
|
||||
private OnOrderClickListener orderClickListener;
|
||||
|
||||
public interface OnOrderClickListener {
|
||||
void onOrderClick(MyOrderEntity order);
|
||||
}
|
||||
|
||||
public void setOnOrderClickListener(OnOrderClickListener listener) {
|
||||
orderClickListener = listener;
|
||||
}
|
||||
|
||||
public MyOrderAdapter() {
|
||||
super(R.layout.item_my_order);
|
||||
}
|
||||
@@ -86,5 +96,9 @@ public class MyOrderAdapter extends BaseQuickAdapter<MyOrderEntity, BaseViewHold
|
||||
}
|
||||
// 外层条目绑定到其他订单时完整替换数据,空商品列表也会清掉旧内容。
|
||||
goodsAdapter.setNewData(new ArrayList<>(order.goods));
|
||||
// 内层商品列表独立消费点击,转交外层当前订单,避免点商品无法进入详情。
|
||||
goodsAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
if (orderClickListener != null) orderClickListener.onOrderClick(order);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ckkj.griddle.mine.order.mvp;
|
||||
|
||||
import com.ckkj.griddle.base.IView;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderDetailEntity;
|
||||
import com.ckkj.griddle.mine.order.entity.AfterSalesRequest;
|
||||
import java.util.List;
|
||||
|
||||
/** 我的订单列表 MVP 协议。 */
|
||||
@@ -13,9 +15,13 @@ public class MyOrderContract {
|
||||
|
||||
public interface DataModel {
|
||||
void getOrders(MyOrderEntity.Status filter, CallBack<List<MyOrderEntity>> callback);
|
||||
void getOrderDetail(String orderId, CallBack<MyOrderDetailEntity> callback);
|
||||
void validateAfterSales(AfterSalesRequest request, CallBack<Integer> callback);
|
||||
}
|
||||
|
||||
public interface MyOrderView extends IView {
|
||||
void showOrders(List<MyOrderEntity> orders);
|
||||
default void showOrders(List<MyOrderEntity> orders) { }
|
||||
default void showOrderDetail(MyOrderDetailEntity detail) { }
|
||||
default void onAfterSalesValidated(int errorResId) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ckkj.griddle.mine.order.mvp;
|
||||
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderDetailEntity;
|
||||
import com.ckkj.griddle.mine.order.entity.AfterSalesRequest;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity.Goods;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity.OrderType;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity.Status;
|
||||
@@ -13,9 +15,32 @@ import java.util.List;
|
||||
public class MyOrderImpl implements MyOrderContract.DataModel {
|
||||
@Override
|
||||
public void getOrders(Status filter, MyOrderContract.CallBack<List<MyOrderEntity>> callback) {
|
||||
List<MyOrderEntity> result = new ArrayList<>();
|
||||
for (MyOrderEntity order : createPreviewOrders()) {
|
||||
if (filter == Status.ALL || order.status == filter) result.add(order);
|
||||
}
|
||||
callback.success(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOrderDetail(String orderId, MyOrderContract.CallBack<MyOrderDetailEntity> callback) {
|
||||
// 以列表传入的订单号查找,避免详情页始终展示同一个示例订单。
|
||||
for (MyOrderEntity order : createPreviewOrders()) {
|
||||
if (order.id.equals(orderId)) {
|
||||
callback.success(new MyOrderDetailEntity(order,
|
||||
"Addis Ababa, Bole Road, Building 12", "Abebe", "0912345678",
|
||||
"Bole Pickup Store", "2026-11-10 14:30:00", "TB202611100001",
|
||||
"ET87654324321010", 1000, 1000));
|
||||
return;
|
||||
}
|
||||
}
|
||||
callback.fail(null);
|
||||
}
|
||||
|
||||
private List<MyOrderEntity> createPreviewOrders() {
|
||||
Goods goods = new Goods(R.string.my_order_goods_preview, R.mipmap.icon_cart_goods_preview,
|
||||
"0.5kg", 1, 20800);
|
||||
List<MyOrderEntity> preview = Arrays.asList(
|
||||
return Arrays.asList(
|
||||
// 预览数据仅第一条为线下提货,其余订单均为线上支付。
|
||||
new MyOrderEntity("ORD20261110001", Status.RECEIPT, OrderType.OFFLINE_PICKUP,
|
||||
"485920", Arrays.asList(goods, goods)),
|
||||
@@ -25,10 +50,30 @@ public class MyOrderImpl implements MyOrderContract.DataModel {
|
||||
null, Arrays.asList(goods)),
|
||||
new MyOrderEntity("ORD20261110004", Status.COMPLETED, OrderType.ONLINE_PAYMENT,
|
||||
null, Arrays.asList(goods)));
|
||||
List<MyOrderEntity> result = new ArrayList<>();
|
||||
for (MyOrderEntity order : preview) {
|
||||
if (filter == Status.ALL || order.status == filter) result.add(order);
|
||||
}
|
||||
callback.success(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateAfterSales(AfterSalesRequest request, MyOrderContract.CallBack<Integer> callback) {
|
||||
getOrderDetail(request.orderId, new MyOrderContract.CallBack<MyOrderDetailEntity>() {
|
||||
@Override
|
||||
public void success(MyOrderDetailEntity detail) {
|
||||
int error = 0;
|
||||
if (request.type == null || request.reason == null) {
|
||||
error = R.string.after_sales_select_required;
|
||||
} else if (request.refundCents <= 0 || request.refundCents > detail.subtotalCents) {
|
||||
error = R.string.after_sales_amount_invalid;
|
||||
} else if (request.description.isEmpty()) {
|
||||
error = R.string.after_sales_description_required;
|
||||
} else if (request.evidence.size() > 5) {
|
||||
error = R.string.fault_report_image_limit;
|
||||
}
|
||||
callback.success(error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String message) {
|
||||
callback.fail(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ckkj.griddle.mine.order.mvp;
|
||||
|
||||
import com.ckkj.griddle.base.BasePresenter;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderDetailEntity;
|
||||
import com.ckkj.griddle.mine.order.entity.AfterSalesRequest;
|
||||
import java.util.List;
|
||||
|
||||
/** 订单筛选交由数据层处理,页面只负责状态及列表展示。 */
|
||||
@@ -12,6 +14,34 @@ public class MyOrderPresenter extends BasePresenter<MyOrderContract.MyOrderView>
|
||||
this.impl = impl;
|
||||
}
|
||||
|
||||
public void getOrderDetail(String orderId) {
|
||||
impl.getOrderDetail(orderId, new MyOrderContract.CallBack<MyOrderDetailEntity>() {
|
||||
@Override
|
||||
public void success(MyOrderDetailEntity detail) {
|
||||
if (getView() != null) getView().showOrderDetail(detail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String message) {
|
||||
if (getView() != null) getView().showError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void validateAfterSales(AfterSalesRequest request) {
|
||||
impl.validateAfterSales(request, new MyOrderContract.CallBack<Integer>() {
|
||||
@Override
|
||||
public void success(Integer errorResId) {
|
||||
if (getView() != null) getView().onAfterSalesValidated(errorResId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String message) {
|
||||
if (getView() != null) getView().showError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getOrders(MyOrderEntity.Status filter) {
|
||||
impl.getOrders(filter, new MyOrderContract.CallBack<List<MyOrderEntity>>() {
|
||||
@Override
|
||||
|
||||
@@ -11,9 +11,9 @@ 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.shop.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopGoodsPageEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
201
app/src/main/java/com/ckkj/griddle/refund/MyRefundActivity.java
Normal file
@@ -0,0 +1,201 @@
|
||||
package com.ckkj.griddle.refund;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
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.databinding.MyRefundLayoutBinding;
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.refund.adapter.RefundAdapter;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity;
|
||||
import com.ckkj.griddle.refund.entity.RefundEntity.Status;
|
||||
import com.ckkj.griddle.refund.mvp.RefundContract;
|
||||
import com.ckkj.griddle.refund.mvp.RefundImpl;
|
||||
import com.ckkj.griddle.refund.mvp.RefundPresenter;
|
||||
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 MyRefundActivity extends BaseActivity<MyRefundLayoutBinding, RefundPresenter>
|
||||
implements RefundContract.RefundView {
|
||||
private static final String STATE_FILTER = "refund_filter";
|
||||
private static final String STATE_CANCELLED_IDS = "refund_cancelled_ids";
|
||||
private Status filter = Status.ALL;
|
||||
private final ArrayList<String> cancelledIds = new ArrayList<>();
|
||||
private RefundAdapter adapter;
|
||||
private RefundCancelDialog cancelDialog;
|
||||
private final ActivityResultLauncher<Intent> detailLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if (result.getResultCode() != RESULT_OK || result.getData() == null) return;
|
||||
String id = result.getData().getStringExtra(RefundDetailActivity.RESULT_CANCELLED_ID);
|
||||
if (TextUtils.isEmpty(id)) return;
|
||||
if (!cancelledIds.contains(id)) cancelledIds.add(id);
|
||||
// 详情与列表的本地预览模型各自独立,返回时同步已取消编号再刷新当前筛选。
|
||||
mPresenter.restoreCancelledIds(cancelledIds);
|
||||
mPresenter.getRefunds(filter);
|
||||
});
|
||||
|
||||
@Override
|
||||
public RefundPresenter createPresenter() {
|
||||
return new RefundPresenter(new RefundImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutResId(Bundle savedInstanceState) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData(Bundle savedInstanceState) {
|
||||
super.initData(savedInstanceState);
|
||||
ImmersionBar.with(this).statusBarColor(R.color.white).statusBarDarkFont(true).init();
|
||||
if (savedInstanceState != null) {
|
||||
int index = savedInstanceState.getInt(STATE_FILTER, 0);
|
||||
if (index >= 0 && index < Status.CANCELLED.ordinal()) filter = Status.values()[index];
|
||||
ArrayList<String> saved = savedInstanceState.getStringArrayList(STATE_CANCELLED_IDS);
|
||||
if (saved != null) cancelledIds.addAll(saved);
|
||||
}
|
||||
mPresenter.restoreCancelledIds(cancelledIds);
|
||||
adapter = new RefundAdapter();
|
||||
adapter.setOnItemClickListener((baseAdapter, view, position) -> {
|
||||
if (position < 0 || position >= adapter.getData().size()) return;
|
||||
RefundEntity refund = adapter.getItem(position);
|
||||
if (refund != null) openRefundDetail(refund);
|
||||
});
|
||||
viewBinding.rvRefunds.setLayoutManager(new LinearLayoutManager(this));
|
||||
viewBinding.rvRefunds.setItemAnimator(null);
|
||||
viewBinding.rvRefunds.setAdapter(adapter);
|
||||
final int spacing = Math.round(10 * getResources().getDisplayMetrics().density);
|
||||
viewBinding.rvRefunds.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 ? spacing : 0, 0, 0);
|
||||
}
|
||||
});
|
||||
adapter.setOnItemChildClickListener((baseAdapter, view, position) -> {
|
||||
if (position < 0 || position >= adapter.getData().size()) return;
|
||||
RefundEntity refund = adapter.getItem(position);
|
||||
if (view.getId() == R.id.tv_refund_cancel_request && refund != null) {
|
||||
showCancelDialog(refund);
|
||||
}
|
||||
});
|
||||
viewBinding.tvRefundCount.setText(getString(R.string.refund_count, 0));
|
||||
renderFilters();
|
||||
mPresenter.getRefunds(filter);
|
||||
}
|
||||
|
||||
@OnClick({R.id.iv_refund_back, R.id.tv_refund_all, R.id.tv_refund_pending,
|
||||
R.id.tv_refund_approved, R.id.tv_refund_rejected})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_refund_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.tv_refund_all:
|
||||
selectFilter(Status.ALL);
|
||||
break;
|
||||
case R.id.tv_refund_pending:
|
||||
selectFilter(Status.PENDING);
|
||||
break;
|
||||
case R.id.tv_refund_approved:
|
||||
selectFilter(Status.APPROVED);
|
||||
break;
|
||||
case R.id.tv_refund_rejected:
|
||||
selectFilter(Status.REJECTED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void selectFilter(Status selected) {
|
||||
if (filter == selected) return;
|
||||
filter = selected;
|
||||
renderFilters();
|
||||
viewBinding.rvRefunds.scrollToPosition(0);
|
||||
mPresenter.getRefunds(filter);
|
||||
}
|
||||
|
||||
private void renderFilters() {
|
||||
viewBinding.tvRefundAll.setSelected(filter == Status.ALL);
|
||||
viewBinding.tvRefundPending.setSelected(filter == Status.PENDING);
|
||||
viewBinding.tvRefundApproved.setSelected(filter == Status.APPROVED);
|
||||
viewBinding.tvRefundRejected.setSelected(filter == Status.REJECTED);
|
||||
}
|
||||
|
||||
private void showCancelDialog(RefundEntity refund) {
|
||||
if (!refund.canCancel() || (cancelDialog != null && cancelDialog.isShowing())) return;
|
||||
// 始终使用所点条目的真实编号,列表变化后仍由数据层再次验证是否可撤销。
|
||||
cancelDialog = new RefundCancelDialog(this, () -> mPresenter.cancelRefund(refund.id));
|
||||
cancelDialog.show();
|
||||
}
|
||||
|
||||
private void openRefundDetail(RefundEntity refund) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(RefundDetailActivity.EXTRA_REFUND_ID, refund.id);
|
||||
bundle.putStringArrayList(RefundDetailActivity.EXTRA_CANCELLED_IDS, new ArrayList<>(cancelledIds));
|
||||
goTo(mContext, RefundDetailActivity.class, bundle, detailLauncher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showRefunds(List<RefundEntity> refunds) {
|
||||
List<RefundEntity> data = refunds == null ? new ArrayList<>() : new ArrayList<>(refunds);
|
||||
adapter.setNewData(data);
|
||||
viewBinding.tvRefundCount.setText(getString(R.string.refund_count, data.size()));
|
||||
viewBinding.tvRefundState.setText(R.string.refund_empty);
|
||||
viewBinding.tvRefundState.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefundCancelled(RefundEntity refund) {
|
||||
if (!cancelledIds.contains(refund.id)) cancelledIds.add(refund.id);
|
||||
mPresenter.getRefunds(filter);
|
||||
// 明确当前为本地交互预览,真实取消结果由后续服务端接口决定。
|
||||
ToastUtil.showShort(mContext, getString(R.string.refund_cancel_preview));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String message) {
|
||||
String error = TextUtils.isEmpty(message) ? getString(R.string.refund_load_failed) : message;
|
||||
if (adapter != null && adapter.getData().isEmpty()) {
|
||||
viewBinding.tvRefundState.setText(error);
|
||||
viewBinding.tvRefundState.setVisibility(View.VISIBLE);
|
||||
}
|
||||
ToastUtil.showShort(mContext, error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut(BaseBean bean) {
|
||||
// 登录失效沿用父类统一处理。
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putInt(STATE_FILTER, filter.ordinal());
|
||||
outState.putStringArrayList(STATE_CANCELLED_IDS, new ArrayList<>(cancelledIds));
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (cancelDialog != null) cancelDialog.dismiss();
|
||||
viewBinding.rvRefunds.setAdapter(null);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.ckkj.griddle.review;
|
||||
|
||||
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.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.ckkj.griddle.R;
|
||||
import com.ckkj.griddle.base.BaseActivity;
|
||||
import com.ckkj.griddle.custom.GridSpacingItemDecoration;
|
||||
import com.ckkj.griddle.databinding.ProductReviewLayoutBinding;
|
||||
import com.ckkj.griddle.mine.order.MyOrderDetailActivity;
|
||||
import com.ckkj.griddle.mine.order.adapter.MyOrderGoodsAdapter;
|
||||
import com.ckkj.griddle.mine.order.entity.MyOrderEntity;
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.review.adapter.ReviewImageAdapter;
|
||||
import com.ckkj.griddle.review.entity.ProductReviewRequest;
|
||||
import com.ckkj.griddle.review.mvp.ReviewContract;
|
||||
import com.ckkj.griddle.review.mvp.ReviewImpl;
|
||||
import com.ckkj.griddle.review.mvp.ReviewPresenter;
|
||||
import com.ckkj.griddle.utils.MediaSelectionHelper;
|
||||
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 ProductReviewActivity extends BaseActivity<ProductReviewLayoutBinding, ReviewPresenter>
|
||||
implements ReviewContract.ReviewView {
|
||||
public static final String EXTRA_ORDER_ID = MyOrderDetailActivity.EXTRA_ORDER_ID;
|
||||
private static final String STATE_COMMENT = "review_comment";
|
||||
private static final String STATE_RATING = "review_rating";
|
||||
private static final int IMAGE_COLUMNS = 3;
|
||||
private final MediaSelectionHelper imageHelper = new MediaSelectionHelper(this,
|
||||
this::renderImages, ReviewPresenter.MAX_IMAGE_COUNT, false,
|
||||
R.string.review_camera_description, R.string.review_image_limit, "product_review");
|
||||
private MyOrderGoodsAdapter goodsAdapter;
|
||||
private ReviewImageAdapter imageAdapter;
|
||||
private MyOrderEntity order;
|
||||
|
||||
@Override
|
||||
public ReviewPresenter createPresenter() {
|
||||
return new ReviewPresenter(new ReviewImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutResId(Bundle savedInstanceState) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData(Bundle savedInstanceState) {
|
||||
super.initData(savedInstanceState);
|
||||
ImmersionBar.with(this).statusBarColor(R.color.white).statusBarDarkFont(true)
|
||||
.keyboardEnable(true).init();
|
||||
initGoods();
|
||||
initImages();
|
||||
if (savedInstanceState != null) {
|
||||
viewBinding.etReviewComment.setText(savedInstanceState.getString(STATE_COMMENT, ""));
|
||||
int rating = savedInstanceState.getInt(STATE_RATING, 0);
|
||||
viewBinding.ratingReviewGoods.setRating(Math.min(5, Math.max(0, rating)));
|
||||
}
|
||||
imageHelper.restore(savedInstanceState);
|
||||
mPresenter.getOrder(getIntent().getStringExtra(EXTRA_ORDER_ID));
|
||||
}
|
||||
|
||||
private void initGoods() {
|
||||
goodsAdapter = new MyOrderGoodsAdapter();
|
||||
viewBinding.rvReviewGoods.setLayoutManager(new LinearLayoutManager(this) {
|
||||
@Override
|
||||
public boolean canScrollVertically() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
viewBinding.rvReviewGoods.setAdapter(goodsAdapter);
|
||||
viewBinding.rvReviewGoods.setItemAnimator(null);
|
||||
final int spacing = Math.round(16 * getResources().getDisplayMetrics().density);
|
||||
viewBinding.rvReviewGoods.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 ? spacing : 0, 0, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initImages() {
|
||||
imageAdapter = new ReviewImageAdapter();
|
||||
// 固定三列等分实际容器宽度,保持图片正方形,不按屏幕宽度写死尺寸。
|
||||
viewBinding.rvReviewImages.setLayoutManager(new GridLayoutManager(this, IMAGE_COLUMNS));
|
||||
viewBinding.rvReviewImages.setItemAnimator(null);
|
||||
viewBinding.rvReviewImages.setAdapter(imageAdapter);
|
||||
viewBinding.rvReviewImages.addItemDecoration(new GridSpacingItemDecoration(IMAGE_COLUMNS,
|
||||
Math.round(6 * getResources().getDisplayMetrics().density), false));
|
||||
imageAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
switch (view.getId()) {
|
||||
case R.id.ll_review_add_image:
|
||||
imageHelper.showSource();
|
||||
break;
|
||||
case R.id.iv_review_delete_image:
|
||||
imageHelper.remove(position);
|
||||
break;
|
||||
case R.id.iv_review_image:
|
||||
imageHelper.preview(position);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void renderImages() {
|
||||
if (imageAdapter == null) return;
|
||||
List<String> display = imageHelper.getEvidence();
|
||||
if (display.size() < ReviewPresenter.MAX_IMAGE_COUNT) display.add("");
|
||||
imageAdapter.setNewData(display);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showOrder(MyOrderEntity data) {
|
||||
if (data == null) {
|
||||
showError(null);
|
||||
return;
|
||||
}
|
||||
order = data;
|
||||
goodsAdapter.setNewData(new ArrayList<>(order.goods));
|
||||
viewBinding.llReviewContent.setVisibility(View.VISIBLE);
|
||||
viewBinding.tvReviewSubmit.setEnabled(order.canReview());
|
||||
if (!order.canReview()) showError(getString(R.string.review_order_unavailable));
|
||||
}
|
||||
|
||||
@OnClick({R.id.iv_review_back, R.id.tv_review_submit})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_review_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.tv_review_submit:
|
||||
submitReview();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void submitReview() {
|
||||
if (order == null) return;
|
||||
if (imageHelper.isProcessing()) {
|
||||
showError(getString(R.string.fault_report_media_processing));
|
||||
return;
|
||||
}
|
||||
mPresenter.validateReview(new ProductReviewRequest(order.id,
|
||||
viewBinding.etReviewComment.getText().toString(),
|
||||
Math.round(viewBinding.ratingReviewGoods.getRating()), imageHelper.getEvidence()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReviewValidated(int errorResId) {
|
||||
// 尚未接入服务端,校验通过保留草稿,不伪造评价提交成功。
|
||||
showError(getString(errorResId == 0 ? R.string.review_submit_pending : errorResId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String message) {
|
||||
ToastUtil.showShort(mContext, TextUtils.isEmpty(message)
|
||||
? getString(R.string.review_load_failed) : message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut(BaseBean bean) {
|
||||
// 登录失效沿用父类统一处理。
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putString(STATE_COMMENT, viewBinding.etReviewComment.getText().toString());
|
||||
outState.putInt(STATE_RATING, Math.round(viewBinding.ratingReviewGoods.getRating()));
|
||||
imageHelper.save(outState);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
imageHelper.destroy();
|
||||
viewBinding.rvReviewGoods.setAdapter(null);
|
||||
viewBinding.rvReviewImages.setAdapter(null);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,5 @@
|
||||
android:state_selected="true"
|
||||
android:color="@android:color/white" />
|
||||
<item
|
||||
android:color="#6B7280" />
|
||||
android:color="#666666" />
|
||||
</selector>
|
||||
@@ -2,7 +2,7 @@
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid
|
||||
android:color="#80FFFFFF" />
|
||||
android:color="#99FFFFFF" />
|
||||
<corners
|
||||
android:radius="999dp" />
|
||||
</shape>
|
||||
@@ -14,9 +14,6 @@
|
||||
<shape>
|
||||
<solid
|
||||
android:color="@android:color/white" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#ECEEF2" />
|
||||
<corners
|
||||
android:radius="999dp" />
|
||||
</shape>
|
||||
|
||||
@@ -9,20 +9,17 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/device_preview_background"
|
||||
android:background="@color/white"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
tools:locale="en">
|
||||
|
||||
<!-- 复用通用标题栏,通过可选参数设置本页标题和深色文字。 -->
|
||||
|
||||
<!-- 白色标题栏与系统状态栏保持一致。 -->
|
||||
<include
|
||||
android:id="@+id/include_title"
|
||||
layout="@layout/include_activity_top_title_layout"
|
||||
layout="@layout/device_preview_title_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
app:title="@{@string/device_preview_title}"
|
||||
app:titleTextColor="@{@color/device_home_text}" />
|
||||
android:layout_height="48dp" />
|
||||
|
||||
<!-- 内容允许滚动,小屏幕和较大字体下仍能查看底部卡片。 -->
|
||||
|
||||
@@ -30,6 +27,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/device_preview_page_background"
|
||||
android:clipToPadding="false"
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none">
|
||||
@@ -48,8 +46,8 @@
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="25dp"
|
||||
android:paddingTop="7dp"
|
||||
android:paddingHorizontal="24dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<!-- 宽窗口:左侧设备信息,右侧减排数据与快捷入口。 -->
|
||||
@@ -82,7 +80,7 @@
|
||||
layout="@layout/device_preview_actions_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp" />
|
||||
android:layout_marginTop="10dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<!-- 全部美食:白色标题栏与状态栏,独立刷新分页的瀑布流列表。 -->
|
||||
<layout
|
||||
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">
|
||||
|
||||
@@ -8,44 +10,52 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/f9f9f9"
|
||||
android:background="@color/white"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
tools:context=".shop.AllGoodsActivity">
|
||||
tools:context=".food.AllGoodsActivity">
|
||||
|
||||
<include
|
||||
android:id="@+id/include_title"
|
||||
layout="@layout/include_activity_top_title_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="10dp"
|
||||
app:title="@{@string/shop_all_goods_title}"
|
||||
app:titleTextColor="@{@color/points_order_text}" />
|
||||
app:title="@{@string/food_all_recipes_title}"
|
||||
app:titleTextColor="@{@color/food_text}"
|
||||
android:background="@color/white" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
android:layout_weight="1"
|
||||
android:background="@color/food_page_background">
|
||||
|
||||
<!-- 双列列表独立滚动,支持下拉刷新和上拉分页。 -->
|
||||
<com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/refresh_all_goods"
|
||||
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:maxContentWidth="1000dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_all_goods"
|
||||
<com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/refresh_all_goods"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="28dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingEnd="28dp"
|
||||
android:paddingBottom="22dp"
|
||||
android:scrollbars="none"
|
||||
tools:itemCount="6"
|
||||
tools:listitem="@layout/all_goods_item" />
|
||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_all_goods"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingStart="18.5dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingEnd="18.5dp"
|
||||
android:paddingBottom="14dp"
|
||||
android:scrollbars="none"
|
||||
tools:itemCount="6"
|
||||
tools:listitem="@layout/food_recommend_item" />
|
||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_all_goods"
|
||||
@@ -54,7 +64,6 @@
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 空列表和首屏失败共用提示区,点击即可重新获取第一页。 -->
|
||||
<TextView
|
||||
android:id="@+id/tv_all_goods_state"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -1,378 +1,412 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
<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/f9f9f9"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
tools:locale="zh">
|
||||
android:background="@color/home_index_background">
|
||||
|
||||
<!-- Fragment content only. MainActivity owns system insets and the bottom TabBar. -->
|
||||
<LinearLayout
|
||||
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="38dp"
|
||||
android:layout_marginHorizontal="29dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
app:maxContentWidth="720dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_title"
|
||||
style="@style/DeviceHomeText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center_vertical"
|
||||
android:letterSpacing="-0.018"
|
||||
android:maxLines="1"
|
||||
android:text="@string/device_home_title"
|
||||
android:textSize="25sp"
|
||||
android:textStyle="bold" />
|
||||
<!-- 整页滚动兼容折叠横屏和大字体,设备宫格不再单独嵌套滚动。 -->
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_notifications"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_notice" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_add_device"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_top_right_add" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 天气为固定示例;点击城市仅演示权限申请,后续再接入实际信息提供方。 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginHorizontal="33dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="106dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_home_weather"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/device_home_weather_sunny" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_weather"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="@string/device_home_weather_demo"
|
||||
android:textColor="#9E9E9E"
|
||||
android:textSize="12sp"
|
||||
tools:text="26°C · Sunny" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_home_location"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="19dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/device_home_location" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_location"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="@string/device_home_location_pending"
|
||||
android:textColor="#9E9E9E"
|
||||
android:textSize="12sp"
|
||||
tools:text="Addis Ababa" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_home_statistics"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="133dp"
|
||||
android:layout_marginHorizontal="29dp"
|
||||
android:layout_marginTop="11dp"
|
||||
android:outlineAmbientShadowColor="@color/device_home_orange"
|
||||
android:outlineSpotShadowColor="@color/device_home_orange"
|
||||
app:cardBackgroundColor="@color/device_home_orange"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="10dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_charcoal_saved"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="18dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_charcoal_saved"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:background="@drawable/device_home_stat_icon_bg"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_charcoal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_charcoal_saved"
|
||||
style="@style/DeviceHomeStatValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="19dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_home_zero_charcoal"
|
||||
android:textSize="14sp"
|
||||
tools:text="128 kg" />
|
||||
|
||||
<TextView
|
||||
style="@style/DeviceHomeStatLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:text="@string/device_home_charcoal_saved" />
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="91dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="#66FFFFFF" />
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_balance"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="14dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_balance"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:background="@drawable/device_home_stat_icon_bg"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_balance" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_balance"
|
||||
style="@style/DeviceHomeStatValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_home_zero"
|
||||
android:textSize="26sp"
|
||||
tools:text="2,847" />
|
||||
|
||||
<TextView
|
||||
style="@style/DeviceHomeStatLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:text="@string/device_home_balance" />
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="91dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="#66FFFFFF" />
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_saving_birr"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="18dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_saving_birr"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:background="@drawable/device_home_stat_icon_bg"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_birr" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_saving_birr"
|
||||
style="@style/DeviceHomeStatValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="19dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_home_zero"
|
||||
android:textSize="14sp"
|
||||
tools:text="9998" />
|
||||
|
||||
<TextView
|
||||
style="@style/DeviceHomeStatLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:text="@string/device_home_saving_birr" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_my_devices"
|
||||
style="@style/DeviceHomeText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginHorizontal="29dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/device_home_my_devices"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginHorizontal="23dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_weight="1"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<!-- Two columns. Item margins leave room for card shadows. -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_devices"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="12dp"
|
||||
android:scrollbars="none"
|
||||
android:visibility="gone"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:spanCount="2"
|
||||
tools:itemCount="4"
|
||||
tools:listitem="@layout/device_index_item" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/sv_empty_devices"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_empty_devices"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="5dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="3dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 首页只绘制业务内容,系统状态栏和底部导航由 MainActivity 处理。 -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="34dp">
|
||||
<ImageView
|
||||
android:id="@+id/iv_empty_devices"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="65dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_add_device" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_empty_devices"
|
||||
style="@style/DeviceHomeText"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/tv_home_title"
|
||||
style="@style/HomeIndexText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="21dp"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_home_empty_message"
|
||||
android:textColor="#1F2329"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginEnd="28dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/device_home_title"
|
||||
android:textSize="26sp"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:autoSizeMinTextSize="18sp"
|
||||
app:autoSizeMaxTextSize="26sp"
|
||||
app:autoSizeStepGranularity="1sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/btn_empty_add_device"
|
||||
android:layout_width="104dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="38dp"
|
||||
android:layout_marginBottom="28dp"
|
||||
android:clickable="true"
|
||||
<ImageView
|
||||
android:id="@+id/iv_notifications"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/home_index_action_background"
|
||||
android:elevation="5dp"
|
||||
android:outlineProvider="background"
|
||||
android:contentDescription="@string/device_home_notifications"
|
||||
android:src="@mipmap/icon_home_notifications" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_add_device"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="@drawable/home_index_action_background"
|
||||
android:elevation="5dp"
|
||||
android:outlineProvider="background"
|
||||
android:contentDescription="@string/device_home_add_device"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardBackgroundColor="@color/device_home_orange"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
android:src="@mipmap/icon_home_add_device" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 天气为固定示例;点击城市仅演示权限申请,后续再接入实际信息提供方。 -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_home_weather"
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_home_weather" />
|
||||
|
||||
<TextView
|
||||
style="@style/DeviceHomeText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_home_add_device"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
android:id="@+id/tv_home_weather"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="@string/device_home_weather_demo"
|
||||
android:textColor="#222222"
|
||||
android:textSize="14sp"
|
||||
tools:text="26°C · Sunny" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_home_location"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="14dp"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_home_location" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_location"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="@string/device_home_location_pending"
|
||||
android:textColor="#222222"
|
||||
android:textSize="14sp"
|
||||
tools:text="Addis Ababa" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</ScrollView>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_home_statistics"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="134dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="30dp"
|
||||
app:cardBackgroundColor="@color/device_home_orange"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_charcoal_saved"
|
||||
style="@style/HomeIndexStatColumn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_charcoal_saved"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@mipmap/icon_home_charcoal" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_charcoal_saved"
|
||||
style="@style/HomeIndexStatValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/device_home_zero_charcoal" />
|
||||
|
||||
<TextView
|
||||
style="@style/HomeIndexStatLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/device_home_charcoal_saved" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
style="@style/HomeIndexStatDivider"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="44dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_balance"
|
||||
style="@style/HomeIndexStatColumn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_balance"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@mipmap/icon_home_balance" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_balance"
|
||||
style="@style/HomeIndexStatValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/device_home_zero" />
|
||||
|
||||
<TextView
|
||||
style="@style/HomeIndexStatLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/device_home_balance" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
style="@style/HomeIndexStatDivider"
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="44dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_electricity_saved"
|
||||
style="@style/HomeIndexStatColumn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_electricity_saved"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@mipmap/icon_home_electricity" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_electricity_saved"
|
||||
style="@style/HomeIndexStatValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/device_home_zero" />
|
||||
|
||||
<TextView
|
||||
style="@style/HomeIndexStatLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_index_electricity_saved" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_my_devices"
|
||||
style="@style/HomeIndexText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/device_home_my_devices"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="18.5dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<!-- 两列设备卡片统一边距,随外层页面滚动。 -->
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_devices"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="12dp"
|
||||
android:scrollbars="none"
|
||||
android:visibility="gone"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:spanCount="2"
|
||||
tools:itemCount="4"
|
||||
tools:listitem="@layout/device_index_item" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sv_empty_devices"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="none">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_empty_devices"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="5.5dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="34dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_empty_devices"
|
||||
android:layout_width="65dp"
|
||||
android:layout_height="65dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_add_device" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_empty_devices"
|
||||
style="@style/HomeIndexText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="21dp"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_home_empty_message"
|
||||
android:textColor="#1F2329"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/btn_empty_add_device"
|
||||
android:layout_width="104dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="38dp"
|
||||
android:layout_marginBottom="28dp"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/device_home_add_device"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardBackgroundColor="@color/device_home_orange"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<TextView
|
||||
style="@style/HomeIndexText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_home_add_device"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -1,133 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
<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="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
tools:layout_width="174dp"
|
||||
tools:locale="zh">
|
||||
android:paddingHorizontal="5.5dp"
|
||||
android:paddingBottom="10dp"
|
||||
tools:layout_width="178dp">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_device"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="182dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="220dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="2dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
<!-- 与设计稿一致保留两行设备名;明细可换行,避免窄屏和大字体截断。 -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="12dp">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="14dp">
|
||||
|
||||
<!-- Set activated=true for the offline icon background and status dot. -->
|
||||
<ImageView
|
||||
android:id="@+id/iv_device"
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="54dp"
|
||||
android:background="@drawable/device_home_icon_bg"
|
||||
android:contentDescription="@null"
|
||||
android:padding="14dp"
|
||||
android:src="@drawable/device_home_griddle_icon"
|
||||
android:tint="@color/device_home_icon_tint" />
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_device_status"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@drawable/device_home_status_dot"
|
||||
android:contentDescription="@string/device_home_online" />
|
||||
<ImageView
|
||||
android:id="@+id/iv_device"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@mipmap/icon_home_device" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_device_status"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="top|end"
|
||||
android:background="@drawable/home_index_status_dot"
|
||||
android:contentDescription="@string/device_home_online" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_device_name"
|
||||
style="@style/DeviceHomeText"
|
||||
style="@style/HomeIndexText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="33dp"
|
||||
android:layout_below="@id/iv_device"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:gravity="top"
|
||||
android:minLines="2"
|
||||
android:maxLines="2"
|
||||
android:textSize="12.5sp"
|
||||
tools:text="@string/device_home_sample_name" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_device_online"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_device_name"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginTop="11dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
style="@style/DeviceHomeDetail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/device_home_current_power" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_device_power"
|
||||
style="@style/DeviceHomeDetail"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/device_home_value"
|
||||
tools:text="1200w" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
style="@style/DeviceHomeDetail"
|
||||
android:id="@+id/tv_device_power"
|
||||
style="@style/HomeIndexDetail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/device_home_current_temperature" />
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Current Power: 1200w" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_device_temperature"
|
||||
style="@style/DeviceHomeDetail"
|
||||
style="@style/HomeIndexDetail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/device_home_value"
|
||||
tools:text="180℃" />
|
||||
tools:text="Current Temperature: 180°C" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_device_carbon"
|
||||
style="@style/HomeIndexDetail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
tools:text="Carbon Reduction: 128.6 kg CO₂e" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_device_offline"
|
||||
style="@style/DeviceHomeDetail"
|
||||
style="@style/HomeIndexDetail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="14dp"
|
||||
android:layout_below="@id/tv_device_name"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="11dp"
|
||||
android:text="@string/device_home_offline"
|
||||
android:textColor="@color/device_home_offline_text"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -9,20 +9,17 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/device_preview_background"
|
||||
android:background="@color/white"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
tools:locale="en">
|
||||
|
||||
<!-- 复用通用标题栏,通过可选参数设置本页标题和深色文字。 -->
|
||||
|
||||
<!-- 白色标题栏与系统状态栏保持一致。 -->
|
||||
<include
|
||||
android:id="@+id/include_title"
|
||||
layout="@layout/include_activity_top_title_layout"
|
||||
layout="@layout/device_preview_title_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
app:title="@{@string/device_preview_title}"
|
||||
app:titleTextColor="@{@color/device_home_text}" />
|
||||
android:layout_height="48dp" />
|
||||
|
||||
<!-- 内容允许滚动,小屏幕和较大字体下仍能查看底部卡片。 -->
|
||||
|
||||
@@ -30,6 +27,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/device_preview_page_background"
|
||||
android:clipToPadding="false"
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none">
|
||||
@@ -48,8 +46,8 @@
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="25dp"
|
||||
android:paddingTop="7dp"
|
||||
android:paddingHorizontal="24dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="24dp">
|
||||
|
||||
<include
|
||||
@@ -61,13 +59,13 @@
|
||||
layout="@layout/device_preview_carbon_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp" />
|
||||
android:layout_marginTop="10dp" />
|
||||
|
||||
<include
|
||||
layout="@layout/device_preview_actions_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp" />
|
||||
android:layout_marginTop="10dp" />
|
||||
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
|
||||
</FrameLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
@@ -1,107 +1,96 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- 今日节省卡片。 -->
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_preview_savings"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="11dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="1dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="160dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="11dp">
|
||||
android:padding="14dp"
|
||||
android:minHeight="224dp">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewSmallHeading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="17dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_savings_title" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="16dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_charcoal_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_charcoal"
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:text="@string/device_preview_demo_charcoal"
|
||||
android:textSize="12.5sp" />
|
||||
android:id="@+id/tv_preview_charcoal"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_charcoal" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="16dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_saving_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_saving"
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:text="@string/device_preview_demo_saving"
|
||||
android:textSize="12.5sp" />
|
||||
android:id="@+id/tv_preview_saving"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_saving" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="45dp"
|
||||
android:id="@+id/iv_preview_savings"
|
||||
android:layout_width="81dp"
|
||||
android:layout_height="53dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
android:src="@mipmap/icon_device_preview_tree" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- 快捷操作暂只保留入口控件,业务点击由后续页面逻辑接入。 -->
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_preview_actions"
|
||||
android:layout_width="0dp"
|
||||
@@ -109,125 +98,138 @@
|
||||
android:layout_weight="1"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="1dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="160dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="11dp">
|
||||
android:padding="14dp"
|
||||
android:minHeight="224dp">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewSmallHeading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="17dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_actions_title" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/ll_preview_stats"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="7dp"
|
||||
android:minHeight="34dp"
|
||||
android:background="@drawable/device_preview_action_bg"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="45dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/device_preview_panel_bg"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="9dp"
|
||||
android:paddingVertical="6dp">
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="5.5dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:background="@drawable/device_preview_action_icon_bg"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:contentDescription="@null"
|
||||
android:padding="4dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
android:src="@mipmap/icon_device_preview_stats" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewAction"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_carbon_status"
|
||||
style="@style/DevicePreviewAction"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="@string/device_preview_stats" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="7dp"
|
||||
android:layout_height="12dp"
|
||||
android:alpha="0.5"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_device_preview_arrow" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/ll_preview_control"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="34dp"
|
||||
android:background="@drawable/device_preview_action_bg"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="45dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:background="@drawable/device_preview_panel_bg"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="9dp"
|
||||
android:paddingVertical="6dp">
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="5.5dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:background="@drawable/device_preview_action_icon_bg"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:contentDescription="@null"
|
||||
android:padding="4dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
android:src="@mipmap/icon_device_preview_control" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewAction"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_control"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="@string/device_preview_control" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="7dp"
|
||||
android:layout_height="12dp"
|
||||
android:alpha="0.5"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_device_preview_arrow" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_preview_carbon_points"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="34dp"
|
||||
android:background="@drawable/device_preview_action_bg"
|
||||
android:id="@+id/ll_preview_carbon_points"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="45dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:background="@drawable/device_preview_panel_bg"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="9dp"
|
||||
android:paddingVertical="6dp">
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="5.5dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:background="@drawable/device_preview_action_icon_bg"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:contentDescription="@null"
|
||||
android:padding="4dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
android:src="@mipmap/icon_device_preview_points" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_carbon_points"
|
||||
style="@style/DevicePreviewAction"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_carbon_points"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="@string/device_preview_carbon_points" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="7dp"
|
||||
android:layout_height="12dp"
|
||||
android:alpha="0.5"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_device_preview_arrow" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 今日减排与累计使用数据;绿色积分环按容器宽度缩放,底部展示累计减排说明。 -->
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
@@ -13,174 +14,200 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="159dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="21dp"
|
||||
android:paddingEnd="14dp"
|
||||
android:paddingTop="9dp"
|
||||
android:paddingBottom="9dp">
|
||||
android:padding="14dp"
|
||||
android:minHeight="324dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_preview_carbon_details"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="19dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="17dp"
|
||||
android:layout_height="17dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
android:id="@+id/ll_preview_carbon_details"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewHeading"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_carbon_title" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="12dp"
|
||||
android:layout_width="7dp"
|
||||
android:layout_height="12dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_point_right"
|
||||
android:tint="@color/device_home_offline" />
|
||||
android:src="@mipmap/icon_device_preview_arrow" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="9dp"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="14dp"
|
||||
android:text="@string/device_preview_electricity_label" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_electricity"
|
||||
style="@style/DevicePreviewValue"
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_electricity_label" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_electricity"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_electricity"
|
||||
android:textColor="#FF6900" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_electricity" />
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<Space
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="7dp" />
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_usage_time_label" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
<TextView
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_usage_time"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_usage_time" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="14dp"
|
||||
android:text="@string/device_preview_money_label" />
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_money"
|
||||
style="@style/DevicePreviewValue"
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_total_electricity_label" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_carbon_total_electricity"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_total_electricity" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_money"
|
||||
android:textColor="@color/device_home_orange" />
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<Space
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="7dp" />
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_total_time_label" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="14dp"
|
||||
android:text="@string/device_preview_carbon_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_carbon"
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_carbon" />
|
||||
<TextView
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_carbon_total_time"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_total_time" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="132dp"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="16dp">
|
||||
android:layout_weight="1">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="66dp"
|
||||
android:layout_height="66dp">
|
||||
|
||||
<!-- 复用配网页面的圆头橙色进度环;此处 74 为静态展示值。 -->
|
||||
|
||||
<com.ckkj.griddle.custom.view.ProvisionProgressView
|
||||
android:id="@+id/preview_points_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:importantForAccessibility="no"
|
||||
app:provisionProgress="74"
|
||||
app:provisionStrokeWidth="6dp"
|
||||
app:provisionInset="0dp" />
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/preview_points_progress"
|
||||
android:background="@drawable/device_preview_points_ring"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintWidth_max="120dp"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_points"
|
||||
style="@style/DevicePreviewText"
|
||||
android:layout_width="wrap_content"
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:minHeight="17dp"
|
||||
android:text="@string/device_preview_demo_points"
|
||||
android:textSize="13sp" />
|
||||
android:id="@+id/tv_preview_points"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_preview_demo_points" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
android:minHeight="11dp"
|
||||
android:text="@string/device_preview_points_label"
|
||||
android:textColor="@color/device_home_muted"
|
||||
android:textSize="8.5sp" />
|
||||
android:layout_marginTop="3dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/device_preview_points_label" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_equivalent"
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="13dp"
|
||||
android:gravity="center"
|
||||
android:minHeight="12dp"
|
||||
android:text="@string/device_preview_equivalent"
|
||||
android:textColor="@color/device_home_muted"
|
||||
android:textSize="9sp" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_equivalent"
|
||||
android:layout_marginTop="16dp"
|
||||
android:minHeight="37dp"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="10dp"
|
||||
android:background="@drawable/device_preview_panel_bg"
|
||||
android:text="@string/device_preview_equivalent" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -1,143 +1,241 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 设备信息与累计指标;内容随字体自然增高,左右两列按可用宽度等分。 -->
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/cv_preview_device"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="1dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="166dp"
|
||||
android:paddingBottom="7dp">
|
||||
android:orientation="vertical"
|
||||
android:padding="14dp"
|
||||
android:minHeight="323dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_preview_device_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:id="@+id/ll_preview_device_header"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="top">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:id="@+id/iv_preview_device_icon"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:background="@drawable/device_home_icon_bg"
|
||||
android:contentDescription="@null"
|
||||
android:padding="10dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
android:src="@mipmap/icon_home_device" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_device_name"
|
||||
style="@style/DevicePreviewHeading"
|
||||
style="@style/DevicePreviewDeviceName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:minHeight="19dp"
|
||||
android:id="@+id/tv_preview_device_name"
|
||||
android:text="@string/device_preview_name" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_preview_online"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/ll_preview_online"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="15dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:id="@+id/view_preview_online_dot"
|
||||
android:layout_width="7dp"
|
||||
android:layout_height="7dp"
|
||||
android:background="@drawable/device_home_status_dot" />
|
||||
android:background="@drawable/home_index_status_dot" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_online"
|
||||
style="@style/DevicePreviewText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@string/device_home_online"
|
||||
android:textColor="@color/device_home_online"
|
||||
android:textSize="11.5sp" />
|
||||
android:id="@+id/tv_preview_online"
|
||||
android:layout_marginStart="4dp"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#22A45D"
|
||||
android:minHeight="17dp"
|
||||
android:text="@string/device_home_online" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_preview_product"
|
||||
android:layout_width="164dp"
|
||||
android:layout_height="116dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="43dp"
|
||||
android:layout_marginEnd="14dp"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_preview_realtime"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/ll_preview_device_header"
|
||||
android:layout_toStartOf="@id/iv_preview_product"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:orientation="vertical">
|
||||
android:id="@+id/ll_preview_realtime"
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="15dp"
|
||||
android:text="@string/device_preview_power_label"
|
||||
android:textSize="11sp" />
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_power"
|
||||
style="@style/DevicePreviewText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:minHeight="22dp"
|
||||
android:text="@string/device_preview_demo_power"
|
||||
android:textSize="17sp" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="7dp"
|
||||
android:minHeight="15dp"
|
||||
android:text="@string/device_preview_temperature_label"
|
||||
android:textSize="11sp" />
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="17dp"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/device_preview_power_label" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_preview_temperature"
|
||||
style="@style/DevicePreviewText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:minHeight="22dp"
|
||||
android:text="@string/device_preview_demo_temperature"
|
||||
android:textSize="17sp" />
|
||||
<TextView
|
||||
style="@style/DevicePreviewRealtime"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_power"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="29dp"
|
||||
android:text="@string/device_preview_demo_power" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="17dp"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/device_preview_temperature_label" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewRealtime"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_temperature"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="29dp"
|
||||
android:text="@string/device_preview_demo_temperature" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="116dp"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/iv_preview_product"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@null"
|
||||
android:src="@mipmap/icon_device_preview_product" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="8dp">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_total_electricity_label" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_total_electricity"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_total_electricity" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="15dp"
|
||||
android:textSize="12sp"
|
||||
android:text="@string/device_preview_total_time_label" />
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tv_preview_total_time"
|
||||
android:layout_marginTop="6dp"
|
||||
android:minHeight="19dp"
|
||||
android:text="@string/device_preview_demo_total_time" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="37dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:background="@drawable/device_preview_panel_bg">
|
||||
|
||||
<TextView
|
||||
style="@style/DevicePreviewDeviceName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/device_preview_power_switch" />
|
||||
|
||||
<com.kyleduo.switchbutton.SwitchButton
|
||||
android:id="@+id/switch_preview_power"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="37dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:checked="true"
|
||||
android:contentDescription="@string/device_preview_power_switch"
|
||||
app:kswThumbDrawable="@drawable/device_timer_switch_thumb"
|
||||
app:kswThumbWidth="17dp"
|
||||
app:kswThumbHeight="17dp"
|
||||
app:kswThumbMargin="2dp"
|
||||
app:kswThumbRangeRatio="2.4"
|
||||
app:kswThumbRadius="8.5dp"
|
||||
app:kswBackRadius="10.5dp"
|
||||
app:kswBackColor="@color/device_preview_switch_track" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 轮播图仅保留图片与右下角指示器,不叠加商品标题及价格。 -->
|
||||
<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:id="@+id/fl_food_banner"
|
||||
android:layout_width="match_parent"
|
||||
@@ -8,6 +10,7 @@
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_food_banner"
|
||||
android:layout_width="match_parent"
|
||||
@@ -15,63 +18,22 @@
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/food_cover_placeholder"
|
||||
android:contentDescription="@null" />
|
||||
<View
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_height="34dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/food_banner_scrim" />
|
||||
android:src="@mipmap/bg_food_banner_scrim"
|
||||
android:scaleType="fitXY"
|
||||
android:contentDescription="@null" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingBottom="14dp">
|
||||
<!-- 指示器由适配器根据 Banner 数量和当前页动态生成。 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_banner_indicators"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="6dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:gravity="center">
|
||||
<View
|
||||
android:id="@+id/view_banner_indicator_active"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="6dp"
|
||||
android:background="@drawable/food_banner_indicator_active" />
|
||||
<View
|
||||
android:layout_width="6dp"
|
||||
android:layout_height="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:background="@drawable/food_banner_indicator_inactive" />
|
||||
<View
|
||||
android:layout_width="6dp"
|
||||
android:layout_height="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:background="@drawable/food_banner_indicator_inactive" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/tv_food_banner_title"
|
||||
style="@style/LoginDesignText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="27dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Doro Wat" />
|
||||
<TextView
|
||||
android:id="@+id/tv_food_banner_subtitle"
|
||||
style="@style/LoginDesignText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Ethiopia’s National Dish" />
|
||||
</LinearLayout>
|
||||
android:id="@+id/ll_banner_indicators"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="4dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal"
|
||||
android:importantForAccessibility="no" />
|
||||
</FrameLayout>
|
||||
|
||||
@@ -1,37 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<!-- 横向美食卡片,白色文案底板随内容增高,不固定文字区域高度。 -->
|
||||
<androidx.cardview.widget.CardView
|
||||
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:id="@+id/ll_food_breakfast"
|
||||
android:layout_width="106dp"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:orientation="vertical"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:foreground="?attr/selectableItemBackground">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="104dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_food_cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/food_cover_placeholder"
|
||||
android:contentDescription="@null" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
<TextView
|
||||
android:id="@+id/tv_food_name"
|
||||
style="@style/FoodItemName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Injera Firfir" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_food_name"
|
||||
style="@style/FoodItemName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="33dp"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
tools:text="Injera Firfir" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 分类标签沿用列表选中状态,文字放大时允许高度随内容增高。 -->
|
||||
<TextView
|
||||
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:id="@+id/tv_food_category"
|
||||
style="@style/LoginDesignText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:minWidth="64dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="33dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/food_category_bg"
|
||||
android:textColor="@color/food_category_text"
|
||||
android:textSize="12sp"
|
||||
android:textSize="14sp"
|
||||
android:maxLines="1"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
tools:text="@string/food_category_breakfast" />
|
||||
@@ -1,39 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<!-- 白色圆角美食卡片:封面按比例缩放,文案最多两行,超出末尾省略。 -->
|
||||
<androidx.cardview.widget.CardView
|
||||
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:id="@+id/ll_food_recommend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="6dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="vertical"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="10dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
android:layout_marginHorizontal="5.5dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:foreground="?attr/selectableItemBackground">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="110dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_food_cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/food_cover_placeholder"
|
||||
android:contentDescription="@null" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
<TextView
|
||||
android:id="@+id/tv_food_name"
|
||||
style="@style/FoodItemName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
tools:text="Chechebsa" />
|
||||
</LinearLayout>
|
||||
android:contentDescription="@null"
|
||||
app:layout_constraintDimensionRatio="167:125"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_food_name"
|
||||
style="@style/FoodItemName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="33dp"
|
||||
android:paddingHorizontal="8dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintTop_toBottomOf="@id/iv_food_cover"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:text="Injera FirfirInjera FirfirInjera Firfir" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
android:layout_height="@dimen/dp_48">
|
||||
<ImageView
|
||||
android:id="@+id/img_back"
|
||||
android:layout_width="@dimen/dp_24"
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingHorizontal="2dp"
|
||||
android:src="@mipmap/img_back_black"
|
||||
android:paddingLeft="@dimen/dp_7"
|
||||
android:paddingRight="@dimen/dp_7"
|
||||
android:layout_marginLeft="@dimen/dp_10"/>
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@mipmap/img_back_black"
|
||||
android:paddingLeft="@dimen/dp_7"
|
||||
android:paddingRight="@dimen/dp_7"
|
||||
android:paddingLeft="@dimen/dp_2"
|
||||
android:paddingRight="@dimen/dp_2"
|
||||
android:layout_marginLeft="@dimen/dp_10" />
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -1,33 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/f9f9f9"
|
||||
android:background="@color/home_index_background"
|
||||
android:fitsSystemWindows="false">
|
||||
|
||||
<!-- 状态栏背景由占位 View 绘制,高度由 ImmersionBar 设置,避免重复避让。 -->
|
||||
|
||||
<View
|
||||
android:id="@+id/statusBarView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/f9f9f9" />
|
||||
android:background="@color/home_index_background" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
<!-- 四个业务入口等分宽度,系统导航栏留白由 ImmersionBar 统一处理。 -->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:itemTextAppearanceActive="@style/BottomNavTextActive"
|
||||
app:itemTextAppearanceInactive="@style/BottomNavTextInactive"
|
||||
app:menu="@menu/bottom_nav_menu"
|
||||
app:itemTextColor="@color/nav_bottom_text_select"
|
||||
android:background="@color/color_white"
|
||||
app:itemBackground="@android:color/transparent"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:itemIconTint="@null"
|
||||
android:visibility="visible" />
|
||||
android:background="@color/color_white">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_gravity="top"
|
||||
android:background="#DDDDDD"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<include
|
||||
android:id="@+id/include_main_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
layout="@layout/include_main_tabs" />
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/nav_viewpage2"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 新版美食首页:大标题、按比例轮播、横向分类与卡片、推荐瀑布流。 -->
|
||||
<com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
@@ -6,30 +7,25 @@
|
||||
android:id="@+id/refresh_shop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/f9f9f9">
|
||||
android:background="@color/food_page_background">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/sv_food_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/f9f9f9"
|
||||
android:background="@color/food_page_background"
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none"
|
||||
tools:locale="zh">
|
||||
|
||||
<!-- 按窗口宽度测量,大屏内容居中,手机保持占满宽度。 -->
|
||||
android:scrollbars="none">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!-- 仅承载商城页面内容,系统栏和底部 TabBar 由 MainActivity 统一处理。 -->
|
||||
|
||||
<com.ckkj.griddle.custom.view.AdaptiveContentLayout
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
app:maxContentWidth="1000dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
app:maxContentWidth="1000dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
@@ -37,34 +33,49 @@
|
||||
android:id="@+id/tv_food_title"
|
||||
style="@style/FoodTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/food_title"
|
||||
android:textSize="18sp" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:minHeight="31dp"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textSize="26sp"
|
||||
android:text="@string/food_title" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_food_banner"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="180dp"
|
||||
android:layout_marginHorizontal="28dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/vp_food_banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/food_banner_item" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cv_food_banner"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:cardBackgroundColor="@android:color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
app:layout_constraintDimensionRatio="345:194"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/vp_food_banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout="@layout/food_banner_item" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_food_categories"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:paddingStart="28dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="18dp"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
android:scrollbars="none"
|
||||
@@ -75,9 +86,11 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginHorizontal="28dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -92,30 +105,35 @@
|
||||
android:id="@+id/tv_food_category_see_all"
|
||||
style="@style/FoodSeeAll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:drawableEnd="@mipmap/icon_food_see_all"
|
||||
android:drawablePadding="5dp"
|
||||
android:text="@string/food_see_all" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_food_breakfast"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="128dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:paddingStart="28dp"
|
||||
android:paddingEnd="18dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:scrollbars="none"
|
||||
tools:itemCount="4"
|
||||
tools:listitem="@layout/food_breakfast_item"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="14dp"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
android:scrollbars="none"
|
||||
android:nestedScrollingEnabled="false"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/food_breakfast_item" />
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginHorizontal="28dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -130,24 +148,23 @@
|
||||
android:id="@+id/tv_food_recommend_see_all"
|
||||
style="@style/FoodSeeAll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="32dp"
|
||||
android:drawableEnd="@mipmap/icon_food_see_all"
|
||||
android:drawablePadding="5dp"
|
||||
android:text="@string/food_see_all" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Each grid cell includes 6dp on either side, giving a 12dp column gap. -->
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_food_recommend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="22dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:spanCount="2"
|
||||
tools:itemCount="4"
|
||||
tools:listitem="@layout/food_recommend_item" />
|
||||
tools:listitem="@layout/food_recommend_item"
|
||||
android:layout_marginHorizontal="18.5dp" />
|
||||
</com.ckkj.griddle.custom.view.AdaptiveContentLayout>
|
||||
</FrameLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<item
|
||||
android:id="@+id/navigation_shop"
|
||||
android:icon="@drawable/bottom_shop_select"
|
||||
android:title="@string/shop_tab_title"
|
||||
android:title="美食"
|
||||
android:visible="true"/>
|
||||
<item
|
||||
android:id="@+id/navigation_fate"
|
||||
|
||||
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 261 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 502 B |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_home_add_device.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_home_notifications.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 316 B |
@@ -1,20 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="device_preview_title">Smart Electric Griddle</string>
|
||||
<string name="device_preview_name">Kitchen Electric Griddle</string>
|
||||
<string name="device_preview_name">Kitchen Electric Pancake Maker</string>
|
||||
<string name="device_preview_power_label">Current Power</string>
|
||||
<string name="device_preview_temperature_label">Current Temperature</string>
|
||||
<string name="device_preview_carbon_title">Carbon Reduction Today</string>
|
||||
<string name="device_preview_electricity_label">Today\'s Electricity Usage</string>
|
||||
<string name="device_preview_electricity_label">Electricity Consumption:</string>
|
||||
<string name="device_preview_usage_time_label">Usage Time:</string>
|
||||
<string name="device_preview_total_electricity_label">Total Electricity Usage</string>
|
||||
<string name="device_preview_total_time_label">Total Usage Time</string>
|
||||
<string name="device_preview_power_switch">On/off</string>
|
||||
<string name="device_preview_back">Back</string>
|
||||
<string name="device_preview_demo_usage_time">1.3 hours</string>
|
||||
<string name="device_preview_demo_total_time">48.5 hours</string>
|
||||
<string name="device_preview_money_label">Money Saved Today</string>
|
||||
<string name="device_preview_carbon_label">Today\'s Carbon Reduction</string>
|
||||
<string name="device_preview_points_label">My Points</string>
|
||||
<string name="device_preview_equivalent">Total Reduction = 32 Trees</string>
|
||||
<string name="device_preview_equivalent">Total Reduction ≈ 32 Trees</string>
|
||||
<string name="device_preview_savings_title">Today\'s Savings</string>
|
||||
<string name="device_preview_charcoal_label">Charcoal Saved</string>
|
||||
<string name="device_preview_saving_label">Electricity Saved</string>
|
||||
<string name="device_preview_actions_title">Quick Actions</string>
|
||||
<string name="device_preview_stats">Stats</string>
|
||||
<string name="device_preview_control">Device Control</string>
|
||||
<string name="device_preview_carbon_points">Carbon Points</string>
|
||||
<string name="device_preview_carbon_points">Points History</string>
|
||||
</resources>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<string name="food_category_drinks">Drinks</string>
|
||||
<string name="food_category_snack">Snack</string>
|
||||
<string name="food_recommend">Recommend</string>
|
||||
<string name="food_see_all">See all ›</string>
|
||||
<string name="food_see_all">See all</string>
|
||||
<string name="shop_tab_title">Shop</string>
|
||||
<string name="food_banner_doro_title">Doro Wat</string>
|
||||
<string name="food_banner_doro_subtitle">Ethiopia\'s national dish</string>
|
||||
|
||||
@@ -6,24 +6,32 @@
|
||||
<string name="device_preview_power_label">当前功率</string>
|
||||
<string name="device_preview_temperature_label">当前温度</string>
|
||||
<string name="device_preview_carbon_title">今日碳减排</string>
|
||||
<string name="device_preview_electricity_label">今日用电量</string>
|
||||
<string name="device_preview_electricity_label">用电量:</string>
|
||||
<string name="device_preview_usage_time_label">使用时长:</string>
|
||||
<string name="device_preview_total_electricity_label">累计用电量</string>
|
||||
<string name="device_preview_total_time_label">累计使用时长</string>
|
||||
<string name="device_preview_power_switch">开关</string>
|
||||
<string name="device_preview_back">返回</string>
|
||||
<string name="device_preview_money_label">今日节省金额</string>
|
||||
<string name="device_preview_carbon_label">今日碳减排量</string>
|
||||
<string name="device_preview_points_label">我的积分</string>
|
||||
<string name="device_preview_equivalent">累计减排相当于32棵树</string>
|
||||
<string name="device_preview_equivalent">累计减排 ≈ 32棵树</string>
|
||||
<string name="device_preview_savings_title">今日节省</string>
|
||||
<string name="device_preview_charcoal_label">节省木炭</string>
|
||||
<string name="device_preview_saving_label">节省电费</string>
|
||||
<string name="device_preview_actions_title">快捷操作</string>
|
||||
<string name="device_preview_stats">统计数据</string>
|
||||
<string name="device_preview_control">设备控制</string>
|
||||
<string name="device_preview_carbon_points">碳积分</string>
|
||||
<string name="device_preview_demo_power" translatable="false">1200w</string>
|
||||
<string name="device_preview_carbon_points">积分记录</string>
|
||||
<string name="device_preview_demo_power" translatable="false">1200W</string>
|
||||
<string name="device_preview_demo_temperature" translatable="false">180°C</string>
|
||||
<string name="device_preview_demo_electricity" translatable="false">8.8 Mwh</string>
|
||||
<string name="device_preview_demo_electricity" translatable="false">8.6 kWh</string>
|
||||
<string name="device_preview_demo_usage_time">1.3 小时</string>
|
||||
<string name="device_preview_demo_total_time">48.5 小时</string>
|
||||
<string name="device_preview_demo_total_electricity" translatable="false">128.6 kWh</string>
|
||||
<string name="device_preview_demo_money" translatable="false">¥ 6.90</string>
|
||||
<string name="device_preview_demo_carbon" translatable="false">12.8 kg CO₂e</string>
|
||||
<string name="device_preview_demo_points" translatable="false">2,860</string>
|
||||
<string name="device_preview_demo_points" translatable="false">2,845</string>
|
||||
<string name="device_preview_demo_charcoal" translatable="false">15.5 kg</string>
|
||||
<string name="device_preview_demo_saving" translatable="false">¥6.9</string>
|
||||
</resources>
|
||||
|
||||
@@ -2,28 +2,37 @@
|
||||
<resources>
|
||||
<color name="device_preview_background">#F9F9F9</color>
|
||||
<color name="device_preview_muted">#A9B1BD</color>
|
||||
<color name="device_preview_page_background">#F5F5F5</color>
|
||||
|
||||
<style name="DevicePreviewText" parent="DeviceHomeText">
|
||||
<item name="android:textColor">#222222</item>
|
||||
<item name="android:fontFamily">sans-serif</item>
|
||||
<item name="android:includeFontPadding">false</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
</style>
|
||||
<style name="DevicePreviewHeading" parent="DevicePreviewText">
|
||||
<item name="android:textSize">14.5sp</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
<style name="DevicePreviewLabel" parent="DevicePreviewText">
|
||||
<item name="android:textColor">@color/device_preview_muted</item>
|
||||
<item name="android:textSize">10sp</item>
|
||||
<item name="android:textColor">#666666</item>
|
||||
<item name="android:textSize">12sp</item>
|
||||
</style>
|
||||
<style name="DevicePreviewValue" parent="DevicePreviewText">
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
<style name="DevicePreviewSmallHeading" parent="DevicePreviewHeading">
|
||||
<item name="android:textSize">13sp</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="DevicePreviewAction" parent="DevicePreviewText">
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
</style>
|
||||
<style name="DevicePreviewDeviceName" parent="DevicePreviewHeading">
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
<style name="DevicePreviewRealtime" parent="DevicePreviewValue">
|
||||
<item name="android:textSize">24sp</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -1,37 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style
|
||||
name="FoodTitle"
|
||||
parent="LoginDesignText">
|
||||
<item
|
||||
name="android:textColor">#252529</item>
|
||||
<item
|
||||
name="android:textSize">17sp</item>
|
||||
<item
|
||||
name="android:textStyle">bold</item>
|
||||
<color name="food_page_background">#F5F5F5</color>
|
||||
<color name="food_text">#222222</color>
|
||||
|
||||
<style name="FoodTitle" parent="LoginDesignText">
|
||||
<item name="android:textColor">@color/food_text</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
<style
|
||||
name="FoodItemName"
|
||||
parent="LoginDesignText">
|
||||
<item
|
||||
name="android:textColor">#292929</item>
|
||||
<item
|
||||
name="android:textSize">12sp</item>
|
||||
|
||||
<!-- 文案自然显示一至两行,不能固定高度,否则大字体下会被裁切。 -->
|
||||
<style name="FoodItemName" parent="LoginDesignText">
|
||||
<item name="android:textColor">@color/food_text</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
<item name="android:gravity">start|center_vertical</item>
|
||||
<item name="android:breakStrategy">simple</item>
|
||||
<item name="android:hyphenationFrequency">none</item>
|
||||
</style>
|
||||
<style
|
||||
name="FoodSeeAll"
|
||||
parent="LoginDesignText">
|
||||
<item
|
||||
name="android:textColor">@color/device_home_orange</item>
|
||||
<item
|
||||
name="android:textSize">12sp</item>
|
||||
<item
|
||||
name="android:gravity">center</item>
|
||||
<item
|
||||
name="android:clickable">true</item>
|
||||
<item
|
||||
name="android:focusable">true</item>
|
||||
<item
|
||||
name="android:background">?attr/selectableItemBackground</item>
|
||||
|
||||
<style name="FoodSeeAll" parent="LoginDesignText">
|
||||
<item name="android:textColor">@color/device_home_orange</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:clickable">true</item>
|
||||
<item name="android:focusable">true</item>
|
||||
<item name="android:background">?attr/selectableItemBackground</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -357,7 +357,7 @@
|
||||
<string name="food_category_drinks">饮品</string>
|
||||
<string name="food_category_snack">小吃</string>
|
||||
<string name="food_recommend">推荐</string>
|
||||
<string name="food_see_all">查看全部 ›</string>
|
||||
<string name="food_see_all">查看全部</string>
|
||||
<string name="shop_tab_title">商城</string>
|
||||
<string name="food_banner_doro_title">Doro Wat</string>
|
||||
<string name="food_banner_doro_subtitle">埃塞俄比亚传统美食</string>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ckkj.griddle.shop.entity;
|
||||
package com.ckkj.griddle.food.entity;
|
||||
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.google.gson.Gson;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.ckkj.griddle.shop.mvp;
|
||||
package com.ckkj.griddle.food.mvp;
|
||||
|
||||
import com.ckkj.griddle.network.BaseBean;
|
||||
import com.ckkj.griddle.shop.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.shop.entity.ShopGoodsPageEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopBannerEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopCategoryEntity;
|
||||
import com.ckkj.griddle.food.entity.ShopGoodsPageEntity;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||