Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
Now cancel button unregisters hr sensor listener
Browse files Browse the repository at this point in the history
Signed-off-by: micrusa <micrusa@hotmail.es>
  • Loading branch information
micrusa committed Apr 12, 2020
1 parent be98dd9 commit 291f000
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/src/main/java/me/micrusa/amaztimer/widget.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ public class widget extends AbstractPlugin {
//Much like a fragment, getView returns the content view of the page. You can set up your layout here
@Override
public View getView(final Context paramContext) {
//Setup view
Log.d(TAG, "getView()" + paramContext.getPackageName() + " AmazTimer");
this.mContext = paramContext;
this.mView = LayoutInflater.from(paramContext).inflate(R.layout.amaztimer, null);
final View gView = this.mView;
final file file = new file("amaztimer", mView.getContext());
//Setup items
this.init();
//Setup hrSensor class
final hrSensor hrSensor = new hrSensor(this.mView.getContext(), hr);
//Text default values
sets.setText(String.valueOf(file.get("sets", defValues.sets)));
work.setText(utils.sToMinS(file.get("work", defValues.workTime)));
Expand Down Expand Up @@ -146,7 +150,6 @@ public void onClick(View view) {
rSets.setText(String.valueOf(file.get("sets", defValues.sets)));
status.setText(gView.getResources().getString(R.string.prepare));
//Start hrSensor listener
final hrSensor hrSensor = new hrSensor(gView.getContext(), hr);
hrSensor.registerListener();
final CountDownTimer PrepareTimer = new CountDownTimer(5 * 1000, 1000) {
@Override
Expand All @@ -173,6 +176,8 @@ public boolean onLongClick(View v) {
L2.setVisibility(View.GONE);
//Stop timers
stopTimers();
//Unregister hr sensor listener to avoid battery drain
hrSensor.unregisterListener();
return true;
}
});
Expand Down

0 comments on commit 291f000

Please sign in to comment.