@@ -7,10 +7,18 @@ import android.widget.Toast; | |||
* 自定义打印吐司函数 | |||
*/ | |||
public class T { | |||
/** | |||
* 信息通知+吐司弹窗 | |||
* @param context | |||
* @param str | |||
*/ | |||
public static void show(Context context, String str){ | |||
//Toast.makeText(context, str, (int)0).show(); | |||
ToastUtil.showToast(str); | |||
Log.i(context.getPackageName(),str); | |||
} | |||
} | |||
@@ -42,6 +42,7 @@ public class sp_adapter extends ArrayAdapter<BPA_GOODS> { | |||
//分别获取 image view 和 textview 的实例 | |||
TextView name = view.findViewById(R.id.name); | |||
TextView sort = view.findViewById(R.id.sort); | |||
TextView status = view.findViewById(R.id.status); | |||
TextView time = view.findViewById(R.id.time); | |||
Button button = view.findViewById(R.id.button_item); | |||
@@ -49,11 +50,14 @@ public class sp_adapter extends ArrayAdapter<BPA_GOODS> { | |||
Button button_down = view.findViewById(R.id.button_item_Down); | |||
Button button_update = view.findViewById(R.id.button_item_update); | |||
Button button_xf = view.findViewById(R.id.button_xf); | |||
Button button_qy = view.findViewById(R.id.button_qy); | |||
Button button_jy = view.findViewById(R.id.button_jy); | |||
// 设置要显示的图片和文字 | |||
name.setText(bpa_goods.name); | |||
time.setText(bpa_goods.createTime); | |||
sort.setText(bpa_goods.sort+""); | |||
status.setText(bpa_goods.status==1?"启用":"禁用"); | |||
button.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
@@ -114,6 +118,31 @@ public class sp_adapter extends ArrayAdapter<BPA_GOODS> { | |||
} | |||
} | |||
}); | |||
button_qy.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
try | |||
{ | |||
mListener.clickListener(view,bpa_goods); | |||
} catch (Exception e) | |||
{ | |||
T.show(view.getContext(),"商品启用出错:"+e.getMessage()); | |||
} | |||
} | |||
}); | |||
button_jy.setOnClickListener(new View.OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
try | |||
{ | |||
mListener.clickListener(view,bpa_goods); | |||
} catch (Exception e) | |||
{ | |||
T.show(view.getContext(),"商品禁用出错:"+e.getMessage()); | |||
} | |||
} | |||
}); | |||
return view; | |||
} | |||
} |
@@ -5,22 +5,121 @@ import androidx.annotation.Nullable; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import androidx.fragment.app.Fragment; | |||
import android.content.Intent; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.ListView; | |||
import com.example.bpa.R; | |||
import com.example.bpa.app.BusinessServer; | |||
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.sp_adapter; | |||
import com.example.bpa.view.from.add_pf_activity; | |||
import com.example.bpa.view.from.yfpf_activity; | |||
import com.example.bpa.view.inteface.MyClickListener; | |||
import java.util.ArrayList; | |||
/** | |||
* 主页界面 | |||
*/ | |||
public class HomeFragment extends Fragment { | |||
public class HomeFragment extends Fragment implements View.OnClickListener, MyClickListener { | |||
//region 变量 | |||
/** | |||
* 界面实例 | |||
*/ | |||
public View view; | |||
/** | |||
* 表格显示 | |||
*/ | |||
public ListView datatab; | |||
/** | |||
* 商品数据 | |||
*/ | |||
public ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>(); | |||
//endregion | |||
//region 私有函数 | |||
@Nullable | |||
@Override | |||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||
View view = inflater.inflate(R.layout.fragment_home, container,false); | |||
view = inflater.inflate(R.layout.fragment_home, container,false); | |||
Init(); | |||
return view; | |||
} | |||
//endregion | |||
//region 公共函数 | |||
/** | |||
* 初始化 | |||
*/ | |||
private void Init(){ | |||
datatab= view.findViewById(R.id.datatab); | |||
Initdata();//初始化数据 | |||
RegisterMessage();//消息中心事件接收 | |||
} | |||
/** | |||
* 初始化按钮事件 | |||
*/ | |||
private void initEvents() { | |||
} | |||
/** | |||
* 初始化数据加载 | |||
*/ | |||
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); | |||
}catch(Exception e){ | |||
} | |||
} | |||
//endregion | |||
//region 点击事件 | |||
/** | |||
* 本页面点击事件监听22 | |||
* | |||
* @param v | |||
*/ | |||
@Override | |||
public void onClick(View v) { | |||
switch (v.getId()) { | |||
case R.id.buttonaddpf://新建配方 | |||
break; | |||
} | |||
} | |||
/** | |||
* 接口方法,响应ListView按钮点击事件 | |||
*/ | |||
@Override | |||
public void clickListener(View v,Object data) { | |||
switch (v.getId()) | |||
{ | |||
case R.id.button_item://删除按钮 | |||
break; | |||
} | |||
} | |||
//endregion | |||
//region 接收事件 | |||
public void RegisterMessage() | |||
{ | |||
} | |||
//endregion | |||
} |
@@ -204,7 +204,7 @@ public class add_pf_activity extends AppCompatActivity implements View.OnClickLi | |||
BPA_GOODS goodx = new BPA_GOODS(); | |||
goodx.name = name; | |||
goodx.sort = bpa_goods.size() + 1; | |||
goodx.status = 1; | |||
goodx.status = 0; | |||
goodx.deviceID = ConfigName.getInstance().DeviceId; | |||
goodx.userID = ConfigName.getInstance().user.userID; | |||
QueryDB.AddGoods(goodx); | |||
@@ -179,6 +179,20 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList | |||
BusinessServer.get().AddCommodity(((BPA_GOODS)data).id); | |||
T.show(this, "下发成功!"); | |||
break; | |||
case R.id.button_qy://启用按钮 | |||
BPA_GOODS good3=(BPA_GOODS)data; | |||
good3.status=1; | |||
QueryDB.UpdateGoods(good3); | |||
Initdata(); | |||
T.show(this, good3.name+"-启用成功!"); | |||
break; | |||
case R.id.button_jy://下发按钮 | |||
BPA_GOODS good4=(BPA_GOODS)data; | |||
good4.status=0; | |||
QueryDB.UpdateGoods(good4); | |||
Initdata(); | |||
T.show(this, good4.name+"-禁用成功!"); | |||
break; | |||
} | |||
} | |||
//endregion | |||
@@ -18,7 +18,7 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_weight="1"> | |||
android:layout_weight="2"> | |||
<TextView | |||
android:id="@+id/name" | |||
android:layout_width="wrap_content" | |||
@@ -33,7 +33,7 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_weight="1"> | |||
android:layout_weight="2"> | |||
<TextView | |||
android:id="@+id/time" | |||
android:layout_width="wrap_content" | |||
@@ -48,7 +48,7 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_weight="1"> | |||
android:layout_weight="0.5"> | |||
<TextView | |||
android:id="@+id/sort" | |||
android:layout_width="wrap_content" | |||
@@ -63,7 +63,22 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_weight="2.3"> | |||
android:layout_weight="0.5"> | |||
<TextView | |||
android:id="@+id/status" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:layout_alignParentLeft="true" | |||
android:text="回锅肉" | |||
android:textColor="@color/foreground" | |||
android:textSize="@dimen/textSize" /> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="match_parent" | |||
android:layout_weight="5"> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
@@ -75,7 +90,7 @@ | |||
android:textColor="@color/foreground" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:layout_width="60dp" | |||
android:layout_width="40dp" | |||
android:layout_height="26dp" | |||
/> | |||
<Button | |||
@@ -86,7 +101,7 @@ | |||
android:textColor="@color/foreground" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:layout_width="60dp" | |||
android:layout_width="40dp" | |||
android:layout_height="26dp" | |||
/> | |||
<Button | |||
@@ -97,7 +112,7 @@ | |||
android:textColor="@color/foreground" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:layout_width="60dp" | |||
android:layout_width="40dp" | |||
android:layout_height="26dp" | |||
/> | |||
<Button | |||
@@ -108,12 +123,34 @@ | |||
android:textColor="@color/foreground" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:layout_width="60dp" | |||
android:layout_width="40dp" | |||
android:layout_height="26dp" | |||
/> | |||
<Button | |||
android:id="@+id/button_qy" | |||
android:text="启用" | |||
android:background="@drawable/btn_button" | |||
android:textSize="@dimen/textSize" | |||
android:textColor="@color/foreground" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:layout_width="40dp" | |||
android:layout_height="26dp" | |||
/> | |||
<Button | |||
android:id="@+id/button_jy" | |||
android:text="禁用" | |||
android:background="@drawable/btn_button" | |||
android:textSize="@dimen/textSize" | |||
android:textColor="@color/foreground" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:layout_width="40dp" | |||
android:layout_height="26dp" | |||
/> | |||
<Button | |||
android:id="@+id/button_xf" | |||
android:text="下发制作" | |||
android:text="模拟订单" | |||
android:background="@drawable/btn_button" | |||
android:textSize="@dimen/textSize" | |||
android:textColor="@color/foreground" | |||
@@ -141,7 +141,7 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1"> | |||
android:layout_weight="2"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
@@ -154,7 +154,7 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1"> | |||
android:layout_weight="2"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
@@ -167,7 +167,7 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="1"> | |||
android:layout_weight="0.5"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
@@ -180,7 +180,20 @@ | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="2"> | |||
android:layout_weight="0.5"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="20dp" | |||
android:layout_alignParentLeft="true" | |||
android:text="状态" | |||
android:textColor="@color/dataGridColumnHeaderColor" | |||
android:textSize="@dimen/textSize" /> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_width="0dp" | |||
android:layout_height="wrap_content" | |||
android:layout_weight="5"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
@@ -190,7 +203,6 @@ | |||
android:textColor="@color/dataGridColumnHeaderColor" | |||
android:textSize="@dimen/textSize" /> | |||
</RelativeLayout> | |||
</TableRow> | |||
</TableLayout> | |||
</RelativeLayout> | |||