Compare commits
7 Commits
Branch_6fd
...
master
Author | SHA1 | Date |
---|---|---|
|
8f60fa3580 | 2 years ago |
|
78b601e556 | 2 years ago |
|
a0a887fcd1 | 2 years ago |
|
5e0fee5014 | 2 years ago |
|
043ad47498 | 2 years ago |
|
23c1e18041 | 2 years ago |
|
3193f079ec | 2 years ago |
@ -1,2 +0,0 @@
|
||||
include ':app'
|
||||
rootProject.name='OrangeSale_05'
|
@ -0,0 +1 @@
|
||||
ShoppingCart
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="http://maven.aliyun.com/nexus/content/repositories/jcenter" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven2" />
|
||||
<option name="name" value="maven2" />
|
||||
<option name="url" value="https://jitpack.io" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,27 @@
|
||||
package com.llw.cart;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("com.llw.cart", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.llw.cart.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.llw.cart.bean.CarResponse;
|
||||
import com.llw.cart.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品适配器
|
||||
*
|
||||
* @author llw
|
||||
*/
|
||||
public class GoodsAdapter extends BaseQuickAdapter<CarResponse.OrderDataBean.CartlistBean, BaseViewHolder> {
|
||||
|
||||
public GoodsAdapter(int layoutResId, @Nullable List<CarResponse.OrderDataBean.CartlistBean> data) {
|
||||
super(layoutResId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, CarResponse.OrderDataBean.CartlistBean item) {
|
||||
helper.setText(R.id.tv_good_name, item.getProductName())
|
||||
.setText(R.id.tv_good_color, item.getColor())
|
||||
.setText(R.id.tv_good_size, item.getSize())
|
||||
.setText(R.id.tv_goods_price, item.getPrice() + "")
|
||||
.setText(R.id.tv_goods_num, item.getCount() + "");
|
||||
ImageView goodImg = helper.getView(R.id.iv_goods);
|
||||
Glide.with(mContext).load(item.getDefaultPic()).into(goodImg);
|
||||
|
||||
ImageView checkedGoods = helper.getView(R.id.iv_checked_goods);
|
||||
//判断商品是否选中
|
||||
if (item.isChecked()) {
|
||||
checkedGoods.setImageDrawable(mContext.getDrawable(R.drawable.ic_checked));
|
||||
} else {
|
||||
checkedGoods.setImageDrawable(mContext.getDrawable(R.drawable.ic_check));
|
||||
}
|
||||
//添加点击事件
|
||||
helper.addOnClickListener(R.id.iv_checked_goods)//选中商品
|
||||
.addOnClickListener(R.id.tv_increase_goods_num)//增加商品
|
||||
.addOnClickListener(R.id.tv_reduce_goods_num);//减少商品
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
package com.llw.cart.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车返回数据
|
||||
* @author llw
|
||||
*/
|
||||
public class CarResponse {
|
||||
|
||||
|
||||
/**
|
||||
* code : 200
|
||||
* orderData : [{"shopId":1,"shopName":"京东自营","cartlist":[{"id":1,"shopId":1,"shopName":"京东自营","defaultPic":"https://img30.360buyimg.com/popWareDetail/jfs/t3208/194/7616404169/244198/369625db/58b7d093N03520fb7.jpg","productId":1,"productName":"三只松鼠_零食大礼包","color":"黑色","size":"18L","price":20,"count":1},{"id":2,"shopId":1,"shopName":"京东自营","defaultPic":"https://img14.360buyimg.com/n0/jfs/t2971/15/167732091/93002/204c1016/574d9d9aNe4e6fa7a.jpg","productId":2,"productName":"小米心跳手环","color":"白色","size":"20XXL","price":148,"count":1}]},{"shopId":2,"shopName":"海澜之家","cartlist":[{"id":1,"shopId":2,"shopName":"海澜之家","defaultPic":"https://img30.360buyimg.com/popWaterMark/jfs/t4075/83/1343091204/132469/9034cb9c/5873496bN68020ba8.jpg","productId":1,"productName":"短袖T恤男 2017夏季新品","color":"蓝色","size":"30X","price":181,"count":1}]},{"shopId":3,"shopName":"OPPO官方旗舰店","cartlist":[{"id":1,"shopId":3,"shopName":"OPPO官方旗舰店","defaultPic":"https://img10.360buyimg.com/cms/jfs/t6064/272/2163314583/157700/442d6477/593c1c49N7c63a7d9.jpg","productId":1,"productName":"OPPO R11 全网通","color":"蓝色","size":"30X","price":1999,"count":1},{"id":2,"shopId":3,"shopName":"OPPO官方旗舰店","defaultPic":"https://img14.360buyimg.com/n0/jfs/t3142/194/4953241722/254855/1651c2b1/585b9021Nf653e48a.jpg","productId":1,"productName":"OPPO R9 全网通","color":"蓝色","size":"30X","price":999,"count":1}]}]
|
||||
*/
|
||||
|
||||
|
||||
private int code;
|
||||
private List<OrderDataBean> orderData;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public List<OrderDataBean> getOrderData() {
|
||||
return orderData;
|
||||
}
|
||||
|
||||
public void setOrderData(List<OrderDataBean> orderData) {
|
||||
this.orderData = orderData;
|
||||
}
|
||||
|
||||
public static class OrderDataBean {
|
||||
/**
|
||||
* shopId : 1
|
||||
* shopName : 京东自营
|
||||
* cartlist : [{"id":1,"shopId":1,"shopName":"京东自营","defaultPic":"https://img30.360buyimg.com/popWareDetail/jfs/t3208/194/7616404169/244198/369625db/58b7d093N03520fb7.jpg","productId":1,"productName":"三只松鼠_零食大礼包","color":"黑色","size":"18L","price":20,"count":1},{"id":2,"shopId":1,"shopName":"京东自营","defaultPic":"https://img14.360buyimg.com/n0/jfs/t2971/15/167732091/93002/204c1016/574d9d9aNe4e6fa7a.jpg","productId":2,"productName":"小米心跳手环","color":"白色","size":"20XXL","price":148,"count":1}]
|
||||
*/
|
||||
|
||||
private int shopId;
|
||||
private String shopName;
|
||||
private List<CartlistBean> cartlist;
|
||||
private boolean isChecked;//店铺是否选中
|
||||
|
||||
public int getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(int shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public List<CartlistBean> getCartlist() {
|
||||
return cartlist;
|
||||
}
|
||||
|
||||
public void setCartlist(List<CartlistBean> cartlist) {
|
||||
this.cartlist = cartlist;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
isChecked = checked;
|
||||
}
|
||||
|
||||
public static class CartlistBean {
|
||||
/**
|
||||
* id : 1
|
||||
* shopId : 1
|
||||
* shopName : 京东自营
|
||||
* defaultPic : https://img30.360buyimg.com/popWareDetail/jfs/t3208/194/7616404169/244198/369625db/58b7d093N03520fb7.jpg
|
||||
* productId : 1
|
||||
* productName : 三只松鼠_零食大礼包
|
||||
* color : 黑色
|
||||
* size : 18L
|
||||
* price : 20
|
||||
* count : 1
|
||||
*/
|
||||
|
||||
private int id;
|
||||
private int shopId;
|
||||
private String shopName;
|
||||
private String defaultPic;
|
||||
private int productId;
|
||||
private String productName;
|
||||
private String color;
|
||||
private String size;
|
||||
private int price;
|
||||
private int count;
|
||||
private boolean isChecked;//商品是否选中
|
||||
|
||||
public boolean isChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
isChecked = checked;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(int shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getDefaultPic() {
|
||||
return defaultPic;
|
||||
}
|
||||
|
||||
public void setDefaultPic(String defaultPic) {
|
||||
this.defaultPic = defaultPic;
|
||||
}
|
||||
|
||||
public int getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(int productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(int price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.llw.cart.util;
|
||||
|
||||
/**
|
||||
* 常量
|
||||
* @author llw
|
||||
*/
|
||||
public class Constant {
|
||||
|
||||
public static final String CAR_JSON = "{ \"code\" : 200 ,\n" +
|
||||
" \"orderData\" : [\n" +
|
||||
" {\n" +
|
||||
"\n" +
|
||||
" \"shopId\": 1,\n" +
|
||||
" \"shopName\":\"水果拼盘\",\n" +
|
||||
" \"cartlist\": [\n" +
|
||||
" {\n" +
|
||||
" \"id\": 1,\n" +
|
||||
" \"shopId\": 1,\n" +
|
||||
" \"shopName\": \"水果拼盘\",\n" +
|
||||
" \"defaultPic\": \"https://tse1-mm.cn.bing.net/th/id/OIP-C.vJftgCb8g6v_gSHsD5HGNgHaE8?w=280&h=187&c=7&r=0&o=5&pid=1.7\",\n" +
|
||||
" \"productId\": 1,\n" +
|
||||
" \"productName\": \"优质新鲜水果\",\n" +
|
||||
" \"color\": \"\",\n" +
|
||||
" \"size\": \"\",\n" +
|
||||
" \"price\": 25,\n" +
|
||||
" \"count\":1\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"id\": 2,\n" +
|
||||
" \"shopId\": 1,\n" +
|
||||
" \"shopName\": \"\",\n" +
|
||||
" \"defaultPic\": \"https://tse4-mm.cn.bing.net/th/id/OIP-C.L32QENiAMoSmmqLf1Ks2BgHaFS?w=288&h=206&c=7&r=0&o=5&pid=1.7\",\n" +
|
||||
" \"productId\": 2,\n" +
|
||||
" \"productName\": \"花彩拼盘\",\n" +
|
||||
" \"color\": \"\",\n" +
|
||||
" \"size\": \"\",\n" +
|
||||
" \"price\": 16,\n" +
|
||||
" \"count\": 1\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
" ,\n" +
|
||||
" {\n" +
|
||||
" \"shopId\": 2,\n" +
|
||||
" \"shopName\":\"水果奶茶\",\n" +
|
||||
" \"cartlist\": [\n" +
|
||||
" {\n" +
|
||||
" \"id\": 1,\n" +
|
||||
" \"shopId\": 2,\n" +
|
||||
" \"shopName\": \"水果奶茶\",\n" +
|
||||
" \"defaultPic\": \"https://tse4-mm.cn.bing.net/th/id/OIP-C.THBnn4_4YiWfbtKTlzdZawHaLG?w=199&h=298&c=7&r=0&o=5&pid=1.7\",\n" +
|
||||
" \"productId\": 1,\n" +
|
||||
" \"productName\": \"青柠芒果\",\n" +
|
||||
" \"color\": \"\",\n" +
|
||||
" \"size\": \"\",\n" +
|
||||
" \"price\": 15,\n" +
|
||||
" \"count\":1\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
" ,\n" +
|
||||
" {\n" +
|
||||
" \"shopId\": 3,\n" +
|
||||
" \"shopName\":\"水果蛋糕\",\n" +
|
||||
" \"cartlist\": [\n" +
|
||||
" {\n" +
|
||||
" \"id\": 1,\n" +
|
||||
" \"shopId\": 3,\n" +
|
||||
" \"shopName\": \"水果蛋糕\",\n" +
|
||||
" \"defaultPic\": \"https://tse1-mm.cn.bing.net/th/id/OIP-C.-MylYp2cdCyNM5ijjLQqSwHaHa?w=192&h=191&c=7&r=0&o=5&pid=1.7\",\n" +
|
||||
" \"productId\": 1,\n" +
|
||||
" \"productName\": \"多彩水果拼盘蛋糕\",\n" +
|
||||
" \"color\": \"\",\n" +
|
||||
" \"size\": \"\",\n" +
|
||||
" \"price\": 50,\n" +
|
||||
" \"count\":1\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"id\": 2,\n" +
|
||||
" \"shopId\": 3,\n" +
|
||||
" \"shopName\": \"水果蛋糕\",\n" +
|
||||
" \"defaultPic\": \"https://tse1-mm.cn.bing.net/th/id/OIP-C.GFSAz_9r7WIXWpGCo72K3AHaGv?w=218&h=199&c=7&r=0&o=5&pid=1.7\",\n" +
|
||||
" \"productId\": 1,\n" +
|
||||
" \"productName\": \"心动情人草莓蛋糕\",\n" +
|
||||
" \"color\": \"\",\n" +
|
||||
" \"size\": \"\",\n" +
|
||||
" \"price\": 68,\n" +
|
||||
" \"count\":1\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.llw.cart.util;
|
||||
|
||||
|
||||
/**
|
||||
* 商品回调接口
|
||||
* @author llw
|
||||
*/
|
||||
public interface GoodsCallback {
|
||||
|
||||
/**
|
||||
* 选中店铺
|
||||
* @param shopId 店铺id
|
||||
* @param state 是否选中
|
||||
*/
|
||||
void checkedStore(int shopId,boolean state);
|
||||
|
||||
/**
|
||||
* 计算价格
|
||||
*/
|
||||
void calculationPrice();
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke android:color="#000"
|
||||
android:width="0.5dp"/>
|
||||
</shape>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke android:color="#000"
|
||||
android:width="0.5dp"/>
|
||||
<corners android:topRightRadius="4dp"
|
||||
android:bottomRightRadius="4dp" />
|
||||
</shape>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke android:color="#000"
|
||||
android:width="0.5dp"/>
|
||||
<corners android:topLeftRadius="4dp"
|
||||
android:bottomLeftRadius="4dp" />
|
||||
</shape>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="20dp"/>
|
||||
<gradient
|
||||
android:startColor="#FF5C13"
|
||||
android:endColor="#FC7D0B"
|
||||
android:angle="90" />
|
||||
</shape>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFF"/>
|
||||
<corners android:radius="8dp"/>
|
||||
</shape>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M12,22.5c-5.79,0 -10.5,-4.71 -10.5,-10.5S6.21,1.5 12,1.5 22.5,6.21 22.5,12 17.79,22.5 12,22.5zM12,3c-4.963,0 -9,4.037 -9,9s4.037,9 9,9 9,-4.037 9,-9S16.963,3 12,3z"
|
||||
android:fillColor="#a9b7b7"/>
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#eb4f38"
|
||||
android:pathData="M12,1.546c-5.764,0 -10.454,4.69 -10.454,10.454 0,5.765 4.689,10.454 10.454,10.454S22.454,17.765 22.454,12C22.454,6.236 17.765,1.546 12,1.546zM17.044,10.276 L11.039,16.346c-0.001,0.001 -0.005,0.002 -0.006,0.005 -0.002,0.001 -0.002,0.005 -0.005,0.006 -0.048,0.046 -0.107,0.075 -0.163,0.107 -0.028,0.016 -0.05,0.04 -0.08,0.051 -0.09,0.036 -0.185,0.055 -0.28,0.055 -0.096,0 -0.193,-0.019 -0.284,-0.056 -0.03,-0.013 -0.054,-0.038 -0.082,-0.054 -0.056,-0.031 -0.113,-0.059 -0.161,-0.107 -0.001,-0.001 -0.002,-0.005 -0.004,-0.006 -0.001,-0.002 -0.005,-0.002 -0.006,-0.005l-2.954,-3.035c-0.289,-0.297 -0.282,-0.772 0.015,-1.061 0.297,-0.288 0.771,-0.283 1.061,0.015l2.42,2.487 5.467,-5.527c0.291,-0.295 0.767,-0.298 1.061,-0.006C17.333,9.506 17.335,9.981 17.044,10.276z" />
|
||||
</vector>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:tint="#616161"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M7,18c-1.1,0 -1.99,0.9 -1.99,2S5.9,22 7,22s2,-0.9 2,-2 -0.9,-2 -2,-2zM1,3c0,0.55 0.45,1 1,1h1l3.6,7.59 -1.35,2.44C4.52,15.37 5.48,17 7,17h11c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L7,15l1.1,-2h7.45c0.75,0 1.41,-0.41 1.75,-1.03l3.58,-6.49c0.37,-0.66 -0.11,-1.48 -0.87,-1.48L5.21,4l-0.67,-1.43c-0.16,-0.35 -0.52,-0.57 -0.9,-0.57L2,2c-0.55,0 -1,0.45 -1,1zM17,18c-1.1,0 -1.99,0.9 -1.99,2s0.89,2 1.99,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" />
|
||||
</vector>
|
After Width: | Height: | Size: 238 KiB |
@ -0,0 +1,204 @@
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<!--顶部-->
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="#FFF">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="购物车"
|
||||
android:textColor="#000"
|
||||
android:textSize="18sp" />
|
||||
<!--编辑-->
|
||||
<TextView
|
||||
android:id="@+id/tv_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginRight="12dp"
|
||||
android:padding="@dimen/dp_4"
|
||||
android:text="编辑"
|
||||
android:textColor="#000"
|
||||
android:textSize="16sp" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<!--下拉刷新区域-->
|
||||
<com.scwang.smartrefresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/lay_bottom"
|
||||
android:layout_below="@+id/toolbar"
|
||||
app:srlAccentColor="#000"
|
||||
app:srlPrimaryColor="#00000000">
|
||||
<!--刷新头部样式-->
|
||||
<com.scwang.smartrefresh.header.StoreHouseHeader
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:shhText="SHOPPING CART" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<!--列表-->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_store"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="12dp" />
|
||||
<!--购物车为空时显示-->
|
||||
<LinearLayout
|
||||
android:id="@+id/lay_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:src="@drawable/ic_shopping_cart" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="空空如也~" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="下拉可以增加数据喔~" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
|
||||
|
||||
<!--底部-->
|
||||
<RelativeLayout
|
||||
android:id="@+id/lay_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#FFF"
|
||||
android:paddingLeft="12dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_checked_all"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="12dp"
|
||||
android:src="@drawable/ic_check" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_checked_all"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toRightOf="@+id/iv_checked_all"
|
||||
android:text="全选"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/tv_total"
|
||||
android:text="合计:"
|
||||
android:textColor="#000"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_total"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_toLeftOf="@+id/tv_settlement"
|
||||
android:text="¥0"
|
||||
android:textColor="#DF3B0D"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!--结算-->
|
||||
<TextView
|
||||
android:id="@+id/tv_settlement"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:background="@drawable/bg_settlement"
|
||||
android:gravity="center"
|
||||
android:text="结算"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<!--点击编辑时出现底部布局-->
|
||||
<LinearLayout
|
||||
android:id="@+id/lay_edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_toRightOf="@+id/tv_checked_all"
|
||||
android:background="#FFF"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_share_goods"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.3"
|
||||
android:background="#f4c600"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:text="分享宝贝"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_collect_goods"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_weight="0.3"
|
||||
android:background="#ea8010"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:text="移到收藏夹"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_delete_goods"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_weight="0.3"
|
||||
android:background="#eb4f38"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:text="删除"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
<!--选中商品-->
|
||||
<ImageView
|
||||
android:id="@+id/iv_checked_goods"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="12dp"
|
||||
android:src="@drawable/ic_check" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp">
|
||||
<!--商品图片-->
|
||||
<ImageView
|
||||
android:id="@+id/iv_goods"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_good_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/iv_goods"
|
||||
android:text="商品名"
|
||||
android:textColor="#000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_good_color"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_good_name"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_toRightOf="@+id/iv_goods"
|
||||
android:text="商品颜色"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_good_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/tv_good_name"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_toRightOf="@+id/tv_good_color"
|
||||
android:text="商品尺寸"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_goods_price"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_toRightOf="@+id/iv_goods"
|
||||
android:lines="1"
|
||||
android:text="¥100000.00"
|
||||
android:textColor="#DF550B"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!--改变商品数量-->
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_reduce_goods_num"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:background="@drawable/bg_reduce_goods_num"
|
||||
android:gravity="center"
|
||||
android:text="—"
|
||||
android:textColor="#000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_goods_num"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="-0.5dp"
|
||||
android:layout_marginRight="-0.5dp"
|
||||
android:layout_toRightOf="@+id/tv_reduce_goods_num"
|
||||
android:background="@drawable/bg_goods_num"
|
||||
android:gravity="center"
|
||||
android:text="1"
|
||||
android:textColor="#000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_increase_goods_num"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_toRightOf="@+id/tv_goods_num"
|
||||
android:background="@drawable/bg_increase_goods_num"
|
||||
android:gravity="center"
|
||||
android:text="+"
|
||||
android:textColor="#000"
|
||||
android:textSize="16sp" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:background="@drawable/bg_white_8"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:gravity="center_vertical">
|
||||
<!--选中店铺-->
|
||||
<ImageView
|
||||
android:id="@+id/iv_checked_store"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="12dp"
|
||||
android:src="@drawable/ic_check" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_store_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="店铺名"
|
||||
android:textColor="#000"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<!--店铺商品列表-->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_goods"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#FFF</color>
|
||||
<color name="colorPrimaryDark">#FFF</color>
|
||||
<color name="colorAccent">#D81B60</color>
|
||||
</resources>
|
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">ShoppingCart</string>
|
||||
</resources>
|
@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true" />
|
||||
</network-security-config>
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_05;
|
||||
package com.llw.cart;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -0,0 +1,28 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://jitpack.io" }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
#Mon Dec 07 09:36:35 CST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
@ -0,0 +1,2 @@
|
||||
include ':app'
|
||||
rootProject.name='ShoppingCart'
|
@ -0,0 +1,76 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
import com.google.android.material.slider.RangeSlider;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CategoryActivity extends Activity {
|
||||
public RangeSlider.OnChangeListener onchangeListener
|
||||
private List<Product>productList;
|
||||
private List<String>productCategory = new ArrayList<>();
|
||||
private ListView titleList;
|
||||
private MyAdapter adapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.content_category);
|
||||
initData();
|
||||
init();
|
||||
setDetailFragment fragment = new SetDetailFragment();
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
transaction.replace(R.id.category_detail,fragment);
|
||||
transaction.commit();
|
||||
titleList.setOnItemClickListener((parent,view,position,id) - >{
|
||||
adapter.setSelectedPosition(position);
|
||||
adapter.notifyDataSetInvalidated();
|
||||
if (onchangeListener!=null) {
|
||||
onchangeListener.changeText(productList.get(position));
|
||||
}
|
||||
});
|
||||
}
|
||||
public void setOnChangeListener(OnChangeListener onChangeListener){
|
||||
this.onchangeListener=onChangeListener;
|
||||
}
|
||||
public interface OnChageListener{
|
||||
void changeText(Product product);
|
||||
}
|
||||
private void initData(){
|
||||
productList=new ArrayList<>();
|
||||
productCategory.add("橘子");
|
||||
productCategory.add("橙子");
|
||||
productCategory.add("柚子");
|
||||
Product product=new Product();
|
||||
product.setImageUrlId(R.drawable.juzi);
|
||||
product.setProductName("橘子");
|
||||
product.setProductPrice(new BigDecimal("9.9"));
|
||||
Product product1=new Product();
|
||||
product.setImageUrlId(R.drawable.chengzi);
|
||||
product.setProductName("橙子");
|
||||
product.setProductPrice(new BigDecimal("29.9"));
|
||||
Product product2=new Product();
|
||||
product.setImageUrlId(R.drawable.youzi);
|
||||
product.setProductName("柚子");
|
||||
product.setProductPrice(new BigDecimal("19.9"));
|
||||
productList.add(product);
|
||||
productList.add(product1);
|
||||
productList.add(product2);
|
||||
}
|
||||
private void init(){
|
||||
titleList=findViewById(R.id.category_title_list);
|
||||
adapter=new MyAdapter(productCategory,CategoryActivity.this);
|
||||
titleList.setAdapter(adapter);
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MyAdapter extends BaseAdapter {
|
||||
private List<String>productCategory;
|
||||
private LayoutInflater layoutInflater;
|
||||
private int selectionPosition=-1;
|
||||
|
||||
public MyAdapter(List<String>productCategory, Context context){
|
||||
this.productCategory=productCategory;
|
||||
this.layoutInflater=LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount(){
|
||||
return productCategory.size();
|
||||
}
|
||||
@Override
|
||||
public Object getItem(int position){
|
||||
return productCategory.get(position);
|
||||
}
|
||||
@Override
|
||||
public long getItemId(int position){
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int position,View convertView,ViewGroup parent){
|
||||
ViewHolder viewHolder =null;
|
||||
if(convertView==null){
|
||||
viewHolder=new ViewHolder();
|
||||
convertView=layoutInflater.inflate(R.layout.category_detail_item,null);
|
||||
Log.i("adapts","getView:"+convertView);
|
||||
viewHolder.tv=convertView.findViewById(R.id.categor_titles);
|
||||
convertView.setTag(viewHolder);
|
||||
}else{
|
||||
viewHolder=(ViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.tv.setText(productCategory.get(position));
|
||||
if(selectionPosition==position){
|
||||
viewHolder.tv.setBackgroundColor(Color.YELLOW);
|
||||
}else {
|
||||
viewHolder.tv.setBackgroundColor(Color.WHITE);
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
public void setSelectedPosition(int position){
|
||||
this.selectionPosition=position;
|
||||
}
|
||||
class ViewHolder{
|
||||
TextView tv;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class SetDetailFragment extends Fragment {
|
||||
private View view;
|
||||
private ImageView imageView;
|
||||
private TextView nameText,priceText;
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState){
|
||||
view=inflater.inflate(R.layout.category_detail_content,container,false);
|
||||
if(view!=null){
|
||||
init();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 2.4 KiB |
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:id="@+id/category_product_image"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="90dp"
|
||||
android:layout_gravity="center" />
|
||||
<TextView
|
||||
android:id="@+id/category_product_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="#050505"
|
||||
android:text="666"
|
||||
android:textSize="16sp"/>
|
||||
<TextView
|
||||
android:id="@+id/category_product_price"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="2dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#050505"
|
||||
android:text="777"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/categor_titles"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textSize="18sp"
|
||||
android:text="标题"/>
|
||||
</LinearLayout>
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#E8E8E8"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:background="#EFB81C"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/category_return"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/jt2" />
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="商品种类"
|
||||
android:textColor="#FFF"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<ListView
|
||||
android:id="@+id/category_title_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent" />
|
||||
<FrameLayout
|
||||
android:id="@+id/category_detail"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="3"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,14 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1 @@
|
||||
Fruitparty
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
/build
|
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_05;
|
||||
package com.example.Fruitparty;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.Fruitparty">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name="com.example.Fruitparty.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.example.Fruitparty.activity.RegisterActivity"></activity>
|
||||
<activity android:name="com.example.Fruitparty.activity.UserActivity" />
|
||||
<activity android:name="com.example.Fruitparty.activity.CategoryActivity" />
|
||||
<activity android:name="com.example.Fruitparty.activity.IndexActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_05.dataoperation;
|
||||
package com.example.Fruitparty.dataoperation;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_05.entity;
|
||||
package com.example.Fruitparty.entity;
|
||||
|
||||
public class OrangeUser {
|
||||
private Integer id;
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_05.entity;
|
||||
package com.example.Fruitparty.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -0,0 +1,107 @@
|
||||
package com.example.Fruitparty.fragment;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.GridView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SearchView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.example.Fruitparty.R;
|
||||
import com.example.Fruitparty.adapter.ProductAdapter;
|
||||
import com.example.Fruitparty.entity.Product;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IndexFragment extends Fragment implements View.OnClickListener {
|
||||
private SearchView searchView;
|
||||
private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine;
|
||||
private GridView gridView;
|
||||
private List<Product> productList;
|
||||
private ProductAdapter productAdapter;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_index, container, false);
|
||||
init(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化组件
|
||||
*/
|
||||
private void init(View view) {
|
||||
searchView = view.findViewById(R.id.searchView);
|
||||
searchView.setOnClickListener(this);
|
||||
orangeLine = view.findViewById(R.id.chengzi);
|
||||
orangeLine.setOnClickListener(this);
|
||||
youziLine = view.findViewById(R.id.youzi);
|
||||
youziLine.setOnClickListener(this);
|
||||
juziLine = view.findViewById(R.id.juzi);
|
||||
juziLine.setOnClickListener(this);
|
||||
|
||||
liLine = view.findViewById(R.id.li);
|
||||
liLine.setOnClickListener(this);
|
||||
lemonLine = view.findViewById(R.id.lemon);
|
||||
lemonLine.setOnClickListener(this);
|
||||
|
||||
appleLine = view.findViewById(R.id.apple);
|
||||
appleLine.setOnClickListener(this);
|
||||
gridView = view.findViewById(R.id.index_famous_gridview);
|
||||
initData();
|
||||
productAdapter = new ProductAdapter(getActivity(), productList);
|
||||
gridView.setAdapter(productAdapter);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化商品数据
|
||||
*/
|
||||
private void initData() {
|
||||
productList = new ArrayList<>();
|
||||
Product product = new Product();
|
||||
product.setImageUrlId(R.drawable.water2);
|
||||
product.setProductName("珍珠果茶");
|
||||
product.setProductPrice(new BigDecimal("9.9"));
|
||||
Product product1 = new Product();
|
||||
product1.setImageUrlId(R.drawable.apple2);
|
||||
product1.setProductName("苹果");
|
||||
product1.setProductPrice(new BigDecimal("5.9"));
|
||||
Product product2 = new Product();
|
||||
product2.setImageUrlId(R.drawable.red2);
|
||||
product2.setProductName("火龙果");
|
||||
product2.setProductPrice(new BigDecimal("7.9"));
|
||||
Product product3 = new Product();
|
||||
product3.setImageUrlId(R.drawable.a);
|
||||
product3.setProductName("果盘A");
|
||||
product3.setProductPrice(new BigDecimal("9.9"));
|
||||
Product product4 = new Product();
|
||||
product4.setImageUrlId(R.drawable.b);
|
||||
product4.setProductName("果盘B");
|
||||
product4.setProductPrice(new BigDecimal("9.9"));
|
||||
Product product5 = new Product();
|
||||
product5.setImageUrlId(R.drawable.c);
|
||||
product5.setProductName("果盘C");
|
||||
product5.setProductPrice(new BigDecimal("9.9"));
|
||||
productList.add(product);
|
||||
productList.add(product1);
|
||||
productList.add(product2);
|
||||
productList.add(product3);
|
||||
productList.add(product4);
|
||||
productList.add(product5);
|
||||
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 12 KiB |