Skip to content

Commit

Permalink
拆分至lib
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxutong committed Oct 31, 2016
1 parent ddc7571 commit eb6b2e2
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 33 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ android {
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -21,10 +20,9 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:23.4.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile project (':swipemenulib')

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import android.view.View;
import android.widget.Toast;

import com.mcxtzhang.swipemenulib.SwipeMenuLayout;

import java.util.ArrayList;
import java.util.List;

import mcxtzhang.listswipemenudemo.R;
import mcxtzhang.swipedelmenu.SwipeBean;
import mcxtzhang.swipedelmenu.view.CstSwipeDelMenu;

/**
* 介绍:完整的删除Demo
Expand Down Expand Up @@ -70,7 +71,7 @@ public void onTop(int pos) {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
CstSwipeDelMenu viewCache = CstSwipeDelMenu.getViewCache();
SwipeMenuLayout viewCache = SwipeMenuLayout.getViewCache();
if (null != viewCache) {
viewCache.smoothClose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import android.widget.TextView;
import android.widget.Toast;

import com.mcxtzhang.swipemenulib.SwipeMenuLayout;

import java.util.List;

import mcxtzhang.listswipemenudemo.R;
import mcxtzhang.swipedelmenu.SwipeBean;
import mcxtzhang.swipedelmenu.view.CstSwipeDelMenu;

/**
* 介绍:
Expand All @@ -41,7 +42,7 @@ public FullDelDemoVH onCreateViewHolder(ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(final FullDelDemoVH holder, final int position) {
((CstSwipeDelMenu) holder.itemView).setIos(false).setLeftSwipe(position % 2 == 0 ? true : false);//这句话关掉IOS阻塞式交互效果 并依次打开左滑右滑
((SwipeMenuLayout) holder.itemView).setIos(false).setLeftSwipe(position % 2 == 0 ? true : false);//这句话关掉IOS阻塞式交互效果 并依次打开左滑右滑

holder.content.setText(mDatas.get(position).name + (position % 2 == 0 ? "我右白虎" : "我左青龙"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import android.widget.ListView;
import android.widget.Toast;

import com.mcxtzhang.swipemenulib.SwipeMenuLayout;

import java.util.ArrayList;
import java.util.List;

import mcxtzhang.listswipemenudemo.R;
import mcxtzhang.swipedelmenu.utils.CommonAdapter;
import mcxtzhang.swipedelmenu.utils.ViewHolder;
import mcxtzhang.swipedelmenu.view.CstSwipeDelMenu;

public class ListViewDelDemoActivity extends AppCompatActivity {
private static final String TAG = "zxt";
Expand Down Expand Up @@ -43,7 +44,7 @@ public void onClick(View v) {
public void onClick(View v) {
Toast.makeText(ListViewDelDemoActivity.this, "删除:" + position, Toast.LENGTH_SHORT).show();
//在ListView里,点击侧滑菜单上的选项时,如果想让擦花菜单同时关闭,调用这句话
((CstSwipeDelMenu) holder.getConvertView()).quickClose();
((SwipeMenuLayout) holder.getConvertView()).quickClose();
mDatas.remove(position);
notifyDataSetChanged();
}
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/layout/activity_linear_layout_del_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
android:orientation="vertical"
tools:context="mcxtzhang.swipedelmenu.LinearLayoutDelDemoActivity">

<mcxtzhang.swipedelmenu.view.CstSwipeDelMenu
<com.mcxtzhang.swipemenulib.SwipeMenuLayout
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:clickable="true">

<LinearLayout
android:id="@+id/llContent"
Expand Down Expand Up @@ -69,13 +69,13 @@
android:text="删除"
android:textColor="@android:color/white"/>

</mcxtzhang.swipedelmenu.view.CstSwipeDelMenu>
</com.mcxtzhang.swipemenulib.SwipeMenuLayout>


<mcxtzhang.swipedelmenu.view.CstSwipeDelMenu
<com.mcxtzhang.swipemenulib.SwipeMenuLayout
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:clickable="true">

<LinearLayout
android:id="@+id/llContent2"
Expand Down Expand Up @@ -133,7 +133,7 @@
android:text="删除"
android:textColor="@android:color/white"/>

</mcxtzhang.swipedelmenu.view.CstSwipeDelMenu>
</com.mcxtzhang.swipemenulib.SwipeMenuLayout>


</LinearLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/item_cst_swipe.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<mcxtzhang.swipedelmenu.view.CstSwipeDelMenu
<com.mcxtzhang.swipemenulib.SwipeMenuLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
Expand Down Expand Up @@ -58,4 +58,4 @@
android:textColor="@android:color/white"/>
</RelativeLayout>-->

</mcxtzhang.swipedelmenu.view.CstSwipeDelMenu>
</com.mcxtzhang.swipemenulib.SwipeMenuLayout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app'
include ':app', ':swipemenulib'
1 change: 1 addition & 0 deletions swipemenulib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
25 changes: 25 additions & 0 deletions swipemenulib/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"

defaultConfig {
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
}
17 changes: 17 additions & 0 deletions swipemenulib/proguard-rules.pro
Original file line number 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 C:\Users\admin\AppData\Local\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 *;
#}
11 changes: 11 additions & 0 deletions swipemenulib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mcxtzhang.swipemenulib">

<application android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mcxtzhang.swipedelmenu.view;
package com.mcxtzhang.swipemenulib;

import android.animation.ValueAnimator;
import android.content.Context;
Expand Down Expand Up @@ -37,7 +37,7 @@
* Created by zhangxutong .
* Date: 16/04/24
*/
public class CstSwipeDelMenu extends ViewGroup {
public class SwipeMenuLayout extends ViewGroup {
private static final String TAG = "zxt";
private boolean isSwipeEnable = true;//右滑删除功能的开关,默认开

Expand All @@ -63,7 +63,7 @@ public class CstSwipeDelMenu extends ViewGroup {
private boolean isUnMoved = true;

//存储的是当前正在展开的View
private static CstSwipeDelMenu mViewCache;
private static SwipeMenuLayout mViewCache;

//防止多只手指一起滑我的flag 在每次down里判断, touch事件结束清空
private static boolean isTouching;
Expand All @@ -78,15 +78,15 @@ public class CstSwipeDelMenu extends ViewGroup {
//20160929add 左滑右滑的开关
private boolean isLeftSwipe = true;

public CstSwipeDelMenu(Context context) {
public SwipeMenuLayout(Context context) {
this(context, null);
}

public CstSwipeDelMenu(Context context, AttributeSet attrs) {
public SwipeMenuLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public CstSwipeDelMenu(Context context, AttributeSet attrs, int defStyleAttr) {
public SwipeMenuLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public boolean isIos() {
*
* @param ios
*/
public CstSwipeDelMenu setIos(boolean ios) {
public SwipeMenuLayout setIos(boolean ios) {
isIos = ios;
return this;
}
Expand All @@ -129,7 +129,7 @@ public boolean isLeftSwipe() {
* @param leftSwipe
* @return
*/
public CstSwipeDelMenu setLeftSwipe(boolean leftSwipe) {
public SwipeMenuLayout setLeftSwipe(boolean leftSwipe) {
isLeftSwipe = leftSwipe;
return this;
}
Expand All @@ -139,7 +139,7 @@ public CstSwipeDelMenu setLeftSwipe(boolean leftSwipe) {
*
* @return
*/
public static CstSwipeDelMenu getViewCache() {
public static SwipeMenuLayout getViewCache() {
return mViewCache;
}

Expand Down Expand Up @@ -470,8 +470,8 @@ private void acquireVelocityTracker(final MotionEvent event) {
/**
* * 释放VelocityTracker
*
* @see android.view.VelocityTracker#clear()
* @see android.view.VelocityTracker#recycle()
* @see VelocityTracker#clear()
* @see VelocityTracker#recycle()
*/
private void releaseVelocityTracker() {
if (null != mVelocityTracker) {
Expand Down
3 changes: 3 additions & 0 deletions swipemenulib/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">SwipeMenuLib</string>
</resources>

0 comments on commit eb6b2e2

Please sign in to comment.