Commit 4eb775c2 by chengchong

返回问题1213

parent d530dc61
package com.example.blu.toys.activity;
import android.Manifest;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Observable;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.example.blu.toys.MainActivity;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.utils.Utils;
import com.example.blu.toys.view.WrapContentGridLayoutManager;
......@@ -29,11 +15,9 @@ import com.hjq.permissions.OnPermission;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import java.util.ArrayList;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.Unbinder;
......@@ -54,7 +38,6 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayout());
// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
AppManager.getInstance().addActivity(this);
checkPermission();
mBinder = ButterKnife.bind(this);
......
......@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.View;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.view.TypefaceTextView;
import butterknife.BindView;
......@@ -17,6 +18,8 @@ public class MusicActivity extends BaseActivity {
TypefaceTextView openMusic;
@BindView(R.id.close_music)
TypefaceTextView closeMusic;
@BindView(R.id.back_but)
TypefaceTextView backBut;
@Override
public int getLayout() {
......@@ -47,4 +50,10 @@ public class MusicActivity extends BaseActivity {
}
startActivity(intent);
}
@OnClick(R.id.back_but)
public void onViewClicked() {
AppManager.getInstance().finishActivity();
}
}
\ No newline at end of file
......@@ -5,12 +5,12 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Toast;
import com.blankj.utilcode.util.LogUtils;
import com.clj.fastble.callback.BleWriteCallback;
import com.clj.fastble.exception.BleException;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.ble.BlePlay;
import com.example.blu.toys.ble.agreement.TrafficLightBean;
import com.example.blu.toys.utils.SpUtils;
......@@ -29,7 +29,7 @@ public class PlayActivity extends BaseActivity {
TypefaceTextView typefaceTextView;//倒计时
private int suspendAndContinue=1;
private int suspendAndContinue = 1;
private int mDay = 0;
private int mHour = 0;
private int mMin = 0;
......@@ -40,13 +40,14 @@ public class PlayActivity extends BaseActivity {
/**
* 不够位数的在前面补0,保留num的长度位数字
*
* @param code
* @return
*/
private String autoGenericCode(String code, int num) {
String result = "";
// 保留num的位数
// 0 代表前面补充0
// 0 代表前面补充0
// num 代表长度为4
// d 代表参数为正数型
result = String.format("%0" + num + "d", Integer.parseInt(code) + 1);
......@@ -55,15 +56,15 @@ public class PlayActivity extends BaseActivity {
}
public static String addZeroForNum(String str,int strLength) {
int strLen =str.length();
if (strLen <strLength) {
while (strLen< strLength) {
public static String addZeroForNum(String str, int strLength) {
int strLen = str.length();
if (strLen < strLength) {
while (strLen < strLength) {
StringBuffer sb = new StringBuffer();
sb.append("0").append(str);//左补0
// sb.append(str).append("0");//右补0
str= sb.toString();
strLen= str.length();
str = sb.toString();
strLen = str.length();
}
}
......@@ -75,11 +76,11 @@ public class PlayActivity extends BaseActivity {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
LogUtils.e("定时器在走111",msg.what,mHour,mMin,mSecond);
if((mHour+mMin+mSecond)<1){
suspendAndContinue=0;
LogUtils.e("定时器在走111", msg.what, mHour, mMin, mSecond);
if ((mHour + mMin + mSecond) < 1) {
suspendAndContinue = 0;
}
if(suspendAndContinue==1) {
if (suspendAndContinue == 1) {
String mHourStr = addZeroForNum(mHour + "", 2);
String mMinStr = addZeroForNum(mMin + "", 2);
......@@ -94,14 +95,16 @@ public class PlayActivity extends BaseActivity {
}
};
private TimerManager timerManager=new TimerManager(timeHandler);;
private TimerManager timerManager = new TimerManager(timeHandler);
;
/**
* 开启倒计时
*/
private void startRun() {
timerManager.startTimer(0,1000);
timerManager.startTimer(0, 1000);
// new Thread(() -> {
// while (isRun) {
......@@ -121,12 +124,10 @@ public class PlayActivity extends BaseActivity {
* 倒计时计算
*/
private void computeTime() {
LogUtils.e("获取的时分秒",mHour,mMin,mSecond);
LogUtils.e("获取的时分秒", mHour, mMin, mSecond);
totalSecond--;
TimeBean timeBean= TimeUtil.getTimeBeanBySecond(Long.valueOf(totalSecond));
TimeBean timeBean = TimeUtil.getTimeBeanBySecond(Long.valueOf(totalSecond));
mSecond = timeBean.getmSecond();
mHour = timeBean.getmHour();
mMin = timeBean.getmMin();
......@@ -146,10 +147,8 @@ public class PlayActivity extends BaseActivity {
mHour = intent.getIntExtra("hour", 0);
mMin = intent.getIntExtra("min", 0);
mSecond = intent.getIntExtra("second", 0);
totalSecond=mHour*3600+mMin*60+mSecond;
LogUtils.e("获取的时分秒",mHour,mMin,mSecond,totalSecond);
totalSecond = mHour * 3600 + mMin * 60 + mSecond;
LogUtils.e("获取的时分秒", mHour, mMin, mSecond, totalSecond);
startRun();
}
......@@ -158,7 +157,7 @@ public class PlayActivity extends BaseActivity {
}
public void sendBleData(){
public void sendBleData() {
SpUtils spUtils = SpUtils.getSpUtils(PlayActivity.this);
int close = spUtils.getSPValue("close", 1);
int open = spUtils.getSPValue("open", 10);
......@@ -171,10 +170,7 @@ public class PlayActivity extends BaseActivity {
BlePlay.getInstance().sendPause(bytes12, new BleWriteCallback() {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
LogUtils.e("发送成功:"+suspendAndContinue);
//timerManager.cancelTimer();
LogUtils.e("发送成功:" + suspendAndContinue);
}
@Override
......@@ -187,9 +183,7 @@ public class PlayActivity extends BaseActivity {
@OnClick(R.id.back_but)
public void onViewClicked() {
timerManager.cancelTimer();
Intent intent = new Intent(PlayActivity.this, SetTimeActivity.class);
startActivity(intent);
AppManager.getInstance().finishActivity();
}
@Override
......@@ -199,6 +193,7 @@ public class PlayActivity extends BaseActivity {
startActivity(intent);
}
@OnClick({R.id.cancel_but, R.id.pause_but, R.id.resume_but})
public void onViewClicked(View view) {
SpUtils spUtils = SpUtils.getSpUtils(PlayActivity.this);
......@@ -210,7 +205,6 @@ public class PlayActivity extends BaseActivity {
switch (view.getId()) {
case R.id.cancel_but://取消 关机
timerManager.cancelTimer();
TrafficLightBean trafficLightBean = new TrafficLightBean(
1, 0,
......@@ -220,9 +214,7 @@ public class PlayActivity extends BaseActivity {
@Override
public void onWriteSuccess(int current, int total, byte[] justWrite) {
ToastUtils.show("关机-发送成功");
finish();
AppManager.getInstance().finishActivity();
}
@Override
......@@ -234,7 +226,7 @@ public class PlayActivity extends BaseActivity {
break;
case R.id.pause_but://暂停
// int time = mHour * 3600 + mMin * 60 + mSecond;
suspendAndContinue=0;
suspendAndContinue = 0;
// TrafficLightBean ttt = new TrafficLightBean(2, suspendAndContinue,
// time, brightness, open, close, green, alarm);
// byte[] bytes12 = ttt.toByte();
......@@ -254,9 +246,7 @@ public class PlayActivity extends BaseActivity {
// });
break;
case R.id.resume_but://开始
suspendAndContinue=1;
suspendAndContinue = 1;
break;
}
}
......
package com.example.blu.toys.activity;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.AppCompatImageView;
import com.blankj.utilcode.util.LogUtils;
import com.clj.fastble.BleManager;
import com.clj.fastble.data.BleDevice;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.ble.BlePlay;
......@@ -21,10 +16,7 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class SearchingActivity extends BaseActivity {
......
......@@ -2,7 +2,6 @@ package com.example.blu.toys.activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.Switch;
......@@ -12,7 +11,6 @@ import com.example.blu.toys.utils.SpUtils;
import com.example.blu.toys.view.TypefaceTextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
//设置
......
......@@ -3,16 +3,13 @@ package com.example.blu.toys.activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.StringUtils;
import com.clj.fastble.callback.BleWriteCallback;
import com.clj.fastble.data.BleDevice;
import com.clj.fastble.exception.BleException;
import com.example.blu.toys.R;
import com.example.blu.toys.app.AppManager;
......@@ -26,9 +23,6 @@ import com.example.blu.toys.view.TypefaceTextView;
import com.example.blu.toys.view.WheelView;
import com.hjq.toast.ToastUtils;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
......@@ -40,15 +34,11 @@ public class SetTimeActivity extends BaseActivity {
@BindView(R.id.wheel_hour) //时
WheelView wheelHour;
WheelView wheelHour;
@BindView(R.id.wheel_minute)//分
WheelView wheelMinute;
WheelView wheelMinute;
@BindView(R.id.wheel_second)//秒
WheelView wheelSecond;
// @BindView(R.id.wheel_am_pm)
// WheelView wheelAmPm;
// amPmList.add("AM");
// amPmList.add("PM");
WheelView wheelSecond;
@BindView(R.id.wheel_hour_dw)
WheelView wheelHour_dw;
......@@ -130,7 +120,6 @@ public class SetTimeActivity extends BaseActivity {
private TimeBean getTopTime() {
TimeBean timeBean = new TimeBean();
String hour = wheelHour.getSeletedItem();
String minute = wheelMinute.getSeletedItem();
String second = wheelSecond.getSeletedItem();
......@@ -331,12 +320,6 @@ public class SetTimeActivity extends BaseActivity {
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void setBleDevice(BleDevice ble) {
LogUtils.e("连接 成功-----开机");
}
@Override
public void onBackPressed() {
BlePlay.getInstance().closeBle();
......@@ -361,8 +344,7 @@ public class SetTimeActivity extends BaseActivity {
break;
case R.id.back_but:
BlePlay.getInstance().closeBle();
intent = new Intent(SetTimeActivity.this, SelectDeviceActivity.class);
startActivity(intent);
AppManager.getInstance().finishActivity();
break;
case R.id.start_but:
boolean bleOpen = BlePlay.getInstance().isBleOpen();
......@@ -378,7 +360,6 @@ public class SetTimeActivity extends BaseActivity {
hour = Integer.valueOf(selectHour_dw);
min = Integer.valueOf(selectMin_dw);
int time = Integer.valueOf(selectHour_dw) * 3600 + Integer.valueOf(selectMin_dw) * 60 + Integer.valueOf(selectSec_dw);
if (time == 0) {
ToastUtils.show("请选择时间");
......
package com.example.blu.toys.activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.clj.fastble.data.BleDevice;
import androidx.recyclerview.widget.RecyclerView;
import com.example.blu.toys.R;
import com.example.blu.toys.adapter.BleDeviceAdapter;
import com.example.blu.toys.adapter.MusicAdapter;
import com.example.blu.toys.app.AppManager;
import com.example.blu.toys.utils.SpUtils;
import com.example.blu.toys.view.TypefaceTextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class SettingMusicActivity extends BaseActivity {
......@@ -26,6 +25,9 @@ public class SettingMusicActivity extends BaseActivity {
RecyclerView mRecyclerView;
MusicAdapter musicAdapter;
@BindView(R.id.back_but)
TypefaceTextView backBut;
private List<Integer> integerList;
private SpUtils spUtils;
......@@ -53,6 +55,7 @@ public class SettingMusicActivity extends BaseActivity {
} else {
spUtils.putSPValue("open", integer);
}
AppManager.getInstance().finishActivity();
});
}
......@@ -60,4 +63,9 @@ public class SettingMusicActivity extends BaseActivity {
public void initData() {
}
@OnClick(R.id.back_but)
public void onViewClicked() {
AppManager.getInstance().finishActivity();
}
}
\ No newline at end of file
......@@ -41,7 +41,7 @@ public class App extends Application {
.setReConnectCount(3, 5000)
.setMaxConnectCount(7)
.setConnectOverTime(20000)
.setOperateTimeout(5000);
.setOperateTimeout(1000);
//
// BleManager.getInstance()
......
......@@ -8,14 +8,27 @@
android:orientation="vertical"
tools:context=".activity.MusicActivity">
<com.example.blu.toys.view.TypefaceTextView
android:id="@+id/back_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:background="@drawable/black_thumb"
android:gravity="center"
android:padding="@dimen/dp_5"
android:text="Back"
android:textColor="@color/white"
android:textSize="@dimen/sp_28"
android:textStyle="bold"
app:typeface="@string/LittleOrion" />
<com.example.blu.toys.view.TypefaceTextView
android:id="@+id/open_music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/back_but"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_14"
android:gravity="center"
android:text="开机音乐"
......@@ -29,8 +42,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/back_but"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_14"
android:gravity="center"
android:text="关机音乐"
......
......@@ -5,8 +5,25 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFCA05"
android:orientation="vertical"
tools:context=".activity.SettingMusicActivity">
<com.example.blu.toys.view.TypefaceTextView
android:id="@+id/back_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:background="@drawable/black_thumb"
android:gravity="center"
android:padding="@dimen/dp_5"
android:text="Back"
android:textColor="@color/white"
android:textSize="@dimen/sp_28"
android:textStyle="bold"
app:typeface="@string/LittleOrion" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
......
......@@ -5,9 +5,7 @@
android:id="@+id/dv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_20"
android:background="@drawable/black_thumb"
android:gravity="center"
android:padding="@dimen/dp_10"
......
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