SDGustInfo fixbug
This commit is contained in:
@@ -40,8 +40,6 @@ public class SDBaseActivity extends Activity {
|
||||
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
||||
super.setContentView(view, params);
|
||||
ButterKnife.bind(this);
|
||||
// ScreenAdapterTools.getInstance().loadView(getWindow().getDecorView());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ydd.sportfaceid.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -19,10 +21,6 @@ import java.util.TimerTask;
|
||||
|
||||
import butterknife.BindView;
|
||||
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.
|
||||
@@ -31,30 +29,18 @@ import rx.schedulers.Schedulers;
|
||||
public class SDGustInfoView extends RelativeLayout {
|
||||
|
||||
public Context mContext;
|
||||
|
||||
public static String mMemberName ="";
|
||||
|
||||
@BindView(R.id.app_logo_imageview)
|
||||
ImageView app_logo_imageview;
|
||||
|
||||
@BindView(R.id.time_label)
|
||||
TextView time_label;
|
||||
@BindView(R.id.date_label)
|
||||
TextView date_label;
|
||||
|
||||
private Timer mTimerOutput;
|
||||
private Timer timer = new Timer();
|
||||
|
||||
public SDGustInfoView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.mContext = context;
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_guest_info_top, this);
|
||||
ButterKnife.bind(this);
|
||||
sdConfigData();
|
||||
startRunUpdateTime();
|
||||
Handler handler = new Handler(){
|
||||
|
||||
}
|
||||
|
||||
public void sdConfigData(){
|
||||
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);
|
||||
@@ -63,34 +49,29 @@ public class SDGustInfoView extends RelativeLayout {
|
||||
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) {
|
||||
super(context, attrs);
|
||||
this.mContext = context;
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_guest_info_top, this);
|
||||
ButterKnife.bind(this);
|
||||
startRunUpdateTime();
|
||||
|
||||
}
|
||||
|
||||
public void startRunUpdateTime(){
|
||||
mTimerOutput = new Timer();
|
||||
mTimerOutput.schedule(new TimerTask() {
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() { //定时器,更新日志
|
||||
Observable.create(subscriber -> {
|
||||
subscriber.onNext(null);
|
||||
subscriber.onCompleted();
|
||||
}).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();
|
||||
}
|
||||
});
|
||||
Message message = new Message();
|
||||
message.what = 1;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
}, 100, 1000);
|
||||
}
|
||||
@@ -99,11 +80,10 @@ public class SDGustInfoView extends RelativeLayout {
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (mTimerOutput != null){
|
||||
this.mTimerOutput.cancel();
|
||||
this.mTimerOutput = null;
|
||||
if (timer != null){
|
||||
this.timer.cancel();
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user