Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
gongwen committed Dec 20, 2016
0 parents commit b99bc95
Show file tree
Hide file tree
Showing 43 changed files with 999 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/build.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')
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
@@ -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());
}
}
20 changes: 20 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -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>
22 changes: 22 additions & 0 deletions app/src/main/java/com/gw/marquee/ComplexViewMF.java
@@ -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;
}
}
85 changes: 85 additions & 0 deletions app/src/main/java/com/gw/marquee/MainActivity.java
@@ -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();
}
}
23 changes: 23 additions & 0 deletions app/src/main/java/com/gw/marquee/NoticeMF.java
@@ -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;
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/anim/bottom_out.xml
@@ -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>
9 changes: 9 additions & 0 deletions app/src/main/res/anim/left_in.xml
@@ -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>
9 changes: 9 additions & 0 deletions app/src/main/res/anim/left_out.xml
@@ -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>
9 changes: 9 additions & 0 deletions app/src/main/res/anim/right_in.xml
@@ -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>
9 changes: 9 additions & 0 deletions app/src/main/res/anim/right_out.xml
@@ -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>
9 changes: 9 additions & 0 deletions app/src/main/res/anim/top_in.xml
@@ -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>
44 changes: 44 additions & 0 deletions app/src/main/res/layout/activity_main.xml
@@ -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>
29 changes: 29 additions & 0 deletions app/src/main/res/layout/complex_view.xml
@@ -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>
8 changes: 8 additions & 0 deletions app/src/main/res/layout/notice_item.xml
@@ -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" />
Binary file added app/src/main/res/mipmap-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/src/main/res/values-w820dp/dimens.xml
@@ -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>
6 changes: 6 additions & 0 deletions app/src/main/res/values/colors.xml
@@ -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>

0 comments on commit b99bc95

Please sign in to comment.