├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── layout
│ │ │ ├── activity_fragment_container.xml
│ │ │ ├── item_text.xml
│ │ │ ├── fragment_draw_circular_fading_view.xml
│ │ │ ├── fragment_custom_view.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── fragment_draw_fading_edge_view.xml
│ │ │ └── fragment_recycler_view.xml
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ ├── string-arrays.xml
│ │ │ └── styles.xml
│ │ └── drawable
│ │ │ └── ic_arrow_back_24dp.xml
│ │ ├── java
│ │ └── me
│ │ │ └── relex
│ │ │ └── fadingedgeresearch
│ │ │ ├── sample
│ │ │ ├── CustomViewFragment.java
│ │ │ ├── DrawFadingEdgeFragment.java
│ │ │ ├── DrawCircularFadingFragment.java
│ │ │ └── RecyclerViewFragment.java
│ │ │ ├── base
│ │ │ ├── BaseFragment.java
│ │ │ └── FragmentContainerActivity.java
│ │ │ ├── widget
│ │ │ ├── DrawCircularFadingView.java
│ │ │ ├── CustomView.java
│ │ │ └── DrawFadingEdgeView.java
│ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── ps.png
├── screenshot.png
├── .idea
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── relex.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/ps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/ps.png
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/screenshot.png
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/relex.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/FadingEdgeResearch/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FadingEdgeResearch
2 | FadingEdge 分析的相关代码
3 |
4 | http://relex.me/fadingedge-research/
5 |
6 | 
7 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Feb 27 11:06:06 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_fragment_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FadingEdge Research
3 |
4 | RecyclerView
5 | Custom View
6 | Draw Fading Edge
7 | Draw Circular Fading
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_back_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #366096
4 | #3B5271
5 | #E5C345
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/string-arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - January
5 | - February
6 | - March
7 | - April
8 | - May
9 | - June
10 | - July
11 | - August
12 | - September
13 | - October
14 | - November
15 | - December
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "me.relex.fadingedgeresearch"
8 | minSdkVersion 14
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile 'com.android.support:appcompat-v7:25.2.0'
23 | compile 'com.android.support:recyclerview-v7:25.2.0'
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/sample/CustomViewFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import me.relex.fadingedgeresearch.R;
9 | import me.relex.fadingedgeresearch.base.BaseFragment;
10 |
11 | public class CustomViewFragment extends BaseFragment {
12 |
13 | @Nullable @Override
14 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
15 | @Nullable Bundle savedInstanceState) {
16 | return inflater.inflate(R.layout.fragment_custom_view, container, false);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/sample/DrawFadingEdgeFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import me.relex.fadingedgeresearch.R;
9 | import me.relex.fadingedgeresearch.base.BaseFragment;
10 |
11 | public class DrawFadingEdgeFragment extends BaseFragment {
12 |
13 | @Nullable @Override
14 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
15 | @Nullable Bundle savedInstanceState) {
16 | return inflater.inflate(R.layout.fragment_draw_fading_edge_view, container, false);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/sample/DrawCircularFadingFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import me.relex.fadingedgeresearch.R;
9 | import me.relex.fadingedgeresearch.base.BaseFragment;
10 |
11 | public class DrawCircularFadingFragment extends BaseFragment {
12 |
13 | @Nullable @Override
14 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
15 | @Nullable Bundle savedInstanceState) {
16 | return inflater.inflate(R.layout.fragment_draw_circular_fading_view, container, false);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.View;
8 | import me.relex.fadingedgeresearch.R;
9 |
10 | public class BaseFragment extends Fragment {
11 |
12 | @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
13 |
14 | View toolbar = view.findViewById(R.id.toolbar);
15 | if (toolbar != null) {
16 | ((Toolbar) toolbar).setNavigationOnClickListener(new View.OnClickListener() {
17 | @Override public void onClick(View v) {
18 | getActivity().onBackPressed();
19 | }
20 | });
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_draw_circular_fading_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_custom_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/relex/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_draw_fading_edge_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/base/FragmentContainerActivity.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentActivity;
7 | import android.text.TextUtils;
8 | import me.relex.fadingedgeresearch.R;
9 |
10 | public class FragmentContainerActivity extends FragmentActivity {
11 |
12 | public static final String INTENT_FRAGMENT_NAME = "INTENT_FRAGMENT_NAME";
13 |
14 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_fragment_container);
17 |
18 | String fragmentName = getIntent().getStringExtra(INTENT_FRAGMENT_NAME);
19 | if (TextUtils.isEmpty(fragmentName)) {
20 | onBackPressed();
21 | return;
22 | }
23 |
24 | getSupportFragmentManager().beginTransaction()
25 | .replace(R.id.fragment_container, Fragment.instantiate(this, fragmentName))
26 | .commit();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/sample/RecyclerViewFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.sample;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.Gravity;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.TextView;
13 | import java.util.Arrays;
14 | import java.util.List;
15 | import me.relex.fadingedgeresearch.R;
16 | import me.relex.fadingedgeresearch.base.BaseFragment;
17 |
18 | public class RecyclerViewFragment extends BaseFragment {
19 |
20 | @Nullable @Override
21 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
22 | @Nullable Bundle savedInstanceState) {
23 | return inflater.inflate(R.layout.fragment_recycler_view, container, false);
24 | }
25 |
26 | @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
27 | super.onViewCreated(view, savedInstanceState);
28 |
29 | RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list_view);
30 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
31 | recyclerView.setAdapter(new SimpleAdapter(getContext()));
32 | }
33 |
34 | public class SimpleAdapter extends RecyclerView.Adapter {
35 | private final List mList;
36 |
37 | private SimpleAdapter(Context context) {
38 | String[] data = context.getResources().getStringArray(R.array.simple_data);
39 | mList = Arrays.asList(data);
40 | }
41 |
42 | @Override public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
43 | return new SimpleViewHolder(LayoutInflater.from(parent.getContext())
44 | .inflate(R.layout.item_text, parent, false));
45 | }
46 |
47 | @Override public void onBindViewHolder(SimpleViewHolder holder, int position) {
48 | ((TextView) holder.itemView).setGravity(Gravity.CENTER);
49 | ((TextView) holder.itemView).setText(mList.get(position));
50 | }
51 |
52 | @Override public int getItemCount() {
53 | return mList.size();
54 | }
55 | }
56 |
57 | public class SimpleViewHolder extends RecyclerView.ViewHolder {
58 | public SimpleViewHolder(View itemView) {
59 | super(itemView);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/widget/DrawCircularFadingView.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.widget;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.annotation.TargetApi;
5 | import android.content.Context;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.PorterDuff;
10 | import android.graphics.PorterDuffXfermode;
11 | import android.graphics.RadialGradient;
12 | import android.graphics.Shader;
13 | import android.os.Build;
14 | import android.support.annotation.Nullable;
15 | import android.support.v4.content.ContextCompat;
16 | import android.util.AttributeSet;
17 | import android.view.View;
18 | import me.relex.fadingedgeresearch.R;
19 |
20 | public class DrawCircularFadingView extends View {
21 |
22 | private Paint mCirclePaint;
23 | private Paint mFadingPaint;
24 |
25 | public DrawCircularFadingView(Context context) {
26 | super(context);
27 | init(context);
28 | }
29 |
30 | public DrawCircularFadingView(Context context, @Nullable AttributeSet attrs) {
31 | super(context, attrs);
32 | init(context);
33 | }
34 |
35 | public DrawCircularFadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
36 | super(context, attrs, defStyleAttr);
37 | init(context);
38 | }
39 |
40 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
41 | public DrawCircularFadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
42 | int defStyleRes) {
43 | super(context, attrs, defStyleAttr, defStyleRes);
44 | init(context);
45 | }
46 |
47 | private void init(Context context) {
48 | mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
49 | mCirclePaint.setColor(ContextCompat.getColor(context, R.color.colorPrimary));
50 | mFadingPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
51 | }
52 |
53 | @SuppressLint("MissingSuperCall") @Override public void draw(Canvas canvas) {
54 | int saveCount = canvas.saveLayer(0, 0, getWidth(), getHeight(), null,
55 | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
56 | canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, getWidth() / 2f, mCirclePaint);
57 | canvas.drawPaint(mFadingPaint);
58 | canvas.restoreToCount(saveCount);
59 | }
60 |
61 | @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) {
62 | RadialGradient shader =
63 | new RadialGradient(w / 2f, h / 2f, w / 2f, Color.TRANSPARENT, Color.BLACK,
64 | Shader.TileMode.CLAMP);
65 | mFadingPaint.setShader(shader);
66 | mFadingPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/widget/CustomView.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.widget;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.os.Build;
9 | import android.support.annotation.Nullable;
10 | import android.text.Layout;
11 | import android.text.StaticLayout;
12 | import android.text.TextPaint;
13 | import android.util.AttributeSet;
14 | import android.util.TypedValue;
15 | import android.view.View;
16 |
17 | public class CustomView extends View {
18 |
19 | private StaticLayout mLayout;
20 |
21 | public CustomView(Context context) {
22 | super(context);
23 | init(context);
24 | }
25 |
26 | public CustomView(Context context, @Nullable AttributeSet attrs) {
27 | super(context, attrs);
28 | init(context);
29 | }
30 |
31 | public CustomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | init(context);
34 | }
35 |
36 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
37 | public CustomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
38 | int defStyleRes) {
39 | super(context, attrs, defStyleAttr, defStyleRes);
40 | init(context);
41 | }
42 |
43 | private void init(Context context) {
44 | /* 1. Enable FadingEdge */
45 | setHorizontalFadingEdgeEnabled(true);
46 |
47 | String text =
48 | "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus augue turpis, ornare sit amet consectetur nec, pellentesque sed magna.";
49 | TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
50 | paint.setColor(Color.WHITE);
51 | paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14,
52 | context.getResources().getDisplayMetrics()));
53 | int width = (int) Layout.getDesiredWidth(text, paint);
54 | mLayout = new StaticLayout(text, paint, width, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, true);
55 | }
56 |
57 | /* 2. Show Left FadingEdge */
58 | @Override protected float getLeftFadingEdgeStrength() {
59 | return 1.0f;
60 | }
61 |
62 | /* 3. Show Right FadingEdge */
63 | @Override protected float getRightFadingEdgeStrength() {
64 | return 1.0f;
65 | }
66 |
67 | @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
68 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
69 | setMeasuredDimension(getMeasuredWidth(), mLayout.getHeight());
70 | }
71 |
72 | @Override protected void onDraw(Canvas canvas) {
73 | mLayout.draw(canvas);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Android
39 |
40 |
41 | Android Lint
42 |
43 |
44 | Java language level migration aids
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | 1.8
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/MainActivity.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.TextView;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 | import me.relex.fadingedgeresearch.base.FragmentContainerActivity;
16 | import me.relex.fadingedgeresearch.sample.CustomViewFragment;
17 | import me.relex.fadingedgeresearch.sample.DrawCircularFadingFragment;
18 | import me.relex.fadingedgeresearch.sample.DrawFadingEdgeFragment;
19 | import me.relex.fadingedgeresearch.sample.RecyclerViewFragment;
20 |
21 | public class MainActivity extends AppCompatActivity {
22 |
23 | @Override protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_main);
26 | SampleAdapter adapter = new SampleAdapter();
27 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list_view);
28 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
29 | recyclerView.setAdapter(adapter);
30 | adapter.updateData(createSampleList());
31 | }
32 |
33 | private List createSampleList() {
34 | List list = new ArrayList<>();
35 |
36 | list.add(new SampleInfo(getString(R.string.sample_recycler_view),
37 | RecyclerViewFragment.class));
38 | list.add(new SampleInfo(getString(R.string.sample_custom_view), CustomViewFragment.class));
39 | list.add(new SampleInfo(getString(R.string.sample_draw_fading_edge),
40 | DrawFadingEdgeFragment.class));
41 | list.add(new SampleInfo(getString(R.string.sample_draw_circular_fading),
42 | DrawCircularFadingFragment.class));
43 |
44 | return list;
45 | }
46 |
47 | public void navigationTo(SampleInfo info) {
48 | Intent intent = new Intent(this, FragmentContainerActivity.class);
49 | intent.putExtra(FragmentContainerActivity.INTENT_FRAGMENT_NAME, info.fragment.getName());
50 | startActivity(intent);
51 | }
52 |
53 | private class SampleAdapter extends RecyclerView.Adapter {
54 |
55 | private final List list = new ArrayList<>();
56 |
57 | @Override public SampleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
58 | return new SampleViewHolder(LayoutInflater.from(parent.getContext())
59 | .inflate(R.layout.item_text, parent, false));
60 | }
61 |
62 | @Override public void onBindViewHolder(SampleViewHolder holder, int position) {
63 | holder.bindViewHolder(list.get(position));
64 | }
65 |
66 | @Override public int getItemCount() {
67 | return list.size();
68 | }
69 |
70 | public void updateData(List list) {
71 | this.list.clear();
72 | this.list.addAll(list);
73 | notifyDataSetChanged();
74 | }
75 | }
76 |
77 | private class SampleViewHolder extends RecyclerView.ViewHolder {
78 |
79 | private TextView textView;
80 |
81 | public SampleViewHolder(View itemView) {
82 | super(itemView);
83 | textView = (TextView) itemView;
84 | }
85 |
86 | public void bindViewHolder(final SampleInfo info) {
87 | textView.setText(info.name);
88 | textView.setOnClickListener(new View.OnClickListener() {
89 | @Override public void onClick(View v) {
90 | navigationTo(info);
91 | }
92 | });
93 | }
94 | }
95 |
96 | private class SampleInfo {
97 | public String name;
98 | public Class extends Fragment> fragment;
99 |
100 | public SampleInfo(String name, Class extends Fragment> fragment) {
101 | this.name = name;
102 | this.fragment = fragment;
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/me/relex/fadingedgeresearch/widget/DrawFadingEdgeView.java:
--------------------------------------------------------------------------------
1 | package me.relex.fadingedgeresearch.widget;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.annotation.TargetApi;
5 | import android.content.Context;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.LinearGradient;
9 | import android.graphics.Matrix;
10 | import android.graphics.Paint;
11 | import android.graphics.PorterDuff;
12 | import android.graphics.PorterDuffXfermode;
13 | import android.graphics.Shader;
14 | import android.os.Build;
15 | import android.support.annotation.Nullable;
16 | import android.text.Layout;
17 | import android.text.StaticLayout;
18 | import android.text.TextPaint;
19 | import android.util.AttributeSet;
20 | import android.util.TypedValue;
21 | import android.view.View;
22 | import android.view.ViewConfiguration;
23 |
24 | public class DrawFadingEdgeView extends View {
25 |
26 | private StaticLayout mLayout;
27 | private FadingEdgeHelper mFadingEdgeHelper;
28 |
29 | public DrawFadingEdgeView(Context context) {
30 | super(context);
31 | init(context);
32 | }
33 |
34 | public DrawFadingEdgeView(Context context, @Nullable AttributeSet attrs) {
35 | super(context, attrs);
36 | init(context);
37 | }
38 |
39 | public DrawFadingEdgeView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
40 | super(context, attrs, defStyleAttr);
41 | init(context);
42 | }
43 |
44 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
45 | public DrawFadingEdgeView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
46 | int defStyleRes) {
47 | super(context, attrs, defStyleAttr, defStyleRes);
48 | init(context);
49 | }
50 |
51 | private void init(Context context) {
52 | String text =
53 | "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus augue turpis, ornare sit amet consectetur nec, pellentesque sed magna.";
54 | TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
55 | paint.setColor(Color.WHITE);
56 | paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14,
57 | context.getResources().getDisplayMetrics()));
58 | int width = (int) Layout.getDesiredWidth(text, paint);
59 | mLayout = new StaticLayout(text, paint, width, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, true);
60 |
61 | mFadingEdgeHelper = new FadingEdgeHelper(context);
62 | }
63 |
64 | @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
65 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
66 | setMeasuredDimension(getMeasuredWidth(), mLayout.getHeight());
67 | }
68 |
69 | @SuppressLint("MissingSuperCall") @Override public void draw(Canvas canvas) {
70 |
71 | mFadingEdgeHelper.saveCanvasLayer(canvas, getWidth(), getWidth());
72 |
73 | mLayout.draw(canvas);
74 |
75 | mFadingEdgeHelper.drawHorizontal(canvas, getWidth(), getWidth());
76 | mFadingEdgeHelper.restoreCanvas(canvas);
77 | }
78 |
79 | private static class FadingEdgeHelper {
80 |
81 | private int fadingEdgeLength;
82 | private final Paint paint;
83 | private final Matrix matrix;
84 | private final Shader shader;
85 | private int saveCount;
86 |
87 | FadingEdgeHelper(Context context) {
88 | fadingEdgeLength = ViewConfiguration.get(context).getScaledFadingEdgeLength();
89 |
90 | paint = new Paint();
91 | matrix = new Matrix();
92 | shader = new LinearGradient(0, 0, 0, 1, Color.BLACK, Color.TRANSPARENT,
93 | Shader.TileMode.CLAMP);
94 | paint.setShader(shader);
95 | paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
96 | }
97 |
98 | public void saveCanvasLayer(Canvas canvas, int width, int height) {
99 | saveCount = canvas.getSaveCount();
100 | canvas.saveLayer(0, 0, fadingEdgeLength, height, null,
101 | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
102 | canvas.saveLayer(width - fadingEdgeLength, 0, width, height, null,
103 | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
104 | }
105 |
106 | public void restoreCanvas(Canvas canvas) {
107 | canvas.restoreToCount(saveCount);
108 | }
109 |
110 | public void drawHorizontal(Canvas canvas, int width, int height) {
111 | matrix.setScale(1, fadingEdgeLength);
112 | matrix.postRotate(-90);
113 | matrix.postTranslate(0, 0);
114 | shader.setLocalMatrix(matrix);
115 | paint.setShader(shader);
116 | canvas.drawRect(0, 0, fadingEdgeLength, height, paint);
117 |
118 | matrix.setScale(1, fadingEdgeLength);
119 | matrix.postRotate(90);
120 | matrix.postTranslate(width, 0);
121 | shader.setLocalMatrix(matrix);
122 | paint.setShader(shader);
123 | canvas.drawRect(width - fadingEdgeLength, 0, width, height, paint);
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------