From cf1830fced1a76e6d52a761d211199f718bdb229 Mon Sep 17 00:00:00 2001 From: qyj <907010200@qq.com> Date: Sun, 6 Nov 2022 23:04:02 +0800 Subject: [PATCH] 1 --- 1/MainActivity.java | 173 +++++++++++++++++++++++++++++++++++++++ 1/MyApplication.java | 21 +++++ 1/TmainActivity.java | 24 ++++++ 1/activity_tmain.xml | 128 +++++++++++++++++++++++++++++ 1/activity_turntable.xml | 42 ++++++++++ 1/bg_turntableleft.xml | 10 +++ 1/bg_turntableright.xml | 10 +++ 1/ninglibrary.jpg | Bin 0 -> 562261 bytes 1/turntable.png | Bin 0 -> 49582 bytes 9 files changed, 408 insertions(+) create mode 100644 1/MainActivity.java create mode 100644 1/MyApplication.java create mode 100644 1/TmainActivity.java create mode 100644 1/activity_tmain.xml create mode 100644 1/activity_turntable.xml create mode 100644 1/bg_turntableleft.xml create mode 100644 1/bg_turntableright.xml create mode 100644 1/ninglibrary.jpg create mode 100644 1/turntable.png diff --git a/1/MainActivity.java b/1/MainActivity.java new file mode 100644 index 0000000..6a64aa4 --- /dev/null +++ b/1/MainActivity.java @@ -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; + } + } + } ); + } +} diff --git a/1/MyApplication.java b/1/MyApplication.java new file mode 100644 index 0000000..4096562 --- /dev/null +++ b/1/MyApplication.java @@ -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(); + } +} diff --git a/1/TmainActivity.java b/1/TmainActivity.java new file mode 100644 index 0000000..166771e --- /dev/null +++ b/1/TmainActivity.java @@ -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() { + + } +} diff --git a/1/activity_tmain.xml b/1/activity_tmain.xml new file mode 100644 index 0000000..bd2c410 --- /dev/null +++ b/1/activity_tmain.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + +