# BndrsntchTimer
**Repository Path**: HarmonyOS-tpc/BndrsntchTimer
## Basic Information
- **Project Name**: BndrsntchTimer
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-09-17
- **Last Updated**: 2023-04-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# BndrsntchTimer
BndrsntchTimer : A horizontal progress bar shrinking with time; similar to Bandersnatch choice interface.
# Inspiration
# Preview
# Supported features
* Timer having a horizontal progressbar shrinking wrt elapsedTime
* Change the progressbar color can be implemented
* Duration of the timer can be implemented
* Able to get the RunningStatus and TotalDuration time
* Reset the timer for the repeated usage
# Usage Instructions
Add namespace for app in layout root.
```
xmlns:app="http://schemas.huawei.com/hap/res-auto"
```
# Layout xml
```
```
Add two text buttons at two ends .
Left : Reset the timer
Right : Initiate the timer
```
```
# Java
```java
final BndrsntchTimer bndrsntchTimer = findViewById( R.id.timer );
// add the lifecycle observer
getLifecycle().addObserver( bndrsntchTimer.getLifecycleObserver() );
// set progress color
bndrsntchTimer.setProgressColor(Color.WHITE);
bndrsntchTimer.start( 10000 );
// attach listener
bndrsntchTimer.setOnTimerElapsedListener( new BndrsntchTimer.OnTimerElapsedListener()
{
@Override
public void onTimeElapsed( long elapsedDuration, long totalDuration )
{
if( elapsedDuration >= totalDuration )
{
// Timer elapsed.
}
}
});
// reset it for repeated usage.
bndrsntchTimer.reset();
// set duration along with listener
bndrsntchTimer.start( 5000, new BndrsntchTimer.OnTimerElapsedListener()
{
@Override
public void onTimeElapsed( long elapsedDuration, long totalDuration )
{
if( elapsedDuration >= totalDuration )
{
// Timer elapsed.
}
}
});
```
# Installation Instructions
1.For using BndrsntchTimer module in sample application, include the below library dependency to generate hap/bndrsntchtimer_library.har.
Modify entry build.gradle as below :
```
dependencies {
implementation project(path: ':bndrsntchtimer_library')
}
```
2.For using BndrsntchTimer in separate application, add the "bndrsntchtimer_library.har" in libs folder of "entry" module.
Modify entry build.gradle as below :
```
dependencies {
implementation fileTree(dir: 'libs', include: ['*.har'])
}
```
3.For using BndrsntchTimer from a remote repository in separate application, add the below dependency in entry/build.gradle file.
Modify entry build.gradle as below :
```gradle
dependencies {
implementation 'io.openharmony.tpc.thirdlib:BndrsntchTimer:1.0.0'
}
```
# License
```
Copyright 2019 Purushottam Pawar
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.
```