├── settings.gradle
├── data
├── demo1.gif
├── device-shot1.png
└── device-shot2.png
├── lib
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── attrs.xml
│ │ │ └── colors.xml
│ │ ├── drawable
│ │ │ ├── border_white.9.png
│ │ │ ├── border_shadow.9.png
│ │ │ ├── border_highlight.9.png
│ │ │ └── border_white_light_10.9.png
│ │ └── layout
│ │ │ └── layout_border.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── org
│ │ └── evilbinary
│ │ └── tv
│ │ ├── util
│ │ ├── DimensionConvert.java
│ │ └── AnimateFactory.java
│ │ └── widget
│ │ ├── TvGridView.java
│ │ ├── TvZorderLinearLayout.java
│ │ ├── RoundedFrameLayout.java
│ │ ├── AutoGridLayoutManager.java
│ │ ├── TvZorderRelativeLayout.java
│ │ ├── TvLinearLayoutManager.java
│ │ ├── TvHorizontalScrollView.java
│ │ ├── TvGridLayoutManagerScrolling.java
│ │ ├── TvTextView.java
│ │ ├── BorderView.java
│ │ ├── RoundImpl.java
│ │ └── BorderEffect.java
├── proguard-rules.pro
└── build.gradle
├── app
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable
│ │ │ │ ├── g2.png
│ │ │ │ ├── g3.png
│ │ │ │ ├── g5.png
│ │ │ │ ├── demo1.png
│ │ │ │ ├── home_bg.png
│ │ │ │ ├── border_shape.xml
│ │ │ │ ├── border_top_right_shape.xml
│ │ │ │ ├── border_down_shape.xml
│ │ │ │ ├── border_red.xml
│ │ │ │ ├── list_item_shape.xml
│ │ │ │ ├── shape.xml
│ │ │ │ ├── border_shape_with_border.xml
│ │ │ │ └── border_shadow_shap.xml
│ │ │ ├── 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
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── demo_fragment.xml
│ │ │ │ ├── item_grid.xml
│ │ │ │ ├── item2.xml
│ │ │ │ ├── demo_recycler_view.xml
│ │ │ │ ├── custom_item.xml
│ │ │ │ ├── viewpage_item.xml
│ │ │ │ ├── demo_grid_view.xml
│ │ │ │ ├── item.xml
│ │ │ │ ├── item_menu_sub.xml
│ │ │ │ ├── demo_menu.xml
│ │ │ │ ├── demo_fragment_grid_view.xml
│ │ │ │ ├── demo_list_view.xml
│ │ │ │ ├── item_list.xml
│ │ │ │ ├── demo_two_recycler_view.xml
│ │ │ │ ├── item_menu.xml
│ │ │ │ ├── item3.xml
│ │ │ │ ├── demo_tab_view.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_home.xml
│ │ ├── java
│ │ │ └── org
│ │ │ │ └── evilbinary
│ │ │ │ └── tv
│ │ │ │ ├── DemoFragmentActivity.java
│ │ │ │ ├── DemoHomeActivity.java
│ │ │ │ ├── MyFragment2.java
│ │ │ │ ├── MyGridViewAdapter.java
│ │ │ │ ├── MyFragment.java
│ │ │ │ ├── DemoGridViewActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── DemoTwoRecyclerViewActivity.java
│ │ │ │ ├── DemoListViewActivity.java
│ │ │ │ ├── DemoRecyclerViewActivity.java
│ │ │ │ ├── MyAdapter.java
│ │ │ │ ├── DemoTopBorderActivity.java
│ │ │ │ ├── DemoTabActivity.java
│ │ │ │ └── DemoMenuActivity.java
│ │ └── AndroidManifest.xml
│ └── test
│ │ └── java
│ │ └── evilbinary
│ │ └── org
│ │ └── tvwidget
│ │ └── ExampleUnitTest.java
├── proguard-rules.pro
└── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':lib'
2 |
--------------------------------------------------------------------------------
/data/demo1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/data/demo1.gif
--------------------------------------------------------------------------------
/data/device-shot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/data/device-shot1.png
--------------------------------------------------------------------------------
/data/device-shot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/data/device-shot2.png
--------------------------------------------------------------------------------
/lib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | lib
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TvWidget
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/g2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/drawable/g2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/g3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/drawable/g3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/g5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/drawable/g5.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/demo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/drawable/demo1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/home_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/drawable/home_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/border_white.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/lib/src/main/res/drawable/border_white.9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/border_shadow.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/lib/src/main/res/drawable/border_shadow.9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/border_highlight.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/lib/src/main/res/drawable/border_highlight.9.png
--------------------------------------------------------------------------------
/lib/src/main/res/drawable/border_white_light_10.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/evilbinary/TvWidget/HEAD/lib/src/main/res/drawable/border_white_light_10.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_top_right_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
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-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_down_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/list_item_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lib/src/main/res/layout/layout_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_shape_with_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/evilbinary/org/tvwidget/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package evilbinary.org.tvwidget;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_shadow_shap.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # General
2 | .DS_Store
3 | *~
4 |
5 | # Android Studio
6 | .idea/
7 | .gradle
8 | local.properties
9 | /*/out
10 | build
11 | *.iml
12 | *.iws
13 | *.ipr
14 | *.swp
15 |
16 |
17 |
18 | # built application files
19 | *.apk
20 | *.ap_
21 |
22 | # files for the dex VM
23 | *.dex
24 |
25 | # Java class files
26 | *.class
27 |
28 | # generated files
29 | /app/app.iml
30 | bin/
31 | gen/
32 |
33 | # Eclipse project files
34 | .classpath
35 | .project
36 |
37 | # Proguard folder generated by Eclipse
38 | proguard/
39 |
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/DemoFragmentActivity.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Activity;
4 | import android.app.Fragment;
5 | import android.os.Bundle;
6 |
7 | /**
8 | * 作者:evilbinary on 2/28/16.
9 | * 邮箱:rootdebug@163.com
10 | */
11 | public class DemoFragmentActivity extends Activity{
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.demo_fragment);
17 |
18 | Fragment fragment=new MyFragment();
19 | getFragmentManager().beginTransaction().replace(R.id.fragment,fragment).commit();
20 |
21 |
22 |
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/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/evil/Applications/adt-bundle-mac-x86_64-20140702/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 |
--------------------------------------------------------------------------------
/lib/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/evil/Applications/adt-bundle-mac-x86_64-20140702/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 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "evilbinary.org.tvwidget"
9 | minSdkVersion 14
10 | targetSdkVersion 19
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:22.+'
26 | compile 'com.flyco.labelview:FlycoLabelView_Lib:1.0.2@aar'
27 | compile project(':lib')
28 | }
29 |
--------------------------------------------------------------------------------
/lib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 19
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 | android {
20 | lintOptions {
21 | abortOnError false
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | compile 'com.android.support:appcompat-v7:22.+'
29 | compile 'com.android.support:cardview-v7:22+'
30 | compile 'com.android.support:recyclerview-v7:22+'
31 | }
32 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/util/DimensionConvert.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.util;
2 |
3 | import android.content.Context;
4 |
5 |
6 | public class DimensionConvert {
7 |
8 | /**
9 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
10 | *
11 | * @param context
12 | * @param dpValue 要转换的dp值
13 | */
14 | public static int dip2px(Context context, float dpValue) {
15 | final float scale = context.getResources().getDisplayMetrics().density;
16 | return (int) (dpValue * scale + 0.5f);
17 | }
18 |
19 | /**
20 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
21 | *
22 | * @param context
23 | * @param pxValue 要转换的px值
24 | */
25 | public static int px2dip(Context context, float pxValue) {
26 | final float scale = context.getResources().getDisplayMetrics().density;
27 | return (int) (pxValue / scale + 0.5f);
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
22 |
23 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/DemoHomeActivity.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.ViewGroup;
6 |
7 | import org.evilbinary.tv.widget.BorderView;
8 |
9 | /**
10 | * 作者:evilbinary on 3/19/16.
11 | * 邮箱:rootdebug@163.com
12 | */
13 | public class DemoHomeActivity extends Activity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_home);
19 |
20 | BorderView border = new BorderView(this);
21 |
22 | border.setBackgroundResource(R.drawable.border_red);
23 | //border.setBackgroundColor(Color.GREEN);
24 |
25 | //border.getEffect().setScale(1.1f);
26 |
27 | ViewGroup list = (ViewGroup) findViewById(R.id.list);
28 | border.attachTo(list);
29 |
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item2.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/MyFragment2.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Fragment;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import org.evilbinary.tv.widget.BorderView;
11 |
12 | /**
13 | * 作者:evilbinary on 2/28/16.
14 | * 邮箱:rootdebug@163.com
15 | */
16 | public class MyFragment2 extends Fragment {
17 | private View mView;
18 |
19 | @Nullable
20 | @Override
21 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
22 | mView = inflater.inflate(R.layout.activity_main, container, false);
23 |
24 |
25 | BorderView borderView = new BorderView(getActivity());
26 | borderView.setBackgroundResource(R.drawable.border_highlight);
27 | borderView.attachTo((ViewGroup) mView);
28 |
29 | return mView;
30 | }
31 | };
--------------------------------------------------------------------------------
/app/src/main/res/layout/viewpage_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_grid_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_menu_sub.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/widget/TvGridView.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.GridView;
6 |
7 | /**
8 | * 作者:evilbinary on 4/2/16.
9 | * 邮箱:rootdebug@163.com
10 | */
11 | public class TvGridView extends GridView {
12 | private int position=0;
13 |
14 | public TvGridView(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | setChildrenDrawingOrderEnabled(true);
17 | }
18 |
19 | @Override
20 | protected void setChildrenDrawingOrderEnabled(boolean enabled) {
21 | super.setChildrenDrawingOrderEnabled(enabled);
22 | }
23 | @Override
24 | protected int getChildDrawingOrder(int childCount, int i) {
25 | position = getSelectedItemPosition() - getFirstVisiblePosition();
26 | if(position<0){
27 | return i;
28 | }else{
29 | if(i == childCount - 1){
30 | if(position>i){
31 | position=i;
32 | }
33 | return position;
34 | }
35 | if(i == position){
36 | return childCount - 1;
37 | }
38 | }
39 | return i;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/widget/TvZorderLinearLayout.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.LinearLayout;
7 |
8 | /**
9 | * 作者:evilbinary on 2/2/16.
10 | * 邮箱:rootdebug@163.com
11 | */
12 | public class TvZorderLinearLayout extends LinearLayout {
13 | private int position = 0;
14 |
15 | public TvZorderLinearLayout(Context context) {
16 | super(context);
17 |
18 | }
19 |
20 | public TvZorderLinearLayout(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | this.setChildrenDrawingOrderEnabled(true);
23 | }
24 |
25 |
26 | public void setCurrentPosition(int pos) {
27 | this.position = pos;
28 | }
29 |
30 | @Override
31 | protected int getChildDrawingOrder(int childCount, int i) {
32 | View v = getFocusedChild();
33 | int pos = indexOfChild(v);
34 | if (pos >= 0 && pos < childCount)
35 | setCurrentPosition(pos);
36 | if (i == childCount - 1) {//这是最后一个需要刷新的item
37 | return position;
38 | }
39 | if (i == position) {//这是原本要在最后一个刷新的item
40 | return childCount - 1;
41 | }
42 | return i;//正常次序的item
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
23 |
24 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_fragment_grid_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
23 |
24 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_list_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
26 |
27 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/widget/RoundedFrameLayout.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.util.AttributeSet;
6 | import android.widget.FrameLayout;
7 |
8 | /**
9 | * 作者:evilbinary on 3/20/16.
10 | * 邮箱:rootdebug@163.com
11 | */
12 |
13 |
14 | public class RoundedFrameLayout extends FrameLayout implements RoundImpl.RoundedView {
15 |
16 |
17 | RoundImpl round;
18 |
19 | public RoundedFrameLayout(Context context) {
20 | super(context);
21 | init(context, null, 0);
22 | }
23 |
24 | public RoundedFrameLayout(Context context, AttributeSet attrs) {
25 | super(context, attrs);
26 | init(context, attrs, 0);
27 | }
28 |
29 | public RoundedFrameLayout(Context context, AttributeSet attrs, int defStyle) {
30 | super(context, attrs, defStyle);
31 | init(context, attrs, defStyle);
32 | }
33 |
34 | private void init(Context context, AttributeSet attrs, int defStyle) {
35 | round = new RoundImpl(this, context, attrs, defStyle);
36 | setWillNotDraw(false);
37 |
38 | }
39 |
40 | @Override
41 | public void draw(Canvas canvas) {
42 | round.draw(canvas);
43 | }
44 |
45 |
46 | @Override
47 | public void drawSuper(Canvas canvas) {
48 | super.draw(canvas);
49 | }
50 |
51 | @Override
52 | public RoundImpl getRoundImpl() {
53 | return round;
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_two_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
22 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/widget/AutoGridLayoutManager.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.widget;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.GridLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.View;
7 |
8 | /**
9 | * 作者:evilbinary on 2/23/16.
10 | * 邮箱:rootdebug@163.com
11 | */
12 | public class AutoGridLayoutManager extends GridLayoutManager {
13 |
14 |
15 | private int measuredWidth = 0;
16 | private int measuredHeight = 0;
17 |
18 |
19 |
20 | public AutoGridLayoutManager(Context context, int spanCount) {
21 | super(context, spanCount);
22 | }
23 |
24 | public AutoGridLayoutManager(Context context, int spanCount,
25 | int orientation, boolean reverseLayout) {
26 | super(context, spanCount, orientation, reverseLayout);
27 | }
28 |
29 | @Override
30 | public void onMeasure(RecyclerView.Recycler recycler,
31 | RecyclerView.State state, int widthSpec, int heightSpec) {
32 | if (measuredHeight <= 0) {
33 | View view = recycler.getViewForPosition(0);
34 | if (view != null) {
35 | measureChild(view, widthSpec, heightSpec);
36 | measuredWidth = View.MeasureSpec.getSize(widthSpec);
37 | measuredHeight = view.getMeasuredHeight() * getSpanCount();
38 | }
39 | }
40 | setMeasuredDimension(measuredWidth, measuredHeight);
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
23 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item3.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
21 |
22 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/MyGridViewAdapter.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.view.LayoutInflater;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.BaseAdapter;
7 | import android.widget.TextView;
8 |
9 | /**
10 | * 作者:evilbinary on 2/28/16.
11 | * 邮箱:rootdebug@163.com
12 | */
13 | public class MyGridViewAdapter extends BaseAdapter {
14 |
15 | private int layoutId;
16 | public MyGridViewAdapter(int resId) {
17 | layoutId=resId;
18 | }
19 |
20 | @Override
21 | public int getCount() {
22 | return 200;
23 | }
24 |
25 | @Override
26 | public Object getItem(int position) {
27 | return null;
28 | }
29 |
30 | @Override
31 | public long getItemId(int position) {
32 | return 0;
33 | }
34 |
35 | @Override
36 | public View getView(int position, View convertView, ViewGroup parent) {
37 |
38 |
39 | ViewHolder viewHolder;
40 | if (convertView == null) {
41 | convertView = LayoutInflater.from(parent.getContext() ).inflate(layoutId, parent, false);
42 | viewHolder = new ViewHolder();
43 | viewHolder.text = (TextView) convertView.findViewById(R.id.textView);
44 | convertView.setTag(viewHolder);
45 | } else {
46 | viewHolder = (ViewHolder) convertView.getTag();
47 | }
48 |
49 | viewHolder.text.setText("text" + position);
50 | return convertView;
51 | }
52 |
53 | private class ViewHolder {
54 | public TextView text;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/widget/TvZorderRelativeLayout.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.KeyEvent;
6 | import android.view.View;
7 | import android.widget.RelativeLayout;
8 |
9 | /**
10 | * 作者:evilbinary on 2/2/16.
11 | * 邮箱:rootdebug@163.com
12 | */
13 | public class TvZorderRelativeLayout extends RelativeLayout {
14 | private int position = 0;
15 |
16 | public TvZorderRelativeLayout(Context context) {
17 | super(context);
18 |
19 | }
20 |
21 | public TvZorderRelativeLayout(Context context, AttributeSet attrs) {
22 | super(context, attrs);
23 | this.setChildrenDrawingOrderEnabled(true);
24 | }
25 |
26 |
27 | public void setCurrentPosition(int pos) {
28 | this.position = pos;
29 | }
30 |
31 | @Override
32 | public boolean dispatchKeyEvent(KeyEvent event) {
33 | View focused = findFocus();
34 | int pos = indexOfChild(focused);
35 | if (pos >= 0 && pos < getChildCount()) {
36 | setCurrentPosition(pos);
37 | postInvalidate();
38 | }
39 |
40 | return super.dispatchKeyEvent(event);
41 | }
42 |
43 | @Override
44 | protected int getChildDrawingOrder(int childCount, int i) {
45 | View v = getFocusedChild();
46 | int pos = indexOfChild(v);
47 | if (pos >= 0 && pos < childCount)
48 | setCurrentPosition(pos);
49 |
50 | if (i == childCount - 1) {//这是最后一个需要刷新的item
51 | return position;
52 | }
53 | if (i == position) {//这是原本要在最后一个刷新的item
54 | return childCount - 1;
55 | }
56 | return i;//正常次序的item
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/widget/TvLinearLayoutManager.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.widget;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.util.Log;
7 | import android.view.View;
8 |
9 | /**
10 | * 作者:evilbinary on 1/31/16.
11 | * 邮箱:rootdebug@163.com
12 | */
13 |
14 | public class TvLinearLayoutManager extends LinearLayoutManager {
15 |
16 | private static String TAG="TvLinearLayoutManager";
17 |
18 | public class ViewHolder extends RecyclerView.ViewHolder {
19 |
20 | private View mCursor;
21 |
22 | public ViewHolder(View itemView) {
23 | super(itemView);
24 | mCursor = (View) itemView;
25 |
26 | }
27 | public View getCursor(){
28 | return mCursor;
29 | }
30 |
31 | }
32 | ViewHolder mCursorViewHolder;
33 |
34 | public TvLinearLayoutManager(Context context) {
35 | super(context);
36 |
37 | //ImageView border= (ImageView) View.inflate(context, R.layout.layout_border, null);
38 | //mCursorViewHolder=new ViewHolder(border);
39 | //addDisappearingView(mCursorViewHolder.mCursor);
40 | }
41 |
42 | @Override
43 | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
44 | super.onLayoutChildren(recycler, state);
45 | }
46 |
47 | @Override
48 | public boolean onRequestChildFocus(RecyclerView parent, RecyclerView.State state, View child, View focused) {
49 | Log.d(TAG, "onRequestChildFocus:"+parent.getChildCount());
50 | //focused.setBackgroundColor(Color.BLUE);
51 |
52 | // View cursor=mCursorViewHolder.mCursor;
53 | //
54 | //
55 |
56 | return super.onRequestChildFocus(parent, state, child, focused);
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/lib/src/main/res/values/attrs.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 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/lib/src/main/java/org/evilbinary/tv/util/AnimateFactory.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv.util;
2 |
3 | import android.view.View;
4 | import android.view.animation.Animation;
5 | import android.view.animation.CycleInterpolator;
6 | import android.view.animation.ScaleAnimation;
7 | import android.view.animation.TranslateAnimation;
8 |
9 | /**
10 | * 作者:evilbinary on 2015/12/10 17:09
11 | * 邮箱:rootdebug@163.com
12 | */
13 | public class AnimateFactory {
14 | /**
15 | * 缩放动画,用于缩放控件
16 | *
17 | * @param startScale 控件的起始尺寸倍率
18 | * @param endScale 控件的终点尺寸倍率
19 | * @return
20 | */
21 | public static Animation zoomAnimation(float startScale, float endScale, long duration) {
22 | ScaleAnimation anim = new ScaleAnimation(startScale, endScale, startScale, endScale,
23 | Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
24 | anim.setFillAfter(true);
25 | anim.setDuration(duration);
26 | return anim;
27 | }
28 |
29 | public static Animation shakeAnimate() {
30 | TranslateAnimation mAnimate = new TranslateAnimation(0, 5, 0, 0);
31 | mAnimate.setInterpolator(new CycleInterpolator(50));
32 | mAnimate.setDuration(600);
33 | return mAnimate;
34 | }
35 |
36 | public static void zoomInView(View v) {
37 | zoomInView(v, 1.1f);
38 | }
39 |
40 | public static void zoomOutView(View v) {
41 | zoomOutView(v, 1.1f);
42 | }
43 |
44 | public static void zoomInView(View v, float zoomSize) {
45 | zoomInView(v,zoomSize,200);
46 | }
47 |
48 | public static void zoomOutView(View v, float zoomSize) {
49 | zoomOutView(v,zoomSize,200);
50 | }
51 | public static void zoomInView(View v, float zoomSize,long duration) {
52 | if (v != null) {
53 | v.startAnimation(AnimateFactory.zoomAnimation(1.0f, zoomSize,duration));
54 | }
55 | }
56 |
57 | public static void zoomOutView(View v, float zoomSize,long duration) {
58 | if (v != null) {
59 | v.startAnimation(AnimateFactory.zoomAnimation(zoomSize, 1.0f, duration));
60 | }
61 | }
62 |
63 |
64 | public static final int ANIMATION_DEFAULT = 0;
65 | public static final int ANIMATION_TRANSLATE = 1;
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/MyFragment.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Fragment;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.AdapterView;
11 | import android.widget.GridView;
12 |
13 | import org.evilbinary.tv.widget.BorderView;
14 |
15 | /**
16 | * 作者:evilbinary on 2/28/16.
17 | * 邮箱:rootdebug@163.com
18 | */
19 | public class MyFragment extends Fragment {
20 | private View mView;
21 |
22 | @Nullable
23 | @Override
24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
25 | mView = inflater.inflate(R.layout.demo_fragment_grid_view, container, false);
26 |
27 | GridView gridView = (GridView) mView.findViewById(R.id.gridView);
28 |
29 | MyGridViewAdapter myAdapter = new MyGridViewAdapter(R.layout.item2);
30 | gridView.setAdapter(myAdapter);
31 | myAdapter.notifyDataSetChanged();
32 |
33 | gridView.setSelection(0);
34 | gridView.setSelected(false);
35 | gridView.setFocusable(false);
36 |
37 | gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
38 | @Override
39 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
40 | Log.d("tt", "setOnItemClickListener");
41 | MyFragment2 fragment2 = new MyFragment2();
42 | getFragmentManager().beginTransaction().hide(MyFragment.this).replace(R.id.fragment, fragment2).addToBackStack(null).commit();
43 | }
44 | });
45 | //gridView.setFocusable(false);
46 |
47 | BorderView borderView = new BorderView(getActivity());
48 | borderView.setBackgroundResource(R.drawable.border_white_light_10);
49 | //borderView.getEffect(BorderEffect.class).setMargin(12);
50 | borderView.attachTo((ViewGroup) mView);
51 |
52 | BorderView borderView2 = new BorderView(getActivity());
53 | borderView2.setBackgroundResource(R.drawable.border_white_light_10);
54 | //borderView2.getEffect(BorderEffect.class).setMargin(12);
55 | borderView2.attachTo((ViewGroup) gridView);
56 |
57 | return mView;
58 | }
59 | };
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/DemoGridViewActivity.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.AdapterView;
8 | import android.widget.RelativeLayout;
9 |
10 | import org.evilbinary.tv.widget.BorderEffect;
11 | import org.evilbinary.tv.widget.BorderView;
12 | import org.evilbinary.tv.widget.TvGridView;
13 |
14 | /**
15 | * 作者:evilbinary on 2/22/16.
16 | * 邮箱:rootdebug@163.com
17 | */
18 | public class DemoGridViewActivity extends Activity {
19 |
20 |
21 | private TvGridView mGridView;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.demo_grid_view);
27 |
28 | mGridView = (TvGridView) findViewById(R.id.gridView);
29 |
30 | MyGridViewAdapter myAdapter = new MyGridViewAdapter(R.layout.item_grid);
31 | mGridView.setAdapter(myAdapter);
32 |
33 | BorderView borderView = new BorderView(this, R.layout.custom_item);
34 |
35 |
36 | mGridView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
37 | @Override
38 | public void onFocusChange(View v, boolean hasFocus) {
39 | Log.d("tt", "onFocusChange");
40 | }
41 | });
42 |
43 | mGridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
44 | @Override
45 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
46 | Log.d("tt", "onItemSelected");
47 | }
48 |
49 | @Override
50 | public void onNothingSelected(AdapterView> parent) {
51 | Log.d("tt", "onNothingSelected");
52 |
53 | }
54 | });
55 |
56 | borderView.attachTo(mGridView);
57 | borderView.getEffect().setMargin(10);
58 | borderView.getEffect().addOnFocusChanged(new BorderEffect.FocusListener() {
59 | @Override
60 | public void onFocusChanged(View oldFocus, View newFocus) {
61 | Log.d("tt", "onFocusChanged=====>" + oldFocus + " " + newFocus);
62 | }
63 | });
64 |
65 | // mGridView.setSelection(0);
66 | // mGridView.requestFocus();
67 | }
68 |
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/demo_tab_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
27 |
28 |
38 |
39 |
48 |
49 |
58 |
59 |
60 |
61 |
68 |
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/MainActivity.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.RelativeLayout;
8 |
9 | import org.evilbinary.tv.widget.BorderView;
10 |
11 | public class MainActivity extends Activity implements View.OnClickListener {
12 |
13 | private RelativeLayout main;
14 | private BorderView border;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 |
21 |
22 | BorderView border = new BorderView(this);
23 | border.setBackgroundResource(R.drawable.border_highlight);
24 |
25 | main = (RelativeLayout) findViewById(R.id.main);
26 | border.attachTo(main);
27 |
28 | for (int i = 0; i < main.getChildCount(); i++) {
29 | main.getChildAt(i).setOnClickListener(this);
30 | }
31 |
32 |
33 | }
34 |
35 | @Override
36 | public void onClick(View v) {
37 | Intent intent = new Intent();
38 | if (v == main.getChildAt(0)) {
39 | intent.setClass(this, DemoRecyclerViewActivity.class);
40 | intent.putExtra("linerLayout", "");
41 | startActivity(intent);
42 | } else if (v == main.getChildAt(1)) {
43 | intent.setClass(this, DemoRecyclerViewActivity.class);
44 | intent.putExtra("gridLayout", "");
45 | startActivity(intent);
46 | }else if (v == main.getChildAt(2)) {
47 | intent.setClass(this, DemoGridViewActivity.class);
48 | startActivity(intent);
49 | }
50 | else if (v == main.getChildAt(3)) {
51 | intent.setClass(this, DemoListViewActivity.class);
52 | startActivity(intent);
53 | }else if (v == main.getChildAt(4)) {
54 | intent.setClass(this, DemoHomeActivity.class);
55 | startActivity(intent);
56 | }else if (v == main.getChildAt(5)) {
57 | intent.setClass(this, DemoTwoRecyclerViewActivity.class);
58 | startActivity(intent);
59 | }
60 | else if (v == main.getChildAt(6)) {
61 | intent.setClass(this, DemoFragmentActivity.class);
62 | startActivity(intent);
63 | }else if (v == main.getChildAt(7)) {
64 | intent.setClass(this, DemoTopBorderActivity.class);
65 | startActivity(intent);
66 | }
67 |
68 | }
69 |
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/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/org/evilbinary/tv/DemoTwoRecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.GridLayoutManager;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 |
9 | import org.evilbinary.tv.widget.BorderView;
10 | import org.evilbinary.tv.widget.TvGridLayoutManagerScrolling;
11 |
12 | /**
13 | * 作者:evilbinary on 2/20/16.
14 | * 邮箱:rootdebug@163.com
15 | */
16 | public class DemoTwoRecyclerViewActivity extends Activity {
17 |
18 | private BorderView border;
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.demo_two_recycler_view);
23 |
24 | border = new BorderView(this);
25 | border.setBackgroundResource(R.drawable.border_red);
26 | testRecyclerViewLinerLayout();
27 | testRecyclerViewGridLayout();
28 |
29 |
30 | }
31 |
32 |
33 | private void testRecyclerViewLinerLayout() {
34 | //test linearlayout
35 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.firstRecyclerView);
36 | // 创建一个线性布局管理器
37 |
38 | GridLayoutManager layoutManager = new GridLayoutManager(this,1);
39 | layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
40 | recyclerView.setLayoutManager(layoutManager);
41 | recyclerView.setFocusable(false);
42 | border.attachTo(recyclerView);
43 |
44 | createData(recyclerView, R.layout.item3);
45 |
46 | }
47 |
48 | private void testRecyclerViewGridLayout() {
49 | //test grid
50 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.secondRecyclerView);
51 | GridLayoutManager gridlayoutManager = new TvGridLayoutManagerScrolling(this, 4);
52 | gridlayoutManager.setOrientation(GridLayoutManager.VERTICAL);
53 | recyclerView.setLayoutManager(gridlayoutManager);
54 | recyclerView.setFocusable(false);
55 |
56 |
57 | border.attachTo(recyclerView);
58 |
59 | createData(recyclerView,R.layout.item);
60 |
61 | }
62 |
63 |
64 | private void createData(RecyclerView recyclerView,int id) {
65 | //创建数据集
66 | String[] dataset = new String[100];
67 | for (int i = 0; i < dataset.length; i++) {
68 | dataset[i] = "item" + i;
69 | }
70 | // 创建Adapter,并指定数据集
71 | MyAdapter adapter = new MyAdapter(this, dataset,id);
72 | // 设置Adapter
73 | recyclerView.setAdapter(adapter);
74 | recyclerView.scrollToPosition(0);
75 | }
76 |
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/org/evilbinary/tv/DemoListViewActivity.java:
--------------------------------------------------------------------------------
1 | package org.evilbinary.tv;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.BaseAdapter;
9 | import android.widget.ListView;
10 | import android.widget.TextView;
11 |
12 | import org.evilbinary.tv.widget.BorderView;
13 |
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | /**
18 | * 作者:evilbinary on 2/22/16.
19 | * 邮箱:rootdebug@163.com
20 | */
21 | public class DemoListViewActivity extends Activity {
22 | private List