You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
5.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.example.test.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.test.R;
import com.example.test.entity.fruitContent;
import com.example.test.entity.fruitKind;
import java.util.ArrayList;
import java.util.List;
public class fruitFragment extends AppCompatActivity {
private String kinds[] = {"超值必抢","鲜果上新","店家推荐","柑桔橙柚","蜜瓜/西瓜","葡萄/提子","热带水果","梨/苹果"};
private int imgs[] ={R.drawable.hot,R.drawable.fresh,R.drawable.recomend};
private int fruit_imgs[][] = {{R.drawable.grapefruit,R.drawable.hamimelon,R.drawable.watermelon},
{R.drawable.grapefruit1,R.drawable.leechee,R.drawable.carambola},
{R.drawable.pineapple,R.drawable.pear,R.drawable.apple},
{R.drawable.orange1,R.drawable.grapefruit,R.drawable.grapefruit1,R.drawable.grapefruit2},
{R.drawable.watermelon,R.drawable.watermelon1,R.drawable.hamimelon,R.drawable.hamimelon1},
{R.drawable.grape,R.drawable.greengrape, R.drawable.grape1},
{R.drawable.coconut,R.drawable.banana,R.drawable.pineapple,R.drawable.carambola,R.drawable.leechee},
{R.drawable.apple,R.drawable.pear,R.drawable.pear1,R.drawable.apple1}};
private String fruit_names[][] = {{"红心西柚 泡水榨汁茶饮佳选","冰淇淋网纹蜜瓜 一口软糯香甜","海南麒麟瓜粒约3KG~4KG"},
{"广西正宗容县沙田柚子新鲜水果白","妃子笑荔枝","福州漳州甜杨桃!只卖书上熟果"},
{"菲律宾凤梨1粒装1KG","正宗烟台红富士苹果|24小时速发","陕西贡梨400g"},
{"江西赣南精选血橙4粒装720g","红心西柚 泡水榨汁茶饮佳选","广西正宗容县沙田柚子新鲜水果白","红心蜜柚10斤新鲜水果应季大红肉柚子"},
{"海南麒麟瓜粒约3KG~4KG","现摘冰糖麒麟大西瓜","冰淇淋网纹蜜瓜 一口软糯香甜","新疆哈密瓜脆甜多汁保熟包甜"},
{"云南夏黑葡萄新鲜采摘无籽葡萄","阳光玫瑰葡萄新鲜水果!现摘!","云南下黑葡萄顺丰冷链新鲜直达"},
{"泰国椰青700g","广西芭蕉酸牛蕉牛角蕉新鲜香蕉","菲律宾凤梨1粒装1KG","福州漳州甜杨桃!只卖书上熟果","妃子笑荔枝"},
{"正宗烟台红富士苹果|24小时速发","陕西贡梨400g","红香酥梨新鲜水果当季整箱","冰糖心苹果 精选好果 脆甜多汁!"}};
private String fruit_descs[][] = {{"皮薄肉厚汁多颗粒饱满","香甜软糯,水分很足","香甜可口,丰富多汁"},
{"个大纯天然,价廉物美","荔枝特别棒,肉厚核小","果子新鲜果肉纤维细腻"},
{"果子新鲜果肉纤维细腻","栖霞苹果|中国大陆|红富士","鲜甜可口,汁多美味"},
{"酸甜可口,一口爆汁","皮薄肉厚汁多颗粒饱满","个大纯天然,价廉物美","核小肉厚,水分足"},
{"香甜可口,丰富多汁","水分足足的,皮薄薄的","香甜软糯,水分很足","往嘴里咬一口满嘴留香"},
{"中国大陆|食用农产品|黑夏","中国大陆|散装","中国大陆|包装|黑夏"},
{"新鲜可口 汁多味美","甜度浓郁","香水菠萝","果子新鲜果肉纤维细腻","荔枝特别棒,肉厚核小"},
{"栖霞苹果|中国大陆|红富士","鲜甜可口,汁多美味","清香爽口甜,果汁充足","烟台苹果|中国大陆|一级"}};
private double fruit_prices[][] = {{16.8,15.3,21.8},
{15.7,22.4,5.8},
{10.8,15.3,20.4},
{24.9,11.5,16.7,13.8},
{21.7,24.6,21.8,25.9},
{21.9,15.3,17.6},
{15.7,10.6,12.9,10.5,20.6},
{24.9,21.2,19.9,24.6}};
private int fruit_tag[][]={{0,1,0},
{1,0,0},
{0,0,0},
{1,0,0,1},
{1,0,1,0},
{0,0,1},
{1,1,0,0,0},
{0,0,1,1}};
private List<fruitContent[]> fruitContents = new ArrayList<>();
public List<fruitContent[]> getFruitContents() {
return fruitContents;
}
List<fruitKind> fruitKinds=new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
initFruitContents();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fruit_fragment);
}
protected void initFruitContents() {
for (int i = 0; i < fruit_imgs.length; i++) {
int len = fruit_imgs[i].length;
fruitContent arr[] = new fruitContent[len];
for (int j = 0; j < arr.length; j++) {
fruitContent f = new fruitContent(fruit_imgs[i][j],fruit_names[i][j],fruit_descs[i][j],fruit_tag[i][j],fruit_prices[i][j]);
arr[j]=f;
}
fruitContents.add(arr);
}
}
public List<fruitKind> getfuritKinds() {
fruitKind f;
for (int i = 0; i < kinds.length; i++) {
if(i<3){
f = new fruitKind(kinds[i], imgs[i]);
}
else {
f = new fruitKind(kinds[i], 0);
}
fruitKinds.add(f);
}
return fruitKinds;
}
}