-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gabor Keszthelyi
committed
Nov 17, 2017
1 parent
a29d04c
commit adb7429
Showing
9 changed files
with
129 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
opentasks/src/main/java/org/dmfs/tasks/widget/ProgressBackgroundView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dmfs.tasks.widget; | ||
|
||
import android.os.Build; | ||
import android.view.View; | ||
|
||
import org.dmfs.optional.Optional; | ||
import org.dmfs.tasks.R; | ||
|
||
|
||
/** | ||
* {@link SmartView} adapting any {@link View} so that its background can be updated with a progress in percent, | ||
* so that it shows the value as a proportionate horizontal overlay. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class ProgressBackgroundView implements SmartView<Optional<Integer>> | ||
{ | ||
private final View mBackgroundView; | ||
|
||
|
||
public ProgressBackgroundView(View backgroundView) | ||
{ | ||
mBackgroundView = backgroundView; | ||
} | ||
|
||
|
||
@Override | ||
public void update(Optional<Integer> percentComplete) | ||
{ | ||
if (Build.VERSION.SDK_INT >= 11 && percentComplete.isPresent()) | ||
{ | ||
mBackgroundView.setPivotX(0); | ||
if (percentComplete.value() < 100) | ||
{ | ||
mBackgroundView.setScaleX(percentComplete.value() / 100f); | ||
mBackgroundView.setBackgroundResource(R.drawable.task_progress_background_shade); | ||
} | ||
else | ||
{ | ||
mBackgroundView.setScaleX(1); | ||
mBackgroundView.setBackgroundResource(R.drawable.complete_task_background_overlay); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.