소스 검색

主界面订单啊

master
NXX 1 년 전
부모
커밋
359ceba9fe
22개의 변경된 파일310개의 추가작업 그리고 29개의 파일을 삭제
  1. +1
    -1
      .idea/misc.xml
  2. +2
    -0
      app/src/main/java/com/example/bpa/MainActivity.java
  3. +1
    -0
      app/src/main/java/com/example/bpa/app/Main.java
  4. +41
    -1
      app/src/main/java/com/example/bpa/config/DataBus.java
  5. +16
    -0
      app/src/main/java/com/example/bpa/db/QueryDB.java
  6. +94
    -0
      app/src/main/java/com/example/bpa/view/adapter/maingoods_adapter.java
  7. +21
    -4
      app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java
  8. +9
    -0
      app/src/main/java/com/example/bpa/view/mode/mainGoods.java
  9. +7
    -0
      app/src/main/res/drawable/btn_ripple_good.xml
  10. +7
    -0
      app/src/main/res/drawable/ripple_goods.xml
  11. +43
    -23
      app/src/main/res/layout/from/layout/fragment_home.xml
  12. +68
    -0
      app/src/main/res/layout/item/layout/maingoods.xml
  13. BIN
     
  14. BIN
     
  15. BIN
     
  16. BIN
     
  17. BIN
     
  18. BIN
     
  19. BIN
     
  20. BIN
     
  21. BIN
     
  22. BIN
     

+ 1
- 1
.idea/misc.xml 파일 보기

@@ -1,7 +1,7 @@
<?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">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">


+ 2
- 0
app/src/main/java/com/example/bpa/MainActivity.java 파일 보기

@@ -14,6 +14,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.example.bpa.config.ConfigName;
import com.example.bpa.config.DataBus;
import com.example.bpa.view.fragment.CloudFragment;
import com.example.bpa.view.fragment.HeplerFragment;
import com.example.bpa.view.fragment.HomeFragment;
@@ -71,6 +72,7 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen
clist_title.setText(ConfigName.getInstance().Shop_Name);
//ShowFragment(homeFragment,"系统主页");
ShowFragment(systemCapabilitiesFragment,"功能菜单");
DataBus.getInstance().UpdateMainGoods();
}
/**
* 初始化按钮事件


+ 1
- 0
app/src/main/java/com/example/bpa/app/Main.java 파일 보기

@@ -2,6 +2,7 @@ package com.example.bpa.app;


import com.example.bpa.config.ConfigName;
import com.example.bpa.config.DataBus;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_SYSTEMSET;
import com.example.bpa.db.mode.BPA_USER;


+ 41
- 1
app/src/main/java/com/example/bpa/config/DataBus.java 파일 보기

@@ -1,5 +1,15 @@
package com.example.bpa.config;

import com.example.bpa.R;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.view.mode.mainGoods;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* 单例模式
* 数据中心
@@ -8,7 +18,13 @@ public class DataBus {
//region 单例模式
private static DataBus mInstance; //实例变量设置私有,防止直接通过类名访问

private DataBus() { //默认构造函数私有,防止类外直接new创建对象
private DataBus() {
//默认构造函数私有,防止类外直接new创建对象
//测试添加图片
good_picMap.put(0, R.mipmap.milktea_1);
good_picMap.put(1, R.mipmap.milktea_2);
good_picMap.put(2,R.mipmap.milktea_3);
good_picMap.put(3,R.mipmap.milktea_4);
}

public static synchronized DataBus getInstance() { //静态同步方法作为唯一的实例对象获取方式
@@ -20,6 +36,30 @@ public class DataBus {
//endregion

//region 数据中心
/**
* 主界面商品列表
*/
public List<mainGoods> mainGoods = new ArrayList<mainGoods>();

public Map<Integer,Integer> good_picMap = new HashMap<Integer,Integer>();

/**
* 更新商品主界面商品列表
*/
public void UpdateMainGoods(){
mainGoods.clear();
ArrayList<BPA_GOODS> res = QueryDB.GetGoodsStateALL();
if (res.size()>0){
for (BPA_GOODS good:res){
mainGoods newgood = new mainGoods();
newgood.id = good.id;
newgood.name = good.name;
newgood.message = "";
mainGoods.add(newgood);
}
}

}

//endregion
}

+ 16
- 0
app/src/main/java/com/example/bpa/db/QueryDB.java 파일 보기

@@ -526,6 +526,22 @@ public class QueryDB {
}
return data;
}
/**
* 获取所有启用的商品
*
* @return
*/
public static ArrayList<BPA_GOODS> GetGoodsStateALL() {
String orderby = Desc_Sort_Up + ',' + Desc_Time_Up;//先按排序 创建时间倒序
String where = "isDelete=? and status=?";
String[] args = new String[]{"0","1"};
ArrayList<BPA_GOODS> data = new ArrayList<>();
ArrayList<Object> obj = Get(BPA_GOODS.class, where, args, orderby);
for (Object k : obj) {
data.add((BPA_GOODS) k);
}
return data;
}

/**
* 判断商品数据是否存在


+ 94
- 0
app/src/main/java/com/example/bpa/view/adapter/maingoods_adapter.java 파일 보기

@@ -0,0 +1,94 @@
package com.example.bpa.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.bpa.R;
import com.example.bpa.app.BusinessServer;
import com.example.bpa.config.DataBus;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.helper.T;
import com.example.bpa.view.mode.mainGoods;

import java.util.List;
import java.util.Random;

public class maingoods_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

private final LayoutInflater mLayoutInflater;

private Context context;

List<mainGoods> mainGoods = DataBus.getInstance().mainGoods;

public maingoods_adapter(Context context) {
this.context = context;
mLayoutInflater = LayoutInflater.from(context);
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View inflate = mLayoutInflater.inflate(R.layout.maingoods, parent, false);
return new maingoods_adapter.MyLCViewHolder(inflate);

}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
try {
if (holder instanceof maingoods_adapter.MyLCViewHolder) {
maingoods_adapter.MyLCViewHolder myViewHolder = (maingoods_adapter.MyLCViewHolder) holder;
myViewHolder.goodname.setText(mainGoods.get(position).name);
myViewHolder.id = mainGoods.get(position).id;
int num = (int) new Random().nextInt(DataBus.getInstance().good_picMap.size());//随机商品图片
myViewHolder.good_pic.setImageResource(DataBus.getInstance().good_picMap.get(num));
}
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public int getItemCount() {
return mainGoods.size();
}

public static class MyLCViewHolder extends RecyclerView.ViewHolder {
TextView goodname;

Button goodmake;

ImageView good_pic;

public String id;


public MyLCViewHolder(View view) {
super(view);
goodname = (TextView) view.findViewById(R.id.goodname);
goodmake = (Button) view.findViewById(R.id.goodmake);
good_pic = (ImageView)view.findViewById(R.id.good_pic);
goodmake.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
BusinessServer.get().AddCommodity(id);
T.show(view.getContext(),"开始制作商品:"+goodname.getText().toString());
}

});

}


}
}

+ 21
- 4
app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java 파일 보기

@@ -4,6 +4,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
@@ -15,11 +17,14 @@ import android.widget.ListView;

import com.example.bpa.R;
import com.example.bpa.app.BusinessServer;
import com.example.bpa.config.DataBus;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.helper.Json;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.maingoods_adapter;
import com.example.bpa.view.adapter.sp_adapter;
import com.example.bpa.view.control.MyLayoutManager;
import com.example.bpa.view.from.add_pf_activity;
import com.example.bpa.view.from.yfpf_activity;
import com.example.bpa.view.inteface.MyClickListener;
@@ -32,6 +37,10 @@ import java.util.ArrayList;
public class HomeFragment extends Fragment implements View.OnClickListener, MyClickListener {

//region 变量
/**
* 商品列表
*/
RecyclerView good_recyclerView;
/**
* 界面实例
*/
@@ -61,7 +70,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
* 初始化
*/
private void Init(){
datatab= view.findViewById(R.id.datatab);
// datatab= view.findViewById(R.id.datatab);
good_recyclerView = view.findViewById(R.id.good_recyclerView);
Initdata();//初始化数据
RegisterMessage();//消息中心事件接收
}
@@ -77,9 +87,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
public void Initdata()
{
try{
bpa_goods= QueryDB.GetGoodsALL();
sp_adapter adapter = new sp_adapter(view.getContext(), R.layout.sp_item, bpa_goods,this);
datatab.setAdapter(adapter);
MyLayoutManager layout = new MyLayoutManager();
layout.setAutoMeasureEnabled(true);
good_recyclerView.setLayoutManager(layout);

maingoods_adapter goodadapter = new maingoods_adapter( getContext());
good_recyclerView.setAdapter(goodadapter);
DataBus.getInstance().UpdateMainGoods();//更新商品
// bpa_goods= QueryDB.GetGoodsALL();
// sp_adapter adapter = new sp_adapter(view.getContext(), R.layout.sp_item, bpa_goods,this);
// datatab.setAdapter(adapter);
}catch(Exception e){

}


+ 9
- 0
app/src/main/java/com/example/bpa/view/mode/mainGoods.java 파일 보기

@@ -0,0 +1,9 @@
package com.example.bpa.view.mode;

public class mainGoods {
public String id;

public String name;

public String message;
}

+ 7
- 0
app/src/main/res/drawable/btn_ripple_good.xml 파일 보기

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

+ 7
- 0
app/src/main/res/drawable/ripple_goods.xml 파일 보기

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#E5514E"
>
<item android:drawable="@drawable/btn_ripple_good"/>

</ripple>

+ 43
- 23
app/src/main/res/layout/from/layout/fragment_home.xml 파일 보기

@@ -1,6 +1,5 @@
<?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"
@@ -10,32 +9,53 @@
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp">
<RelativeLayout
android:layout_width="260dp"
android:layout_height="400dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:src="@mipmap/rqbk">
</ImageView>
</RelativeLayout>
android:layout_marginBottom="20dp"
android:orientation="vertical">

<RelativeLayout
android:layout_width="260dp"
android:layout_marginLeft="20dp"
android:layout_height="400dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/good_recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:src="@mipmap/rqbk">
</ImageView>
android:layout_height="wrap_content"
android:scrollbarStyle="outsideOverlay"
>
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
<!-- <RelativeLayout-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_weight="1"-->
<!-- android:layout_margin="10dp">-->

<!-- </RelativeLayout>-->
<!-- <RelativeLayout-->
<!-- android:layout_width="260dp"-->
<!-- android:layout_height="400dp">-->

<!-- <ImageView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:scaleType="fitXY"-->
<!-- android:src="@mipmap/rqbk"></ImageView>-->
<!-- </RelativeLayout>-->

<!-- <RelativeLayout-->
<!-- android:layout_width="260dp"-->
<!-- android:layout_marginLeft="20dp"-->
<!-- android:layout_height="400dp">-->
<!-- <ImageView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_centerInParent="true"-->
<!-- android:scaleType="fitXY"-->
<!-- android:src="@mipmap/rqbk">-->
<!-- </ImageView>-->
<!-- </RelativeLayout>-->

</LinearLayout>
</RelativeLayout>

+ 68
- 0
app/src/main/res/layout/item/layout/maingoods.xml 파일 보기

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="180dp"
android:layout_height="130dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg_f3"
android:layout_margin="10dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<ImageView
android:id="@+id/good_pic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:adjustViewBounds="true"
android:alpha="0.8"
android:scaleType="centerCrop"
android:src="@mipmap/milktea_1" />
<RelativeLayout
android:layout_margin="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg_text1">

<TextView
android:id="@+id/goodname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="22dp"
android:text="原味奶茶"
android:textColor="@color/white"
android:textSize="14dp"
android:textStyle="bold"
android:typeface="serif" />

<Button
android:id="@+id/goodmake"
android:layout_width="100dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="18dp"
android:layout_marginBottom="23dp"
android:textColor="@color/white"
android:background="@drawable/ripple_goods"
android:text="make" />
</RelativeLayout>





</RelativeLayout>


</LinearLayout>
</LinearLayout>











불러오는 중...
취소
저장