Commit 0fd819b0 by Wyh

04-02 長連接接單模塊提交

parent d54a9745
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: "config.gradle"
buildscript {
ext.kotlin_version = '1.3.10'
ext.kotlin_version = '1.3.41'
repositories {
google()
......@@ -18,7 +18,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath'com.jakewharton:butterknife-gradle-plugin:10.2.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1'
classpath 'com.novoda:bintray-release:0.9.2'
classpath 'com.billy.android:cc-register:1.1.2'
......@@ -26,7 +26,7 @@ buildscript {
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
// classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8'
classpath fileTree(dir:'plugins', include:['*.jar'])
classpath fileTree(dir: 'plugins', include: ['*.jar'])
}
}
......@@ -44,8 +44,8 @@ allprojects {
maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
// 私有仓库地址
maven { url "http://lib.gcssloop.com/repository/gcssloop-central/" }
maven{ url 'https://maven.aliyun.com/repository/google' }
maven{ url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
}
}
......
package com.gingersoft.gsa.cloud.main.mvp.ui.activity;
import android.content.Intent;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
......@@ -201,24 +200,25 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
// return;
// }
List<Function> functions = new ArrayList<>();
functions.add(new Function((long) 150, 0, 5, "點餐", 0));
functions.add(new Function((long) 138, 150, 5, "餐臺模式", R.drawable.ic_dining_table_mode));
functions.add(new Function((long) 139, 150, 5, "外送模式", R.drawable.ic_delivery_mode));
functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model));
functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode));
functions.add(new Function((long) 150, 0, 5, "點餐", 0, 0));
functions.add(new Function((long) 138, 150, 5, "餐臺模式", R.drawable.ic_dining_table_mode, 0));
functions.add(new Function((long) 139, 150, 5, "外送模式", R.drawable.ic_delivery_mode, 1));
functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model, 1));
functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode, 1));
functions.add(new Function((long) 151, 0, 5, "管理", 0));
functions.add(new Function((long) 151, 0, 5, "管理", 0, 0));
// functions.add(new Function((long) 142, 151, 5, "餐牌管理", R.drawable.ic_meals_menu_management));
functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management));
functions.add(new Function((long) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management));
functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management));
functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management));
functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management));
functions.add(new Function((long) 152, 0, 5, "員工", 0));
functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management));
functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management));
functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record));
functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 142, 151, 5, "訂單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management, 1));
functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0));
functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management, 1));
functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management, 1));
functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management, 1));
functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management, 1));
functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record, 1));
//將功能列表數據分組
SparseArray<String> parents = new SparseArray<>();
SparseArray<List<Function>> funMap = new SparseArray<>();
......@@ -252,12 +252,16 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
return false;
}
});
adapter.setOnItemClickListener((adapter1, view, position) -> functionClick(mOrderingMeals.get(position).getResName()));
adapter.setOnItemClickListener((adapter1, view, position) -> functionClick(mOrderingMeals.get(position).getResName(), mOrderingMeals.get(position).getStatus()));
rvOrdering.setAdapter(adapter);
}
}
private void functionClick(String name) {
private void functionClick(String name, int status) {
if (status != 0) {
ToastUtils.show(mContext, "服務暫未開通,敬請期待");
return;
}
if (name.equals("餐臺模式")) {
CC.obtainBuilder("Component.Table")
.setActionName("showTableActivity")
......@@ -273,6 +277,11 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
.setActionName("showOrderCenterActivity")
.build()
.call();
} else if (name.equals("訂單管理")) {
CC.obtainBuilder("Component.OtherOrder")
.setActionName("orderActivity")
.build()
.call();
}
}
......@@ -314,7 +323,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
setTitleInfo();
CC.obtainBuilder("Component.Download")
.setActionName("showDownloadActivity")
.addParam("fromPage",2)
.addParam("fromPage", 2)
.build()
.call();
dialog.dismiss();
......
......@@ -102,7 +102,7 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
@Override
public void initData(@Nullable Bundle savedInstanceState) {
String startTime = TimeUtils.getOldDate(-6);
String startTime = TimeUtils.getOldDate(-2);
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime);
mTvStartTime.setText(startTime);
......
......@@ -105,7 +105,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
@Override
public void initData(@Nullable Bundle savedInstanceState) {
String startTime = TimeUtils.getOldDate(-6);
String startTime = TimeUtils.getOldDate(-2);
mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime);
mTvStartTime.setText(startTime);
mTvEndTime.setText(TimeUtils.getOldDate(0));
......
......@@ -161,7 +161,6 @@
android:layout_marginLeft="@dimen/dp_13"
android:layout_marginTop="-4dp"
android:layout_marginRight="@dimen/dp_13"
android:layout_marginBottom="@dimen/dp_10"
app:hl_cornerRadius="@dimen/dp_4"
app:hl_shadowBackColor="@color/white"
app:hl_shadowLimit="@dimen/dp_0">
......@@ -171,8 +170,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_16"
android:paddingBottom="@dimen/dp_16">
android:paddingTop="@dimen/dp_16">
<TextView
android:id="@+id/tv_function_name2"
......@@ -193,7 +191,6 @@
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_20"
android:background="#F0F0F0" />
<TextView
......@@ -210,7 +207,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout>
</com.lihang.ShadowLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
<com.gingersoft.gsa.cloud.ui.view.AutoFitTextView
android:id="@+id/tv_item1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="item1"
android:maxLines="1"
android:text="item1"
android:textColor="@color/black"
android:textSize="@dimen/settlement_report_text_size" />
android:textSize="@dimen/settlement_report_text_size"/>
<TextView
android:id="@+id/tv_item2"
......@@ -44,8 +45,8 @@
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center"
android:text="item4"
android:maxLines="1"
android:text="item4"
android:textColor="@color/black"
android:textSize="@dimen/settlement_report_text_size" />
......@@ -54,9 +55,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="marquee"
android:gravity="right"
android:text="item5"
android:ellipsize="marquee"
android:textColor="@color/black"
android:textSize="@dimen/settlement_report_text_size" />
......
......@@ -3,6 +3,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="@dimen/dp_20"
android:orientation="vertical">
<ImageView
......
......@@ -19,8 +19,14 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
includeCompileClasspath true
}
}
}
resourcePrefix "otherOrder"
buildTypes {
release {
minifyEnabled false
......
package com.gingersoft.gsa.other_order_mode
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.gingersoft.gsa.other_order_mode", appContext.packageName)
}
}
......@@ -8,13 +8,13 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_android"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".OtherOrderActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
......@@ -24,6 +24,9 @@
</activity>
<service android:name=".service.GetInfoUpdateService" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
</application>
</manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.other_order_mode">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_android"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".OtherOrderActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".service.GetInfoUpdateService" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
</application>
</manifest>
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode;
import com.billy.cc.core.component.CC;
import com.jess.arms.base.BaseApplication;
/**
* Created by Wyh on 2020/1/7.
*/
public class MyApp extends BaseApplication {
@Override
public void onCreate() {
super.onCreate();
CC.enableVerboseLog(true);
CC.enableDebug(true);
CC.enableRemoteCC(true);
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="user_register_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode
import android.animation.ValueAnimator
import android.content.ComponentName
import android.content.Context
import android.content.Intent
......@@ -8,19 +9,23 @@ import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.os.IBinder
import android.os.Looper
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.other_order_mode.databinding.ActivityOtherOrderBinding
import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService
import com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel
import com.gingersoft.gsa.other_order_mode.ui.main.SectionsPagerAdapter
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import kotlinx.android.synthetic.main.activity_other_order.*
class OtherOrderActivity : AppCompatActivity() {
private lateinit var pageViewModel: PageViewModel
......@@ -43,22 +48,46 @@ class OtherOrderActivity : AppCompatActivity() {
)
private var titls: ArrayList<TextView> = ArrayList()
private var layoutHeight: Float = 0F
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_other_order)
var binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order)
binding.switchBtn = btn_switch_restaurant_state
//開啟websocket
var intent = Intent(this, GetInfoUpdateService::class.java)
// startService(intent)
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
pageViewModel = ViewModelProvider(this, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java]
initAppTop()
//綁定營業按鈕狀態
pageViewModel.restaurantState.observe(this, Observer {
btn_switch_restaurant_state.isChecked = it
tv_restaurant_state.text = if (it) {
resources.getString(R.string.normal)
} else {
resources.getString(R.string.rest)
}
})
val sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager, ints)
val viewPager: ViewPager = findViewById(R.id.view_pager)
viewPager.adapter = sectionsPagerAdapter
viewPager.offscreenPageLimit = 4
iv_search_order.setOnClickListener {
//搜索
if (ed_order_num_search.text != null && ed_order_num_search.text.isNotEmpty()) {
pageViewModel.phone = ed_order_num_search.text.toString()
pageViewModel.getOrderList(viewPager.currentItem, "0", false) {}
} else {
ToastUtils.show(this@OtherOrderActivity, "請輸入手機號或訂單號")
}
}
tabs.setupWithViewPager(viewPager)
for (i in 0 until ints.size) {
......@@ -78,29 +107,36 @@ class OtherOrderActivity : AppCompatActivity() {
drawable.cornerRadius = 5f
mNumber.background = drawable
mNumber.text = "0"
when (i) {
0 -> pageViewModel.allOrderNum.observe(instance, Observer {
mNumber.text = it
Log.e("aaa", "接收到訂單數變化$it")
})
1 -> pageViewModel.toBeConfirmedNum.observe(instance, Observer {
mNumber.text = it
Log.e("aaa", "接收到待確認訂單數變化$it")
})
2 -> pageViewModel.makingNum.observe(instance, Observer {
mNumber.text = it
Log.e("aaa", "接收到製作中訂單數變化$it")
})
3 -> pageViewModel.inDeliveryNum.observe(instance, Observer {
mNumber.text = it
Log.e("aaa", "接收到送貨中訂單數變化$it")
})
4 -> pageViewModel.waitingForMealNum.observe(instance, Observer {
mNumber.text = it
Log.e("aaa", "接收到待取餐訂單數變化$it")
while (pageViewModel.mOrderList.size <= i) {
pageViewModel.mOrderList.add(MutableLiveData())
}
pageViewModel.mOrderList[i].observe(instance, Observer {
mNumber.text = it.size.toString()
})
}
}
//餐廳營業信息
pageViewModel.otherInfo.observe(this, Observer {
binding.data = pageViewModel
sb_takeaway.maxValue = it.MaxOrder
sb_takeaway.progress = it.num
sb_self.maxValue = it.maxOrderSelf
sb_self.progress = it.selflNum
if (it.orderType_2 != null) {
tv_takeaway_num.text = it.orderType_2!!.typeDayOrderNum.toString()
tv_takeaway_amount.text = "$" + it.orderType_2!!.typeTotalAmount.toString()
}
if (it.orderType_7 != null) {
tv_today_self_order_num.text = it.orderType_7!!.typeDayOrderNum.toString()
tv_today_self_amount_num.text = "$" + it.orderType_7!!.typeTotalAmount.toString()
}
})
cl_order_info.post {
layoutHeight = cl_order_info.height.toFloat()
}
btn_open_or_close_info.setOnClickListener {
setOrderInfoOpenOrClose()
}
}
......@@ -109,17 +145,15 @@ class OtherOrderActivity : AppCompatActivity() {
var bind: GetInfoUpdateService.MyBind = service as GetInfoUpdateService.MyBind
bind.setOnPostCallBack(object : GetInfoUpdateService.PostCallBack {
override fun callBack(type: Int) {
Log.e("aaa", "類型:$type")
//-1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知"
if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) {
Looper.prepare()
pageViewModel.refreshState.value = pageViewModel.refreshState.value?.plus(1)
Looper.loop()
//播放提示音
pageViewModel.refreshState.postValue(type)
}
}
})
}
override fun onServiceDisconnected(name: ComponentName) {
......@@ -128,6 +162,36 @@ class OtherOrderActivity : AppCompatActivity() {
}
private var isOpen: Boolean = true
private fun setOrderInfoOpenOrClose() {
btn_open_or_close_info.isClickable = false
isOpen = !isOpen
//如果是打開的,則關閉
val heightAnimation = if (isOpen)
ValueAnimator.ofFloat(0f, layoutHeight)
else
ValueAnimator.ofFloat(layoutHeight, 0f)
heightAnimation.duration = 200
heightAnimation.addUpdateListener { animation ->
val `val` = animation.animatedValue as Float
setViewHeight(cl_order_info, `val`.toInt())
btn_open_or_close_info.text =
if (isOpen) {
"點擊收起"
} else {
"點擊展開"
}
btn_open_or_close_info.isClickable = true
}
heightAnimation.start()
}
private fun setViewHeight(view: View, height: Int) {
val params = view.layoutParams
params.height = height
view.requestLayout()
}
private fun initAppTop() {
qm_other_order_bar.setTitle(R.string.app_name)
qm_other_order_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
......
package com.gingersoft.gsa.other_order_mode;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
public class OtherOrderComponent implements IComponent {
@Override
public String getName() {
//组件的名称,调用此组件的方式:
// CC.obtainBuilder("ComponentA")...build().callAsync()
return "Component.OtherOrder";
}
/**
* 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity
*
* @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
*/
@Override
public boolean onCall(CC cc) {
String actionName = cc.getActionName();
switch (actionName) {
case "getInfo":
getInfo(cc);
break;
case "getLifecycleFragment":
//demo for provide fragment object to other component
getLifecycleFragment(cc);
break;
case "lifecycleFragment.addText":
lifecycleFragmentDoubleText(cc);
break;
case "orderActivity":
CCUtil.navigateTo(cc, OtherOrderActivity.class);
break;
default:
// cc.callAsync(new IComponentCallback() {
// @Override
// public void onResult(CC cc, CCResult result) {
//
// }
// });
//这个逻辑分支上没有调用CC.sendCCResult(...),是一种错误的示例
//并且方法的返回值为false,代表不会异步调用CC.sendCCResult(...)
//在LocalCCInterceptor中将会返回错误码为-10的CCResult
break;
}
return false;
}
private void lifecycleFragmentDoubleText(CC cc) {
// LifecycleFragment lifecycleFragment = cc.getParamItem("fragment");
// if (lifecycleFragment != null) {
// String text = cc.getParamItem("text", "");
// lifecycleFragment.addText(text);
// CC.sendCCResult(cc.getCallId(), CCResult.success());
// } else {
// CC.sendCCResult(cc.getCallId(), CCResult.error("no fragment params"));
// }
}
private void getLifecycleFragment(CC cc) {
// CC.sendCCResult(cc.getCallId(), CCResult.successWithNoKey(new LifecycleFragment()));
}
private void getInfo(CC cc) {
String userName = "billy";
CC.sendCCResult(cc.getCallId(), CCResult.success("userName", userName));
}
}
......@@ -8,19 +8,29 @@ import okhttp3.FormBody
class WeatherRepository private constructor(private val network: CoolWeatherNetwork) {
suspend fun requestOrderList(status: String, type: String) = withContext(Dispatchers.IO) {
suspend fun requestOrderList(status: String, type: String, page: String, orderNo: String, phone: String) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restaurantId", "26")
.add("page", "1")
.add("page", page)
.add("status", status)
.add("orderNo", "")
.add("phone", "")
.add("orderNo", orderNo)
.add("phone", phone)
.add("type", type)
.build()
val heWeather = network.fetchOrderList(requestBody)
heWeather
}
suspend fun updateRestOpenStatus(state: Boolean) = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restId", "26")
.add("openStatus", if (state) "1" else "2")
.build()
val data = network.updateRestOpenStatus(requestBody)
data
}
companion object {
private lateinit var instance: WeatherRepository
......
package com.gingersoft.gsa.other_order_mode.data.model.bean
class MessageBean {
private var data: String? = null
get() = field
set(value) {
field = value
/**
* success : true
* sysTime : 1585723657344
* data : {"msg":"數據更新成功!","num":1}
*/
private var success: Boolean = false
private var sysTime: Long = 0
private var data: DataBean? = null
fun isSuccess(): Boolean {
return success
}
private var password: String? = null
get() = field
set(value) {
field = value
fun setSuccess(success: Boolean) {
this.success = success
}
fun getSysTime(): Long {
return sysTime
}
private var token: String? = null
get() = field
set(value) {
field = value
fun setSysTime(sysTime: Long) {
this.sysTime = sysTime
}
private var type: Int? = null
get() = field
set(value) {
field = value
fun getData(): DataBean? {
return data
}
private var username: String? = null
get() = field
set(value) {
field = value
fun setData(data: DataBean) {
this.data = data
}
class DataBean {
/**
* msg : 數據更新成功!
* num : 1
*/
var msg: String? = null
var num: Int = 0
}
}
\ No newline at end of file
......@@ -59,25 +59,32 @@ class OrderList {
* Open_Status : 1
*/
var status: Int = 0
var membeR_NAME: String? = null
var addresS_DETAIL: String? = null
var paY_AMOUNT: Double = 0.toDouble()
var phone: String? = null
var STATUS: Int = 0
var MEMBER_NAME: String? = null
var ADDRESS_DETAIL: String? = null
var PAY_AMOUNT: Double = 0.toDouble()
var PHONE: String? = null
var orderPayType: Int = 0
var ordeR_NO: String? = null
var id: Int = 0
var creatE_TIME: String? = null
var ORDER_NO: String? = null
var Id: Int = 0
var CREATE_TIME: String? = null
var takeFoodCode: String? = null
var order_type: Int = 0
var receiver: String? = null
var maxOrder: Int = 0
var RECEIVER: String? = null
var MaxOrder: Int = 0
var selflNum: Int = 0
var totalAmount: Double = 0.toDouble()
var maxOrderSelf: Int = 0
var num: Int = 0
var dayOrderNum: Int = 0
var open_Status: String? = null
var Open_Status: String? = null//1為營業中 2為休息中
var orderType_2: OrderType? = null
var orderType_7: OrderType? = null
class OrderType {
var typeTotalAmount: Double = 0.toDouble()
var typeDayOrderNum: Int = 0
}
}
}
......
package com.gingersoft.gsa.other_order_mode.data.network
import android.util.Log
import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.RequestBody
import retrofit2.Call
......@@ -13,8 +14,12 @@ class CoolWeatherNetwork {
private val orderService = ServiceCreator.create(WeatherService::class.java)
private val service = ServiceCreator.create2(WeatherService::class.java)
suspend fun fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await()
suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await()
private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation ->
enqueue(object : Callback<T> {
......
......@@ -8,7 +8,8 @@ import retrofit2.converter.scalars.ScalarsConverterFactory
object ServiceCreator {
private const val BASE_URL = "https://hktest.ricepon.com:64377/ricepon-wechat/api/"
private const val BASE_URL2 = "https://hktest.ricepon.com:64377/member-web/api/"
//https://hktest.ricepon.com:64377/member-web/api/wx/updateRestOpenStatus
private val httpClient = OkHttpClient.Builder()
private val builder = Retrofit.Builder()
......@@ -17,9 +18,19 @@ object ServiceCreator {
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
private val builder2 = Retrofit.Builder()
.baseUrl(BASE_URL2)
.client(httpClient.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
private val retrofit = builder.build()
private val retrofit2 = builder2.build()
fun <T> create(serviceClass: Class<T>): T = retrofit.create(serviceClass)
fun <T> create2(serviceClass: Class<T>): T = retrofit2.create(serviceClass)
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.data.network.api
import com.gingersoft.gsa.other_order_mode.data.model.bean.MessageBean
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import okhttp3.RequestBody
import retrofit2.Call
......@@ -11,4 +12,6 @@ interface WeatherService {
@POST("wechat/findOrderList")
fun getOrderList(@Body requestBody: RequestBody): Call<OrderList>
@POST("wx/updateRestOpenStatus")
fun updateRestOpenStatus(@Body requestBody: RequestBody): Call<MessageBean>
}
\ No newline at end of file
package com.gingersoft.gsa.other_order_mode.ui.adapter
import android.content.Context
import android.graphics.drawable.GradientDrawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Adapter
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import com.gingersoft.gsa.other_order_mode.databinding.LayoutOtherOrderItemBinding
class OtherOrdersAdapter : Adapter<OtherOrdersAdapter.ViewHolder>() {
class OtherOrdersAdapter(var context: Context) : Adapter<OtherOrdersAdapter.ViewHolder>() {
var databeans: List<OrderList.DataBeanX.DataBean>? = null
private var databeans: List<OrderList.DataBeanX.DataBean>? = null
fun setData(databeans: List<OrderList.DataBeanX.DataBean>) {
this.databeans = databeans
......@@ -24,7 +32,74 @@ class OtherOrdersAdapter : Adapter<OtherOrdersAdapter.ViewHolder>() {
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val data = this.databeans!![position]
holder.binding.data = data
var state: String? = null
val bg = GradientDrawable()
bg.cornerRadius = 10F
when {
data.STATUS == 0 -> {
state = "待確定"
bg.setColor(getColor(R.color.order_state0_color))
}
data.STATUS == 1 -> {
state = "待確定"
bg.setColor(getColor(R.color.order_state0_color))
}
data.STATUS == 2 -> {
state = "製作中"
bg.setColor(getColor(R.color.order_state1_color))
}
data.STATUS == 3 -> {
state = if (data.order_type == 7) {
"待取餐"
} else {
"送貨中"
}
bg.setColor(getColor(R.color.order_state2_color))
}
}
holder.binding.state = state
holder.binding.stateBg = bg
//堂食外賣背景
val orderingMethodBg = GradientDrawable()
orderingMethodBg.shape = GradientDrawable.OVAL
holder.binding.orderingMethod =
when {
data.order_type == 2 -> {
orderingMethodBg.setColor(getColor(R.color.order_state1_color))
"外"
}
data.order_type == 7 -> {
orderingMethodBg.setColor(getColor(R.color.self_order_bg))
"自"
}
else -> {
orderingMethodBg.setColor(getColor(R.color.order_state1_color))
"堂"
}
}
holder.binding.orderingMethodBg = orderingMethodBg
//支付方式背景 data.orderPayType==1?@color/table_send:@color/table_use
//data.orderPayType==1?@string/cash_on_delivery:@string/online_payments
val payMethodBg = GradientDrawable()
payMethodBg.cornerRadius = 10F
holder.binding.payMethod =
when {
data.orderPayType == 1 -> {
payMethodBg.setColor(getColor(R.color.cash_on_delivery_bg))
"貨到付款"
}
else -> {
payMethodBg.setColor(getColor(R.color.online_payments_bg))
"在線支付"
}
}
holder.binding.payMethodBg = payMethodBg
}
override fun getItemCount(): Int {
......@@ -35,7 +110,23 @@ class OtherOrdersAdapter : Adapter<OtherOrdersAdapter.ViewHolder>() {
}
}
fun getColor(color: Int): Int {
return context.resources.getColor(color)
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binding: LayoutOtherOrderItemBinding = DataBindingUtil.bind(itemView)!!
@BindingAdapter("imageUrl")
fun bindImageUrl(view: ImageView, imageUrl: String) {
var options: RequestOptions = RequestOptions()
.centerCrop()
.dontAnimate()
Glide.with(view)
.load(imageUrl)
.apply(options)
.into(view)
}
}
}
\ No newline at end of file
......@@ -10,112 +10,87 @@ import kotlinx.coroutines.launch
class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
companion object {
var allOrderStatus: String = "0,1,2,3"
var allOrderType: String = "0"
var toBeConfirmedStatus: String = "0,1"
var toBeConfirmedType: String = "0"
var makingStatus: String = "2"
var makingType: String = "0"
var inDeliveryStatus: String = "3"
var inDeliveryType: String = "2"
var waitingForMealStatus: String = "3"
var waitingForMealType: String = "7"
var fragmentStatus = arrayOf("0,1,2,3", "0,1", "2", "3", "3")
var fragmentType = arrayOf("0", "0", "0", "2", "7")
}
var allOrderList = MutableLiveData<List<OrderList.DataBeanX.DataBean>>()
var toBeConfirmedOrderList = MutableLiveData<List<OrderList.DataBeanX.DataBean>>()
var makingOrderList = MutableLiveData<List<OrderList.DataBeanX.DataBean>>()
var inDeliveryOrderList = MutableLiveData<List<OrderList.DataBeanX.DataBean>>()
var mOrderList = arrayListOf<MutableLiveData<ArrayList<OrderList.DataBeanX.DataBean>>>()
var waitingForMealOrderList = MutableLiveData<List<OrderList.DataBeanX.DataBean>>()
//其他的所有數據
var otherInfo = MutableLiveData<OrderList.DataBeanX.DataBean>()
//總訂單數量
var allOrderNum = MutableLiveData<String>()
//待確認訂單數量
var toBeConfirmedNum = MutableLiveData<String>()
//製作中的訂單數量
var makingNum = MutableLiveData<String>()
//送貨中的訂單數量
var inDeliveryNum = MutableLiveData<String>()
//待取餐的訂單數量
var waitingForMealNum = MutableLiveData<String>()
//營業狀態,1為營業中,2為休息中
lateinit var businessStatus: String
//外賣訂單數 100/200
lateinit var takeawayOrders: String
//自取訂單數 50/200
lateinit var pickUpOrders: String
//今日訂單總數
lateinit var todayOrderNum: String
//今日營業額
lateinit var todayTurnover: String
//刷新狀態,有數據更新就會更改這個變量,將這個變量修改為allOrderStatus...上面五種狀態,fragment中監聽這個變量,再調用接口獲取最新數據
var refreshState = MutableLiveData<Int>()
var refreshType: String = "0"
var orderList = MutableLiveData<OrderList>()
fun getOrderList(status: String, type: String, position: Int) {
Log.e("aaa", status + "請求" + type)
//訂單號
var orderNo: String = ""
//手機號
var phone: String = ""
/**
* 獲取訂單信息
*/
fun getOrderList(position: Int, page: String, isLoadMore: Boolean, listener: (String) -> Unit) {
launch({
repository.requestOrderList(status, type).apply {
repository.requestOrderList(fragmentStatus[position], fragmentType[position], page, orderNo, phone).apply {
loadInfo(listener, isLoadMore, position)
}
}, {
//出錯
})
}
Log.e("aaa", "數據:")
private fun OrderList.loadInfo(listener: (String) -> Unit, isLoadMore: Boolean, position: Int) {
listener.invoke("加載完成")
if (getData() != null && getData()?.data != null) {
val myData: ArrayList<OrderList.DataBeanX.DataBean> = getData()?.data as ArrayList<OrderList.DataBeanX.DataBean>
if (myData.isNotEmpty()) {
//取得最後一個對象,裡面有營業狀態和外賣訂單數,自取訂單數
val dataBean: OrderList.DataBeanX.DataBean = myData[myData.size - 1]
if (dataBean.open_Status != null) {
businessStatus = dataBean.open_Status!!
if (dataBean.Open_Status != null) {
restaurantState.value = dataBean.Open_Status!! == "1"
}
if (myData.size == 1) {
otherInfo.value = myData[0]
} else {
otherInfo.value = myData[myData.size - 1]
}
takeawayOrders = "本月外賣訂單數:" + dataBean.num + "/" + dataBean.maxOrder
pickUpOrders = "本月自取訂單數:" + dataBean.selflNum + "/" + dataBean.maxOrderSelf
todayOrderNum = dataBean.dayOrderNum.toString()
todayTurnover = dataBean.totalAmount.toString()
myData.removeAt(myData.size - 1)
Log.e("aaa", "數據:" + myData.size)
if (status == allOrderStatus) {
allOrderList.value = myData
Log.e("aaa", "全部訂單數變化" + allOrderNum.value)
allOrderNum.value = (myData.size).toString()
} else if (status == toBeConfirmedStatus) {
Log.e("aaa", "待確認訂單數變化" + (myData.size).toString())
toBeConfirmedOrderList.value = myData
toBeConfirmedNum.value = (myData.size).toString()
} else if (status == makingStatus) {
makingOrderList.value = myData
Log.e("aaa", "製作中訂單數變化" + (myData.size).toString())
makingNum.value = (myData.size).toString()
} else if (status == inDeliveryStatus || status == waitingForMealStatus) {
if (type == "2") {
//送貨中
inDeliveryOrderList.value = myData
Log.e("aaa", "送貨中訂單數變化" + (myData.size).toString())
inDeliveryNum.value = (myData.size).toString()
if (isLoadMore) {
if (mOrderList[position].value != null) {
mOrderList[position].value!!.addAll(myData)
} else {
//待取餐
waitingForMealOrderList.value = myData
Log.e("aaa", "待取餐訂單數變化" + (myData.size).toString())
waitingForMealNum.value = (myData.size).toString()
mOrderList[position].value = myData
}
} else {
mOrderList[position].value = myData
}
} else {
Log.e("aaa", "數據為空")
}
}
}
//餐廳營業狀態,控制按鈕
var restaurantState = MutableLiveData<Boolean>()
/**
* 修改餐廳營業狀態
*/
fun setRestaurantState(state: Boolean) {
launch({
repository.updateRestOpenStatus(state).apply {
if (isSuccess()) {
restaurantState.value = state
}
}
}, {
//出錯
})
}
private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try {
block()
......
......@@ -4,8 +4,8 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
......@@ -20,79 +20,68 @@ import kotlinx.android.synthetic.main.fragment_other_order.*
class PlaceholderFragment : Fragment() {
private lateinit var pageViewModel: PageViewModel
private lateinit var textView: TextView
private var page = 1
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
pageViewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply {
getOrderList(this)
//第一次進入獲取數據
getOrderList(this, false)
//綁定狀態,如果這個值發生變化
refreshState.observe(viewLifecycleOwner, Observer {
//觸發刷新,判斷是否更新
// if (it == arguments?.getString(STATUS) && pageViewModel.refreshType == arguments?.getString(TYPE)) {
//如果狀態和當前fragment狀態一致,並且type一致,刷新數據
getOrderList(this)
// }
//並且type一致//
//如果當前fragment的狀態中包含需要刷新的狀態,獲取數據
if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
getOrderList(this, false)
}
})
}
//初始化recyclerview
rv_other_order.layoutManager = LinearLayoutManager(activity)
var adapter = OtherOrdersAdapter()
var adapter = OtherOrdersAdapter(activity!!)
rv_other_order.adapter = adapter
if (arguments?.getString(STATUS) == PageViewModel.allOrderStatus) {
pageViewModel.allOrderList.observe(viewLifecycleOwner, Observer {
it.let { it1 -> adapter.setData(it1) }
})
} else if (arguments?.getString(STATUS) == PageViewModel.toBeConfirmedStatus) {
pageViewModel.toBeConfirmedOrderList.observe(viewLifecycleOwner, Observer {
it.let { it1 -> adapter.setData(it1) }
})
} else if (arguments?.getString(STATUS) == PageViewModel.makingStatus) {
pageViewModel.makingOrderList.observe(viewLifecycleOwner, Observer {
it.let { it1 -> adapter.setData(it1) }
})
} else if (arguments?.getString(STATUS) == PageViewModel.inDeliveryStatus || arguments?.getString(STATUS) == PageViewModel.waitingForMealStatus) {
if (arguments?.getString(TYPE) == "2") {
//送貨中
pageViewModel.inDeliveryOrderList.observe(viewLifecycleOwner, Observer {
it.let { it1 -> adapter.setData(it1) }
})
} else {
//待取餐
pageViewModel.waitingForMealOrderList.observe(viewLifecycleOwner, Observer {
it.let { it1 -> adapter.setData(it1) }
while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) {
pageViewModel.mOrderList.add(MutableLiveData())
}
//綁定當前fragment的數據項
pageViewModel.mOrderList[arguments?.getInt(INDEX)!!].observe(viewLifecycleOwner, Observer {
it.let { adapter.setData(it) }
})
//下拉刷新,加載更多
refresh_layout.setOnRefreshListener {
page = 0
pageViewModel.orderNo = ""
pageViewModel.phone = ""
getOrderList(pageViewModel, false)
}
refresh_layout.setOnLoadMoreListener {
page++
getOrderList(pageViewModel, true)
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val root = inflater.inflate(R.layout.fragment_other_order, container, false)
return root
return inflater.inflate(R.layout.fragment_other_order, container, false)
}
private fun getOrderList(pageViewModel: PageViewModel) {
pageViewModel.getOrderList(arguments?.getString(STATUS)
?: "", arguments?.getString(TYPE)
?: "", arguments?.getInt(INDEX) ?: 0)
private fun getOrderList(pageViewModel: PageViewModel, isLoadMore: Boolean) {
pageViewModel.getOrderList(arguments?.getInt(INDEX) ?: 0, page.toString(), isLoadMore) {
refresh_layout.finishRefresh()
refresh_layout.finishLoadMore()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
}
companion object {
private const val STATUS = "status"
private const val TYPE = "type"
private const val INDEX = "index"
@JvmStatic
fun newInstance(status: String, type: String, position: Int): PlaceholderFragment {
fun newInstance(position: Int): PlaceholderFragment {
return PlaceholderFragment().apply {
arguments = Bundle().apply {
putString(STATUS, status)
putString(TYPE, type)
putInt(INDEX, position)
}
}
......
......@@ -20,31 +20,7 @@ class SectionsPagerAdapter(private val context: Context, fm: FragmentManager, va
override fun getItem(position: Int): Fragment {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
var status = "0"
var type = "0"
when (position) {
0 -> {
status = PageViewModel.allOrderStatus
type = PageViewModel.allOrderType
}
1 -> {
status = PageViewModel.toBeConfirmedStatus
type = PageViewModel.toBeConfirmedType
}
2 -> {
status = PageViewModel.makingStatus
type = PageViewModel.makingType
}
3 -> {
status = PageViewModel.inDeliveryStatus
type = PageViewModel.inDeliveryType
}
4 -> {
status = PageViewModel.waitingForMealStatus
type = PageViewModel.waitingForMealType
}
}
return PlaceholderFragment.newInstance(status, type, position)
return PlaceholderFragment.newInstance(position)
}
override fun getPageTitle(position: Int): CharSequence? {
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_8" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/color_ccc" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="@dimen/dp_8"
android:bottomRightRadius="@dimen/dp_8" />
<solid android:color="@color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_8" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/color_ccc" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#E4E4E4" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#FFCC33" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#FFCC33" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel" />
</data>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
......@@ -7,4 +18,5 @@
android:id="@+id/rv_other_order"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
\ No newline at end of file
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.lihang.ShadowLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="com.gingersoft.gsa.cloud.base.utils.time.TimeUtils" />
<variable
name="data"
type="com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList.DataBeanX.DataBean" />
<variable
name="state"
type="String" />
<variable
name="orderingMethod"
type="String" />
<variable
name="payMethod"
type="String" />
<variable
name="orderingMethodBg"
type="android.graphics.drawable.Drawable" />
<variable
name="stateBg"
type="android.graphics.drawable.Drawable" />
<variable
name="payMethodBg"
type="android.graphics.drawable.Drawable" />
</data>
<com.lihang.ShadowLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_7"
android:layout_marginRight="@dimen/dp_7"
app:hl_cornerRadius="@dimen/dp_8"
app:hl_shadowLimit="@dimen/dp_5">
app:hl_shadowLimit="@dimen/dp_3">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
......@@ -19,20 +57,27 @@
android:id="@+id/tv_payment_method"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="貨到付款"
android:background="@{payMethodBg}"
android:paddingLeft="@dimen/dp_5"
android:paddingTop="@dimen/dp_1"
android:paddingRight="@dimen/dp_5"
android:paddingBottom="@dimen/dp_1"
android:text="@{payMethod}"
android:textColor="@color/white"
android:textSize="@dimen/sp_12"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_ordering_method"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="外"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_marginLeft="@dimen/dp_8"
android:background="@{orderingMethodBg}"
android:gravity="center"
android:text="@{orderingMethod}"
android:textColor="@color/white"
android:textSize="@dimen/sp_12"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toRightOf="@id/tv_payment_method"
app:layout_constraintTop_toTopOf="parent" />
......@@ -41,7 +86,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="123456"
android:text="@{data.rECEIVER}"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_14"
android:textStyle="bold"
......@@ -53,7 +98,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="2020-03-28 14:59:11"
android:text="@{TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="@id/tv_order_user_name"
......@@ -84,7 +129,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:text="18938995556"
android:text="@{data.pHONE}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
......@@ -106,7 +151,7 @@
android:id="@+id/tv_order_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18938995556"
android:text="@{data.oRDER_NO}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
......@@ -117,7 +162,11 @@
android:id="@+id/tv_order_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="製作中"
android:background="@{stateBg}"
android:padding="@dimen/dp_5"
android:text="@{state}"
android:textColor="@color/white"
android:textSize="@dimen/dp_14"
app:layout_constraintBottom_toBottomOf="@id/tv_order_num_text"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_cellphone_num_text" />
......@@ -139,20 +188,22 @@
android:id="@+id/tv_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="香港島中環餐飲服務公司"
android:text="@{data.aDDRESS_DETAIL}"
android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintTop_toTopOf="@id/tv_address_text" />
<TextView
android:id="@+id/tv_order_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$88.0"
android:text="@{@string/amount_unit + data.pAY_AMOUNT}"
android:textColor="@color/red_600"
android:textSize="@dimen/sp_14"
app:layout_constraintBottom_toBottomOf="@id/tv_address"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_address" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.lihang.ShadowLayout>
\ No newline at end of file
</com.lihang.ShadowLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<!-- <color name="colorPrimary">#008577</color>-->
<!-- <color name="colorPrimaryDark">#00574B</color>-->
<!-- <color name="colorAccent">#D81B60</color>-->
</resources>
......@@ -6,4 +6,9 @@
<string name="tab_text_4">送貨中</string>
<string name="tab_text_5">待取餐</string>
<string name="slash">/</string>
<string name="amount_unit">$</string>
<string name="normal">正常</string>
<string name="rest">休息</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<!-- &lt;!&ndash; Customize your theme here. &ndash;&gt;-->
<!-- <item name="colorPrimary">@color/colorPrimary</item>-->
<!-- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
<!-- <item name="colorAccent">@color/colorAccent</item>-->
<!-- </style>-->
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
......
package com.gingersoft.gsa.other_order_mode
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
......@@ -17,7 +17,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_logo"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_android"
android:theme="@style/AppTheme">
......
......@@ -39,7 +39,7 @@ public class TestPrintDataMaker implements PrintDataMaker {
printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(height, width) : new PrinterWriter80mm(height, width);
printer.setAlignCenter();
data.add(printer.getDataAndReset());
ArrayList<byte[]> image = printer.getImageByte(context.getResources(), R.mipmap.ic_logo);
ArrayList<byte[]> image = printer.getImageByte(context.getResources(), R.mipmap.ic_launcher);
data.addAll(image);
List<Bitmap> bitmaps = PrintUtils.getPrintBitmap(context, -1, width);//根據打印類型獲得不同的bitmap
......
......@@ -76,7 +76,7 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta
initDialog();
initIntent();
callId = getIntent().getStringExtra(EXTRA_KEY_CALL_ID);
if (type == 3) {
// if (type == 3) {
//廚房單,可能會有多個IP打印
//獲得ip打印列表,
//再將食品數據根據打印位置分組。
......@@ -84,9 +84,9 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta
//打印完成之後,返回所有打印結果。
} else {
// } else {
printOrder(this);
}
// }
}
......
ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错
apply from: rootProject.file("cc-settings.gradle")
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'android-aspectjx'
......@@ -90,4 +92,9 @@ dependencies {
api 'com.sunmi:printerlibrary:1.0.7'
//上下拉刷新
api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0'
compile "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
package com.gingersoft.gsa.cloud.base.utils.time;
import android.text.TextUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
......@@ -444,6 +446,9 @@ public class TimeUtils {
*/
public static String parseTimeRepeat(String time, SimpleDateFormat dateFormat) {
Date date = null;
if(TextUtils.isEmpty(time)){
return "";
}
try {
date = new Date(time);
} catch (IllegalArgumentException e) {
......
......@@ -91,12 +91,13 @@ public class Function {
this.textSize = textSize;
}
public Function(Long id, int parentId, int groupId, String resName, int icRes) {
public Function(Long id, int parentId, int groupId, String resName, int icRes, int status) {
this.id = id;
this.parentId = parentId;
this.groupId = groupId;
this.resName = resName;
this.icRes = icRes;
this.status = status;
}
public Function(int nameRes, int textColorRes, int backgroundColorRes, int textSizeRes) {
......
package com.gingersoft.gsa.cloud.ui.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.TypedValue;
import androidx.appcompat.widget.AppCompatTextView;
public class AutoFitTextView extends AppCompatTextView {
private Paint mTextPaint;
private float mTextSize;
public AutoFitTextView(Context context) {
super(context);
}
public AutoFitTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Re size the font so the specified text fits in the text box assuming the
* text box is the specified width.
*
* @param text
* @param textViewWidth
*/
private void refitText(String text, int textViewWidth) {
if (text == null || textViewWidth <= 0)
return;
mTextPaint = new Paint();
mTextPaint.set(this.getPaint());
int availableTextViewWidth = getWidth() - getPaddingLeft() - getPaddingRight();
float[] charsWidthArr = new float[text.length()];
Rect boundsRect = new Rect();
mTextPaint.getTextBounds(text, 0, text.length(), boundsRect);
int textWidth = boundsRect.width();
mTextSize = getTextSize();
while (textWidth > availableTextViewWidth) {
mTextSize -= 1;
mTextPaint.setTextSize(mTextSize);
textWidth = mTextPaint.getTextWidths(text, charsWidthArr);
}
this.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
refitText(this.getText().toString(), this.getWidth());
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view
import android.view.animation.Interpolator
import kotlin.math.cos
import kotlin.math.pow
/**
* Created by Evgenii Neumerzhitckii
* (read more on https://evgenii.com/blog/spring-button-animation-on-android/)
*/
class BounceInterpolator(
private val amplitude: Double,
private val frequency: Double
) : Interpolator {
override fun getInterpolation(time: Float): Float =
(-1 * Math.E.pow(-time / amplitude) * cos(frequency * time) + 1).toFloat()
}
\ No newline at end of file
......@@ -409,4 +409,14 @@
<enum name="left" value="3" />
</attr>
</declare-styleable>
<declare-styleable name="SwitchButton">
<attr name="elevation" />
<attr name="switcherBtn_width" format="dimension"/>
<attr name="switcherBtn_height" format="dimension"/>
<attr name="android:checked" format="boolean" />
<attr name="switcherBtn_on_color" format="color" />
<attr name="switcherBtn_off_color" format="color" />
<attr name="switcherBtn_icon_color" format="color" />
</declare-styleable>
</resources>
\ No newline at end of file
......@@ -447,6 +447,24 @@
<color name="color_8f">#8f8f8f</color>
<color name="color_3c">#3c3c3c</color>
<color name="color_e4">#E4E4E4</color>
<color name="color_f0">#F0F0F0</color>
<!-- 待確認背景色-->
<color name="order_state0_color">#6EBE8C</color>
<!-- 製作中背景色-->
<color name="order_state1_color">#5896F4</color>
<!-- 送貨中中背景色-->
<color name="order_state2_color">#FF5722</color>
<!-- 待取餐背景色-->
<color name="order_state3_color">#FF5722</color>
<!-- 在線支付背景色-->
<color name="cash_on_delivery_bg">#FF5722</color>
<color name="online_payments_bg">#6EBE8C</color>
<color name="self_order_bg">#FFCC33</color>
<color name="switcher_on_color">#6EBE8C</color>
<color name="switcher_off_color">#ff4651</color>
<color name="switcher_icon_color">@color/white</color>
</resources>
......@@ -482,4 +482,6 @@
<dimen name="sp_48">48sp</dimen>
<!-- 清機報表字體大小 -->
<dimen name="settlement_report_text_size">@dimen/sp_18</dimen>
<dimen name="switcher_elevation">4dp</dimen>
</resources>
\ No newline at end of file
......@@ -137,4 +137,10 @@
<string name="app_exception">很抱歉,程序出現異常,即將退出!</string>
<string name="queue_write_external_storage_permission_hint">保存失敗,請先前往設置開放存儲權限</string>
<string name="cash_on_delivery">貨到付款</string>
<string name="online_payments">在線支付</string>
<string name="tang"></string>
<string name="wai"></string>
<string name="amount_unit">$</string>
</resources>
......@@ -291,4 +291,13 @@
<item name="android:textSize">@dimen/sp_13</item>
<item name="android:textColor">@color/theme_hint_color</item>
</style>
<style name="MySwitcher">
<item name="switcherBtn_width">@dimen/dp_46</item>
<item name="switcherBtn_height">@dimen/dp_26</item>
<item name="switcherBtn_on_color">@color/switcher_on_color</item>
<item name="switcherBtn_off_color">@color/switcher_off_color</item>
<item name="switcherBtn_icon_color">@color/switcher_icon_color</item>
<item name="elevation">@dimen/switcher_elevation</item>
</style>
</resources>
......@@ -14,7 +14,7 @@
<application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_logo"
android:icon="@mipmap/ic_launcher"
android:label="@string/user_login_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
......
......@@ -58,10 +58,12 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
TextView mTvGuideTitle;
@BindView(R2.id.tv_guide_details)
TextView mTvGuideDetails;
@BindView(R2.id.tv_experience)
TextView mTvExperience;
List<GuideBean> guideBeanList = new ArrayList<>();
private final long ANIMATION_TIME = 1300;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerWelcomeComponent //如找不到该类,请编译一下项目
......@@ -111,7 +113,6 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
}
});
guideBeanList.add(new GuideBean("多终端云同步,轻松管理所有", "為您搭建優良高效管理平台", getResources().getDrawable(R.mipmap.pic_guide_one)));
guideBeanList.add(new GuideBean("數據分析可視化", "數據統計一目了然,直觀看到數據變化趨勢", getResources().getDrawable(R.mipmap.pic_guide_two)));
guideBeanList.add(new GuideBean("多種點餐方式", "提供方便快捷的點餐服務,減低落錯單機會", getResources().getDrawable(R.mipmap.pic_guide_three)));
......@@ -124,6 +125,11 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
public void onPageSelected(int position) {
super.onPageSelected(position);
updateUI(position);
if (++position == guideBeanList.size() && mTvExperience.getVisibility() != View.VISIBLE) {
//當前選中最後一個page,顯示進入按鈕
mTvExperience.setVisibility(View.VISIBLE);
mTvExperience.startAnimation(animation);
}
}
});
......@@ -280,11 +286,12 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
.show();
}
@OnClick({R2.id.iv_guide_close})
@OnClick({R2.id.iv_guide_close,R2.id.tv_experience})
@Override
public void onClick(View v) {
if (v.getId() == R.id.iv_guide_close) {
if (v.getId() == R.id.iv_guide_close || v.getId() == R.id.tv_experience) {
//去登陸頁,設置下次不顯示引導頁
//立即體驗
SPUtils.put(mContext, UserConstans.IS_GUIDE, false);
startActivity(new Intent(mContext, LoginActivity.class));
killMyself();
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_18" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/white" />
</shape>
\ No newline at end of file
......@@ -107,6 +107,24 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_experience"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_15"
android:background="@drawable/shape_experience_bg"
android:paddingLeft="@dimen/dp_28"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_28"
android:paddingBottom="@dimen/dp_10"
android:text="立即體驗"
android:textColor="@color/white"
android:textSize="@dimen/dp_14"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/guide_magic_indicator"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<com.gingersoft.gsa.cloud.ui.widget.Indicator.UIndicator
android:id="@+id/guide_magic_indicator"
android:layout_width="wrap_content"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment