|
|
@@ -9,6 +9,8 @@ import androidx.annotation.Nullable; |
|
|
|
import androidx.fragment.app.Fragment; |
|
|
|
import androidx.core.content.ContextCompat; |
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
|
|
|
|
import android.os.CountDownTimer; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.ImageView; |
|
|
@@ -17,8 +19,12 @@ import android.widget.RelativeLayout; |
|
|
|
import com.bonait.bnframework.R; |
|
|
|
import com.bonait.bnframework.common.base.BaseFragment; |
|
|
|
import com.bonait.bnframework.common.constant.DataBus; |
|
|
|
import com.bonait.bnframework.common.db.QueryDB; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_GOODS; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; |
|
|
|
import com.bonait.bnframework.common.helper.I.IThread; |
|
|
|
import com.bonait.bnframework.common.helper.I.MyClickListener; |
|
|
|
import com.bonait.bnframework.common.helper.ThreadManager; |
|
|
|
import com.bonait.bnframework.common.utils.AlertDialogUtils; |
|
|
|
import com.bonait.bnframework.common.utils.ToastUtils; |
|
|
|
import com.bonait.bnframework.common.view.MyLayoutManager; |
|
|
@@ -32,6 +38,10 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialog; |
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; |
|
|
|
import com.qmuiteam.qmui.widget.textview.QMUILinkTextView; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import butterknife.BindView; |
|
|
|
import butterknife.ButterKnife; |
|
|
|
import butterknife.OnClick; |
|
|
@@ -57,7 +67,10 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
@BindView(R.id.startbutton) |
|
|
|
ImageView startbutton;//启动安 |
|
|
|
public boolean Status=false; |
|
|
|
|
|
|
|
/** |
|
|
|
* 当前制作商品信息 |
|
|
|
*/ |
|
|
|
BPA_GOODS good=null; |
|
|
|
private Context context; |
|
|
|
|
|
|
|
public Home1Fragment() { |
|
|
@@ -109,8 +122,6 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
|
|
|
|
DataBus.getInstance().lcadapter = new lc_adapter( getContext()); |
|
|
|
recyclerView.setAdapter(DataBus.getInstance().lcadapter); |
|
|
|
|
|
|
|
|
|
|
|
}catch(Exception e){ |
|
|
|
ToastUtils.info("异常信息:"+e.getMessage()); |
|
|
|
} |
|
|
@@ -136,9 +147,9 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
DataBus.getInstance().mListener=new MyClickListener() { |
|
|
|
@Override |
|
|
|
public void clickListener(View v, Object data) { |
|
|
|
BPA_GOODS good=(BPA_GOODS)data; |
|
|
|
good=(BPA_GOODS)data; |
|
|
|
caipumingcheng.setText(good.name); |
|
|
|
shengyushijian.setText("预计剩余时间:300s"); |
|
|
|
shengyushijian.setText("预计剩余时间:"+good.maketime+"s"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@@ -149,6 +160,45 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 制作商品 |
|
|
|
*/ |
|
|
|
private CountDownTimer countDownTimer=null; |
|
|
|
public void MakeGood() |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
shengyushijian.setText("预计剩余时间:"+good.maketime+"s"); |
|
|
|
//获取工艺 |
|
|
|
ArrayList<BPA_GOODSRECIPE> goodsrecipes= QueryDB.GetGoodsSrecipeID(good.id); |
|
|
|
|
|
|
|
countDownTimer= new CountDownTimer(good.maketime*1000, 1000) { |
|
|
|
@Override |
|
|
|
public void onTick(long millisUntilFinished) { |
|
|
|
int ms=(int)((millisUntilFinished)/1000); |
|
|
|
int syTime=(int) (((good.maketime-ms)*100)/good.maketime); |
|
|
|
jingdu.setProgress(syTime); |
|
|
|
jingdu.setSecondProgress(syTime); |
|
|
|
shengyushijian.setText("预计剩余时间:"+ms+"s"); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onFinish() { |
|
|
|
Status=false; |
|
|
|
startbutton.setImageResource(R.mipmap.qdzz); |
|
|
|
jingdu.setProgress(0); |
|
|
|
jingdu.setSecondProgress(0); |
|
|
|
shengyushijian.setText("预计剩余时间:"+good.maketime+"s"); |
|
|
|
ToastUtils.info(good.name+",商品制作完成!"); |
|
|
|
cancel(); |
|
|
|
} |
|
|
|
}; |
|
|
|
countDownTimer.start(); |
|
|
|
}catch (Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@OnClick({R.id.xzcp,R.id.startbutton,R.id.qdjb,R.id.ztjb,R.id.tzjb |
|
|
|
,R.id.ccw,R.id.chucw,R.id.dsw,R.id.yaoqian,R.id.tingyao}) |
|
|
|
public void onViewClicked(View view) { |
|
|
@@ -168,15 +218,28 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
public void onClick(QMUIDialog dialog, int index) { |
|
|
|
startbutton.setImageResource(R.mipmap.qdzz); |
|
|
|
Status=false; |
|
|
|
ToastUtils.info("点击停止制作按钮"); |
|
|
|
jingdu.setProgress(0); |
|
|
|
jingdu.setSecondProgress(0); |
|
|
|
shengyushijian.setText("预计剩余时间:0s"); |
|
|
|
if(countDownTimer!=null) |
|
|
|
{ |
|
|
|
countDownTimer.cancel(); |
|
|
|
countDownTimer=null; |
|
|
|
} |
|
|
|
|
|
|
|
if(good!=null) |
|
|
|
{ |
|
|
|
shengyushijian.setText("预计剩余时间:"+good.maketime+"s"); |
|
|
|
jingdu.setProgress(0); |
|
|
|
jingdu.setSecondProgress(0); |
|
|
|
} |
|
|
|
dialog.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}else |
|
|
|
{ |
|
|
|
if(good==null) |
|
|
|
{ |
|
|
|
ToastUtils.info("请先选择一个商品"); |
|
|
|
return; |
|
|
|
} |
|
|
|
//按钮点击 |
|
|
|
String title = "开始操作提示!"; |
|
|
|
String message = "请问客官确定要开始制作吗,小菠萝好开心呀,马上就有好吃的耶?"; |
|
|
@@ -185,10 +248,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
public void onClick(QMUIDialog dialog, int index) { |
|
|
|
startbutton.setImageResource(R.mipmap.tzzz); |
|
|
|
Status=true; |
|
|
|
ToastUtils.info("点击启动制作按钮"); |
|
|
|
jingdu.setProgress(20); |
|
|
|
jingdu.setSecondProgress(20); |
|
|
|
shengyushijian.setText("预计剩余时间:300s"); |
|
|
|
MakeGood(); |
|
|
|
dialog.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|