Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
biodunalfet committed Feb 5, 2017
0 parents commit 9dcf231
Show file tree
Hide file tree
Showing 33 changed files with 1,230 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
.idea
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2017] [Hamza Fetuga]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions README.md
@@ -0,0 +1,53 @@
# SlidingSquaresLoader

Sliding Square Loader - A simple progress loader inspired by [Can you Code this UI? Volume 6!](https://stories.uplabs.com/can-you-code-this-ui-volume-6-7bd09fa6dd92#.nyh2zhpvb)

![sslv animation](https://media.giphy.com/media/l3q2HR5PQ5K5fL7gI/giphy.gif)

## Gradle

```
dependencies {
...
compile 'com.xxx.xxx.1.0.0'
}
```

## Usage

* In XML Layout

```
<com.hamza.slidingsquaresloader.SlidingSquareLoaderView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:sslv_start="true"
app:sslv_delay="15"
app:sslv_duration="150"
app:sslv_gap="2dp"
app:sslv_square_length="12dp"
app:sslv_color="@color/colorPrimary"
xmlns:app="http://schemas.android.com/apk/res-auto"
/>
```

1. `sslv_start` = `boolean` that determines if the loader should start sliding. Default value is `true`.
2. `sslv_duration` = the amount of milliseconds it takes for a square to complete sliding. Default value is `350`
3. `sslv_delay` = the number of milliseconds to wait before sliding. Default value is `25`
4. `sslv_square_length` = the dimension of each square. Default value is `25dp`
5. `sslv_gap` = the dimension of the gap between each square. Default value is `5dp`
6. `sslv_color` = the `color` of the square. Defaults to `#2342h3`

* In Java

```
SlidingSquareLoaderView slidingview2 = (SlidingSquareLoaderView) findViewById(R.id.sliding_view2);
slidingview.start(); // starts the sliding
slidingview.stop(); // stops the sliding
slidingview.setDuration(xxx); // sets duration of sliding
slidingview.setDelay(xxx); // sets delay period before sliding
slidingview.setColor(Color.parseColor("#2196F3")); // sets the color of the squares
```

## License
The contents of this repository are covered under the [MIT License](https://github.com/biodunalfet/SlidingSquareLoader/blob/master/LICENSE)
1 change: 1 addition & 0 deletions app/.gitignore
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions app/build.gradle
@@ -0,0 +1,29 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.hamza.slidingsquaresloader"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Hamza Fetuga\Desktop\Android Calabash\adt-bundle-windows-x86-20131030\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -0,0 +1,26 @@
package com.hamza.slidingsquaresloader;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.hamza.slidingsquaresloader", appContext.getPackageName());
}
}
20 changes: 20 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hamza.slidingsquaresloader">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
54 changes: 54 additions & 0 deletions app/src/main/java/com/hamza/slidingsquaresloader/MainActivity.java
@@ -0,0 +1,54 @@
package com.hamza.slidingsquaresloader;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.os.HandlerThread;
import android.support.v7.app.AppCompatActivity;
import android.view.Display;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.widget.Button;
import android.widget.RelativeLayout;

import java.util.Random;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

public class MainActivity extends AppCompatActivity {

private SlidingSquareLoaderView slidingview;
private SlidingSquareLoaderView slidingview2;
private Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.slidingview = (SlidingSquareLoaderView) findViewById(R.id.sliding_view);
this.slidingview2 = (SlidingSquareLoaderView) findViewById(R.id.sliding_view2);
this.button = (Button) findViewById(R.id.button);

slidingview.start();

slidingview2.start();
slidingview2.setDuration(200);
slidingview2.setDelay(15);
slidingview2.setColor(Color.parseColor("#2196F3"));

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (slidingview2.isAnimating()){
slidingview2.stop();
}
else {
slidingview2.start();
}
}
});

}
}

0 comments on commit 9dcf231

Please sign in to comment.