Permalink
Browse files

init

  • Loading branch information...
0 parents commit b99bc95636b3d1e8a91c9a650f6b0881ba0b6450 @gongwen committed Dec 20, 2016
Showing with 999 additions and 0 deletions.
  1. +30 −0 app/build.gradle
  2. +17 −0 app/proguard-rules.pro
  3. +26 −0 app/src/androidTest/java/com/gw/marquee/ExampleInstrumentedTest.java
  4. +20 −0 app/src/main/AndroidManifest.xml
  5. +22 −0 app/src/main/java/com/gw/marquee/ComplexViewMF.java
  6. +85 −0 app/src/main/java/com/gw/marquee/MainActivity.java
  7. +23 −0 app/src/main/java/com/gw/marquee/NoticeMF.java
  8. +9 −0 app/src/main/res/anim/bottom_out.xml
  9. +9 −0 app/src/main/res/anim/left_in.xml
  10. +9 −0 app/src/main/res/anim/left_out.xml
  11. +9 −0 app/src/main/res/anim/right_in.xml
  12. +9 −0 app/src/main/res/anim/right_out.xml
  13. +9 −0 app/src/main/res/anim/top_in.xml
  14. +44 −0 app/src/main/res/layout/activity_main.xml
  15. +29 −0 app/src/main/res/layout/complex_view.xml
  16. +8 −0 app/src/main/res/layout/notice_item.xml
  17. BIN app/src/main/res/mipmap-hdpi/ic_launcher.png
  18. BIN app/src/main/res/mipmap-mdpi/ic_launcher.png
  19. BIN app/src/main/res/mipmap-xhdpi/ic_launcher.png
  20. BIN app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  21. +6 −0 app/src/main/res/values-w820dp/dimens.xml
  22. +6 −0 app/src/main/res/values/colors.xml
  23. +5 −0 app/src/main/res/values/dimens.xml
  24. +3 −0 app/src/main/res/values/strings.xml
  25. +11 −0 app/src/main/res/values/styles.xml
  26. +17 −0 app/src/test/java/com/gw/marquee/ExampleUnitTest.java
  27. +23 −0 build.gradle
  28. +17 −0 gradle.properties
  29. BIN gradle/wrapper/gradle-wrapper.jar
  30. +6 −0 gradle/wrapper/gradle-wrapper.properties
  31. +160 −0 gradlew
  32. +90 −0 gradlew.bat
  33. +31 −0 marqueelibrary/build.gradle
  34. +17 −0 marqueelibrary/proguard-rules.pro
  35. +26 −0 marqueelibrary/src/androidTest/java/com/gongwen/marqueen/ExampleInstrumentedTest.java
  36. +8 −0 marqueelibrary/src/main/AndroidManifest.xml
  37. +82 −0 marqueelibrary/src/main/java/com/gongwen/marqueen/MarqueeFactory.java
  38. +94 −0 marqueelibrary/src/main/java/com/gongwen/marqueen/MarqueeView.java
  39. +9 −0 marqueelibrary/src/main/res/anim/bottom_in.xml
  40. +9 −0 marqueelibrary/src/main/res/anim/top_out.xml
  41. +3 −0 marqueelibrary/src/main/res/values/strings.xml
  42. +17 −0 marqueelibrary/src/test/java/com/gongwen/marqueen/ExampleUnitTest.java
  43. +1 −0 settings.gradle
@@ -0,0 +1,30 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 24
+ buildToolsVersion "24.0.2"
+ defaultConfig {
+ applicationId "com.gw.marquee"
+ minSdkVersion 15
+ targetSdkVersion 24
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:24.2.1'
+ testCompile 'junit:junit:4.12'
+ compile project(':marqueelibrary')
+}
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/fenghuacaijing/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
@@ -0,0 +1,26 @@
+package com.gw.marquee;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.gw.marquee", appContext.getPackageName());
+ }
+}
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.gw.marquee">
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme">
+ <activity android:name=".MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
@@ -0,0 +1,22 @@
+package com.gw.marquee;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.widget.RelativeLayout;
+
+import com.gongwen.marqueen.MarqueeFactory;
+
+public class ComplexViewMF extends MarqueeFactory<RelativeLayout, String> {
+ private LayoutInflater inflater;
+
+ public ComplexViewMF(Context mContext) {
+ super(mContext);
+ inflater = LayoutInflater.from(mContext);
+ }
+
+ @Override
+ public RelativeLayout generateMarqueeItemView(String data) {
+ RelativeLayout mView = (RelativeLayout) inflater.inflate(R.layout.complex_view, null);
+ return mView;
+ }
+}
@@ -0,0 +1,85 @@
+package com.gw.marquee;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.gongwen.marqueen.MarqueeFactory;
+import com.gongwen.marqueen.MarqueeView;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ List<String> datas = Arrays.asList("《赋得古原草送别》", "离离原上草,一岁一枯荣。", "野火烧不尽,春风吹又生。", "远芳侵古道,晴翠接荒城。", "又送王孙去,萋萋满别情。");
+ MarqueeView marqueeView1 = (MarqueeView) findViewById(R.id.marqueeView1);
+ MarqueeView marqueeView2 = (MarqueeView) findViewById(R.id.marqueeView2);
+ MarqueeView marqueeView3 = (MarqueeView) findViewById(R.id.marqueeView3);
+ MarqueeView marqueeView4 = (MarqueeView) findViewById(R.id.marqueeView4);
+ MarqueeView marqueeView5 = (MarqueeView) findViewById(R.id.marqueeView5);
+
+ MarqueeFactory<TextView, String> marqueeFactory1 = new NoticeMF(this);
+ marqueeFactory1.setOnItemClickListener(new MarqueeFactory.OnItemClickListener<TextView, String>() {
+ @Override
+ public void onItemClickListener(MarqueeFactory.ViewHolder<TextView, String> holder) {
+ Toast.makeText(MainActivity.this, holder.data, Toast.LENGTH_SHORT).show();
+ }
+ });
+ marqueeFactory1.setData(datas);
+ marqueeView1.setMarqueeFactory(marqueeFactory1);
+ marqueeView1.startFlipping();
+
+ MarqueeFactory<TextView, String> marqueeFactory2 = new NoticeMF(this);
+ marqueeFactory2.setOnItemClickListener(new MarqueeFactory.OnItemClickListener<TextView, String>() {
+ @Override
+ public void onItemClickListener(MarqueeFactory.ViewHolder<TextView, String> holder) {
+ Toast.makeText(MainActivity.this, holder.data, Toast.LENGTH_SHORT).show();
+ }
+ });
+ marqueeFactory2.setData(datas);
+ marqueeView2.setMarqueeFactory(marqueeFactory2);
+ marqueeView2.setAnimInAndOut(R.anim.right_in, R.anim.left_out);
+ marqueeView2.setAnimDuration(2000);
+ marqueeView2.setInterval(2500);
+ marqueeView2.startFlipping();
+
+ MarqueeFactory<TextView, String> marqueeFactory3 = new NoticeMF(this);
+ marqueeFactory3.setOnItemClickListener(new MarqueeFactory.OnItemClickListener<TextView, String>() {
+ @Override
+ public void onItemClickListener(MarqueeFactory.ViewHolder<TextView, String> holder) {
+ Toast.makeText(MainActivity.this, holder.data, Toast.LENGTH_SHORT).show();
+ }
+ });
+ marqueeFactory3.setData(datas);
+ marqueeView3.setMarqueeFactory(marqueeFactory3);
+ marqueeView3.setAnimInAndOut(R.anim.left_in, R.anim.right_out);
+ marqueeView3.setAnimDuration(2000);
+ marqueeView3.setInterval(2500);
+ marqueeView3.startFlipping();
+
+ MarqueeFactory<TextView, String> marqueeFactory4 = new NoticeMF(this);
+ marqueeFactory4.setOnItemClickListener(new MarqueeFactory.OnItemClickListener<TextView, String>() {
+ @Override
+ public void onItemClickListener(MarqueeFactory.ViewHolder<TextView, String> holder) {
+ Toast.makeText(MainActivity.this, holder.data, Toast.LENGTH_SHORT).show();
+ }
+ });
+ marqueeFactory4.setData(datas);
+ marqueeView4.setAnimInAndOut(R.anim.top_in, R.anim.bottom_out);
+ marqueeView4.setMarqueeFactory(marqueeFactory4);
+ marqueeView4.startFlipping();
+
+ MarqueeFactory<RelativeLayout, String> marqueeFactory5 = new ComplexViewMF(this);
+ marqueeFactory5.setData(datas);
+ marqueeView5.setAnimInAndOut(R.anim.top_in, R.anim.bottom_out);
+ marqueeView5.setMarqueeFactory(marqueeFactory5);
+ marqueeView5.startFlipping();
+ }
+}
@@ -0,0 +1,23 @@
+package com.gw.marquee;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.widget.TextView;
+
+import com.gongwen.marqueen.MarqueeFactory;
+
+public class NoticeMF extends MarqueeFactory<TextView, String> {
+ private LayoutInflater inflater;
+
+ public NoticeMF(Context mContext) {
+ super(mContext);
+ inflater = LayoutInflater.from(mContext);
+ }
+
+ @Override
+ public TextView generateMarqueeItemView(String data) {
+ TextView mView = (TextView) inflater.inflate(R.layout.notice_item, null);
+ mView.setText(data);
+ return mView;
+ }
+}
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromYDelta="0"
+ android:toYDelta="100%p"/>
+ <alpha
+ android:fromAlpha="1.0"
+ android:toAlpha="0.0"/>
+</set>
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="-100%p"
+ android:toXDelta="0.0"/>
+ <alpha
+ android:fromAlpha="0.0"
+ android:toAlpha="1.0"/>
+</set>
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="0"
+ android:toXDelta="-100%p"/>
+ <alpha
+ android:fromAlpha="1.0"
+ android:toAlpha="0.0"/>
+</set>
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="100%p"
+ android:toXDelta="0"/>
+ <alpha
+ android:fromAlpha="0.0"
+ android:toAlpha="1.0"/>
+</set>
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="0"
+ android:toXDelta="100%p"/>
+ <alpha
+ android:fromAlpha="1.0"
+ android:toAlpha="0.0"/>
+</set>
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromYDelta="-100%p"
+ android:toYDelta="0.0"/>
+ <alpha
+ android:fromAlpha="0.0"
+ android:toAlpha="1.0"/>
+</set>
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/activity_main"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:context="com.gw.marquee.MainActivity">
+
+ <com.gongwen.marqueen.MarqueeView
+ android:id="@+id/marqueeView1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:background="#88dddddd"></com.gongwen.marqueen.MarqueeView>
+
+ <com.gongwen.marqueen.MarqueeView
+ android:id="@+id/marqueeView2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:background="#88dddddd"></com.gongwen.marqueen.MarqueeView>
+
+ <com.gongwen.marqueen.MarqueeView
+ android:id="@+id/marqueeView3"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:background="#88dddddd"></com.gongwen.marqueen.MarqueeView>
+
+ <com.gongwen.marqueen.MarqueeView
+ android:id="@+id/marqueeView4"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:background="#88dddddd"></com.gongwen.marqueen.MarqueeView>
+
+ <com.gongwen.marqueen.MarqueeView
+ android:id="@+id/marqueeView5"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:background="#88dddddd"></com.gongwen.marqueen.MarqueeView>
+</LinearLayout>
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="10dp">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="标题" />
+
+ <TextView
+ android:id="@+id/secondTitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/title"
+ android:layout_marginTop="10dp"
+ android:text="副标题" />
+
+ <TextView
+ android:id="@+id/time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:text="2016-12-20 18:18" />
+
+</RelativeLayout>
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:padding="15dp"
+ android:textSize="15sp" />
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,6 @@
+<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#3F51B5</color>
+ <color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorAccent">#FF4081</color>
+</resources>
Oops, something went wrong.

0 comments on commit b99bc95

Please sign in to comment.