Commit 0fd819b0 by Wyh

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

parent d54a9745
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: "config.gradle" apply from: "config.gradle"
buildscript { buildscript {
ext.kotlin_version = '1.3.10' ext.kotlin_version = '1.3.41'
repositories { repositories {
google() google()
...@@ -18,7 +18,7 @@ buildscript { ...@@ -18,7 +18,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 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.novoda:bintray-release:0.9.2'
classpath 'com.billy.android:cc-register:1.1.2' classpath 'com.billy.android:cc-register:1.1.2'
...@@ -26,7 +26,7 @@ buildscript { ...@@ -26,7 +26,7 @@ buildscript {
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
// classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8' // 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 { ...@@ -44,8 +44,8 @@ allprojects {
maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" } maven { url "http://maven.aliyun.com/nexus/content/repositories/releases" }
// 私有仓库地址 // 私有仓库地址
maven { url "http://lib.gcssloop.com/repository/gcssloop-central/" } maven { url "http://lib.gcssloop.com/repository/gcssloop-central/" }
maven{ url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/google' }
maven{ url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/jcenter' }
} }
} }
......
package com.gingersoft.gsa.cloud.main.mvp.ui.activity; package com.gingersoft.gsa.cloud.main.mvp.ui.activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
import android.os.Bundle; import android.os.Bundle;
...@@ -201,24 +200,25 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N ...@@ -201,24 +200,25 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
// return; // return;
// } // }
List<Function> functions = new ArrayList<>(); List<Function> functions = new ArrayList<>();
functions.add(new Function((long) 150, 0, 5, "點餐", 0)); functions.add(new Function((long) 150, 0, 5, "點餐", 0, 0));
functions.add(new Function((long) 138, 150, 5, "餐臺模式", R.drawable.ic_dining_table_mode)); 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)); 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)); 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)); 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) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management)); 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)); functions.add(new Function((long) 142, 151, 5, "訂單管理", R.drawable.ic_meals_menu_management, 0));
functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management)); functions.add(new Function((long) 143, 151, 5, "餐臺管理", R.drawable.ic_dining_table_management, 1));
functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management)); functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0));
functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management)); 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));
functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management)); functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management)); functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management, 1));
functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record)); 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<String> parents = new SparseArray<>();
SparseArray<List<Function>> funMap = new SparseArray<>(); SparseArray<List<Function>> funMap = new SparseArray<>();
...@@ -252,12 +252,16 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N ...@@ -252,12 +252,16 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
return false; 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); 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("餐臺模式")) { if (name.equals("餐臺模式")) {
CC.obtainBuilder("Component.Table") CC.obtainBuilder("Component.Table")
.setActionName("showTableActivity") .setActionName("showTableActivity")
...@@ -273,6 +277,11 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N ...@@ -273,6 +277,11 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
.setActionName("showOrderCenterActivity") .setActionName("showOrderCenterActivity")
.build() .build()
.call(); .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 ...@@ -314,7 +323,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
setTitleInfo(); setTitleInfo();
CC.obtainBuilder("Component.Download") CC.obtainBuilder("Component.Download")
.setActionName("showDownloadActivity") .setActionName("showDownloadActivity")
.addParam("fromPage",2) .addParam("fromPage", 2)
.build() .build()
.call(); .call();
dialog.dismiss(); dialog.dismiss();
......
...@@ -102,7 +102,7 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor ...@@ -102,7 +102,7 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
String startTime = TimeUtils.getOldDate(-6); String startTime = TimeUtils.getOldDate(-2);
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime); mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime);
mTvStartTime.setText(startTime); mTvStartTime.setText(startTime);
......
...@@ -105,7 +105,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales ...@@ -105,7 +105,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
String startTime = TimeUtils.getOldDate(-6); String startTime = TimeUtils.getOldDate(-2);
mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime); mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime);
mTvStartTime.setText(startTime); mTvStartTime.setText(startTime);
mTvEndTime.setText(TimeUtils.getOldDate(0)); mTvEndTime.setText(TimeUtils.getOldDate(0));
......
...@@ -161,7 +161,6 @@ ...@@ -161,7 +161,6 @@
android:layout_marginLeft="@dimen/dp_13" android:layout_marginLeft="@dimen/dp_13"
android:layout_marginTop="-4dp" android:layout_marginTop="-4dp"
android:layout_marginRight="@dimen/dp_13" android:layout_marginRight="@dimen/dp_13"
android:layout_marginBottom="@dimen/dp_10"
app:hl_cornerRadius="@dimen/dp_4" app:hl_cornerRadius="@dimen/dp_4"
app:hl_shadowBackColor="@color/white" app:hl_shadowBackColor="@color/white"
app:hl_shadowLimit="@dimen/dp_0"> app:hl_shadowLimit="@dimen/dp_0">
...@@ -171,8 +170,7 @@ ...@@ -171,8 +170,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="@dimen/dp_16" android:paddingTop="@dimen/dp_16">
android:paddingBottom="@dimen/dp_16">
<TextView <TextView
android:id="@+id/tv_function_name2" android:id="@+id/tv_function_name2"
...@@ -193,7 +191,6 @@ ...@@ -193,7 +191,6 @@
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dp_1" android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_20"
android:background="#F0F0F0" /> android:background="#F0F0F0" />
<TextView <TextView
...@@ -210,7 +207,6 @@ ...@@ -210,7 +207,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/main_recyclerview_marginLeft" android:layout_marginLeft="@dimen/main_recyclerview_marginLeft"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/main_recyclerview_marginRight" /> android:layout_marginRight="@dimen/main_recyclerview_marginRight" />
</LinearLayout> </LinearLayout>
</com.lihang.ShadowLayout> </com.lihang.ShadowLayout>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <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:id="@+id/cl_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <com.gingersoft.gsa.cloud.ui.view.AutoFitTextView
android:id="@+id/tv_item1" android:id="@+id/tv_item1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="left" android:gravity="left"
android:text="item1"
android:maxLines="1" android:maxLines="1"
android:text="item1"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="@dimen/settlement_report_text_size" /> android:textSize="@dimen/settlement_report_text_size"/>
<TextView <TextView
android:id="@+id/tv_item2" android:id="@+id/tv_item2"
...@@ -44,8 +45,8 @@ ...@@ -44,8 +45,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.5" android:layout_weight="0.5"
android:gravity="center" android:gravity="center"
android:text="item4"
android:maxLines="1" android:maxLines="1"
android:text="item4"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="@dimen/settlement_report_text_size" /> android:textSize="@dimen/settlement_report_text_size" />
...@@ -54,9 +55,9 @@ ...@@ -54,9 +55,9 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="marquee"
android:gravity="right" android:gravity="right"
android:text="item5" android:text="item5"
android:ellipsize="marquee"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="@dimen/settlement_report_text_size" /> android:textSize="@dimen/settlement_report_text_size" />
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:layout_marginBottom="@dimen/dp_20"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
......
...@@ -19,8 +19,14 @@ android { ...@@ -19,8 +19,14 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
includeCompileClasspath true
} }
}
}
resourcePrefix "otherOrder"
buildTypes { buildTypes {
release { release {
minifyEnabled false 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 @@ ...@@ -8,13 +8,13 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_android"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity <activity
android:name=".OtherOrderActivity" android:name=".OtherOrderActivity"
android:label="@string/app_name" android:label="@string/app_name">
android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
</activity> </activity>
<service android:name=".service.GetInfoUpdateService" /> <service android:name=".service.GetInfoUpdateService" />
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
</application> </application>
</manifest> </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 package com.gingersoft.gsa.other_order_mode
import android.animation.ValueAnimator
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
...@@ -8,19 +9,23 @@ import android.graphics.Color ...@@ -8,19 +9,23 @@ import android.graphics.Color
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.os.Looper import android.view.View
import android.util.Log
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager 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.service.GetInfoUpdateService
import com.gingersoft.gsa.other_order_mode.ui.main.PageViewModel 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.ui.main.SectionsPagerAdapter
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import kotlinx.android.synthetic.main.activity_other_order.* import kotlinx.android.synthetic.main.activity_other_order.*
class OtherOrderActivity : AppCompatActivity() { class OtherOrderActivity : AppCompatActivity() {
private lateinit var pageViewModel: PageViewModel private lateinit var pageViewModel: PageViewModel
...@@ -43,22 +48,46 @@ class OtherOrderActivity : AppCompatActivity() { ...@@ -43,22 +48,46 @@ class OtherOrderActivity : AppCompatActivity() {
) )
private var titls: ArrayList<TextView> = ArrayList() private var titls: ArrayList<TextView> = ArrayList()
private var layoutHeight: Float = 0F
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) 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) var intent = Intent(this, GetInfoUpdateService::class.java)
// startService(intent)
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
pageViewModel = ViewModelProvider(this, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java] pageViewModel = ViewModelProvider(this, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java]
initAppTop() 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 sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager, ints)
val viewPager: ViewPager = findViewById(R.id.view_pager) val viewPager: ViewPager = findViewById(R.id.view_pager)
viewPager.adapter = sectionsPagerAdapter viewPager.adapter = sectionsPagerAdapter
viewPager.offscreenPageLimit = 4 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) tabs.setupWithViewPager(viewPager)
for (i in 0 until ints.size) { for (i in 0 until ints.size) {
...@@ -78,29 +107,36 @@ class OtherOrderActivity : AppCompatActivity() { ...@@ -78,29 +107,36 @@ class OtherOrderActivity : AppCompatActivity() {
drawable.cornerRadius = 5f drawable.cornerRadius = 5f
mNumber.background = drawable mNumber.background = drawable
mNumber.text = "0" mNumber.text = "0"
when (i) { while (pageViewModel.mOrderList.size <= i) {
0 -> pageViewModel.allOrderNum.observe(instance, Observer { pageViewModel.mOrderList.add(MutableLiveData())
mNumber.text = it }
Log.e("aaa", "接收到訂單數變化$it") pageViewModel.mOrderList[i].observe(instance, Observer {
}) mNumber.text = it.size.toString()
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")
}) })
} }
} }
//餐廳營業信息
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() { ...@@ -109,17 +145,15 @@ class OtherOrderActivity : AppCompatActivity() {
var bind: GetInfoUpdateService.MyBind = service as GetInfoUpdateService.MyBind var bind: GetInfoUpdateService.MyBind = service as GetInfoUpdateService.MyBind
bind.setOnPostCallBack(object : GetInfoUpdateService.PostCallBack { bind.setOnPostCallBack(object : GetInfoUpdateService.PostCallBack {
override fun callBack(type: Int) { override fun callBack(type: Int) {
Log.e("aaa", "類型:$type")
//-1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知" //-1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知"
if (type == 3 || type == 4 || type == 5 if (type == 3 || type == 4 || type == 5
|| type == 6 || type == 7) { || type == 6 || type == 7) {
//播放提示音
Looper.prepare() pageViewModel.refreshState.postValue(type)
pageViewModel.refreshState.value = pageViewModel.refreshState.value?.plus(1)
Looper.loop()
} }
} }
}) })
} }
override fun onServiceDisconnected(name: ComponentName) { override fun onServiceDisconnected(name: ComponentName) {
...@@ -128,6 +162,36 @@ class OtherOrderActivity : AppCompatActivity() { ...@@ -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() { private fun initAppTop() {
qm_other_order_bar.setTitle(R.string.app_name) 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() } 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 ...@@ -8,19 +8,29 @@ import okhttp3.FormBody
class WeatherRepository private constructor(private val network: CoolWeatherNetwork) { 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() val requestBody = FormBody.Builder()
.add("restaurantId", "26") .add("restaurantId", "26")
.add("page", "1") .add("page", page)
.add("status", status) .add("status", status)
.add("orderNo", "") .add("orderNo", orderNo)
.add("phone", "") .add("phone", phone)
.add("type", type) .add("type", type)
.build() .build()
val heWeather = network.fetchOrderList(requestBody) val heWeather = network.fetchOrderList(requestBody)
heWeather 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 { companion object {
private lateinit var instance: WeatherRepository private lateinit var instance: WeatherRepository
......
package com.gingersoft.gsa.other_order_mode.data.model.bean package com.gingersoft.gsa.other_order_mode.data.model.bean
class MessageBean { class MessageBean {
private var data: String? = null /**
get() = field * success : true
set(value) { * sysTime : 1585723657344
field = value * 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 fun setSuccess(success: Boolean) {
set(value) { this.success = success
field = value }
fun getSysTime(): Long {
return sysTime
} }
private var token: String? = null
get() = field fun setSysTime(sysTime: Long) {
set(value) { this.sysTime = sysTime
field = value
} }
private var type: Int? = null
get() = field fun getData(): DataBean? {
set(value) { return data
field = value
} }
private var username: String? = null
get() = field fun setData(data: DataBean) {
set(value) { this.data = data
field = value
} }
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 { ...@@ -59,25 +59,32 @@ class OrderList {
* Open_Status : 1 * Open_Status : 1
*/ */
var status: Int = 0 var STATUS: Int = 0
var membeR_NAME: String? = null var MEMBER_NAME: String? = null
var addresS_DETAIL: String? = null var ADDRESS_DETAIL: String? = null
var paY_AMOUNT: Double = 0.toDouble() var PAY_AMOUNT: Double = 0.toDouble()
var phone: String? = null var PHONE: String? = null
var orderPayType: Int = 0 var orderPayType: Int = 0
var ordeR_NO: String? = null var ORDER_NO: String? = null
var id: Int = 0 var Id: Int = 0
var creatE_TIME: String? = null var CREATE_TIME: String? = null
var takeFoodCode: String? = null var takeFoodCode: String? = null
var order_type: Int = 0 var order_type: Int = 0
var receiver: String? = null var RECEIVER: String? = null
var maxOrder: Int = 0 var MaxOrder: Int = 0
var selflNum: Int = 0 var selflNum: Int = 0
var totalAmount: Double = 0.toDouble() var totalAmount: Double = 0.toDouble()
var maxOrderSelf: Int = 0 var maxOrderSelf: Int = 0
var num: Int = 0 var num: Int = 0
var dayOrderNum: 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 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 com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
...@@ -13,8 +14,12 @@ class CoolWeatherNetwork { ...@@ -13,8 +14,12 @@ class CoolWeatherNetwork {
private val orderService = ServiceCreator.create(WeatherService::class.java) 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 fetchOrderList(requestBody: RequestBody) = orderService.getOrderList(requestBody).await()
suspend fun updateRestOpenStatus(requestBody: RequestBody) = service.updateRestOpenStatus(requestBody).await()
private suspend fun <T> Call<T>.await(): T { private suspend fun <T> Call<T>.await(): T {
return suspendCoroutine { continuation -> return suspendCoroutine { continuation ->
enqueue(object : Callback<T> { enqueue(object : Callback<T> {
......
...@@ -8,7 +8,8 @@ import retrofit2.converter.scalars.ScalarsConverterFactory ...@@ -8,7 +8,8 @@ import retrofit2.converter.scalars.ScalarsConverterFactory
object ServiceCreator { object ServiceCreator {
private const val BASE_URL = "https://hktest.ricepon.com:64377/ricepon-wechat/api/" 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 httpClient = OkHttpClient.Builder()
private val builder = Retrofit.Builder() private val builder = Retrofit.Builder()
...@@ -17,9 +18,19 @@ object ServiceCreator { ...@@ -17,9 +18,19 @@ object ServiceCreator {
.addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.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 retrofit = builder.build()
private val retrofit2 = builder2.build()
fun <T> create(serviceClass: Class<T>): T = retrofit.create(serviceClass) 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 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 com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
...@@ -11,4 +12,6 @@ interface WeatherService { ...@@ -11,4 +12,6 @@ interface WeatherService {
@POST("wechat/findOrderList") @POST("wechat/findOrderList")
fun getOrderList(@Body requestBody: RequestBody): Call<OrderList> 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 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.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup 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
import androidx.recyclerview.widget.RecyclerView.Adapter 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.R
import com.gingersoft.gsa.other_order_mode.data.model.bean.OrderList 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>) { fun setData(databeans: List<OrderList.DataBeanX.DataBean>) {
this.databeans = databeans this.databeans = databeans
...@@ -24,7 +32,74 @@ class OtherOrdersAdapter : Adapter<OtherOrdersAdapter.ViewHolder>() { ...@@ -24,7 +32,74 @@ class OtherOrdersAdapter : Adapter<OtherOrdersAdapter.ViewHolder>() {
override fun onBindViewHolder(holder: ViewHolder, position: Int) { 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 { override fun getItemCount(): Int {
...@@ -35,7 +110,23 @@ class OtherOrdersAdapter : Adapter<OtherOrdersAdapter.ViewHolder>() { ...@@ -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) { 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 ...@@ -10,112 +10,87 @@ import kotlinx.coroutines.launch
class PageViewModel(private val repository: WeatherRepository) : ViewModel() { class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
companion object { companion object {
var allOrderStatus: String = "0,1,2,3" var fragmentStatus = arrayOf("0,1,2,3", "0,1", "2", "3", "3")
var allOrderType: String = "0" var fragmentType = arrayOf("0", "0", "0", "2", "7")
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 allOrderList = MutableLiveData<List<OrderList.DataBeanX.DataBean>>() var mOrderList = arrayListOf<MutableLiveData<ArrayList<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 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中監聽這個變量,再調用接口獲取最新數據 //刷新狀態,有數據更新就會更改這個變量,將這個變量修改為allOrderStatus...上面五種狀態,fragment中監聽這個變量,再調用接口獲取最新數據
var refreshState = MutableLiveData<Int>() var refreshState = MutableLiveData<Int>()
var refreshType: String = "0" //訂單號
var orderList = MutableLiveData<OrderList>() var orderNo: String = ""
fun getOrderList(status: String, type: String, position: Int) { //手機號
Log.e("aaa", status + "請求" + type) var phone: String = ""
/**
* 獲取訂單信息
*/
fun getOrderList(position: Int, page: String, isLoadMore: Boolean, listener: (String) -> Unit) {
launch({ 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) { if (getData() != null && getData()?.data != null) {
val myData: ArrayList<OrderList.DataBeanX.DataBean> = getData()?.data as ArrayList<OrderList.DataBeanX.DataBean> val myData: ArrayList<OrderList.DataBeanX.DataBean> = getData()?.data as ArrayList<OrderList.DataBeanX.DataBean>
if (myData.isNotEmpty()) { if (myData.isNotEmpty()) {
//取得最後一個對象,裡面有營業狀態和外賣訂單數,自取訂單數 //取得最後一個對象,裡面有營業狀態和外賣訂單數,自取訂單數
val dataBean: OrderList.DataBeanX.DataBean = myData[myData.size - 1] val dataBean: OrderList.DataBeanX.DataBean = myData[myData.size - 1]
if (dataBean.open_Status != null) { if (dataBean.Open_Status != null) {
businessStatus = dataBean.open_Status!! 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) myData.removeAt(myData.size - 1)
if (isLoadMore) {
Log.e("aaa", "數據:" + myData.size) if (mOrderList[position].value != null) {
if (status == allOrderStatus) { mOrderList[position].value!!.addAll(myData)
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()
} else { } else {
//待取餐 mOrderList[position].value = myData
waitingForMealOrderList.value = myData
Log.e("aaa", "待取餐訂單數變化" + (myData.size).toString())
waitingForMealNum.value = (myData.size).toString()
} }
} else {
mOrderList[position].value = myData
} }
} else { } else {
Log.e("aaa", "數據為空") 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 { private fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = viewModelScope.launch {
try { try {
block() block()
......
...@@ -4,8 +4,8 @@ import android.os.Bundle ...@@ -4,8 +4,8 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
...@@ -20,79 +20,68 @@ import kotlinx.android.synthetic.main.fragment_other_order.* ...@@ -20,79 +20,68 @@ import kotlinx.android.synthetic.main.fragment_other_order.*
class PlaceholderFragment : Fragment() { class PlaceholderFragment : Fragment() {
private lateinit var pageViewModel: PageViewModel private lateinit var pageViewModel: PageViewModel
private lateinit var textView: TextView private var page = 1
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
pageViewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply { pageViewModel = ViewModelProvider(activity?.viewModelStore!!, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply {
getOrderList(this) //第一次進入獲取數據
getOrderList(this, false)
//綁定狀態,如果這個值發生變化
refreshState.observe(viewLifecycleOwner, Observer { refreshState.observe(viewLifecycleOwner, Observer {
//觸發刷新,判斷是否更新 //觸發刷新,判斷是否更新
// if (it == arguments?.getString(STATUS) && pageViewModel.refreshType == arguments?.getString(TYPE)) { //並且type一致//
//如果狀態和當前fragment狀態一致,並且type一致,刷新數據 //如果當前fragment的狀態中包含需要刷新的狀態,獲取數據
getOrderList(this) if (PageViewModel.fragmentStatus[arguments?.getInt(INDEX)!!].contains(it.toString())) {
// } getOrderList(this, false)
}
}) })
} }
//初始化recyclerview
rv_other_order.layoutManager = LinearLayoutManager(activity) rv_other_order.layoutManager = LinearLayoutManager(activity)
var adapter = OtherOrdersAdapter() var adapter = OtherOrdersAdapter(activity!!)
rv_other_order.adapter = adapter rv_other_order.adapter = adapter
if (arguments?.getString(STATUS) == PageViewModel.allOrderStatus) {
pageViewModel.allOrderList.observe(viewLifecycleOwner, Observer { while (pageViewModel.mOrderList.size <= arguments?.getInt(INDEX)!!) {
it.let { it1 -> adapter.setData(it1) } pageViewModel.mOrderList.add(MutableLiveData())
}) }
} else if (arguments?.getString(STATUS) == PageViewModel.toBeConfirmedStatus) {
pageViewModel.toBeConfirmedOrderList.observe(viewLifecycleOwner, Observer { //綁定當前fragment的數據項
it.let { it1 -> adapter.setData(it1) } pageViewModel.mOrderList[arguments?.getInt(INDEX)!!].observe(viewLifecycleOwner, Observer {
}) it.let { adapter.setData(it) }
} 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) }
}) })
//下拉刷新,加載更多
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? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val root = inflater.inflate(R.layout.fragment_other_order, container, false) return inflater.inflate(R.layout.fragment_other_order, container, false)
return root
} }
private fun getOrderList(pageViewModel: PageViewModel) { private fun getOrderList(pageViewModel: PageViewModel, isLoadMore: Boolean) {
pageViewModel.getOrderList(arguments?.getString(STATUS) pageViewModel.getOrderList(arguments?.getInt(INDEX) ?: 0, page.toString(), isLoadMore) {
?: "", arguments?.getString(TYPE) refresh_layout.finishRefresh()
?: "", arguments?.getInt(INDEX) ?: 0) refresh_layout.finishLoadMore()
} }
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
} }
companion object { companion object {
private const val STATUS = "status"
private const val TYPE = "type"
private const val INDEX = "index" private const val INDEX = "index"
@JvmStatic @JvmStatic
fun newInstance(status: String, type: String, position: Int): PlaceholderFragment { fun newInstance(position: Int): PlaceholderFragment {
return PlaceholderFragment().apply { return PlaceholderFragment().apply {
arguments = Bundle().apply { arguments = Bundle().apply {
putString(STATUS, status)
putString(TYPE, type)
putInt(INDEX, position) putInt(INDEX, position)
} }
} }
......
...@@ -20,31 +20,7 @@ class SectionsPagerAdapter(private val context: Context, fm: FragmentManager, va ...@@ -20,31 +20,7 @@ class SectionsPagerAdapter(private val context: Context, fm: FragmentManager, va
override fun getItem(position: Int): Fragment { override fun getItem(position: Int): Fragment {
// getItem is called to instantiate the fragment for the given page. // getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below). // Return a PlaceholderFragment (defined as a static inner class below).
var status = "0" return PlaceholderFragment.newInstance(position)
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)
} }
override fun getPageTitle(position: Int): CharSequence? { 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"?> <?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_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -7,4 +18,5 @@ ...@@ -7,4 +18,5 @@
android:id="@+id/rv_other_order" android:id="@+id/rv_other_order"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout> </com.scwang.smartrefresh.layout.SmartRefreshLayout>
\ No newline at end of file </layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.lihang.ShadowLayout xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" 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_width="match_parent"
android:layout_height="wrap_content" 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_cornerRadius="@dimen/dp_8"
app:hl_shadowLimit="@dimen/dp_5"> app:hl_shadowLimit="@dimen/dp_3">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -19,20 +57,27 @@ ...@@ -19,20 +57,27 @@
android:id="@+id/tv_payment_method" android:id="@+id/tv_payment_method"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="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:textColor="@color/white"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/tv_ordering_method" android:id="@+id/tv_ordering_method"
android:layout_width="wrap_content" android:layout_width="@dimen/dp_20"
android:layout_height="wrap_content" android:layout_height="@dimen/dp_20"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_8"
android:text="外" android:background="@{orderingMethodBg}"
android:gravity="center"
android:text="@{orderingMethod}"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toRightOf="@id/tv_payment_method" app:layout_constraintLeft_toRightOf="@id/tv_payment_method"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
...@@ -41,7 +86,7 @@ ...@@ -41,7 +86,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5" android:layout_marginTop="@dimen/dp_5"
android:text="123456" android:text="@{data.rECEIVER}"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_14" android:textSize="@dimen/sp_14"
android:textStyle="bold" android:textStyle="bold"
...@@ -53,7 +98,7 @@ ...@@ -53,7 +98,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5" 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:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="@id/tv_order_user_name" app:layout_constraintBottom_toBottomOf="@id/tv_order_user_name"
...@@ -84,7 +129,7 @@ ...@@ -84,7 +129,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_5"
android:text="18938995556" android:text="@{data.pHONE}"
android:textColor="@color/color_ccc" android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toRightOf="@id/barrier_order_info" app:layout_constraintLeft_toRightOf="@id/barrier_order_info"
...@@ -106,7 +151,7 @@ ...@@ -106,7 +151,7 @@
android:id="@+id/tv_order_num" android:id="@+id/tv_order_num"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="18938995556" android:text="@{data.oRDER_NO}"
android:textColor="@color/color_ccc" android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num" app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
...@@ -117,7 +162,11 @@ ...@@ -117,7 +162,11 @@
android:id="@+id/tv_order_state" android:id="@+id/tv_order_state"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="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_constraintBottom_toBottomOf="@id/tv_order_num_text"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_cellphone_num_text" /> app:layout_constraintTop_toTopOf="@id/tv_cellphone_num_text" />
...@@ -139,20 +188,22 @@ ...@@ -139,20 +188,22 @@
android:id="@+id/tv_address" android:id="@+id/tv_address"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="香港島中環餐飲服務公司" android:text="@{data.aDDRESS_DETAIL}"
android:textColor="@color/color_ccc" android:textColor="@color/color_ccc"
android:textSize="@dimen/sp_12" android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num" app:layout_constraintLeft_toLeftOf="@id/tv_cellphone_num"
app:layout_constraintTop_toTopOf="@id/tv_address_text" /> app:layout_constraintTop_toTopOf="@id/tv_address_text" />
<TextView <TextView
android:id="@+id/tv_order_amount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="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:textColor="@color/red_600"
android:textSize="@dimen/sp_14" android:textSize="@dimen/sp_14"
app:layout_constraintBottom_toBottomOf="@id/tv_address" app:layout_constraintBottom_toBottomOf="@id/tv_address"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_address" /> app:layout_constraintTop_toTopOf="@id/tv_address" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.lihang.ShadowLayout> </com.lihang.ShadowLayout>
\ No newline at end of file </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"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#008577</color> <!-- <color name="colorPrimary">#008577</color>-->
<color name="colorPrimaryDark">#00574B</color> <!-- <color name="colorPrimaryDark">#00574B</color>-->
<color name="colorAccent">#D81B60</color> <!-- <color name="colorAccent">#D81B60</color>-->
</resources> </resources>
...@@ -6,4 +6,9 @@ ...@@ -6,4 +6,9 @@
<string name="tab_text_4">送貨中</string> <string name="tab_text_4">送貨中</string>
<string name="tab_text_5">待取餐</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>
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<!-- Customize your theme here. --> <!-- &lt;!&ndash; Customize your theme here. &ndash;&gt;-->
<item name="colorPrimary">@color/colorPrimary</item> <!-- <item name="colorPrimary">@color/colorPrimary</item>-->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <!-- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
<item name="colorAccent">@color/colorAccent</item> <!-- <item name="colorAccent">@color/colorAccent</item>-->
</style> <!-- </style>-->
<style name="AppTheme.NoActionBar"> <style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item> <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 @@ ...@@ -17,7 +17,7 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_logo" android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true" android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_android" android:networkSecurityConfig="@xml/network_android"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
......
...@@ -39,7 +39,7 @@ public class TestPrintDataMaker implements PrintDataMaker { ...@@ -39,7 +39,7 @@ public class TestPrintDataMaker implements PrintDataMaker {
printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(height, width) : new PrinterWriter80mm(height, width); printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(height, width) : new PrinterWriter80mm(height, width);
printer.setAlignCenter(); printer.setAlignCenter();
data.add(printer.getDataAndReset()); 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); data.addAll(image);
List<Bitmap> bitmaps = PrintUtils.getPrintBitmap(context, -1, width);//根據打印類型獲得不同的bitmap List<Bitmap> bitmaps = PrintUtils.getPrintBitmap(context, -1, width);//根據打印類型獲得不同的bitmap
......
...@@ -76,7 +76,7 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta ...@@ -76,7 +76,7 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta
initDialog(); initDialog();
initIntent(); initIntent();
callId = getIntent().getStringExtra(EXTRA_KEY_CALL_ID); callId = getIntent().getStringExtra(EXTRA_KEY_CALL_ID);
if (type == 3) { // if (type == 3) {
//廚房單,可能會有多個IP打印 //廚房單,可能會有多個IP打印
//獲得ip打印列表, //獲得ip打印列表,
//再將食品數據根據打印位置分組。 //再將食品數據根據打印位置分組。
...@@ -84,9 +84,9 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta ...@@ -84,9 +84,9 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta
//打印完成之後,返回所有打印結果。 //打印完成之後,返回所有打印結果。
} else { // } else {
printOrder(this); printOrder(this);
} // }
} }
......
ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错 ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错
apply from: rootProject.file("cc-settings.gradle") apply from: rootProject.file("cc-settings.gradle")
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.jakewharton.butterknife' apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'org.greenrobot.greendao' apply plugin: 'org.greenrobot.greendao'
apply plugin: 'android-aspectjx' apply plugin: 'android-aspectjx'
...@@ -90,4 +92,9 @@ dependencies { ...@@ -90,4 +92,9 @@ dependencies {
api 'com.sunmi:printerlibrary:1.0.7' api 'com.sunmi:printerlibrary:1.0.7'
//上下拉刷新 //上下拉刷新
api 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' 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; package com.gingersoft.gsa.cloud.base.utils.time;
import android.text.TextUtils;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
...@@ -444,6 +446,9 @@ public class TimeUtils { ...@@ -444,6 +446,9 @@ public class TimeUtils {
*/ */
public static String parseTimeRepeat(String time, SimpleDateFormat dateFormat) { public static String parseTimeRepeat(String time, SimpleDateFormat dateFormat) {
Date date = null; Date date = null;
if(TextUtils.isEmpty(time)){
return "";
}
try { try {
date = new Date(time); date = new Date(time);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
......
...@@ -91,12 +91,13 @@ public class Function { ...@@ -91,12 +91,13 @@ public class Function {
this.textSize = textSize; 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.id = id;
this.parentId = parentId; this.parentId = parentId;
this.groupId = groupId; this.groupId = groupId;
this.resName = resName; this.resName = resName;
this.icRes = icRes; this.icRes = icRes;
this.status = status;
} }
public Function(int nameRes, int textColorRes, int backgroundColorRes, int textSizeRes) { 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 @@ ...@@ -409,4 +409,14 @@
<enum name="left" value="3" /> <enum name="left" value="3" />
</attr> </attr>
</declare-styleable> </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> </resources>
\ No newline at end of file
...@@ -447,6 +447,24 @@ ...@@ -447,6 +447,24 @@
<color name="color_8f">#8f8f8f</color> <color name="color_8f">#8f8f8f</color>
<color name="color_3c">#3c3c3c</color> <color name="color_3c">#3c3c3c</color>
<color name="color_e4">#E4E4E4</color>
<color name="color_f0">#F0F0F0</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> </resources>
...@@ -482,4 +482,6 @@ ...@@ -482,4 +482,6 @@
<dimen name="sp_48">48sp</dimen> <dimen name="sp_48">48sp</dimen>
<!-- 清機報表字體大小 --> <!-- 清機報表字體大小 -->
<dimen name="settlement_report_text_size">@dimen/sp_18</dimen> <dimen name="settlement_report_text_size">@dimen/sp_18</dimen>
<dimen name="switcher_elevation">4dp</dimen>
</resources> </resources>
\ No newline at end of file
...@@ -137,4 +137,10 @@ ...@@ -137,4 +137,10 @@
<string name="app_exception">很抱歉,程序出現異常,即將退出!</string> <string name="app_exception">很抱歉,程序出現異常,即將退出!</string>
<string name="queue_write_external_storage_permission_hint">保存失敗,請先前往設置開放存儲權限</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> </resources>
...@@ -291,4 +291,13 @@ ...@@ -291,4 +291,13 @@
<item name="android:textSize">@dimen/sp_13</item> <item name="android:textSize">@dimen/sp_13</item>
<item name="android:textColor">@color/theme_hint_color</item> <item name="android:textColor">@color/theme_hint_color</item>
</style> </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> </resources>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<application <application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication" android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_logo" android:icon="@mipmap/ic_launcher"
android:label="@string/user_login_name" android:label="@string/user_login_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
......
...@@ -58,10 +58,12 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -58,10 +58,12 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
TextView mTvGuideTitle; TextView mTvGuideTitle;
@BindView(R2.id.tv_guide_details) @BindView(R2.id.tv_guide_details)
TextView mTvGuideDetails; TextView mTvGuideDetails;
@BindView(R2.id.tv_experience)
TextView mTvExperience;
List<GuideBean> guideBeanList = new ArrayList<>(); List<GuideBean> guideBeanList = new ArrayList<>();
private final long ANIMATION_TIME = 1300; private final long ANIMATION_TIME = 1300;
@Override @Override
public void setupActivityComponent(@NonNull AppComponent appComponent) { public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerWelcomeComponent //如找不到该类,请编译一下项目 DaggerWelcomeComponent //如找不到该类,请编译一下项目
...@@ -111,7 +113,6 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -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_one)));
guideBeanList.add(new GuideBean("數據分析可視化", "數據統計一目了然,直觀看到數據變化趨勢", getResources().getDrawable(R.mipmap.pic_guide_two))); guideBeanList.add(new GuideBean("數據分析可視化", "數據統計一目了然,直觀看到數據變化趨勢", getResources().getDrawable(R.mipmap.pic_guide_two)));
guideBeanList.add(new GuideBean("多種點餐方式", "提供方便快捷的點餐服務,減低落錯單機會", getResources().getDrawable(R.mipmap.pic_guide_three))); guideBeanList.add(new GuideBean("多種點餐方式", "提供方便快捷的點餐服務,減低落錯單機會", getResources().getDrawable(R.mipmap.pic_guide_three)));
...@@ -124,6 +125,11 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -124,6 +125,11 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
public void onPageSelected(int position) { public void onPageSelected(int position) {
super.onPageSelected(position); super.onPageSelected(position);
updateUI(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 ...@@ -280,11 +286,12 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
.show(); .show();
} }
@OnClick({R2.id.iv_guide_close}) @OnClick({R2.id.iv_guide_close,R2.id.tv_experience})
@Override @Override
public void onClick(View v) { 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); SPUtils.put(mContext, UserConstans.IS_GUIDE, false);
startActivity(new Intent(mContext, LoginActivity.class)); startActivity(new Intent(mContext, LoginActivity.class));
killMyself(); 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 @@ ...@@ -107,6 +107,24 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="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 <com.gingersoft.gsa.cloud.ui.widget.Indicator.UIndicator
android:id="@+id/guide_magic_indicator" android:id="@+id/guide_magic_indicator"
android:layout_width="wrap_content" 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