SDGustInfo fixbug

This commit is contained in:
limqhz
2020-07-28 21:13:18 +08:00
parent 7557fa202d
commit e20862daf1
2 changed files with 30 additions and 52 deletions

View File

@@ -40,8 +40,6 @@ public class SDBaseActivity extends Activity {
public void setContentView(View view, ViewGroup.LayoutParams params) { public void setContentView(View view, ViewGroup.LayoutParams params) {
super.setContentView(view, params); super.setContentView(view, params);
ButterKnife.bind(this); ButterKnife.bind(this);
// ScreenAdapterTools.getInstance().loadView(getWindow().getDecorView());
} }
@Override @Override

View File

@@ -1,6 +1,8 @@
package com.ydd.sportfaceid.view; package com.ydd.sportfaceid.view;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -19,10 +21,6 @@ import java.util.TimerTask;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/** /**
* Created by sandershan on 2018/12/4. * Created by sandershan on 2018/12/4.
@@ -31,66 +29,49 @@ import rx.schedulers.Schedulers;
public class SDGustInfoView extends RelativeLayout { public class SDGustInfoView extends RelativeLayout {
public Context mContext; public Context mContext;
public static String mMemberName ="";
@BindView(R.id.app_logo_imageview)
ImageView app_logo_imageview;
@BindView(R.id.time_label) @BindView(R.id.time_label)
TextView time_label; TextView time_label;
@BindView(R.id.date_label) @BindView(R.id.date_label)
TextView date_label; TextView date_label;
private Timer mTimerOutput; private Timer timer = new Timer();
Handler handler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
Date now_date = new Date();
SimpleDateFormat time_format =new SimpleDateFormat("HH:mm");
String time_string = time_format.format(now_date);
time_label.setText(time_string);
SimpleDateFormat date_format =new SimpleDateFormat("yyyy/MM/dd");
String date_string = date_format.format(now_date);
String weak_string = TimeUntil.getWeakDay(now_date);
date_label.setText(date_string + " " + weak_string);
break;
}
super.handleMessage(msg);
}
};
public SDGustInfoView(Context context, @Nullable AttributeSet attrs) { public SDGustInfoView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs); super(context, attrs);
this.mContext = context; this.mContext = context;
LayoutInflater.from(context).inflate(R.layout.layout_guest_info_top, this); LayoutInflater.from(context).inflate(R.layout.layout_guest_info_top, this);
ButterKnife.bind(this); ButterKnife.bind(this);
sdConfigData();
startRunUpdateTime(); startRunUpdateTime();
} }
public void sdConfigData(){
Date now_date = new Date();
SimpleDateFormat time_format =new SimpleDateFormat("HH:mm");
String time_string = time_format.format(now_date);
time_label.setText(time_string);
SimpleDateFormat date_format =new SimpleDateFormat("yyyy/MM/dd");
String date_string = date_format.format(now_date);
String weak_string = TimeUntil.getWeakDay(now_date);
date_label.setText(date_string + " " + weak_string);
}
public void startRunUpdateTime(){ public void startRunUpdateTime(){
mTimerOutput = new Timer(); timer.schedule(new TimerTask() {
mTimerOutput.schedule(new TimerTask() {
@Override @Override
public void run() { //定时器,更新日志 public void run() { //定时器,更新日志
Observable.create(subscriber -> { Message message = new Message();
subscriber.onNext(null); message.what = 1;
subscriber.onCompleted(); handler.sendMessage(message);
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<Object>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Object o) {
sdConfigData();
}
});
} }
}, 100, 1000); }, 100, 1000);
} }
@@ -99,11 +80,10 @@ public class SDGustInfoView extends RelativeLayout {
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
if (mTimerOutput != null){ if (timer != null){
this.mTimerOutput.cancel(); this.timer.cancel();
this.mTimerOutput = null; this.timer = null;
} }
} }
} }