loop fragment cleanup

This commit is contained in:
Milos Kozak 2016-08-02 19:03:02 +02:00
parent 6b75dd3dc9
commit 2f47f2a048

View file

@ -11,8 +11,6 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.NotificationCompat; import android.support.v7.app.NotificationCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -57,7 +55,7 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
public static HandlerThread mHandlerThread; public static HandlerThread mHandlerThread;
public class LastRun implements Parcelable { public class LastRun {
public APSResult request = null; public APSResult request = null;
public APSResult constraintsProcessed = null; public APSResult constraintsProcessed = null;
public PumpEnactResult setByPump = null; public PumpEnactResult setByPump = null;
@ -65,46 +63,7 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
public Date lastAPSRun = null; public Date lastAPSRun = null;
public Date lastEnact = null; public Date lastEnact = null;
public Date lastOpenModeAccept = null; public Date lastOpenModeAccept = null;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(request, 0);
dest.writeParcelable(constraintsProcessed, 0);
dest.writeParcelable(setByPump, 0);
dest.writeString(source);
dest.writeLong(lastAPSRun.getTime());
dest.writeLong(lastEnact != null ? lastEnact.getTime() : 0l);
dest.writeLong(lastOpenModeAccept != null ? lastOpenModeAccept.getTime() : 0l);
}
public final Parcelable.Creator<LastRun> CREATOR = new Parcelable.Creator<LastRun>() {
public LastRun createFromParcel(Parcel in) {
return new LastRun(in);
}
public LastRun[] newArray(int size) {
return new LastRun[size];
}
};
private LastRun(Parcel in) {
request = in.readParcelable(APSResult.class.getClassLoader());
constraintsProcessed = in.readParcelable(APSResult.class.getClassLoader());
setByPump = in.readParcelable(PumpEnactResult.class.getClassLoader());
source = in.readString();
lastAPSRun = new Date(in.readLong());
lastEnact = new Date(in.readLong());
lastOpenModeAccept = new Date(in.readLong());
}
public LastRun() {
}
}
static public LastRun lastRun = null; static public LastRun lastRun = null;
@ -159,11 +118,6 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
return fragment; return fragment;
} }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -178,19 +132,10 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
runNowButton = (Button) view.findViewById(R.id.loop_run); runNowButton = (Button) view.findViewById(R.id.loop_run);
runNowButton.setOnClickListener(this); runNowButton.setOnClickListener(this);
//if (savedInstanceState != null) {
// lastRun = savedInstanceState.getParcelable("lastrun");
//}
updateGUI(); updateGUI();
return view; return view;
} }
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable("lastrun", lastRun);
}
private void registerBus() { private void registerBus() {
try { try {
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
@ -238,7 +183,7 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
final ConfigBuilderFragment configBuilder = MainApp.getConfigBuilder(); final ConfigBuilderFragment configBuilder = MainApp.getConfigBuilder();
APSResult result = null; APSResult result = null;
if (constraintsInterface == null || configBuilder == null || !isEnabled(PluginBase.GENERAL)) if (configBuilder == null || !isEnabled(PluginBase.GENERAL))
return; return;
APSInterface usedAPS = null; APSInterface usedAPS = null;