├── Drag-FlowLayout ├── .gitignore ├── .idea │ ├── encodings.xml │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── heaven7 │ │ │ │ └── android │ │ │ │ ├── AbsMainActivity.java │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── drag │ │ │ │ └── demo │ │ │ │ │ └── DragFlowLayoutTest.java │ │ │ │ ├── receive │ │ │ │ └── NetstateChangeReceiver.java │ │ │ │ ├── service │ │ │ │ └── SimpleService.java │ │ │ │ └── transition │ │ │ │ └── TransitionProvider.java │ │ └── res │ │ │ ├── drawable-xxhdpi │ │ │ ├── common_ic_search.png │ │ │ ├── edit_text_delete_checked.png │ │ │ └── edit_text_delete_normal.png │ │ │ ├── drawable │ │ │ └── shape_brand_selected.xml │ │ │ ├── layout │ │ │ ├── ac_drag_flow_test2.xml │ │ │ ├── activity_main.xml │ │ │ └── item_drag_flow.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 │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── heaven7 │ │ └── android │ │ └── ui │ │ └── drag │ │ └── ExampleUnitTest.java ├── build.gradle ├── dragflowlayout │ ├── .gitignore │ ├── bintrayUpload.gradle │ ├── build.gradle │ ├── proguard-rules.pro │ ├── project.properties │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── heaven7 │ │ │ └── android │ │ │ └── dragflowlayout │ │ │ ├── AlertWindowHelper.java │ │ │ ├── ClickToDeleteItemListenerImpl.java │ │ │ ├── Debugger.java │ │ │ ├── DefaultDragCallback.java │ │ │ ├── DragAdapter.java │ │ │ ├── DragFlowLayout.java │ │ │ ├── FlowLayout.java │ │ │ ├── FlowLayoutManager.java │ │ │ ├── IDraggable.java │ │ │ ├── IViewManager.java │ │ │ ├── IViewObserver.java │ │ │ └── ViewUtils.java │ │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── LICENSE ├── README.md ├── apk └── app-debug.apk └── art └── drag_flowlayout.gif /Drag-FlowLayout/.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Android Studio 23 | .idea/ 24 | .gradle 25 | /*/local.properties 26 | /*/out 27 | build 28 | /*/*/production 29 | *.iml 30 | *.iws 31 | *.ipr 32 | *~ 33 | *.swp 34 | -------------------------------------------------------------------------------- /Drag-FlowLayout/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Drag-FlowLayout/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | -------------------------------------------------------------------------------- /Drag-FlowLayout/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /Drag-FlowLayout/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Drag-FlowLayout/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /Drag-FlowLayout/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | //apply plugin: 'com.jakewharton.butterknife' 3 | 4 | android { 5 | compileSdkVersion 28 6 | buildToolsVersion "28.0.3" 7 | 8 | defaultConfig { 9 | applicationId "com.heaven7.android.drag.demo" 10 | minSdkVersion 19 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | javaCompileOptions { 16 | annotationProcessorOptions { 17 | includeCompileClasspath = true 18 | } 19 | } 20 | } 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | compileOptions { 28 | sourceCompatibility JavaVersion.VERSION_1_8 29 | targetCompatibility JavaVersion.VERSION_1_8 30 | } 31 | } 32 | 33 | dependencies { 34 | implementation fileTree(dir: 'libs', include: ['*.jar']) 35 | def androidX_ver='1.0.0' 36 | implementation "androidx.appcompat:appcompat:$androidX_ver" 37 | implementation "androidx.recyclerview:recyclerview:$androidX_ver" 38 | 39 | implementation 'com.github.LightSun:SuperAdapter:2.0.9-x' 40 | /* implementation ('com.heaven7.volley:volley_with_extra:1.0.1'){ 41 | exclude group: 'com.android.support' 42 | }*/ 43 | implementation 'com.jakewharton:butterknife:10.2.1' 44 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1' 45 | 46 | implementation('com.github.LightSun:util-v1:1.1.7-beta-x') { 47 | exclude group: 'com.android.support' 48 | exclude group: 'com.heaven7.android.component' 49 | } 50 | 51 | implementation project (':dragflowlayout') 52 | // compile 'com.heaven7.android.dragflowlayout:dragflowlayout:1.8.8' 53 | } 54 | -------------------------------------------------------------------------------- /Drag-FlowLayout/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 I:\android\sdk2/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 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/java/com/heaven7/android/AbsMainActivity.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.android; 2 | 3 | import android.app.Activity; 4 | import android.app.ListActivity; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.widget.ListView; 10 | 11 | import com.heaven7.adapter.ISelectable; 12 | import com.heaven7.adapter.QuickAdapter; 13 | import com.heaven7.core.util.ViewHelper; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | 19 | public abstract class AbsMainActivity extends ListActivity { 20 | 21 | protected final List mInfos = new ArrayList<>(); 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | // setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, options)); 27 | addDemos(mInfos); 28 | setListAdapter(new QuickAdapter(android.R.layout.simple_list_item_1, mInfos) { 29 | @Override 30 | protected void onBindData(Context context, int position,final ActivityInfo item, 31 | int itemLayoutId, ViewHelper helper) { 32 | helper.setText(android.R.id.text1, item.desc) 33 | .setRootOnClickListener(new View.OnClickListener() { 34 | @Override 35 | public void onClick(View v) { 36 | startActivity(new Intent(AbsMainActivity.this ,item.clazz)); 37 | } 38 | }); 39 | } 40 | }); 41 | } 42 | 43 | protected abstract void addDemos(List list); 44 | 45 | @Override 46 | protected void onListItemClick(ListView l, View v, int position, long id) { 47 | 48 | } 49 | 50 | public static class ActivityInfo implements ISelectable { 51 | final String desc; 52 | final Class clazz; 53 | 54 | public ActivityInfo(Class clazz, String desc) { 55 | this.clazz = clazz; 56 | this.desc = desc; 57 | } 58 | public ActivityInfo(Context context, Class clazz, int stringResId) { 59 | this.clazz = clazz; 60 | this.desc = context.getResources().getString(stringResId); 61 | } 62 | 63 | @Override 64 | public void setSelected(boolean selected) { 65 | } 66 | @Override 67 | public boolean isSelected() { 68 | return false; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/java/com/heaven7/android/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.android; 2 | 3 | import android.app.Activity; 4 | import android.app.Service; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | 9 | import androidx.appcompat.app.AppCompatActivity; 10 | import androidx.fragment.app.Fragment; 11 | import androidx.fragment.app.FragmentTransaction; 12 | 13 | import com.heaven7.core.util.Toaster; 14 | import com.heaven7.core.util.ViewHelper; 15 | 16 | import butterknife.ButterKnife; 17 | 18 | 19 | public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener{ 20 | 21 | private Toaster mToaster; 22 | private ViewHelper mViewHelper; 23 | private IntentExecutor mIntentExecutor; 24 | 25 | protected abstract int getlayoutId(); 26 | 27 | protected abstract void initView(); 28 | 29 | protected abstract void initData(Bundle savedInstanceState); 30 | 31 | 32 | @Override 33 | protected void onCreate(Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | mIntentExecutor = new IntentExecutor(); 36 | mToaster = new Toaster(this); 37 | mViewHelper = new ViewHelper(getWindow().getDecorView()); 38 | 39 | onPreSetContentView(); 40 | setContentView(getlayoutId()); 41 | ButterKnife.bind(this); 42 | 43 | initView(); 44 | initData(savedInstanceState); 45 | } 46 | 47 | protected void onPreSetContentView(){} 48 | 49 | @Override 50 | protected void onStop() { 51 | super.onStop(); 52 | // mHttpExecutor.cancelAll(); 53 | } 54 | 55 | protected void showToast(String msg){ 56 | mToaster.show(msg); 57 | } 58 | protected void showToast(int resID){ 59 | mToaster.show(resID); 60 | } 61 | protected Toaster getToaster(){ 62 | return mToaster; 63 | } 64 | public ViewHelper getViewHelper(){ 65 | return mViewHelper; 66 | } 67 | 68 | public IntentExecutor getIntentExecutor() { 69 | return mIntentExecutor; 70 | } 71 | 72 | //================================ 73 | protected void replaceFragment(int containerViewId, Fragment fragment) { 74 | replaceFragment(containerViewId, fragment, true); 75 | } 76 | 77 | protected void replaceFragment(int containerViewId, Fragment fragment, boolean addToback) { 78 | FragmentTransaction ft = getSupportFragmentManager().beginTransaction().replace(containerViewId, fragment); 79 | if (addToback) { 80 | ft.addToBackStack(fragment.getClass().getName()); 81 | } 82 | ft.commit(); 83 | } 84 | 85 | protected void replaceFragmentByPreviousIfExist(int containerViewId, Fragment fragment, boolean addBack) { 86 | FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); 87 | String tag = fragment.getClass().getName(); 88 | Fragment previousFragment = getSupportFragmentManager().findFragmentByTag(tag); 89 | ft.replace(containerViewId, previousFragment != null ? previousFragment : fragment, tag); 90 | if (addBack) 91 | ft.addToBackStack(null); 92 | ft.commit(); 93 | } 94 | 95 | protected void setCommonBackListener(View v){ 96 | v.setOnClickListener(new View.OnClickListener() { 97 | @Override 98 | public void onClick(View v) { 99 | finish(); 100 | } 101 | }); 102 | } 103 | 104 | @Override 105 | public void onClick(View v) { 106 | } 107 | 108 | public class IntentExecutor{ 109 | 110 | public void launchActivity(Class clazz, int intentFlags) { 111 | startActivity(new Intent(BaseActivity.this, clazz).addFlags(intentFlags)); 112 | } 113 | 114 | public void launchActivity(Class clazz) { 115 | startActivity(new Intent(BaseActivity.this, clazz)); 116 | } 117 | 118 | public void launchActivity(Class clazz, Bundle data) { 119 | launchActivity(clazz, data, 0); 120 | } 121 | 122 | public void launchActivity(Class clazz, Bundle data, int intentFlags) { 123 | startActivity(new Intent(BaseActivity.this, clazz).putExtras(data).addFlags(intentFlags)); 124 | } 125 | 126 | public void launchActivityForResult(Class clazz, int requestCode) { 127 | startActivityForResult(new Intent(BaseActivity.this, clazz), requestCode); 128 | } 129 | 130 | public void launchService(Class clazz, Bundle data){ 131 | startService(new Intent(BaseActivity.this,clazz).putExtras(data)); 132 | } 133 | 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/java/com/heaven7/android/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.android; 2 | 3 | import com.heaven7.android.drag.demo.DragFlowLayoutTest; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by heaven7 on 2016/5/25. 9 | */ 10 | public class MainActivity extends AbsMainActivity { 11 | 12 | @Override 13 | protected void addDemos(List list) { 14 | list.add(new ActivityInfo(DragFlowLayoutTest.class, "test Drag FlowLayout")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/java/com/heaven7/android/drag/demo/DragFlowLayoutTest.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.android.drag.demo; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.view.WindowManager; 6 | import android.widget.TextView; 7 | 8 | import androidx.annotation.NonNull; 9 | 10 | import com.heaven7.adapter.BaseSelector; 11 | import com.heaven7.android.BaseActivity; 12 | import com.heaven7.android.dragflowlayout.ClickToDeleteItemListenerImpl; 13 | import com.heaven7.android.dragflowlayout.DragAdapter; 14 | import com.heaven7.android.dragflowlayout.DragFlowLayout; 15 | import com.heaven7.android.dragflowlayout.IDraggable; 16 | import com.heaven7.android.dragflowlayout.IViewObserver; 17 | 18 | import butterknife.BindView; 19 | import butterknife.OnClick; 20 | 21 | /** 拖拽流布局 示例程序 22 | * Created by heaven7 on 2016/8/1. 23 | */ 24 | public class DragFlowLayoutTest extends BaseActivity { 25 | 26 | private static final String TAG = "DragFlowLayoutTest"; 27 | 28 | @BindView(R.id.drag_flowLayout) 29 | DragFlowLayout mDragflowLayout; 30 | 31 | private int mIndex; 32 | @Override 33 | protected int getlayoutId() { 34 | return R.layout.ac_drag_flow_test2; 35 | } 36 | 37 | @Override 38 | protected void onPreSetContentView() { 39 | //test full screen 40 | getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , 41 | WindowManager.LayoutParams. FLAG_FULLSCREEN); 42 | } 43 | 44 | @Override 45 | protected void initView() { 46 | // mDragflowLayout.setLayoutTransition(TransitionProvider.createTransition(this)); 47 | mDragflowLayout.setOnItemClickListener(new ClickToDeleteItemListenerImpl(R.id.iv_close){ 48 | @Override 49 | protected void onDeleteSuccess(DragFlowLayout dfl, View child, Object data) { 50 | //删除成功后的处理。 51 | } 52 | }); 53 | mDragflowLayout.setDragAdapter(new DragAdapter() { 54 | @Override 55 | public int getItemLayoutId() { 56 | return R.layout.item_drag_flow; 57 | } 58 | @Override 59 | public void onBindData(View itemView, int dragState, TestBean data) { 60 | itemView.setTag(data); 61 | 62 | TextView tv = (TextView) itemView.findViewById(R.id.tv_text); 63 | tv.setText(data.text); 64 | //iv_close是关闭按钮。只有再非拖拽空闲的情况吓才显示 65 | itemView.findViewById(R.id.iv_close).setVisibility( 66 | dragState!= DragFlowLayout.DRAG_STATE_IDLE 67 | && data.draggable ? View.VISIBLE : View.INVISIBLE); 68 | } 69 | @NonNull 70 | @Override 71 | public TestBean getData(View itemView) { 72 | return (TestBean) itemView.getTag(); 73 | } 74 | }); 75 | //预存指定个数的Item. 这些Item view会反复使用,避免重复创建, 默认10个 76 | mDragflowLayout.prepareItemsByCount(10); 77 | //设置拖拽状态监听器 78 | mDragflowLayout.setOnDragStateChangeListener(new DragFlowLayout.OnDragStateChangeListener() { 79 | @Override 80 | public void onDragStateChange(DragFlowLayout dfl, int dragState) { 81 | // System.out.println("on drag state change : dragState = " + dragState); 82 | } 83 | }); 84 | //添加view观察者 85 | mDragflowLayout.addViewObserver(new IViewObserver() { 86 | @Override 87 | public void onAddView(View child, int index) { 88 | // Logger.i(TAG, "onAddView", "index = " + index); 89 | } 90 | @Override 91 | public void onRemoveView(View child, int index) { 92 | // Logger.i(TAG, "onRemoveView", "index = " + index); 93 | } 94 | }); 95 | } 96 | 97 | @Override 98 | protected void initData(Bundle savedInstanceState) { 99 | 100 | } 101 | 102 | @OnClick(R.id.bt_begin_drag) 103 | public void onClickBeginDrag(View v){ 104 | mDragflowLayout.beginDrag(); 105 | } 106 | @OnClick(R.id.bt_done) 107 | public void onClickDone(View v){ 108 | //标记拖拽结束, 内部会自动将拖拽状态改为idle 109 | mDragflowLayout.finishDrag(); 110 | } 111 | 112 | @OnClick(R.id.bt_add) 113 | public void onClickAdd(View v){ 114 | final TestBean bean = new TestBean( "test_" + (mIndex ++ ) * caculateShift( mIndex ) + "" ); 115 | int index; 116 | if(mDragflowLayout.getChildCount()==0) { 117 | //为了测试,设置第一个条目不准拖拽 118 | bean.draggable = false; 119 | index = 0; 120 | }else{ 121 | index = 1; 122 | } 123 | mDragflowLayout.getDragItemManager().addItem(index, bean); 124 | } 125 | private int caculateShift(int src){ 126 | return (int) Math.pow(10, src % 3 + 1 ); 127 | } 128 | @OnClick(R.id.bt_remove_center) 129 | public void onClickRemoveCenter(View v){ 130 | final DragFlowLayout.DragItemManager itemManager = mDragflowLayout.getDragItemManager(); 131 | final int count = itemManager.getItemCount(); 132 | if(count == 0){ 133 | return; 134 | } 135 | if(count <=2) { 136 | itemManager.removeItem(count-1); 137 | }else{ 138 | itemManager.removeItem(count-2); 139 | } 140 | } 141 | 142 | /** 如果想禁止某些Item拖拽请实现 {@link IDraggable} 接口 */ 143 | private static class TestBean extends BaseSelector implements IDraggable{ 144 | String text; 145 | boolean draggable = true; 146 | public TestBean(String text) { 147 | this.text = text; 148 | } 149 | @Override 150 | public boolean isDraggable() { 151 | return draggable; 152 | } 153 | 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/java/com/heaven7/android/receive/NetstateChangeReceiver.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.android.receive; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | import com.heaven7.android.service.SimpleService; 8 | import com.heaven7.core.util.Logger; 9 | import com.heaven7.core.util.Toaster; 10 | 11 | /** 12 | * ggggg 13 | * Created by heaven7 on 2016/8/23. 14 | */ 15 | public class NetstateChangeReceiver extends BroadcastReceiver { 16 | 17 | @Override 18 | public void onReceive(Context context, Intent intent) { 19 | if(intent ==null) return; 20 | /** 21 | * 22 | 1, 只要app的没有一个进程存活(正在运行的进程和缓存进程都不存在),都将启动不了service(通过系统receiver) 23 | 2,强制停止后也 启动不了service(通过系统receiver) 24 | 3,只要该app有进程存活,就可以. 25 | */ 26 | Toaster.show(context, "NetstateChangeReceiver"); 27 | Logger.i("NetstateChangeReceiver", "action = " + intent.getAction()); 28 | context.startService(new Intent(context, SimpleService.class)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/java/com/heaven7/android/service/SimpleService.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.android.service; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | 7 | import com.heaven7.core.util.Logger; 8 | import com.heaven7.core.util.Toaster; 9 | 10 | /** 11 | * Created by heaven7 on 2016/8/23. 12 | */ 13 | public class SimpleService extends Service{ 14 | 15 | @Override 16 | public IBinder onBind(Intent intent) { 17 | return null; 18 | } 19 | 20 | @Override 21 | public void onCreate() { 22 | super.onCreate(); 23 | Logger.i("SimpleService", "onCreate"); 24 | Toaster.show(this, "NetstateChangeReceiver_onCreate"); 25 | } 26 | 27 | @Override 28 | public int onStartCommand(Intent intent, int flags, int startId) { 29 | return START_REDELIVER_INTENT; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/java/com/heaven7/android/transition/TransitionProvider.java: -------------------------------------------------------------------------------- 1 | package com.heaven7.android.transition; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.animation.Keyframe; 6 | import android.animation.LayoutTransition; 7 | import android.animation.ObjectAnimator; 8 | import android.animation.PropertyValuesHolder; 9 | import android.view.View; 10 | 11 | /** 12 | * Created by heaven7 on 2016/8/29. 13 | */ 14 | public class TransitionProvider { 15 | 16 | public static LayoutTransition createTransition(Object target){ 17 | LayoutTransition mLayoutTransition = new LayoutTransition(); 18 | mLayoutTransition.setStagger(LayoutTransition.CHANGE_APPEARING, 30); 19 | mLayoutTransition.setStagger(LayoutTransition.CHANGE_DISAPPEARING, 30); 20 | //设置每个动画持续的时间 21 | mLayoutTransition.setDuration(300); 22 | 23 | /** 24 | * Add Button 25 | * LayoutTransition.APPEARING 26 | * 增加一个Button时,设置该Button的动画效果 27 | */ 28 | ObjectAnimator mAnimatorAppearing = ObjectAnimator.ofFloat(null, "rotationY", 90.0f,0.0f) 29 | .setDuration(mLayoutTransition.getDuration(LayoutTransition.APPEARING)); 30 | //为LayoutTransition设置动画及动画类型 31 | mLayoutTransition.setAnimator(LayoutTransition.APPEARING, mAnimatorAppearing); 32 | mAnimatorAppearing.addListener(new AnimatorListenerAdapter() { 33 | @Override 34 | public void onAnimationEnd(Animator animation) { 35 | // TODO Auto-generated method stub 36 | super.onAnimationEnd(animation); 37 | View view = (View) ((ObjectAnimator) animation).getTarget(); 38 | view.setRotationY(0.0f); 39 | } 40 | }); 41 | 42 | /** 43 | * Add Button 44 | * LayoutTransition.CHANGE_APPEARING 45 | * 当增加一个Button时,设置其他Button的动画效果 46 | */ 47 | 48 | PropertyValuesHolder pvhLeft = 49 | PropertyValuesHolder.ofInt("left", 0, 1); 50 | PropertyValuesHolder pvhTop = 51 | PropertyValuesHolder.ofInt("top", 0, 1); 52 | PropertyValuesHolder pvhRight = 53 | PropertyValuesHolder.ofInt("right", 0, 1); 54 | PropertyValuesHolder pvhBottom = 55 | PropertyValuesHolder.ofInt("bottom", 0, 1); 56 | 57 | PropertyValuesHolder mHolderScaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f,0.0f,1.0f); 58 | PropertyValuesHolder mHolderScaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f,0.0f,1.0f); 59 | ObjectAnimator mObjectAnimatorChangeAppearing = ObjectAnimator.ofPropertyValuesHolder(target, pvhLeft, 60 | pvhTop,pvhRight,pvhBottom,mHolderScaleX,mHolderScaleY).setDuration(mLayoutTransition 61 | .getDuration(LayoutTransition.CHANGE_APPEARING)); 62 | mLayoutTransition.setAnimator(LayoutTransition.CHANGE_APPEARING, mObjectAnimatorChangeAppearing); 63 | mObjectAnimatorChangeAppearing.addListener(new AnimatorListenerAdapter() { 64 | @Override 65 | public void onAnimationEnd(Animator animation) { 66 | // TODO Auto-generated method stub 67 | super.onAnimationEnd(animation); 68 | View view = (View) ((ObjectAnimator) animation).getTarget(); 69 | view.setScaleX(1f); 70 | view.setScaleY(1f); 71 | } 72 | }); 73 | 74 | /** 75 | * Delete Button 76 | * LayoutTransition.DISAPPEARING 77 | * 当删除一个Button时,设置该Button的动画效果 78 | */ 79 | ObjectAnimator mObjectAnimatorDisAppearing = ObjectAnimator.ofFloat(null, "rotationX", 0.0f,90.0f) 80 | .setDuration(mLayoutTransition.getDuration(LayoutTransition.DISAPPEARING)); 81 | mLayoutTransition.setAnimator(LayoutTransition.DISAPPEARING, mObjectAnimatorDisAppearing); 82 | mObjectAnimatorDisAppearing.addListener(new AnimatorListenerAdapter() { 83 | @Override 84 | public void onAnimationEnd(Animator animation) { 85 | // TODO Auto-generated method stub 86 | super.onAnimationEnd(animation); 87 | View view = (View) ((ObjectAnimator) animation).getTarget(); 88 | view.setRotationX(0.0f); 89 | } 90 | }); 91 | 92 | /** 93 | * Delete Button 94 | * LayoutTransition.CHANGE_DISAPPEARING 95 | * 当删除一个Button时,设置其它Button的动画效果 96 | */ 97 | //Keyframe 对象中包含了一个时间/属性值的键值对,用于定义某个时刻的动画状态。 98 | Keyframe mKeyframeStart = Keyframe.ofFloat(0.0f, 0.0f); 99 | Keyframe mKeyframeMiddle = Keyframe.ofFloat(0.5f, 180.0f); 100 | Keyframe mKeyframeEndBefore = Keyframe.ofFloat(0.999f, 360.0f); 101 | Keyframe mKeyframeEnd = Keyframe.ofFloat(1.0f, 0.0f); 102 | 103 | PropertyValuesHolder mPropertyValuesHolder = PropertyValuesHolder.ofKeyframe("rotation", 104 | mKeyframeStart,mKeyframeMiddle,mKeyframeEndBefore,mKeyframeEnd); 105 | ObjectAnimator mObjectAnimatorChangeDisAppearing = ObjectAnimator.ofPropertyValuesHolder(target, 106 | pvhLeft,pvhTop,pvhRight,pvhBottom,mPropertyValuesHolder) 107 | .setDuration(mLayoutTransition.getDuration(LayoutTransition.CHANGE_DISAPPEARING)); 108 | mLayoutTransition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, mObjectAnimatorChangeDisAppearing); 109 | mObjectAnimatorChangeDisAppearing.addListener(new AnimatorListenerAdapter() { 110 | @Override 111 | public void onAnimationEnd(Animator animation) { 112 | // TODO Auto-generated method stub 113 | super.onAnimationEnd(animation); 114 | View view = (View) ((ObjectAnimator) animation).getTarget(); 115 | view.setRotation(0.0f); 116 | } 117 | }); 118 | return mLayoutTransition ; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/res/drawable-xxhdpi/common_ic_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-drag-FlowLayout/56b0ba58749bd0da873de7346a14dacaaf5fc408/Drag-FlowLayout/app/src/main/res/drawable-xxhdpi/common_ic_search.png -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/res/drawable-xxhdpi/edit_text_delete_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-drag-FlowLayout/56b0ba58749bd0da873de7346a14dacaaf5fc408/Drag-FlowLayout/app/src/main/res/drawable-xxhdpi/edit_text_delete_checked.png -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/res/drawable-xxhdpi/edit_text_delete_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LightSun/android-drag-FlowLayout/56b0ba58749bd0da873de7346a14dacaaf5fc408/Drag-FlowLayout/app/src/main/res/drawable-xxhdpi/edit_text_delete_normal.png -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/res/drawable/shape_brand_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Drag-FlowLayout/app/src/main/res/layout/ac_drag_flow_test2.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 |