Branch_QYJ
parent
6f3ca2e138
commit
cf1830fced
@ -0,0 +1,173 @@
|
||||
package com.sbw.atrue.Order.Activity;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.franzliszt.SP;
|
||||
import com.franzliszt.foodturntable.AnimatedCircleLoadingView;
|
||||
import com.franzliszt.foodturntable.Turntable;
|
||||
import com.sbw.atrue.Order.R;
|
||||
|
||||
//import com.sbw.atrue.Order.Activity.Turntable;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private AnimatedCircleLoadingView loadingView;
|
||||
protected Turntable turntable;
|
||||
private int count = 0;
|
||||
private ImageView ChangeStatus;
|
||||
private RadioGroup RG;
|
||||
private SP sp;
|
||||
private Context context = null;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate( savedInstanceState );
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
View decorView = getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE );
|
||||
getWindow().setStatusBarColor( Color.TRANSPARENT );
|
||||
}
|
||||
setContentView( R.layout.activity_tmain );
|
||||
InitView();
|
||||
SelectNumber();
|
||||
}
|
||||
|
||||
private void InitView() {
|
||||
turntable = findViewById( R.id.TurnTable );
|
||||
loadingView = findViewById( R.id.loadingView );
|
||||
ChangeStatus = findViewById( R.id.StartAndEnd );
|
||||
RG = findViewById( R.id.RG );
|
||||
/*默认设置8等份*/
|
||||
turntable.InitNumber( 8 );
|
||||
if (context == null) {
|
||||
context = MainActivity.this;
|
||||
}
|
||||
sp = new SP( context );
|
||||
}
|
||||
|
||||
public void Start(View view) {
|
||||
count++;
|
||||
/*暂停*/
|
||||
if (count % 2 == 0) {
|
||||
turntable.Stop();
|
||||
StartIcon();
|
||||
} else {
|
||||
/*开始*/
|
||||
turntable.Start( -1 );
|
||||
StopIcon();
|
||||
}
|
||||
}
|
||||
|
||||
private void StartIcon() {
|
||||
ChangeStatus.setImageDrawable( getResources().getDrawable( R.drawable.start ) );
|
||||
}
|
||||
|
||||
private void StopIcon() {
|
||||
ChangeStatus.setImageDrawable( getResources().getDrawable( R.drawable.stop ) );
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public void Confirm(View view) {
|
||||
RevealAnim( view );
|
||||
loadingView.setVisibility( View.VISIBLE );
|
||||
startLoading();
|
||||
startPercentMockThread();
|
||||
int num = (int) sp.GetData( context, "num", 0 );
|
||||
turntable.InitNumber( num );
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public void Reset(View view) {
|
||||
RevealAnim( view );
|
||||
loadingView.setVisibility( View.GONE );
|
||||
resetLoading();
|
||||
}
|
||||
|
||||
private void startLoading() {
|
||||
loadingView.startIndeterminate();
|
||||
}
|
||||
|
||||
private void startPercentMockThread() {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep( 500 );
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
Thread.sleep( 40 );
|
||||
changePercent( i );
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
new Thread(runnable).start();
|
||||
}
|
||||
|
||||
private void changePercent(final int percent) {
|
||||
runOnUiThread( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadingView.setPercent( percent );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public void resetLoading() {
|
||||
runOnUiThread( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadingView.resetLoading();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void RevealAnim(View view) {
|
||||
Animator animator = ViewAnimationUtils.createCircularReveal(
|
||||
view, view.getWidth() / 2, view.getHeight() / 2, view.getWidth(), 0
|
||||
);
|
||||
animator.setInterpolator( new AccelerateDecelerateInterpolator() );
|
||||
animator.setDuration( 2000 );
|
||||
animator.start();
|
||||
|
||||
}
|
||||
|
||||
private void SelectNumber() {
|
||||
RG.setOnCheckedChangeListener( new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
switch (checkedId) {
|
||||
case R.id.threeParts:
|
||||
sp.PutData( context, "num", 3 );
|
||||
break;
|
||||
/*
|
||||
case R.id.fourParts:
|
||||
sp.PutData( context, "num", 4 );
|
||||
break;
|
||||
case R.id.sixParts:
|
||||
sp.PutData( context, "num", 6 );
|
||||
break;
|
||||
|
||||
*/
|
||||
case R.id.eightParts:
|
||||
sp.PutData( context, "num", 8 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.sbw.atrue.Order.Activity;
|
||||
|
||||
|
||||
import com.yanzhenjie.nohttp.InitializationConfig;
|
||||
import com.yanzhenjie.nohttp.NoHttp;
|
||||
|
||||
import org.litepal.LitePalApplication;
|
||||
|
||||
public class MyApplication extends LitePalApplication {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
InitializationConfig config = InitializationConfig.newBuilder(this)
|
||||
.connectionTimeout(30 * 1000)
|
||||
.readTimeout(30 * 1000)
|
||||
.retry(10)
|
||||
.build();
|
||||
NoHttp.initialize(config);
|
||||
Connection.mymysql();
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.sbw.atrue.Order.Activity;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.sbw.atrue.Order.R;
|
||||
|
||||
public class TmainActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_tmain);
|
||||
initViews(); //初始化页面控件
|
||||
//initEvents(); //初始化控件事件
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#ffffff">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="#cc00cc"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="航吃Hang吃"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="17sp"
|
||||
android:padding="10dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.sbw.atrue.Order.Activity.Turntable
|
||||
android:id="@+id/TurnTable"
|
||||
android:layout_width="389dp"
|
||||
android:layout_height="345dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:padding="20dp" />
|
||||
<ImageView
|
||||
android:id="@+id/StartAndEnd"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/start"
|
||||
android:onClick="Start"/>
|
||||
<com.franzliszt.foodturntable.AnimatedCircleLoadingView
|
||||
android:id="@+id/loadingView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000000"
|
||||
android:alpha="0.9"
|
||||
android:layout_centerInParent="true"
|
||||
app:animCircleLoadingView_mainColor="#cc00cc"
|
||||
app:animCircleLoadingView_secondaryColor="#ff0000"
|
||||
app:animCircleLoadingView_textColor="@android:color/white"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/TurnTable"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="20dp"
|
||||
>
|
||||
<RadioGroup
|
||||
android:id="@+id/RG"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
>
|
||||
<RadioButton
|
||||
android:id="@+id/eightParts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="食堂"
|
||||
android:layout_marginRight="10dp"
|
||||
/>
|
||||
<RadioButton
|
||||
android:id="@+id/threeParts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="楼层"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginLeft="10dp"/>
|
||||
<RadioButton
|
||||
android:id="@+id/eightParts1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="窗口"
|
||||
android:layout_marginLeft="10dp"/>
|
||||
</RadioGroup>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="20dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/ConfirmSelection"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginRight="20dp"
|
||||
android:background="@drawable/oval"
|
||||
android:elevation="4dp"
|
||||
android:onClick="Confirm"
|
||||
android:text="Confirm"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="12sp" />
|
||||
<Button
|
||||
android:elevation="10dp"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:text="Reset"
|
||||
android:textSize="12sp"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="#ffffff"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:onClick="Reset"
|
||||
android:background="@drawable/oval"
|
||||
android:layout_marginLeft="20dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/background01">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="14dp"
|
||||
android:paddingTop="220dp"
|
||||
android:paddingRight="14dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/canteen_floor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="楼层"
|
||||
android:textColor="#000"
|
||||
android:textSize="30sp"
|
||||
android:background="@drawable/bg_turntableleft"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/canteen_window"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_weight="2"
|
||||
android:gravity="center"
|
||||
android:text="窗口"
|
||||
android:textColor="#000"
|
||||
android:textSize="30sp"
|
||||
android:background="@drawable/bg_turntableright"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/colorBlack"/>
|
||||
<corners
|
||||
android:bottomLeftRadius="5dp"
|
||||
android:topLeftRadius="5dp"/>
|
||||
|
||||
</shape>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/colorBlack"/>
|
||||
<corners
|
||||
android:bottomRightRadius="5dp"
|
||||
android:topRightRadius="5dp"/>
|
||||
|
||||
</shape>
|
After Width: | Height: | Size: 549 KiB |
After Width: | Height: | Size: 48 KiB |
Loading…
Reference in new issue