Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b99bc95
Showing
43 changed files
with
999 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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') | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 *; | |||
#} |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/gw/marquee/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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()); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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(); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.