Repository: Hitomis/CrazyShadow
Branch: master
Commit: 98140b76fed9
Files: 40
Total size: 95.5 KB
Directory structure:
gitextract_svsycx0l/
├── .gitignore
├── README.md
├── app/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── hitomi/
│ │ └── crazyshadow/
│ │ └── ApplicationTest.java
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── hitomi/
│ │ │ └── crazyshadow/
│ │ │ └── MainActivity.java
│ │ └── res/
│ │ ├── drawable/
│ │ │ ├── shape_float.xml
│ │ │ └── shape_wrap.xml
│ │ ├── layout/
│ │ │ └── activity_main.xml
│ │ ├── values/
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── values-w820dp/
│ │ └── dimens.xml
│ └── test/
│ └── java/
│ └── com/
│ └── hitomi/
│ └── crazyshadow/
│ └── ExampleUnitTest.java
├── build.gradle
├── cslibrary/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── hitomi/
│ │ └── cslibrary/
│ │ ├── CrazyShadow.java
│ │ ├── base/
│ │ │ ├── CrazyShadowAttr.java
│ │ │ ├── CrazyShadowDirection.java
│ │ │ ├── ShadowHandler.java
│ │ │ └── view/
│ │ │ ├── CornerShadowView.java
│ │ │ └── EdgeShadowView.java
│ │ ├── draw/
│ │ │ ├── RoundRectShadowDrawable.java
│ │ │ └── ShadowDrawer.java
│ │ ├── floating/
│ │ │ └── ShadowFloating.java
│ │ └── wrap/
│ │ └── ShadowWrapper.java
│ └── res/
│ ├── color/
│ │ └── background.xml
│ └── values/
│ └── strings.xml
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
================================================
FILE: README.md
================================================
# CrazyShadow
[](https://jitpack.io/#Hitomis/CrazyShadow)
CrazyShadow 是一个专门为 View 添加阴影效果的库。 CrazyShadow 支持自定义阴影实现方式、阴影颜色、阴影经度大小、阴影附加方位。
说明:<br/>
CrazyShadow 主要是因为自己一直想为最近编写的 [ActivitySwitch](https://github.com/Hitomis/ActivitySwitcher)
添加阴影效果,之前在网上一直没有找到合适的可以用的参考案例。所以只能自己去编写这样一个 library。
而在实际运用在,发现理想总是丰满的,现实很骨感。虽然可以实现优美的效果以及多功能性,但是使用场景比较单一:只能
为传统的矩形UI(即最终显示效果)添加阴影。为什么结果会是这样呢?大家都知道,一个 View 显示的模型肯定是一个矩形,不
管如何自定义 View 都有 left、top、right、bottom 以及 width、height 等一些概念,而这些概念也定位了 View 的模
型必定为一个矩形。所以 阴影效果的添加依据模型必定也是一个矩形。
虽然有了很多限制,我想既然都做了,还是尽自己最大努力吧,目前 CrazyShadow 支持三种方式为 View 添加阴影效果。
1. wrap : 以包装 View 的方式添加阴影效果。该方式会改变 View 的大小。因为如果保持 View 大小不变同时又在 View四周添加了阴影,那么 View 的尺寸定会比之前大,这样可能会引起 View 周围其他 View 的位置变化。
2. float : 以 View 的根视图(ContentFrameLayout) 中添加一层阴影效果。不过因为与 View 不在一个布局层面上,所以当发生用户交互使原 View 的位置发生改变后,阴影还是会留在原来的位置。此种方式只能在位置不会发生改变的 View 上使用。慎用啊
3. drawable : 直接创建一个附带阴影效果的矩形(支持圆角) drawable 作为 View 的 background, 简单粗暴。不过因为 background 的最大尺寸为原 View 的尺寸,所以设置了阴影后,原 View 大小会依据配置的阴影大小发生变化,并且原 View 的位置会向上的偏移来显示出阴影的效果。
# Preview
<img src="preview/crazyshadow.jpg" width="400" />
# Import
### Gradle
Step 1. Add the JitPack repository to your build file
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.Hitomis:CrazyShadow:v1.0.1'
}
### Maven
Step 1. Add the JitPack repository to your build file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Step 2. Add the dependency
<dependency>
<groupId>com.github.Hitomis</groupId>
<artifactId>CrazyShadow</artifactId>
<version>v1.0.1</version>
</dependency>
# Usage
new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(3))
.setCorner(dip2Px(5))
.setBackground(Color.parseColor("#96a993"))
.setImpl(CrazyShadow.IMPL_DRAW)
.action(findViewById(R.id.relay_draw1));
更多示例代码可以查看 [MainActivity](https://github.com/Hitomis/CrazyShadow/blob/master/app/src/main/java/com/hitomi/crazyshadow/MainActivity.java)
# Attribute
| 属性 | 说明 |
| :--: | :--: |
| impl | 以何种方式添加阴影,支持 wrap、float、drawable 三种方式 |
| baseShadowColor | 阴影的基本颜色,即最深的颜色,与 colors 表示为同一个作用, 如果baseShadowColor 与 colors 都不设置,阴影会使用默认颜色|
| background | 修改 View 的背景色,如果使用 drawable 方式添加阴影,那么该属性必须添加 |
| colors | 绘制阴影时需要的一个颜色由深到浅且长度为3的数组, 该属性与 baseShadowColor 起同一个作用,如果单单只设置 baseShadowColor 也会自动转换成为 colors |
| corner | 阴影顶点的内侧弧度。以适配被设置的 View 是圆角的情况, 对使用 drawable 方式设置阴影时,该属性表示为圆角矩形背景的圆角角度 |
| shadowRadius | 阴影大小 |
| direction | 设定阴影在 View 上显示的方位, 支持的方位详情可以查看 [CrazyShadowDirection](https://github.com/Hitomis/CrazyShadow/blob/master/cslibrary/src/main/java/com/hitomi/cslibrary/base/CrazyShadowDirection.java) |
# Method
| 方法 | 说明 |
| :--: | :--: |
| make | 为 View 添加阴影效果, 使用 Builder 的 action 方法时会自动调用 |
| remove | 移除阴影|
| hide | 隐藏阴影,与 remove 不同的是,hide 只是隐藏了 View 周围的阴影效果,并没有移除 |
| show | 如果调用了 hide ,可以再使用 show 将阴影效果显示出来 |
#Licence
Copyright 2016 Hitomis, Inc.
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.
================================================
FILE: app/.gitignore
================================================
/build
================================================
FILE: app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.hitomi.crazyshadow"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile project(':cslibrary')
}
================================================
FILE: app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\androidstuido_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 *;
#}
================================================
FILE: app/src/androidTest/java/com/hitomi/crazyshadow/ApplicationTest.java
================================================
package com.hitomi.crazyshadow;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hitomi.crazyshadow">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: app/src/main/java/com/hitomi/crazyshadow/MainActivity.java
================================================
package com.hitomi.crazyshadow;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.hitomi.cslibrary.CrazyShadow;
import com.hitomi.cslibrary.base.CrazyShadowDirection;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private View titleView;
private View drawView0, drawView1;
private View floatView0, floatView1;
private View wrapView0, wrapView1;
private View shadowView0, shadowView1;
private CrazyShadow titleCrazyShadow;
private CrazyShadow drawCrazyShadow0, drawCrazyShadow1;
private CrazyShadow floatCrazyShadow0, floatCrazyShadow1;
private CrazyShadow wrapCrazyShadow0, wrapCrazyShadow1;
private CrazyShadow shadowCrazyShadow0, shadowCrazyShadow1;
private boolean titleFlag = true, draw0Flag = true, draw1Flag = true, float0Flag = true, float1Flag = true;
private boolean wrap0Flag = true, wrap1Flag = true, shadow0Flag = true, shadow1Flag = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initShadow();
initListener();
}
private void initListener() {
titleView.setOnClickListener(this);
drawView0.setOnClickListener(this);
drawView1.setOnClickListener(this);
floatView0.setOnClickListener(this);
floatView1.setOnClickListener(this);
wrapView0.setOnClickListener(this);
wrapView1.setOnClickListener(this);
shadowView0.setOnClickListener(this);
shadowView1.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.relay_title:
if (titleFlag) {
titleCrazyShadow.hide();
} else {
titleCrazyShadow.show();
}
titleFlag = !titleFlag;
break;
case R.id.relay_draw0:
if (draw0Flag) {
drawCrazyShadow0.hide();
} else {
drawCrazyShadow0.show();
}
draw0Flag = !draw0Flag;
break;
case R.id.relay_draw1:
if (draw1Flag) {
drawCrazyShadow1.hide();
} else {
drawCrazyShadow1.show();
}
draw1Flag = !draw1Flag;
break;
case R.id.relay_float0:
if (float0Flag) {
floatCrazyShadow0.hide();
} else {
floatCrazyShadow0.show();
}
float0Flag = !float0Flag;
break;
case R.id.relay_float1:
if (float1Flag) {
floatCrazyShadow1.hide();
} else {
floatCrazyShadow1.show();
}
float1Flag = !float1Flag;
break;
case R.id.relay_wrap0:
if (wrap0Flag) {
wrapCrazyShadow0.hide();
} else {
wrapCrazyShadow0.show();
}
wrap0Flag = !wrap0Flag;
break;
case R.id.relay_wrap1:
if (wrap1Flag) {
wrapCrazyShadow1.hide();
} else {
wrapCrazyShadow1.show();
}
wrap1Flag = !wrap1Flag;
break;
case R.id.relay_shadow0:
if (shadow0Flag) {
shadowCrazyShadow0.hide();
} else {
shadowCrazyShadow0.show();
}
shadow0Flag = !shadow0Flag;
break;
case R.id.relay_shadow1:
if (shadow1Flag) {
shadowCrazyShadow1.hide();
} else {
shadowCrazyShadow1.show();
}
shadow1Flag = !shadow1Flag;
break;
}
}
private void initShadow() {
titleCrazyShadow = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.BOTTOM)
.setShadowRadius(dip2Px(5))
.setImpl(CrazyShadow.IMPL_WRAP)
.action(titleView);
drawCrazyShadow0 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(3))
.setBaseShadowColor(Color.RED)
.setImpl(CrazyShadow.IMPL_DRAW)
.action(drawView0);
drawCrazyShadow1 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(3))
.setCorner(dip2Px(5))
.setBackground(Color.parseColor("#96a993"))
.setImpl(CrazyShadow.IMPL_DRAW)
.action(drawView1);
floatCrazyShadow0 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(3))
.setImpl(CrazyShadow.IMPL_FLOAT)
.action(floatView0);
floatCrazyShadow1 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(3))
.setCorner(dip2Px(4))
.setImpl(CrazyShadow.IMPL_FLOAT)
.action(floatView1);
wrapCrazyShadow0 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(3))
.setImpl(CrazyShadow.IMPL_WRAP)
.action(wrapView0);
wrapCrazyShadow1 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(5))
.setCorner(dip2Px(8))
.setImpl(CrazyShadow.IMPL_WRAP)
.action(wrapView1);
shadowCrazyShadow0 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.ALL)
.setShadowRadius(dip2Px(3))
.setBackground(Color.parseColor("#a0a0a0"))
.setBaseShadowColor(Color.parseColor("#a0a0a0"))
.setImpl(CrazyShadow.IMPL_WRAP)
.action(findViewById(R.id.relay_shadow0));
shadowCrazyShadow1 = new CrazyShadow.Builder()
.setContext(this)
.setDirection(CrazyShadowDirection.TOP)
.setShadowRadius(dip2Px(5))
.setImpl(CrazyShadow.IMPL_WRAP)
.action(findViewById(R.id.relay_shadow1));
}
private void initView() {
titleView = findViewById(R.id.relay_title);
drawView0 = findViewById(R.id.relay_draw0);
drawView1 = findViewById(R.id.relay_draw1);
floatView0 = findViewById(R.id.relay_float0);
floatView1 = findViewById(R.id.relay_float1);
wrapView0 = findViewById(R.id.relay_wrap0);
wrapView1 = findViewById(R.id.relay_wrap1);
shadowView0 = findViewById(R.id.relay_shadow0);
shadowView1 = findViewById(R.id.relay_shadow1);
}
public int dip2Px(float dpValue) {
final float scale = getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
}
================================================
FILE: app/src/main/res/drawable/shape_float.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="#96d0c7" />
</shape>
================================================
FILE: app/src/main/res/drawable/shape_wrap.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="8dp" />
<solid android:color="#96d0c7" />
</shape>
================================================
FILE: app/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.hitomi.crazyshadow.MainActivity">
<RelativeLayout
android:id="@+id/relay_title"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#6161c9">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="带阴影的标题栏"
android:textColor="@android:color/white" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay_draw0"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#d07784"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="直角drawable背景[修改了阴影色]" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay_draw1"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#d07784"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:text="圆角drawable背景[修改了背景色]" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay_float0"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#96d0c7">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="浮动式阴影,不修改原 View ,在周围直接添加阴影。整体 View 看起来变大。但原 View 不能动"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay_float1"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/shape_float">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="浮动式阴影,设置 shape_float (圆角) 的背景后,CrazyShadow可以设置圆角阴影以适配圆角的 drawable"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay_wrap0"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#c376d0">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="包装式阴影,修改原 View 大小,并添加阴影效果"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay_wrap1"
android:layout_width="250dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/shape_wrap">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="包装式阴影,设置 shape_wrap (圆角) 的背景后,CrazyShadow可以设置圆角阴影以适配圆角的 drawable"
android:textSize="9sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/relay_shadow0"
android:layout_width="280dp"
android:layout_height="50dp"
android:layout_centerInParent="true">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="可以设置 CrazyShadow 的 baseShadowColor 或者 shadowColors 来设置阴影色 / 可设置 background 直接修改背景色"
android:textColor="@android:color/white"
android:textSize="10sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relay_shadow1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#23df77">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="可指定阴影附加在 View 的方位" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
================================================
FILE: app/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
================================================
FILE: app/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
================================================
FILE: app/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">CrazyShadow</string>
</resources>
================================================
FILE: app/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
================================================
FILE: app/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: app/src/test/java/com/hitomi/crazyshadow/ExampleUnitTest.java
================================================
package com.hitomi.crazyshadow;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: cslibrary/.gitignore
================================================
/build
================================================
FILE: cslibrary/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.Hitomi'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
}
================================================
FILE: cslibrary/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\androidstuido_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 *;
#}
================================================
FILE: cslibrary/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hitomi.cslibrary">
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
</application>
</manifest>
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/CrazyShadow.java
================================================
package com.hitomi.cslibrary;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import com.hitomi.cslibrary.base.CrazyShadowAttr;
import com.hitomi.cslibrary.base.CrazyShadowDirection;
import com.hitomi.cslibrary.base.ShadowHandler;
import com.hitomi.cslibrary.draw.ShadowDrawer;
import com.hitomi.cslibrary.floating.ShadowFloating;
import com.hitomi.cslibrary.wrap.ShadowWrapper;
/**
* Created by hitomi on 2016/10/19.
*
* email : 196425254@qq.com
*
* https://github.com/Hitomis
*/
public class CrazyShadow {
/**
* 以 {@link android.view.View#setBackground(Drawable)} 的形式为你的
* View 添加阴影背景,同时可以设置圆角 [{@link com.hitomi.cslibrary.draw.ShadowDrawer}]
*/
public static final String IMPL_DRAW = "drawer";
/**
* 以包装的形式为你的 View 添加阴影 [{@link com.hitomi.cslibrary.wrap.ShadowWrapper}]
*/
public static final String IMPL_WRAP = "wrapper";
/**
* 以浮动修饰的形式为你的 View 添加阴影 [{@link ShadowFloating}]
*/
public static final String IMPL_FLOAT = "floating";
private Context context;
private ShadowHandler shadowHandler;
private boolean makeShadow;
private CrazyShadow(Context context) {
this.context = context;
}
private void createShadowHandler(CrazyShadowAttr attr) {
if (attr.getImpl().equals(IMPL_DRAW)) {
shadowHandler = new ShadowDrawer(attr);
} else if (attr.getImpl().equals(IMPL_WRAP)) {
shadowHandler = new ShadowWrapper(context, attr);
} else {
shadowHandler = new ShadowFloating(context, attr);
}
}
/**
* 为 View 添加阴影效果
* @param view
*/
public void make(View view) {
if (!makeShadow) {
shadowHandler.makeShadow(view);
makeShadow = true;
}
}
/**
* 将添加的阴影效果移除
*/
public void remove() {
if (makeShadow) {
shadowHandler.removeShadow();
makeShadow = false;
}
}
/**
* 显示阴影效果
*/
public void show() {
shadowHandler.showShadow();
}
/**
* 隐藏阴影效果
*/
public void hide() {
shadowHandler.hideShadow();
}
public static class Builder {
private Context context;
/**
* {@link #IMPL_DRAW} <br/>
* {@link #IMPL_WRAP} <br/>
* {@link #IMPL_FLOAT} <br/>
*/
private String impl;
/**
* 阴影的基本色
*/
private int baseShadowColor;
/**
* 背景色
*/
private int background;
/**
* 表示阴影的一个颜色由深到浅且长度为3的数组
*/
private int[] colors;
/**
* 对 {@link #IMPL_DRAW} 形式表示为背景的圆角角度.<br/>
* 对 {@link #IMPL_WRAP} 与 {@link #IMPL_FLOAT}
* 表示为阴影顶点的内侧弧度。以适配被设置的 View 是圆角的情况
*/
private float corner;
/**
* 阴影半径
*/
private float shadowRadius;
/**
* 阴影设置在 View 的方向
*/
@CrazyShadowDirection
private int direction;
public Builder setContext(Context context) {
this.context = context;
return this;
}
/**
* 以何种方式添加阴影:<br/>
* {@link #IMPL_DRAW} <br/>
* {@link #IMPL_WRAP} <br/>
* {@link #IMPL_FLOAT} <br/>
* @param impl
* @return Builder
*/
public Builder setImpl(String impl) {
this.impl = impl;
return this;
}
/**
* 阴影的基本颜色,即最深的颜色, {@link CrazyShadowAttr#setBaseShadowColor(int)}
* 方法会自动计算出绘制阴影时需要的 {@link #colors}
* @param baseColor
* @return Builder
*/
public Builder setBaseShadowColor(int baseColor) {
this.baseShadowColor = baseColor;
return this;
}
/**
* 背景色
* @param background
* @return Builder
*/
public Builder setBackground(int background) {
this.background = background;
return this;
}
/**
* 绘制阴影时需要的一个颜色由深到浅且长度为3的数组
* @param colors
* @return Builder
*/
public Builder setColors(int[] colors) {
this.colors = colors;
return this;
}
/**
* 对 {@link #IMPL_DRAW} 形式表示为背景的圆角角度.<br/>
* 对 {@link #IMPL_WRAP} 与 {@link #IMPL_FLOAT}
* 表示为阴影顶点的内侧弧度。以适配被设置的 View 是圆角的情况
* @param corner [unit : pixels]
* @return Builder
*/
public Builder setCorner(float corner) {
this.corner = corner;
return this;
}
/**
* 设置阴影半径
* @param shadowRadius [unit : pixels]
* @return Builder
*/
public Builder setShadowRadius(float shadowRadius) {
this.shadowRadius = shadowRadius;
return this;
}
/**
* 设置阴影的方向,具体查看 {@link CrazyShadowAttr}
* @param direction
* @return Builder
*/
public Builder setDirection(int direction) {
this.direction = direction;
return this;
}
private CrazyShadow create() {
if (colors == null && baseShadowColor == 0)
// 默认的颜色。由深到浅
//分别为开始颜色,中间颜色,结束颜色
colors = new int[]{0x63000000, 0x32000000, 0x00000000};
CrazyShadowAttr attr = new CrazyShadowAttr();
attr.setImpl(impl);
attr.setBaseShadowColor(baseShadowColor);
attr.setBackground(background);
attr.setColors(colors);
attr.setCorner(corner);
attr.setShadowRadius(shadowRadius);
attr.setDirection(direction);
CrazyShadow crazyShadow = new CrazyShadow(context);
crazyShadow.createShadowHandler(attr);
return crazyShadow;
}
/**
* 绘制阴影的启动方法,你需要保证参数已经正确设置完毕
* @param view 被添加阴影的 View
*/
public CrazyShadow action(View view) {
CrazyShadow crazyShadow = create();
crazyShadow.make(view);
return crazyShadow;
}
}
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/CrazyShadowAttr.java
================================================
package com.hitomi.cslibrary.base;
import android.support.v4.graphics.ColorUtils;
/**
* Created by hitomi on 2016/10/19.
*/
public class CrazyShadowAttr {
/**
* 以何种方式添加阴影:<br/>
* {@link com.hitomi.cslibrary.CrazyShadow#IMPL_DRAW} <br/>
* {@link com.hitomi.cslibrary.CrazyShadow#IMPL_WRAP} <br/>
* {@link com.hitomi.cslibrary.CrazyShadow#IMPL_FLOAT} <br/>
*/
private String impl;
/**
* 阴影的基本颜色,即最深的颜色, {@link #setBaseShadowColor(int)} 方法会自动计算出
* 绘制阴影时需要的 {@link #colors}
*/
private int baseShadowColor;
/**
* 仅仅对 {@link com.hitomi.cslibrary.CrazyShadow#IMPL_DRAW} 形式的方设置阴影时需要的属性
*/
private int background;
/**
* 绘制阴影时需要的一个颜色由深到浅且长度为3的数组
*/
private int[] colors;
/**
* 对 {@link com.hitomi.cslibrary.CrazyShadow#IMPL_DRAW} 形式表示为背景的圆角角度.<br/>
* 对 {@link com.hitomi.cslibrary.CrazyShadow#IMPL_WRAP} 与
* {@link com.hitomi.cslibrary.CrazyShadow#IMPL_FLOAT}
* 表示为阴影顶点的内侧弧度。以适配被设置的 View 是圆角的情况
*/
private float corner;
/**
* 阴影半径
*/
private float shadowRadius;
/**
* 设置阴影的方向,具体查看 {@link CrazyShadowAttr}
*/
@CrazyShadowDirection
private int direction;
public String getImpl() {
return impl;
}
public void setImpl(String impl) {
this.impl = impl;
}
public void setBaseShadowColor(int baseShadowColor) {
this.baseShadowColor = baseShadowColor;
if (colors == null) {
colors = new int[3];
colors[0] = ColorUtils.setAlphaComponent(baseShadowColor, 255);
colors[1] = ColorUtils.setAlphaComponent(baseShadowColor, 128);
colors[2] = ColorUtils.setAlphaComponent(baseShadowColor, 0);
}
}
public int getBackground() {
return background;
}
public void setBackground(int background) {
this.background = background;
}
public int[] getColors() {
return colors;
}
public void setColors(int[] colors) {
if (colors != null)
this.colors = colors;
}
public float getCorner() {
return corner;
}
public void setCorner(float corner) {
this.corner = corner;
}
public float getShadowRadius() {
return shadowRadius;
}
public void setShadowRadius(float shadowRadius) {
this.shadowRadius = shadowRadius;
}
public int getDirection() {
return direction;
}
public void setDirection(@CrazyShadowDirection int direction) {
this.direction = direction;
}
public boolean containLeft() {
return direction == CrazyShadowDirection.ALL ||
direction == CrazyShadowDirection.LEFT ||
direction == CrazyShadowDirection.LEFT_TOP ||
direction == CrazyShadowDirection.BOTTOM_LEFT ||
direction == CrazyShadowDirection.BOTTOM_LEFT_TOP ||
direction == CrazyShadowDirection.RIGHT_BOTTOM_LEFT ||
direction == CrazyShadowDirection.LEFT_TOP_RIGHT;
}
public boolean containTop() {
return direction == CrazyShadowDirection.ALL ||
direction == CrazyShadowDirection.TOP ||
direction == CrazyShadowDirection.LEFT_TOP ||
direction == CrazyShadowDirection.TOP_RIGHT ||
direction == CrazyShadowDirection.LEFT_TOP_RIGHT ||
direction == CrazyShadowDirection.BOTTOM_LEFT_TOP ||
direction == CrazyShadowDirection.TOP_RIGHT_BOTTOM;
}
public boolean containRight() {
return direction == CrazyShadowDirection.ALL ||
direction == CrazyShadowDirection.RIGHT ||
direction == CrazyShadowDirection.TOP_RIGHT ||
direction == CrazyShadowDirection.RIGHT_BOTTOM ||
direction == CrazyShadowDirection.TOP_RIGHT_BOTTOM ||
direction == CrazyShadowDirection.LEFT_TOP_RIGHT ||
direction == CrazyShadowDirection.RIGHT_BOTTOM_LEFT;
}
public boolean containBottom() {
return direction == CrazyShadowDirection.ALL ||
direction == CrazyShadowDirection.BOTTOM ||
direction == CrazyShadowDirection.BOTTOM_LEFT ||
direction == CrazyShadowDirection.RIGHT_BOTTOM ||
direction == CrazyShadowDirection.RIGHT_BOTTOM_LEFT ||
direction == CrazyShadowDirection.TOP_RIGHT_BOTTOM ||
direction == CrazyShadowDirection.BOTTOM_LEFT_TOP;
}
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/CrazyShadowDirection.java
================================================
package com.hitomi.cslibrary.base;
import android.support.annotation.IntDef;
/**
* Created by hitomi on 2016/10/10.
*/
@IntDef(flag = true, value = {CrazyShadowDirection.LEFT, CrazyShadowDirection.TOP,
CrazyShadowDirection.RIGHT, CrazyShadowDirection.BOTTOM,
CrazyShadowDirection.LEFT_TOP, CrazyShadowDirection.TOP_RIGHT,
CrazyShadowDirection.RIGHT_BOTTOM, CrazyShadowDirection.BOTTOM_LEFT,
CrazyShadowDirection.BOTTOM_LEFT_TOP, CrazyShadowDirection.LEFT_TOP_RIGHT,
CrazyShadowDirection.TOP_RIGHT_BOTTOM, CrazyShadowDirection.RIGHT_BOTTOM_LEFT,
CrazyShadowDirection.ALL})
public @interface CrazyShadowDirection {
int LEFT = 1;
int TOP = 1 << 1;
int RIGHT = 1 << 2;
int BOTTOM = 1 << 3;
int LEFT_TOP = 1 << 4;
int TOP_RIGHT = 1 << 5;
int RIGHT_BOTTOM = 1 << 6;
int BOTTOM_LEFT = 1 << 7;
int BOTTOM_LEFT_TOP = 1 << 8;
int LEFT_TOP_RIGHT = 1 << 9;
int TOP_RIGHT_BOTTOM = 1 << 10;
int RIGHT_BOTTOM_LEFT = 1 << 11;
int ALL = 1 << 12;
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/ShadowHandler.java
================================================
package com.hitomi.cslibrary.base;
import android.view.View;
/**
* Created by hitomi on 2016/10/19.
*/
public interface ShadowHandler {
void makeShadow(View view);
void removeShadow();
void hideShadow();
void showShadow();
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/view/CornerShadowView.java
================================================
package com.hitomi.cslibrary.base.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RadialGradient;
import android.graphics.RectF;
import android.graphics.Shader;
import android.view.View;
import com.hitomi.cslibrary.base.CrazyShadowDirection;
/**
* Created by hitomi on 2016/10/18.
*/
public class CornerShadowView extends View {
private Paint shadowPaint;
private Path cornerShadowPath;
private int degrees;
private int[] shadowColors;
private float cornerRadius;
private float shadowSize;
private CornerShadowView(Context context) {
super(context);
init();
}
private void init() {
shadowPaint = new Paint(Paint.DITHER_FLAG);
shadowPaint.setStyle(Paint.Style.FILL);
cornerShadowPath = new Path();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int measureSize = (int) (shadowSize + cornerRadius);
setMeasuredDimension(measureSize, measureSize);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.translate(getMeasuredWidth(), getMeasuredHeight());
canvas.rotate(degrees, -getMeasuredWidth() / 2f, -getMeasuredHeight() / 2f);
canvas.drawPath(cornerShadowPath, shadowPaint);
canvas.restore();
}
private void buildRingSectorShadow() {
RectF innerBounds = new RectF(-cornerRadius, -cornerRadius,
cornerRadius, cornerRadius);
RectF outerBounds = new RectF(innerBounds);
outerBounds.inset(-shadowSize, -shadowSize);
cornerShadowPath.reset();
cornerShadowPath.setFillType(Path.FillType.EVEN_ODD);
cornerShadowPath.moveTo(-cornerRadius, 0);
cornerShadowPath.rLineTo(-shadowSize, 0);
// outer arc
cornerShadowPath.arcTo(outerBounds, 180f, 90f, false);
// inner arc
cornerShadowPath.arcTo(innerBounds, 270f, -90f, false);
cornerShadowPath.close();
float startRatio = cornerRadius / (cornerRadius + shadowSize);
shadowPaint.setShader(new RadialGradient(0, 0, cornerRadius + shadowSize,
shadowColors,
new float[]{0f, startRatio, 1f}
, Shader.TileMode.CLAMP));
}
public void setShadowColors(int[] shadowColors) {
this.shadowColors = shadowColors;
}
public void setCornerRadius(float cornerRadius) {
this.cornerRadius = cornerRadius;
}
public void setShadowSize(float shadowSize) {
this.shadowSize = shadowSize;
}
public void setDirection(@CrazyShadowDirection int direction) {
switch (direction) {
case CrazyShadowDirection.LEFT_TOP:
degrees = 0;
break;
case CrazyShadowDirection.TOP_RIGHT:
degrees = 90;
break;
case CrazyShadowDirection.RIGHT_BOTTOM:
degrees = 180;
break;
case CrazyShadowDirection.BOTTOM_LEFT:
degrees = 270;
break;
default:
degrees = 0;
}
}
public static class Builder {
private Context context;
private int[] shadowColors;
private float cornerRadius;
private float shadowSize;
@CrazyShadowDirection
private int direction;
public Builder setContext(Context context) {
this.context = context;
return this;
}
public Builder setShadowColors(int[] shadowColors) {
this.shadowColors = shadowColors;
return this;
}
public Builder setCornerRadius(float cornerRadius) {
this.cornerRadius = cornerRadius;
return this;
}
public Builder setShadowSize(float shadowSize) {
this.shadowSize = shadowSize;
return this;
}
public Builder setDirection(@CrazyShadowDirection int direction) {
this.direction = direction;
return this;
}
public CornerShadowView create() {
// 创建 CornerShadowView
CornerShadowView cornerShadowView = new CornerShadowView(context);
cornerShadowView.setShadowColors(shadowColors);
cornerShadowView.setCornerRadius(cornerRadius);
cornerShadowView.setShadowSize(shadowSize);
cornerShadowView.setDirection(direction);
cornerShadowView.buildRingSectorShadow();
return cornerShadowView;
}
}
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/view/EdgeShadowView.java
================================================
package com.hitomi.cslibrary.base.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.view.View;
import com.hitomi.cslibrary.base.CrazyShadowDirection;
/**
* Created by hitomi on 2016/10/17.
*/
public class EdgeShadowView extends View {
private Paint shadowPaint;
private int[] shadowColors;
private float shadowRadius;
private float shadowSize;
private float cornerRadius;
@CrazyShadowDirection
private int direction;
private EdgeShadowView(Context context) {
super(context);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int measureWidth, measureHeight;
if (direction == CrazyShadowDirection.LEFT || direction == CrazyShadowDirection.RIGHT) {
measureWidth = Math.round(shadowRadius);
measureHeight = Math.round(shadowSize);
} else {
measureWidth = Math.round(shadowSize);
measureHeight = Math.round(shadowRadius);
}
setMeasuredDimension(measureWidth, measureHeight);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
switch (direction) {
case CrazyShadowDirection.TOP:
canvas.translate(0, cornerRadius + shadowRadius);
break;
case CrazyShadowDirection.RIGHT:
canvas.translate(-cornerRadius, 0);
canvas.rotate(90);
break;
case CrazyShadowDirection.BOTTOM:
canvas.translate(shadowSize, -cornerRadius);
canvas.rotate(180);
break;
case CrazyShadowDirection.LEFT:
canvas.translate(cornerRadius + shadowRadius, shadowSize);
canvas.rotate(270f);
break;
default:
}
canvas.drawRect(0, -cornerRadius -shadowRadius, shadowSize, -cornerRadius, shadowPaint);
canvas.restore();
}
private void buildEdgeShadowTool() {
shadowPaint = new Paint();
shadowPaint.setStyle(Paint.Style.FILL);
shadowPaint.setShader(new LinearGradient(0, -cornerRadius + shadowRadius, 0, -cornerRadius - shadowRadius,
shadowColors,
new float[]{0f, .5f, 1f}, Shader.TileMode.CLAMP));
}
public void setShadowColors(int[] shadowColors) {
this.shadowColors = shadowColors;
}
public void setShadowRadius(float shadowRadius) {
this.shadowRadius = shadowRadius;
}
public void setCornerRadius(float cornerRadius) {
this.cornerRadius = cornerRadius;
}
public void setShadowSize(float shadowSize) {
this.shadowSize = shadowSize;
}
public void setDirection(@CrazyShadowDirection int direction) {
this.direction = direction;
}
public static class Builder {
private Context context;
private int[] shadowColors;
private float shadowRadius;
private float shadowSize;
private float cornerRadius;
@CrazyShadowDirection
private int direction;
public Builder setContext(Context context) {
this.context = context;
return this;
}
public Builder setShadowColors(int[] shadowColors) {
this.shadowColors = shadowColors;
return this;
}
public Builder setShadowRadius(float shadowRadius) {
this.shadowRadius = shadowRadius;
return this;
}
public Builder setShadowSize(float shadowSize) {
this.shadowSize = shadowSize;
return this;
}
public Builder setCornerRadius(float cornerRadius) {
this.cornerRadius = cornerRadius;
return this;
}
public Builder setDirection(@CrazyShadowDirection int direction) {
this.direction = direction;
return this;
}
public EdgeShadowView create() {
// 创建 EdgeShadowView
EdgeShadowView edgeShadowView = new EdgeShadowView(context);
edgeShadowView.setShadowColors(shadowColors);
edgeShadowView.setShadowRadius(shadowRadius);
edgeShadowView.setShadowSize(shadowSize);
edgeShadowView.setCornerRadius(cornerRadius);
edgeShadowView.setDirection(direction);
edgeShadowView.buildEdgeShadowTool();
return edgeShadowView;
}
}
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/draw/RoundRectShadowDrawable.java
================================================
package com.hitomi.cslibrary.draw;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
/**
* Created by hitomi on 2016/10/17.
*/
public class RoundRectShadowDrawable extends Drawable {
// used to calculate content padding
final static double COS_45 = Math.cos(Math.toRadians(45));
final static float SHADOW_MULTIPLIER = 1.5f;
final int insetShadow; // extra shadow to avoid gaps between card and shadow
final RectF bounds;
Paint paint;
Paint cornerShadowPaint;
Paint edgeShadowPaint;
float cornerRadius;
Path cornerShadowPath;
// updated value with inset
float maxShadowSize;
// actual value set by developer
float rawMaxShadowSize;
// multiplied value to account for shadow offset
float shadowSize;
// actual value set by developer
float rawShadowSize;
private int[] shadowColors;
private boolean dirty = true;
private boolean addPaddingForCorners = true;
public RoundRectShadowDrawable(int background, int[] shadowColors, float radius, float shadowSize, float maxShadowSize) {
insetShadow = 10;
this.shadowColors = shadowColors;
paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
paint.setColor(background);
cornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
cornerShadowPaint.setStyle(Paint.Style.FILL);
cornerRadius = (int) (radius + .5f);
bounds = new RectF();
edgeShadowPaint = new Paint(cornerShadowPaint);
edgeShadowPaint.setAntiAlias(false);
setShadowSize(shadowSize, maxShadowSize);
}
/**
* Casts the value to an even integer.
*/
private int toEven(float value) {
int i = (int) (value + .5f);
if (i % 2 == 1) {
return i - 1;
}
return i;
}
public void setAddPaddingForCorners(boolean addPaddingForCorners) {
this.addPaddingForCorners = addPaddingForCorners;
invalidateSelf();
}
@Override
public void setAlpha(int alpha) {
paint.setAlpha(alpha);
cornerShadowPaint.setAlpha(alpha);
edgeShadowPaint.setAlpha(alpha);
}
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
dirty = true;
}
void setShadowSize(float shadowSize, float maxShadowSize) {
if (shadowSize < 0f) {
throw new IllegalArgumentException("Invalid shadow size " + shadowSize +
". Must be >= 0");
}
if (maxShadowSize < 0f) {
throw new IllegalArgumentException("Invalid max shadow size " + maxShadowSize +
". Must be >= 0");
}
shadowSize = toEven(shadowSize);
maxShadowSize = toEven(maxShadowSize);
if (shadowSize > maxShadowSize) {
shadowSize = maxShadowSize;
}
if (rawShadowSize == shadowSize && rawMaxShadowSize == maxShadowSize) {
return;
}
rawShadowSize = shadowSize;
rawMaxShadowSize = maxShadowSize;
this.shadowSize = (int) (shadowSize * SHADOW_MULTIPLIER + insetShadow + .5f);
this.maxShadowSize = maxShadowSize + insetShadow;
dirty = true;
invalidateSelf();
}
@Override
public boolean getPadding(Rect padding) {
int vOffset = (int) Math.ceil(calculateVerticalPadding(rawMaxShadowSize, cornerRadius,
addPaddingForCorners));
int hOffset = (int) Math.ceil(calculateHorizontalPadding(rawMaxShadowSize, cornerRadius,
addPaddingForCorners));
padding.set(hOffset, vOffset, hOffset, vOffset);
return true;
}
float calculateVerticalPadding(float maxShadowSize, float cornerRadius,
boolean addPaddingForCorners) {
if (addPaddingForCorners) {
return (float) (maxShadowSize * SHADOW_MULTIPLIER + (1 - COS_45) * cornerRadius);
} else {
return maxShadowSize * SHADOW_MULTIPLIER;
}
}
float calculateHorizontalPadding(float maxShadowSize, float cornerRadius,
boolean addPaddingForCorners) {
if (addPaddingForCorners) {
return (float) (maxShadowSize + (1 - COS_45) * cornerRadius);
} else {
return maxShadowSize;
}
}
@Override
public void setColorFilter(ColorFilter cf) {
paint.setColorFilter(cf);
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
@Override
public void draw(Canvas canvas) {
if (dirty) {
buildComponents(getBounds());
dirty = false;
}
canvas.translate(0, rawShadowSize / 2);
drawShadow(canvas);
canvas.translate(0, -rawShadowSize / 2);
canvas.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
}
private void drawShadow(Canvas canvas) {
final float edgeShadowTop = -cornerRadius - shadowSize;
final float inset = cornerRadius + insetShadow + rawShadowSize / 2;
final boolean drawHorizontalEdges = bounds.width() - 2 * inset > 0;
final boolean drawVerticalEdges = bounds.height() - 2 * inset > 0;
// LT
int saved = canvas.save();
canvas.translate(bounds.left + inset, bounds.top + inset);
canvas.drawPath(cornerShadowPath, cornerShadowPaint);
if (drawHorizontalEdges) {
canvas.drawRect(0, edgeShadowTop,
bounds.width() - 2 * inset, -cornerRadius,
edgeShadowPaint);
}
canvas.restoreToCount(saved);
// RB
saved = canvas.save();
canvas.translate(bounds.right - inset, bounds.bottom - inset);
canvas.rotate(180f);
canvas.drawPath(cornerShadowPath, cornerShadowPaint);
if (drawHorizontalEdges) {
canvas.drawRect(0, edgeShadowTop,
bounds.width() - 2 * inset, -cornerRadius,
edgeShadowPaint);
}
canvas.restoreToCount(saved);
// LB
saved = canvas.save();
canvas.translate(bounds.left + inset, bounds.bottom - inset);
canvas.rotate(270f);
canvas.drawPath(cornerShadowPath, cornerShadowPaint);
if (drawVerticalEdges) {
canvas.drawRect(0, edgeShadowTop,
bounds.height() - 2 * inset, -cornerRadius, edgeShadowPaint);
}
canvas.restoreToCount(saved);
// RT
saved = canvas.save();
canvas.translate(bounds.right - inset, bounds.top + inset);
canvas.rotate(90f);
canvas.drawPath(cornerShadowPath, cornerShadowPaint);
if (drawVerticalEdges) {
canvas.drawRect(0, edgeShadowTop,
bounds.height() - 2 * inset, -cornerRadius, edgeShadowPaint);
}
canvas.restoreToCount(saved);
}
private void buildShadowCorners() {
RectF innerBounds = new RectF(-cornerRadius, -cornerRadius, cornerRadius, cornerRadius);
RectF outerBounds = new RectF(innerBounds);
outerBounds.inset(-shadowSize, -shadowSize);
if (cornerShadowPath == null) {
cornerShadowPath = new Path();
} else {
cornerShadowPath.reset();
}
cornerShadowPath.setFillType(Path.FillType.EVEN_ODD);
cornerShadowPath.moveTo(-cornerRadius, 0);
cornerShadowPath.rLineTo(-shadowSize, 0);
// outer arc
cornerShadowPath.arcTo(outerBounds, 180f, 90f, false);
// inner arc
cornerShadowPath.arcTo(innerBounds, 270f, -90f, false);
cornerShadowPath.close();
float startRatio = cornerRadius / (cornerRadius + shadowSize);
cornerShadowPaint.setShader(new RadialGradient(0, 0, cornerRadius + shadowSize,
shadowColors,
new float[]{0f, startRatio, 1f}
, Shader.TileMode.CLAMP));
// we offset the content shadowSize/2 pixels up to make it more realistic.
// this is why edge shadow shader has some extra space
// When drawing bottom edge shadow, we use that extra space.
edgeShadowPaint.setShader(new LinearGradient(0, -cornerRadius + shadowSize, 0,
-cornerRadius - shadowSize,
shadowColors,
new float[]{0f, .5f, 1f}, Shader.TileMode.CLAMP));
edgeShadowPaint.setAntiAlias(false);
}
private void buildComponents(Rect bounds) {
// Card is offset SHADOW_MULTIPLIER * maxShadowSize to account for the shadow shift.
// We could have different top-bottom offsets to avoid extra gap above but in that case
// center aligning Views inside the CardView would be problematic.
final float verticalOffset = rawMaxShadowSize * SHADOW_MULTIPLIER;
this.bounds.set(bounds.left + rawMaxShadowSize, bounds.top + verticalOffset,
bounds.right - rawMaxShadowSize, bounds.bottom - verticalOffset);
buildShadowCorners();
}
float getCornerRadius() {
return cornerRadius;
}
void setCornerRadius(float radius) {
if (radius < 0f) {
throw new IllegalArgumentException("Invalid radius " + radius + ". Must be >= 0");
}
radius = (int) (radius + .5f);
if (cornerRadius == radius) {
return;
}
cornerRadius = radius;
dirty = true;
invalidateSelf();
}
void getMaxShadowAndCornerPadding(Rect into) {
getPadding(into);
}
float getShadowSize() {
return rawShadowSize;
}
void setShadowSize(float size) {
setShadowSize(size, rawMaxShadowSize);
}
float getMaxShadowSize() {
return rawMaxShadowSize;
}
void setMaxShadowSize(float size) {
setShadowSize(rawShadowSize, size);
}
float getMinWidth() {
final float content = 2 *
Math.max(rawMaxShadowSize, cornerRadius + insetShadow + rawMaxShadowSize / 2);
return content + (rawMaxShadowSize + insetShadow) * 2;
}
float getMinHeight() {
final float content = 2 * Math.max(rawMaxShadowSize, cornerRadius + insetShadow
+ rawMaxShadowSize * SHADOW_MULTIPLIER / 2);
return content + (rawMaxShadowSize * SHADOW_MULTIPLIER + insetShadow) * 2;
}
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/draw/ShadowDrawer.java
================================================
package com.hitomi.cslibrary.draw;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
import com.hitomi.cslibrary.base.CrazyShadowAttr;
import com.hitomi.cslibrary.base.ShadowHandler;
/**
* Created by hitomi on 2016/10/21. <br/>
*
* 使用 Drawable 添加阴影效果,同时支持圆角模式. <br/>
*
* 因为背景的最大尺寸为原 View 的尺寸,所以设置了阴影
* 后,原 View 大小会依据配置的阴影尺寸发生变化,并且
* 原 View 的位置会发生向上的偏移来显示出阴影的效果
*/
public class ShadowDrawer implements ShadowHandler {
private CrazyShadowAttr attr;
private View view;
private Drawable orignalDrawable, shadowDrawable;
public ShadowDrawer(CrazyShadowAttr attr) {
this.attr = attr;
}
@Override
public void makeShadow(View view) {
this.view = view;
orignalDrawable = view.getBackground();
int background;
if (attr.getBackground() != 0) {
background = attr.getBackground();
} else {
ColorDrawable colorDrawable = (ColorDrawable) view.getBackground();
if (colorDrawable == null) {
background = Color.WHITE;
} else {
background = colorDrawable.getColor();
}
}
shadowDrawable = new RoundRectShadowDrawable(
background, attr.getColors(), attr.getCorner(),
attr.getShadowRadius(), attr.getShadowRadius());
view.setBackgroundDrawable(shadowDrawable);
}
@Override
public void removeShadow() {
if (view != null && view.getBackground() instanceof RoundRectShadowDrawable)
view.setBackgroundDrawable(orignalDrawable);
}
@Override
public void hideShadow() {
if (view != null && view.getBackground() instanceof RoundRectShadowDrawable)
view.setBackgroundDrawable(orignalDrawable);
}
@Override
public void showShadow() {
if (view == null || shadowDrawable == null) return ;
view.setBackgroundDrawable(shadowDrawable);
}
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/floating/ShadowFloating.java
================================================
package com.hitomi.cslibrary.floating;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import com.hitomi.cslibrary.base.view.CornerShadowView;
import com.hitomi.cslibrary.base.CrazyShadowAttr;
import com.hitomi.cslibrary.base.CrazyShadowDirection;
import com.hitomi.cslibrary.base.view.EdgeShadowView;
import com.hitomi.cslibrary.base.ShadowHandler;
import java.util.ArrayList;
import java.util.List;
/**
* Created by hitomi on 2016/10/19. <br/>
*
* 考虑到不希望改变原 View 大小的情况,而又需要阴影效果的情况下。
* 此种方案应运而生,其原理是在原 View 根布局层面中添加阴影效果。
* 从 Z 轴的角度看就像是浮在原 View 的周围一样。不过因为与原
* View 不在一个布局层面上,所以当发生用户交互使原 View 的位置
* 发生改变后,阴影还是会留在原来的位置。
*
*/
public class ShadowFloating implements ShadowHandler {
private CrazyShadowAttr attr;
private Context context;
private View contentView;
private List<View> shadowViewList;
private Drawable orignalDrawable;
private boolean init;
public ShadowFloating(Context context, CrazyShadowAttr attr) {
this.context = context;
this.attr = attr;
shadowViewList = new ArrayList<>();
}
private void addShadow() {
addEdgeShadow();
addCornerShadow();
}
private FrameLayout getParentContainer() {
Activity activity = (Activity) context;
return (FrameLayout) activity.findViewById(Window.ID_ANDROID_CONTENT);
}
private void addEdgeShadow() {
EdgeShadowView.Builder edgeShadowBuilder = new EdgeShadowView.Builder()
.setContext(context)
.setShadowColors(attr.getColors())
.setCornerRadius(attr.getCorner())
.setShadowRadius(attr.getShadowRadius());
FrameLayout parentLayout = getParentContainer();
if (attr.containLeft())
decorateLeft(edgeShadowBuilder, parentLayout);
if (attr.containTop())
decorateTop(edgeShadowBuilder, parentLayout);
if (attr.containRight())
decorateRight(edgeShadowBuilder, parentLayout);
if (attr.containBottom())
decorateBottom(edgeShadowBuilder, parentLayout);
}
private void decorateLeft(EdgeShadowView.Builder edgeShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
float shadowSize;
float leftMargin, topMargin;
leftMargin = contentView.getLeft() - attr.getShadowRadius();
if (attr.getDirection() == CrazyShadowDirection.LEFT) {
shadowSize = contentView.getHeight();
topMargin = contentView.getTop();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT_TOP) {
shadowSize = contentView.getHeight() - 2 * attr.getCorner();
topMargin = contentView.getTop() + attr.getCorner();
} else {
shadowSize = contentView.getHeight() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.LEFT_TOP || attr.getDirection() == CrazyShadowDirection.LEFT_TOP_RIGHT) {
topMargin = contentView.getTop() + attr.getCorner();
} else {
topMargin = contentView.getTop();
}
}
parentLp.leftMargin = (int) leftMargin;
parentLp.topMargin = (int) topMargin;
View leftEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.LEFT)
.create();
shadowViewList.add(leftEdgeShadow);
parentLayout.addView(leftEdgeShadow, parentLp);
}
private void decorateTop(EdgeShadowView.Builder edgeShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
float shadowSize;
float leftMargin, topMargin;
topMargin = contentView.getTop() - attr.getShadowRadius();
if (attr.getDirection() == CrazyShadowDirection.TOP) {
shadowSize = contentView.getWidth();
leftMargin = contentView.getLeft();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.LEFT_TOP_RIGHT) {
shadowSize = contentView.getWidth() - 2 * attr.getCorner();
leftMargin = contentView.getLeft() + attr.getCorner();
} else {
shadowSize = contentView.getWidth() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.LEFT_TOP || attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT_TOP) {
leftMargin = contentView.getLeft() + attr.getCorner();
} else {
leftMargin = contentView.getLeft();
}
}
parentLp.leftMargin = (int) leftMargin;
parentLp.topMargin = (int) topMargin;
View topEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.TOP)
.create();
shadowViewList.add(topEdgeShadow);
parentLayout.addView(topEdgeShadow, parentLp);
}
private void decorateRight(EdgeShadowView.Builder edgeShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
float shadowSize;
float leftMargin, topMargin;
leftMargin = contentView.getRight();
if (attr.getDirection() == CrazyShadowDirection.RIGHT) {
shadowSize = contentView.getHeight();
topMargin = contentView.getTop();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.TOP_RIGHT_BOTTOM) {
shadowSize = contentView.getHeight() - 2 * attr.getCorner();
topMargin = contentView.getTop() + attr.getCorner();
} else {
shadowSize = contentView.getHeight() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.TOP_RIGHT || attr.getDirection() == CrazyShadowDirection.LEFT_TOP_RIGHT) {
topMargin = contentView.getTop() + attr.getCorner();
} else {
topMargin = contentView.getTop();
}
}
parentLp.leftMargin = (int) leftMargin;
parentLp.topMargin = (int) topMargin;
View rightEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.RIGHT)
.create();
shadowViewList.add(rightEdgeShadow);
parentLayout.addView(rightEdgeShadow, parentLp);
}
private void decorateBottom(EdgeShadowView.Builder edgeShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
float shadowSize;
float leftMargin, topMargin;
topMargin = contentView.getBottom();
if (attr.getDirection() == CrazyShadowDirection.BOTTOM) {
shadowSize = contentView.getWidth();
leftMargin = contentView.getLeft();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.RIGHT_BOTTOM_LEFT) {
shadowSize = contentView.getWidth() - 2 * attr.getCorner();
leftMargin = contentView.getLeft() + attr.getCorner();
} else {
shadowSize = contentView.getWidth() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT || attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT_TOP) {
leftMargin = contentView.getLeft() + attr.getCorner();
} else {
leftMargin = contentView.getLeft();
}
}
parentLp.leftMargin = (int) leftMargin;
parentLp.topMargin = (int) topMargin;
View bottomEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.BOTTOM)
.create();
shadowViewList.add(bottomEdgeShadow);
parentLayout.addView(bottomEdgeShadow, parentLp);
}
private void addCornerShadow() {
CornerShadowView.Builder cornerShadowBuilder = new CornerShadowView.Builder()
.setContext(context)
.setShadowColors(attr.getColors())
.setShadowSize(attr.getShadowRadius())
.setCornerRadius(attr.getCorner());
FrameLayout parentLayout = getParentContainer();
if (attr.containLeft() && attr.containTop())
decorateLeftTop(cornerShadowBuilder, parentLayout);
if (attr.containRight() && attr.containTop())
decorateRightTop(cornerShadowBuilder, parentLayout);
if (attr.containRight() && attr.containBottom())
decorateRightBottom(cornerShadowBuilder, parentLayout);
if (attr.containLeft() && attr.containBottom())
decorateLeftBottom(cornerShadowBuilder, parentLayout);
}
private void decorateLeftTop(CornerShadowView.Builder cornerShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
parentLp.leftMargin = (int) (contentView.getLeft() - attr.getShadowRadius());
parentLp.topMargin = (int) (contentView.getTop() - attr.getShadowRadius());
View leftTopCorner = cornerShadowBuilder
.setDirection(CrazyShadowDirection.LEFT_TOP)
.create();
shadowViewList.add(leftTopCorner);
parentLayout.addView(leftTopCorner, parentLp);
}
private void decorateRightTop(CornerShadowView.Builder cornerShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
parentLp.leftMargin = (int) (contentView.getRight() - attr.getCorner());
parentLp.topMargin = (int) (contentView.getTop() - attr.getShadowRadius());
View rightTopCorner = cornerShadowBuilder
.setDirection(CrazyShadowDirection.TOP_RIGHT)
.create();
shadowViewList.add(rightTopCorner);
parentLayout.addView(rightTopCorner, parentLp);
}
private void decorateRightBottom(CornerShadowView.Builder cornerShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
parentLp.leftMargin = (int) (contentView.getRight() - attr.getCorner());
parentLp.topMargin = (int) (contentView.getBottom() - attr.getCorner());
View rightBottomCorner = cornerShadowBuilder
.setDirection(CrazyShadowDirection.RIGHT_BOTTOM)
.create();
shadowViewList.add(rightBottomCorner);
parentLayout.addView(rightBottomCorner, parentLp);
}
private void decorateLeftBottom(CornerShadowView.Builder cornerShadowBuilder, FrameLayout parentLayout) {
FrameLayout.LayoutParams parentLp = new FrameLayout.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
parentLp.leftMargin = (int) (contentView.getLeft() - attr.getShadowRadius());
parentLp.topMargin = (int) (contentView.getBottom() - attr.getCorner());
View leftBottomCorner = cornerShadowBuilder
.setDirection(CrazyShadowDirection.BOTTOM_LEFT)
.create();
shadowViewList.add(leftBottomCorner);
parentLayout.addView(leftBottomCorner, parentLp);
}
@Override
public void makeShadow(View view) {
contentView = view;
init = true;
if (attr.getBackground() !=0) {
orignalDrawable = contentView.getBackground();
contentView.setBackgroundColor(attr.getBackground());
}
contentView.getViewTreeObserver().addOnGlobalLayoutListener(new OnMeasureListener());
}
@Override
public void removeShadow() {
FrameLayout parentLayout = getParentContainer();
for (View shadowView : shadowViewList) {
parentLayout.removeView(shadowView);
}
if (attr.getBackground() != 0) {
contentView.setBackgroundDrawable(orignalDrawable);
}
}
@Override
public void hideShadow() {
for (View shadowView : shadowViewList) {
shadowView.setAlpha(0);
}
if (attr.getBackground() != 0) {
contentView.setBackgroundDrawable(orignalDrawable);
}
}
@Override
public void showShadow() {
for (View shadowView : shadowViewList) {
shadowView.setAlpha(1);
}
if (attr.getBackground() !=0 && contentView != null) {
contentView.setBackgroundColor(attr.getBackground());
}
}
private class OnMeasureListener implements ViewTreeObserver.OnGlobalLayoutListener {
@Override
public void onGlobalLayout() {
if (init) {
addShadow();
init = false;
contentView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
}
}
================================================
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/wrap/ShadowWrapper.java
================================================
package com.hitomi.cslibrary.wrap;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.RelativeLayout;
import com.hitomi.cslibrary.base.view.CornerShadowView;
import com.hitomi.cslibrary.base.CrazyShadowAttr;
import com.hitomi.cslibrary.base.CrazyShadowDirection;
import com.hitomi.cslibrary.base.view.EdgeShadowView;
import com.hitomi.cslibrary.base.ShadowHandler;
/**
* Created by hitomi on 2016/10/17. <br/>
*
* 使用包装的方式为 View 添加阴影。<br/>
*
* 其原理是根据配置的阴影尺寸大小来修改原 View 的大小后,在原 View 的四周
* 附加阴影效果。<br/>
*
*/
public class ShadowWrapper implements ShadowHandler {
private Context context;
private View contentView;
private RelativeLayout shadowLayout;
private Drawable orignalDrawable;
private OnMeasureListener measureListener;
private CrazyShadowAttr attr;
private boolean init;
public ShadowWrapper(Context context, CrazyShadowAttr attr) {
this.context = context;
this.attr = attr;
measureListener = new OnMeasureListener();
}
private void prepareLayout() {
ViewGroup parent = (ViewGroup) contentView.getParent();
int orignalIndex = parent.indexOfChild(contentView);
parent.removeView(contentView);
shadowLayout = new RelativeLayout(context);
ViewGroup.LayoutParams contentViewLp = contentView.getLayoutParams();
contentViewLp.width = contentView.getWidth();
contentViewLp.height = contentView.getHeight();
shadowLayout.setLayoutParams(contentViewLp);
parent.addView(shadowLayout, orignalIndex);
shadowLayout.addView(contentView, getContentViewLayoutParams());
}
@NonNull
private RelativeLayout.LayoutParams getContentViewLayoutParams() {
int width, height;
RelativeLayout.LayoutParams rlp;
int direction = attr.getDirection();
if (direction == CrazyShadowDirection.LEFT || direction == CrazyShadowDirection.RIGHT) {
width = (int) (contentView.getWidth() - attr.getShadowRadius());
height = contentView.getHeight();
rlp = new RelativeLayout.LayoutParams(width, height);
if (direction == CrazyShadowDirection.LEFT)
rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
} else if (direction == CrazyShadowDirection.TOP || direction == CrazyShadowDirection.BOTTOM) {
width = contentView.getWidth();
height = (int) (contentView.getHeight() - attr.getShadowRadius());
rlp = new RelativeLayout.LayoutParams(width, height);
if (direction == CrazyShadowDirection.TOP)
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
} else if (direction == CrazyShadowDirection.LEFT_TOP || direction == CrazyShadowDirection.TOP_RIGHT) {
width = (int) (contentView.getWidth() - attr.getShadowRadius());
height = (int) (contentView.getHeight() - attr.getShadowRadius());
rlp = new RelativeLayout.LayoutParams(width, height);
if (direction == CrazyShadowDirection.LEFT_TOP) {
rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
} else {
rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
}
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
} else if (direction == CrazyShadowDirection.BOTTOM_LEFT || direction == CrazyShadowDirection.RIGHT_BOTTOM) {
width = (int) (contentView.getWidth() - attr.getShadowRadius());
height = (int) (contentView.getHeight() - attr.getShadowRadius());
rlp = new RelativeLayout.LayoutParams(width, height);
if (direction == CrazyShadowDirection.BOTTOM_LEFT)
rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
} else if (direction == CrazyShadowDirection.BOTTOM_LEFT_TOP || direction == CrazyShadowDirection.TOP_RIGHT_BOTTOM) {
width = (int) (contentView.getWidth() - attr.getShadowRadius());
height = (int) (contentView.getHeight() - attr.getShadowRadius() * 2);
rlp = new RelativeLayout.LayoutParams(width, height);
if (direction == CrazyShadowDirection.BOTTOM_LEFT_TOP) {
rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
}
rlp.addRule(RelativeLayout.CENTER_VERTICAL);
} else if (direction == CrazyShadowDirection.LEFT_TOP_RIGHT || direction == CrazyShadowDirection.RIGHT_BOTTOM_LEFT) {
width = (int) (contentView.getWidth() - attr.getShadowRadius() * 2);
height = (int) (contentView.getHeight() - attr.getShadowRadius());
rlp = new RelativeLayout.LayoutParams(width, height);
if (direction == CrazyShadowDirection.LEFT_TOP_RIGHT) {
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
}
rlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
} else { // All
width = (int) (contentView.getWidth() - attr.getShadowRadius() * 2);
height = (int) (contentView.getHeight() - attr.getShadowRadius() * 2);
rlp = new RelativeLayout.LayoutParams(width, height);
rlp.addRule(RelativeLayout.CENTER_IN_PARENT);
}
return rlp;
}
private void addShadow() {
addEdgeShadow();
addCornerShadow();
}
private void addEdgeShadow() {
EdgeShadowView.Builder edgeShadowBuilder = new EdgeShadowView.Builder()
.setContext(context)
.setShadowColors(attr.getColors())
.setCornerRadius(attr.getCorner())
.setShadowRadius(attr.getShadowRadius());
if (attr.containLeft())
decorateLeft(edgeShadowBuilder);
if (attr.containTop())
decorateTop(edgeShadowBuilder);
if (attr.containRight())
decorateRight(edgeShadowBuilder);
if (attr.containBottom())
decorateBottom(edgeShadowBuilder);
}
private void decorateLeft(EdgeShadowView.Builder edgeShadowBuilder) {
RelativeLayout.LayoutParams leftRlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
float shadowSize;
if (attr.getDirection() == CrazyShadowDirection.LEFT) {
shadowSize = contentView.getHeight();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT_TOP) {
shadowSize = contentView.getHeight() - 2 * (attr.getShadowRadius() + attr.getCorner());
leftRlp.addRule(RelativeLayout.CENTER_VERTICAL);
} else {
shadowSize = contentView.getHeight() - attr.getShadowRadius() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.LEFT_TOP || attr.getDirection() == CrazyShadowDirection.LEFT_TOP_RIGHT) {
leftRlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
}
}
if (shadowSize <= 0) return ;
EdgeShadowView leftEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.LEFT)
.create();
shadowLayout.addView(leftEdgeShadow, leftRlp);
}
private void decorateTop(EdgeShadowView.Builder edgeShadowBuilder) {
RelativeLayout.LayoutParams topRlp = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
float shadowSize;
if (attr.getDirection() == CrazyShadowDirection.TOP) {
shadowSize = contentView.getWidth();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.LEFT_TOP_RIGHT) {
shadowSize = contentView.getWidth() - 2 * (attr.getShadowRadius() + attr.getCorner());
topRlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
} else {
shadowSize = contentView.getWidth() - attr.getShadowRadius() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.LEFT_TOP || attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT_TOP) {
topRlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
}
}
if (shadowSize <= 0) return ;
EdgeShadowView topEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.TOP)
.create();
shadowLayout.addView(topEdgeShadow, topRlp);
}
private void decorateRight(EdgeShadowView.Builder edgeShadowBuilder) {
RelativeLayout.LayoutParams rightRlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
rightRlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
float shadowSize;
if (attr.getDirection() == CrazyShadowDirection.RIGHT) {
shadowSize = contentView.getHeight();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.TOP_RIGHT_BOTTOM) {
shadowSize = contentView.getHeight() - 2 * (attr.getShadowRadius() + attr.getCorner());
rightRlp.addRule(RelativeLayout.CENTER_VERTICAL);
} else {
shadowSize = contentView.getHeight() - attr.getShadowRadius() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.TOP_RIGHT || attr.getDirection() == CrazyShadowDirection.LEFT_TOP_RIGHT) {
rightRlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
}
}
if (shadowSize <= 0) return ;
EdgeShadowView rightEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.RIGHT)
.create();
shadowLayout.addView(rightEdgeShadow, rightRlp);
}
private void decorateBottom(EdgeShadowView.Builder edgeShadowBuilder) {
RelativeLayout.LayoutParams bottomRlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
bottomRlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
float shadowSize;
if (attr.getDirection() == CrazyShadowDirection.BOTTOM) {
shadowSize = contentView.getWidth();
} else if (attr.getDirection() == CrazyShadowDirection.ALL
|| attr.getDirection() == CrazyShadowDirection.RIGHT_BOTTOM_LEFT) {
shadowSize = contentView.getWidth() - 2 * (attr.getShadowRadius() + attr.getCorner());
bottomRlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
} else {
shadowSize = contentView.getWidth() - attr.getShadowRadius() - attr.getCorner();
if (attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT || attr.getDirection() == CrazyShadowDirection.BOTTOM_LEFT_TOP) {
bottomRlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
}
}
if (shadowSize <= 0) return ;
EdgeShadowView bottomEdgeShadow = edgeShadowBuilder
.setShadowSize(shadowSize)
.setDirection(CrazyShadowDirection.BOTTOM)
.create();
shadowLayout.addView(bottomEdgeShadow, bottomRlp);
}
private void addCornerShadow() {
CornerShadowView.Builder cornerShadowBuilder = new CornerShadowView.Builder()
.setContext(context)
.setShadowColors(attr.getColors())
.setShadowSize(attr.getShadowRadius())
.setCornerRadius(attr.getCorner());
if (attr.containLeft() && attr.containTop())
decorateLeftTop(cornerShadowBuilder);
if (attr.containRight() && attr.containTop())
decorateRightTop(cornerShadowBuilder);
if (attr.containRight() && attr.containBottom())
decorateRightBottom(cornerShadowBuilder);
if (attr.containLeft() && attr.containBottom())
decorateLeftBottom(cornerShadowBuilder);
}
private void decorateLeftTop(CornerShadowView.Builder cornerShadowBuilder) {
CornerShadowView leftTopCornerShadow = cornerShadowBuilder
.setDirection(CrazyShadowDirection.LEFT_TOP)
.create();
RelativeLayout.LayoutParams leftTopRlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
leftTopRlp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
leftTopRlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
shadowLayout.addView(leftTopCornerShadow, leftTopRlp);
}
private void decorateRightTop(CornerShadowView.Builder cornerShadowbuilder) {
CornerShadowView rightTopCornerShadow = cornerShadowbuilder
.setDirection(CrazyShadowDirection.TOP_RIGHT)
.create();
RelativeLayout.LayoutParams rightTopRlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
rightTopRlp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rightTopRlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
shadowLayout.addView(rightTopCornerShadow, rightTopRlp);
}
private void decorateRightBottom(CornerShadowView.Builder cornerShadowbuilder) {
CornerShadowView RightBottomCornerShadow = cornerShadowbuilder
.setDirection(CrazyShadowDirection.RIGHT_BOTTOM)
.create();
RelativeLayout.LayoutParams rightBottomRlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
rightBottomRlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
rightBottomRlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
shadowLayout.addView(RightBottomCornerShadow, rightBottomRlp);
}
private void decorateLeftBottom(CornerShadowView.Builder cornerShadowbuilder) {
CornerShadowView leftBottomCornerShadow = cornerShadowbuilder
.setDirection(CrazyShadowDirection.BOTTOM_LEFT)
.create();
RelativeLayout.LayoutParams leftBottomRlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT
, ViewGroup.LayoutParams.WRAP_CONTENT);
leftBottomRlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
leftBottomRlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
shadowLayout.addView(leftBottomCornerShadow, leftBottomRlp);
}
@Override
public void makeShadow(View view) {
contentView = view;
init = true;
if (attr.getBackground() != 0) {
orignalDrawable = contentView.getBackground();
contentView.setBackgroundColor(attr.getBackground());
}
contentView.getViewTreeObserver().addOnGlobalLayoutListener(measureListener);
}
@Override
public void removeShadow() {
shadowLayout.removeView(contentView);
ViewGroup parent = (ViewGroup) shadowLayout.getParent();
int orignalIndex = parent.indexOfChild(shadowLayout);
parent.removeView(shadowLayout);
contentView.setLayoutParams(shadowLayout.getLayoutParams());
parent.addView(contentView, orignalIndex);
if (attr.getBackground() != 0) {
contentView.setBackgroundDrawable(orignalDrawable);
}
}
@Override
public void hideShadow() {
setShadowViewAlpha(0);
ViewGroup.LayoutParams contentViewLp = contentView.getLayoutParams();
contentViewLp.width = shadowLayout.getLayoutParams().width;
contentViewLp.height = shadowLayout.getLayoutParams().height;
contentView.setLayoutParams(contentViewLp);
if (attr.getBackground() != 0) {
contentView.setBackgroundDrawable(orignalDrawable);
}
}
@Override
public void showShadow() {
setShadowViewAlpha(1);
contentView.setLayoutParams(getContentViewLayoutParams());
if (attr.getBackground() != 0 && contentView != null) {
contentView.setBackgroundColor(attr.getBackground());
}
}
private void setShadowViewAlpha(int alpha) {
int childCount = shadowLayout.getChildCount();
View child;
for (int i = 0; i < childCount; i++) {
child = shadowLayout.getChildAt(i);
if (child instanceof EdgeShadowView || child instanceof CornerShadowView) {
child.setAlpha(alpha);
}
}
}
private class OnMeasureListener implements ViewTreeObserver.OnGlobalLayoutListener {
@Override
public void onGlobalLayout() {
if (init) {
prepareLayout();
addShadow();
init = false;
contentView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
}
}
================================================
FILE: cslibrary/src/main/res/color/background.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#00000000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#00000000"/> <!-- focused -->
<item android:color="#00000000"/> <!-- default -->
</selector>
================================================
FILE: cslibrary/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">csLibrary</string>
</resources>
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Mon Dec 05 08:49:55 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
================================================
FILE: gradle.properties
================================================
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: settings.gradle
================================================
include ':app', ':cslibrary'
gitextract_svsycx0l/ ├── .gitignore ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── hitomi/ │ │ └── crazyshadow/ │ │ └── ApplicationTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── hitomi/ │ │ │ └── crazyshadow/ │ │ │ └── MainActivity.java │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── shape_float.xml │ │ │ └── shape_wrap.xml │ │ ├── layout/ │ │ │ └── activity_main.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ └── test/ │ └── java/ │ └── com/ │ └── hitomi/ │ └── crazyshadow/ │ └── ExampleUnitTest.java ├── build.gradle ├── cslibrary/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── hitomi/ │ │ └── cslibrary/ │ │ ├── CrazyShadow.java │ │ ├── base/ │ │ │ ├── CrazyShadowAttr.java │ │ │ ├── CrazyShadowDirection.java │ │ │ ├── ShadowHandler.java │ │ │ └── view/ │ │ │ ├── CornerShadowView.java │ │ │ └── EdgeShadowView.java │ │ ├── draw/ │ │ │ ├── RoundRectShadowDrawable.java │ │ │ └── ShadowDrawer.java │ │ ├── floating/ │ │ │ └── ShadowFloating.java │ │ └── wrap/ │ │ └── ShadowWrapper.java │ └── res/ │ ├── color/ │ │ └── background.xml │ └── values/ │ └── strings.xml ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle
SYMBOL INDEX (160 symbols across 12 files)
FILE: app/src/androidTest/java/com/hitomi/crazyshadow/ApplicationTest.java
class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 10) | public ApplicationTest() {
FILE: app/src/main/java/com/hitomi/crazyshadow/MainActivity.java
class MainActivity (line 11) | public class MainActivity extends AppCompatActivity implements View.OnCl...
method onCreate (line 37) | @Override
method initListener (line 47) | private void initListener() {
method onClick (line 59) | @Override
method initShadow (line 137) | private void initShadow() {
method initView (line 210) | private void initView() {
method dip2Px (line 223) | public int dip2Px(float dpValue) {
FILE: app/src/test/java/com/hitomi/crazyshadow/ExampleUnitTest.java
class ExampleUnitTest (line 10) | public class ExampleUnitTest {
method addition_isCorrect (line 11) | @Test
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/CrazyShadow.java
class CrazyShadow (line 21) | public class CrazyShadow {
method CrazyShadow (line 45) | private CrazyShadow(Context context) {
method createShadowHandler (line 49) | private void createShadowHandler(CrazyShadowAttr attr) {
method make (line 63) | public void make(View view) {
method remove (line 73) | public void remove() {
method show (line 83) | public void show() {
method hide (line 90) | public void hide() {
class Builder (line 94) | public static class Builder {
method setContext (line 138) | public Builder setContext(Context context) {
method setImpl (line 151) | public Builder setImpl(String impl) {
method setBaseShadowColor (line 162) | public Builder setBaseShadowColor(int baseColor) {
method setBackground (line 172) | public Builder setBackground(int background) {
method setColors (line 182) | public Builder setColors(int[] colors) {
method setCorner (line 194) | public Builder setCorner(float corner) {
method setShadowRadius (line 204) | public Builder setShadowRadius(float shadowRadius) {
method setDirection (line 214) | public Builder setDirection(int direction) {
method create (line 219) | private CrazyShadow create() {
method action (line 241) | public CrazyShadow action(View view) {
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/CrazyShadowAttr.java
class CrazyShadowAttr (line 8) | public class CrazyShadowAttr {
method getImpl (line 53) | public String getImpl() {
method setImpl (line 57) | public void setImpl(String impl) {
method setBaseShadowColor (line 61) | public void setBaseShadowColor(int baseShadowColor) {
method getBackground (line 71) | public int getBackground() {
method setBackground (line 75) | public void setBackground(int background) {
method getColors (line 79) | public int[] getColors() {
method setColors (line 83) | public void setColors(int[] colors) {
method getCorner (line 88) | public float getCorner() {
method setCorner (line 92) | public void setCorner(float corner) {
method getShadowRadius (line 96) | public float getShadowRadius() {
method setShadowRadius (line 100) | public void setShadowRadius(float shadowRadius) {
method getDirection (line 104) | public int getDirection() {
method setDirection (line 108) | public void setDirection(@CrazyShadowDirection int direction) {
method containLeft (line 112) | public boolean containLeft() {
method containTop (line 122) | public boolean containTop() {
method containRight (line 132) | public boolean containRight() {
method containBottom (line 142) | public boolean containBottom() {
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/ShadowHandler.java
type ShadowHandler (line 8) | public interface ShadowHandler {
method makeShadow (line 10) | void makeShadow(View view);
method removeShadow (line 12) | void removeShadow();
method hideShadow (line 14) | void hideShadow();
method showShadow (line 16) | void showShadow();
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/view/CornerShadowView.java
class CornerShadowView (line 17) | public class CornerShadowView extends View {
method CornerShadowView (line 31) | private CornerShadowView(Context context) {
method init (line 36) | private void init() {
method onMeasure (line 42) | @Override
method onDraw (line 48) | @Override
method buildRingSectorShadow (line 57) | private void buildRingSectorShadow() {
method setShadowColors (line 79) | public void setShadowColors(int[] shadowColors) {
method setCornerRadius (line 83) | public void setCornerRadius(float cornerRadius) {
method setShadowSize (line 87) | public void setShadowSize(float shadowSize) {
method setDirection (line 91) | public void setDirection(@CrazyShadowDirection int direction) {
class Builder (line 110) | public static class Builder {
method setContext (line 123) | public Builder setContext(Context context) {
method setShadowColors (line 128) | public Builder setShadowColors(int[] shadowColors) {
method setCornerRadius (line 133) | public Builder setCornerRadius(float cornerRadius) {
method setShadowSize (line 138) | public Builder setShadowSize(float shadowSize) {
method setDirection (line 144) | public Builder setDirection(@CrazyShadowDirection int direction) {
method create (line 149) | public CornerShadowView create() {
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/base/view/EdgeShadowView.java
class EdgeShadowView (line 15) | public class EdgeShadowView extends View {
method EdgeShadowView (line 30) | private EdgeShadowView(Context context) {
method onMeasure (line 34) | @Override
method onDraw (line 47) | @Override
method buildEdgeShadowTool (line 72) | private void buildEdgeShadowTool() {
method setShadowColors (line 80) | public void setShadowColors(int[] shadowColors) {
method setShadowRadius (line 84) | public void setShadowRadius(float shadowRadius) {
method setCornerRadius (line 88) | public void setCornerRadius(float cornerRadius) {
method setShadowSize (line 92) | public void setShadowSize(float shadowSize) {
method setDirection (line 96) | public void setDirection(@CrazyShadowDirection int direction) {
class Builder (line 100) | public static class Builder {
method setContext (line 115) | public Builder setContext(Context context) {
method setShadowColors (line 120) | public Builder setShadowColors(int[] shadowColors) {
method setShadowRadius (line 125) | public Builder setShadowRadius(float shadowRadius) {
method setShadowSize (line 130) | public Builder setShadowSize(float shadowSize) {
method setCornerRadius (line 135) | public Builder setCornerRadius(float cornerRadius) {
method setDirection (line 140) | public Builder setDirection(@CrazyShadowDirection int direction) {
method create (line 145) | public EdgeShadowView create() {
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/draw/RoundRectShadowDrawable.java
class RoundRectShadowDrawable (line 18) | public class RoundRectShadowDrawable extends Drawable {
method RoundRectShadowDrawable (line 43) | public RoundRectShadowDrawable(int background, int[] shadowColors, flo...
method toEven (line 60) | private int toEven(float value) {
method setAddPaddingForCorners (line 68) | public void setAddPaddingForCorners(boolean addPaddingForCorners) {
method setAlpha (line 73) | @Override
method onBoundsChange (line 80) | @Override
method setShadowSize (line 86) | void setShadowSize(float shadowSize, float maxShadowSize) {
method getPadding (line 111) | @Override
method calculateVerticalPadding (line 121) | float calculateVerticalPadding(float maxShadowSize, float cornerRadius,
method calculateHorizontalPadding (line 130) | float calculateHorizontalPadding(float maxShadowSize, float cornerRadius,
method setColorFilter (line 139) | @Override
method getOpacity (line 144) | @Override
method draw (line 149) | @Override
method drawShadow (line 161) | private void drawShadow(Canvas canvas) {
method buildShadowCorners (line 209) | private void buildShadowCorners() {
method buildComponents (line 243) | private void buildComponents(Rect bounds) {
method getCornerRadius (line 253) | float getCornerRadius() {
method setCornerRadius (line 257) | void setCornerRadius(float radius) {
method getMaxShadowAndCornerPadding (line 270) | void getMaxShadowAndCornerPadding(Rect into) {
method getShadowSize (line 274) | float getShadowSize() {
method setShadowSize (line 278) | void setShadowSize(float size) {
method getMaxShadowSize (line 282) | float getMaxShadowSize() {
method setMaxShadowSize (line 286) | void setMaxShadowSize(float size) {
method getMinWidth (line 290) | float getMinWidth() {
method getMinHeight (line 296) | float getMinHeight() {
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/draw/ShadowDrawer.java
class ShadowDrawer (line 20) | public class ShadowDrawer implements ShadowHandler {
method ShadowDrawer (line 28) | public ShadowDrawer(CrazyShadowAttr attr) {
method makeShadow (line 32) | @Override
method removeShadow (line 53) | @Override
method hideShadow (line 59) | @Override
method showShadow (line 65) | @Override
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/floating/ShadowFloating.java
class ShadowFloating (line 31) | public class ShadowFloating implements ShadowHandler {
method ShadowFloating (line 45) | public ShadowFloating(Context context, CrazyShadowAttr attr) {
method addShadow (line 51) | private void addShadow() {
method getParentContainer (line 56) | private FrameLayout getParentContainer() {
method addEdgeShadow (line 61) | private void addEdgeShadow() {
method decorateLeft (line 82) | private void decorateLeft(EdgeShadowView.Builder edgeShadowBuilder, Fr...
method decorateTop (line 114) | private void decorateTop(EdgeShadowView.Builder edgeShadowBuilder, Fra...
method decorateRight (line 146) | private void decorateRight(EdgeShadowView.Builder edgeShadowBuilder, F...
method decorateBottom (line 178) | private void decorateBottom(EdgeShadowView.Builder edgeShadowBuilder, ...
method addCornerShadow (line 210) | private void addCornerShadow() {
method decorateLeftTop (line 231) | private void decorateLeftTop(CornerShadowView.Builder cornerShadowBuil...
method decorateRightTop (line 246) | private void decorateRightTop(CornerShadowView.Builder cornerShadowBui...
method decorateRightBottom (line 261) | private void decorateRightBottom(CornerShadowView.Builder cornerShadow...
method decorateLeftBottom (line 276) | private void decorateLeftBottom(CornerShadowView.Builder cornerShadowB...
method makeShadow (line 291) | @Override
method removeShadow (line 302) | @Override
method hideShadow (line 313) | @Override
method showShadow (line 323) | @Override
class OnMeasureListener (line 333) | private class OnMeasureListener implements ViewTreeObserver.OnGlobalLa...
method onGlobalLayout (line 334) | @Override
FILE: cslibrary/src/main/java/com/hitomi/cslibrary/wrap/ShadowWrapper.java
class ShadowWrapper (line 27) | public class ShadowWrapper implements ShadowHandler {
method ShadowWrapper (line 43) | public ShadowWrapper(Context context, CrazyShadowAttr attr) {
method prepareLayout (line 49) | private void prepareLayout() {
method getContentViewLayoutParams (line 63) | @NonNull
method addShadow (line 121) | private void addShadow() {
method addEdgeShadow (line 126) | private void addEdgeShadow() {
method decorateLeft (line 146) | private void decorateLeft(EdgeShadowView.Builder edgeShadowBuilder) {
method decorateTop (line 171) | private void decorateTop(EdgeShadowView.Builder edgeShadowBuilder) {
method decorateRight (line 197) | private void decorateRight(EdgeShadowView.Builder edgeShadowBuilder) {
method decorateBottom (line 223) | private void decorateBottom(EdgeShadowView.Builder edgeShadowBuilder) {
method addCornerShadow (line 249) | private void addCornerShadow() {
method decorateLeftTop (line 269) | private void decorateLeftTop(CornerShadowView.Builder cornerShadowBuil...
method decorateRightTop (line 280) | private void decorateRightTop(CornerShadowView.Builder cornerShadowbui...
method decorateRightBottom (line 291) | private void decorateRightBottom(CornerShadowView.Builder cornerShadow...
method decorateLeftBottom (line 302) | private void decorateLeftBottom(CornerShadowView.Builder cornerShadowb...
method makeShadow (line 313) | @Override
method removeShadow (line 324) | @Override
method hideShadow (line 340) | @Override
method showShadow (line 352) | @Override
method setShadowViewAlpha (line 361) | private void setShadowViewAlpha(int alpha) {
class OnMeasureListener (line 372) | private class OnMeasureListener implements ViewTreeObserver.OnGlobalLa...
method onGlobalLayout (line 374) | @Override
Condensed preview — 40 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (108K chars).
[
{
"path": ".gitignore",
"chars": 97,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n"
},
{
"path": "README.md",
"chars": 3828,
"preview": "# CrazyShadow\n\n[](https://jitpack.io/#Hitomis/CrazyShadow)\n\n CrazySha"
},
{
"path": "app/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "app/build.gradle",
"chars": 657,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 24\n buildToolsVersion \"24.0.2\"\n\n defaultC"
},
{
"path": "app/proguard-rules.pro",
"chars": 651,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "app/src/androidTest/java/com/hitomi/crazyshadow/ApplicationTest.java",
"chars": 353,
"preview": "package com.hitomi.crazyshadow;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a hre"
},
{
"path": "app/src/main/AndroidManifest.xml",
"chars": 748,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package="
},
{
"path": "app/src/main/java/com/hitomi/crazyshadow/MainActivity.java",
"chars": 7817,
"preview": "package com.hitomi.crazyshadow;\n\nimport android.graphics.Color;\nimport android.os.Bundle;\nimport android.support.v7.app."
},
{
"path": "app/src/main/res/drawable/shape_float.xml",
"chars": 222,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:sha"
},
{
"path": "app/src/main/res/drawable/shape_wrap.xml",
"chars": 222,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:sha"
},
{
"path": "app/src/main/res/layout/activity_main.xml",
"chars": 5431,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmln"
},
{
"path": "app/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#3F51B5</color>\n <color name=\"color"
},
{
"path": "app/src/main/res/values/dimens.xml",
"chars": 211,
"preview": "<resources>\n <!-- Default screen margins, per the Android Design guidelines. -->\n <dimen name=\"activity_horizontal"
},
{
"path": "app/src/main/res/values/strings.xml",
"chars": 74,
"preview": "<resources>\n <string name=\"app_name\">CrazyShadow</string>\n</resources>\n"
},
{
"path": "app/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "app/src/main/res/values-w820dp/dimens.xml",
"chars": 358,
"preview": "<resources>\n <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n (such as s"
},
{
"path": "app/src/test/java/com/hitomi/crazyshadow/ExampleUnitTest.java",
"chars": 315,
"preview": "package com.hitomi.crazyshadow;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests"
},
{
"path": "build.gradle",
"chars": 573,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n r"
},
{
"path": "cslibrary/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "cslibrary/build.gradle",
"chars": 507,
"preview": "apply plugin: 'com.android.library'\napply plugin: 'com.github.dcendents.android-maven'\ngroup='com.github.Hitomi'\n\nandroi"
},
{
"path": "cslibrary/proguard-rules.pro",
"chars": 651,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
},
{
"path": "cslibrary/src/main/AndroidManifest.xml",
"chars": 268,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.hitomi.cslibrary\">\n\n <applicati"
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/CrazyShadow.java",
"chars": 6208,
"preview": "package com.hitomi.cslibrary;\n\nimport android.content.Context;\nimport android.graphics.drawable.Drawable;\nimport android"
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/base/CrazyShadowAttr.java",
"chars": 4553,
"preview": "package com.hitomi.cslibrary.base;\n\nimport android.support.v4.graphics.ColorUtils;\n\n/**\n * Created by hitomi on 2016/10/"
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/base/CrazyShadowDirection.java",
"chars": 1048,
"preview": "package com.hitomi.cslibrary.base;\n\nimport android.support.annotation.IntDef;\n\n/**\n * Created by hitomi on 2016/10/10.\n "
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/base/ShadowHandler.java",
"chars": 250,
"preview": "package com.hitomi.cslibrary.base;\n\nimport android.view.View;\n\n/**\n * Created by hitomi on 2016/10/19.\n */\npublic interf"
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/base/view/CornerShadowView.java",
"chars": 4691,
"preview": "package com.hitomi.cslibrary.base.view;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android."
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/base/view/EdgeShadowView.java",
"chars": 4610,
"preview": "package com.hitomi.cslibrary.base.view;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android."
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/draw/RoundRectShadowDrawable.java",
"chars": 10727,
"preview": "package com.hitomi.cslibrary.draw;\n\nimport android.graphics.Canvas;\nimport android.graphics.ColorFilter;\nimport android."
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/draw/ShadowDrawer.java",
"chars": 2041,
"preview": "package com.hitomi.cslibrary.draw;\n\nimport android.graphics.Color;\nimport android.graphics.drawable.ColorDrawable;\nimpor"
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/floating/ShadowFloating.java",
"chars": 14143,
"preview": "package com.hitomi.cslibrary.floating;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.grap"
},
{
"path": "cslibrary/src/main/java/com/hitomi/cslibrary/wrap/ShadowWrapper.java",
"chars": 17107,
"preview": "package com.hitomi.cslibrary.wrap;\n\nimport android.content.Context;\nimport android.graphics.drawable.Drawable;\nimport an"
},
{
"path": "cslibrary/src/main/res/color/background.xml",
"chars": 359,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <item a"
},
{
"path": "cslibrary/src/main/res/values/strings.xml",
"chars": 72,
"preview": "<resources>\n <string name=\"app_name\">csLibrary</string>\n</resources>\n"
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 233,
"preview": "#Mon Dec 05 08:49:55 CST 2016\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "gradle.properties",
"chars": 855,
"preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
},
{
"path": "gradlew",
"chars": 4971,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "gradlew.bat",
"chars": 2314,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "settings.gradle",
"chars": 29,
"preview": "include ':app', ':cslibrary'\n"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the Hitomis/CrazyShadow GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 40 files (95.5 KB), approximately 24.0k tokens, and a symbol index with 160 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.