├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── cjj │ │ └── onestep │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── cjj │ │ │ └── onestep │ │ │ ├── BindingHolder.java │ │ │ ├── DividerGridItemDecoration.java │ │ │ ├── DividerItemDecoration.java │ │ │ ├── IconUrls.java │ │ │ ├── MainActivity.java │ │ │ ├── OneStepAdapter.java │ │ │ ├── OneStepEntity.java │ │ │ ├── OneStepSideBar.java │ │ │ └── ViewBindingAdapter.java │ └── res │ │ ├── drawable │ │ └── icon_launcher.png │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── item_app_icon_txt.xml │ │ ├── item_icon.xml │ │ └── view_side_bar.xml │ │ ├── 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 │ └── cjj │ └── onestep │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OneStep 2 | 3 | 本 Demo 模仿了 Smartisan One Step 动画功能,只是练习下拖拽而已,看看就好! 4 | 5 | ![](http://ww2.sinaimg.cn/mw690/7ef01fcagw1f915opv9mhg208c0fzqbn.gif) 6 | 7 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # Custom 2 | _site 3 | 4 | # Ant 5 | MANIFEST.MF 6 | ./*.jar 7 | build.num 8 | build 9 | 10 | # ADT 11 | .classpath 12 | .project 13 | .settings 14 | local.properties 15 | bin 16 | gen 17 | _layouts 18 | proguard.cfg 19 | 20 | # OSX 21 | .DS_Store 22 | 23 | # Github 24 | gh-pages 25 | 26 | # Gradle 27 | .gradle 28 | build 29 | 30 | # IDEA 31 | *.iml 32 | *.ipr 33 | *.iws 34 | out 35 | .idea 36 | 37 | # Maven 38 | target 39 | release.properties 40 | pom.xml.* -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.2" 6 | defaultConfig { 7 | applicationId "com.cjj.onestep" 8 | minSdkVersion 14 9 | targetSdkVersion 24 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | dataBinding{ 22 | enabled = true; 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(include: ['*.jar'], dir: 'libs') 28 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 29 | exclude group: 'com.android.support', module: 'support-annotations' 30 | }) 31 | compile 'com.android.support:appcompat-v7:24.2.1' 32 | testCompile 'junit:junit:4.12' 33 | compile 'com.android.support:recyclerview-v7:24.2.1' 34 | compile 'com.github.bumptech.glide:glide:3.7.0' 35 | } 36 | -------------------------------------------------------------------------------- /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 D:\android\utils\sdk/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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/cjj/onestep/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.cjj.onestep", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/BindingHolder.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | import android.databinding.ViewDataBinding; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by cjj on 2016/10/22. 9 | */ 10 | public class BindingHolder extends RecyclerView.ViewHolder { 11 | 12 | private T mBinding; 13 | 14 | public BindingHolder(T binding) { 15 | super(binding.getRoot()); 16 | mBinding = binding; 17 | } 18 | 19 | public T getBinding() { 20 | return mBinding; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/DividerGridItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | import android.graphics.Rect; 6 | import android.support.v7.widget.GridLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.support.v7.widget.StaggeredGridLayoutManager; 9 | import android.view.View; 10 | 11 | public class DividerGridItemDecoration extends RecyclerView.ItemDecoration { 12 | 13 | private static final int[] ATTRS = new int[]{android.R.attr.listDivider}; 14 | private int dividerHeight; 15 | private int spanCount; 16 | private int color; 17 | 18 | private Paint mPaint; 19 | 20 | public DividerGridItemDecoration(int dividerHeight, int spanCount, int color) { 21 | this.dividerHeight = dividerHeight; 22 | this.spanCount = spanCount; 23 | this.color = color; 24 | mPaint = new Paint(); 25 | mPaint.setColor(color); 26 | } 27 | 28 | @Override 29 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { 30 | drawHorizontal(c, parent); 31 | drawVertical(c, parent); 32 | } 33 | 34 | private int getSpanCount(RecyclerView parent) { 35 | // 列数 36 | int spanCount = -1; 37 | RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); 38 | if (layoutManager instanceof GridLayoutManager) { 39 | spanCount = ((GridLayoutManager) layoutManager).getSpanCount(); 40 | } else if (layoutManager instanceof StaggeredGridLayoutManager) { 41 | spanCount = ((StaggeredGridLayoutManager) layoutManager) 42 | .getSpanCount(); 43 | } 44 | return spanCount; 45 | } 46 | 47 | public void drawHorizontal(Canvas c, RecyclerView parent) { 48 | int childCount = parent.getChildCount(); 49 | for (int i = 0; i < childCount; i++) { 50 | final View child = parent.getChildAt(i); 51 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 52 | .getLayoutParams(); 53 | final int left = child.getLeft() - params.leftMargin; 54 | final int right = child.getRight() + params.rightMargin + dividerHeight; 55 | // + mDivider.getIntrinsicWidth(); 56 | final int top = child.getBottom() + params.bottomMargin; 57 | final int bottom = top + dividerHeight; 58 | c.drawRect(left, top, right, bottom, mPaint); 59 | } 60 | } 61 | 62 | public void drawVertical(Canvas c, RecyclerView parent) { 63 | final int childCount = parent.getChildCount(); 64 | for (int i = 0; i < childCount; i++) { 65 | final View child = parent.getChildAt(i); 66 | 67 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 68 | .getLayoutParams(); 69 | final int top = child.getTop() - params.topMargin; 70 | final int bottom = child.getBottom() + params.bottomMargin; 71 | final int left = child.getRight() + params.rightMargin; 72 | final int right = left + dividerHeight; 73 | c.drawRect(left, top, right, bottom, mPaint); 74 | } 75 | } 76 | 77 | private boolean isLastColum(RecyclerView parent, int pos, int spanCount, 78 | int childCount) { 79 | RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); 80 | if (layoutManager instanceof GridLayoutManager) { 81 | if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边 82 | { 83 | return true; 84 | } 85 | } else if (layoutManager instanceof StaggeredGridLayoutManager) { 86 | int orientation = ((StaggeredGridLayoutManager) layoutManager) 87 | .getOrientation(); 88 | if (orientation == StaggeredGridLayoutManager.VERTICAL) { 89 | if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边 90 | { 91 | return true; 92 | } 93 | } else { 94 | childCount = childCount - childCount % spanCount; 95 | if (pos >= childCount)// 如果是最后一列,则不需要绘制右边 96 | return true; 97 | } 98 | } 99 | return false; 100 | } 101 | 102 | private boolean isLastRaw(RecyclerView parent, int pos, int spanCount, 103 | int childCount) { 104 | RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); 105 | if (layoutManager instanceof GridLayoutManager) { 106 | childCount = childCount - childCount % spanCount; 107 | if (pos >= childCount)// 如果是最后一行,则不需要绘制底部 108 | return true; 109 | } else if (layoutManager instanceof StaggeredGridLayoutManager) { 110 | int orientation = ((StaggeredGridLayoutManager) layoutManager) 111 | .getOrientation(); 112 | // StaggeredGridLayoutManager 且纵向滚动 113 | if (orientation == StaggeredGridLayoutManager.VERTICAL) { 114 | childCount = childCount - childCount % spanCount; 115 | // 如果是最后一行,则不需要绘制底部 116 | if (pos >= childCount) 117 | return true; 118 | } else 119 | // StaggeredGridLayoutManager 且横向滚动 120 | { 121 | // 如果是最后一行,则不需要绘制底部 122 | if ((pos + 1) % spanCount == 0) { 123 | return true; 124 | } 125 | } 126 | } 127 | return false; 128 | } 129 | 130 | @Override 131 | public void getItemOffsets(Rect outRect, int itemPosition, 132 | RecyclerView parent) { 133 | int spanCount = getSpanCount(parent); 134 | int childCount = parent.getAdapter().getItemCount(); 135 | if (isLastRaw(parent, itemPosition, spanCount, childCount))// 如果是最后一行,则不需要绘制底部 136 | { 137 | outRect.set(0, 0, dividerHeight, 0); 138 | } else if (isLastColum(parent, itemPosition, spanCount, childCount))// 如果是最后一列,则不需要绘制右边 139 | { 140 | outRect.set(0, 0, 0, dividerHeight); 141 | } else { 142 | outRect.set(0, 0, dividerHeight, dividerHeight); 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/DividerItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep;/* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * limitations under the License. 6 | */ 7 | 8 | import android.content.Context; 9 | import android.content.res.TypedArray; 10 | import android.graphics.Canvas; 11 | import android.graphics.Rect; 12 | import android.graphics.drawable.Drawable; 13 | import android.support.v7.widget.LinearLayoutManager; 14 | import android.support.v7.widget.RecyclerView; 15 | import android.view.View; 16 | 17 | 18 | /** 19 | * This class is from the v7 samples of the Android SDK. It's not by me! 20 | *

21 | * See the license above for details. 22 | */ 23 | public class DividerItemDecoration extends RecyclerView.ItemDecoration { 24 | 25 | private static final int[] ATTRS = new int[]{ 26 | android.R.attr.listDivider 27 | }; 28 | 29 | public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; 30 | 31 | public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; 32 | 33 | private Drawable mDivider; 34 | 35 | private int mOrientation; 36 | 37 | public DividerItemDecoration(Context context, int orientation) { 38 | final TypedArray a = context.obtainStyledAttributes(ATTRS); 39 | mDivider = a.getDrawable(0); 40 | a.recycle(); 41 | setOrientation(orientation); 42 | } 43 | 44 | public void setOrientation(int orientation) { 45 | if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) { 46 | throw new IllegalArgumentException("invalid orientation"); 47 | } 48 | mOrientation = orientation; 49 | } 50 | 51 | @Override 52 | public void onDraw(Canvas c, RecyclerView parent) { 53 | if (mOrientation == VERTICAL_LIST) { 54 | drawVertical(c, parent); 55 | } else { 56 | drawHorizontal(c, parent); 57 | } 58 | } 59 | 60 | public void drawVertical(Canvas c, RecyclerView parent) { 61 | final int left = parent.getPaddingLeft(); 62 | final int right = parent.getWidth() - parent.getPaddingRight(); 63 | 64 | final int childCount = parent.getChildCount(); 65 | for (int i = 0; i < childCount; i++) { 66 | final View child = parent.getChildAt(i); 67 | // android.support.v7.widget.RecyclerView v = new android.support.v7.widget.RecyclerView(parent.getContext()); 68 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 69 | .getLayoutParams(); 70 | final int top = child.getBottom() + params.bottomMargin; 71 | final int bottom = top + mDivider.getIntrinsicHeight(); 72 | mDivider.setBounds(left, top, right, bottom); 73 | mDivider.draw(c); 74 | } 75 | } 76 | 77 | public void drawHorizontal(Canvas c, RecyclerView parent) { 78 | final int top = parent.getPaddingTop(); 79 | final int bottom = parent.getHeight() - parent.getPaddingBottom(); 80 | 81 | final int childCount = parent.getChildCount(); 82 | for (int i = 0; i < childCount; i++) { 83 | final View child = parent.getChildAt(i); 84 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 85 | .getLayoutParams(); 86 | final int left = child.getRight() + params.rightMargin; 87 | final int right = left + mDivider.getIntrinsicHeight(); 88 | mDivider.setBounds(left, top, right, bottom); 89 | mDivider.draw(c); 90 | } 91 | } 92 | 93 | @Override 94 | public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) { 95 | if (mOrientation == VERTICAL_LIST) { 96 | outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); 97 | } else { 98 | outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/IconUrls.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | /** 4 | * Created by cjj on 2016/10/22. 5 | */ 6 | 7 | public class IconUrls { 8 | 9 | public static final String icon0 = "http://ww3.sinaimg.cn/mw690/7ef01fcajw1f911vsqugtj203k03kgli.jpg"; 10 | public static final String icon1 = "http://ww2.sinaimg.cn/mw690/7ef01fcajw1f911vs2rc0j203k03ka9v.jpg"; 11 | public static final String icon2 = "http://ww1.sinaimg.cn/mw690/7ef01fcajw1f911vr3qd9j203k03kdfu.jpg"; 12 | public static final String icon3 = "http://ww2.sinaimg.cn/mw690/7ef01fcajw1f911vq9sufj203k03k0so.jpg"; 13 | public static final String icon4 = "http://ww3.sinaimg.cn/mw690/7ef01fcajw1f911vp1umlj203k03kweh.jpg"; 14 | public static final String icon5 = "http://ww1.sinaimg.cn/mw690/7ef01fcajw1f911vntap6j203k03kwef.jpg"; 15 | public static final String icon6 = "http://ww1.sinaimg.cn/mw690/7ef01fcajw1f911vmp1clj203k03kaa3.jpg"; 16 | public static final String icon7 = "http://ww2.sinaimg.cn/mw690/7ef01fcajw1f911vintyrj203k03k3ye.jpg"; 17 | public static final String icon8 = "http://ww3.sinaimg.cn/mw690/7ef01fcajw1f911vhieklj203k03k748.jpg"; 18 | public static final String icon9 = "http://ww3.sinaimg.cn/mw690/7ef01fcajw1f911vfx4mnj203k03k0sr.jpg"; 19 | public static final String icon10 = "http://ww4.sinaimg.cn/mw690/7ef01fcajw1f911verp91j203k03kq2x.jpg"; 20 | public static final String icon11= "http://ww4.sinaimg.cn/mw690/7ef01fcajw1f911vdfegwj203k03kjre.jpg"; 21 | public static final String icon12= "http://ww1.sinaimg.cn/mw690/7ef01fcajw1f911vcjg93j203k03kmx4.jpg"; 22 | public static final String icon13= "http://ww2.sinaimg.cn/mw690/7ef01fcajw1f911vb9256j203k03kt8n.jpg"; 23 | public static final String icon14= "http://ww2.sinaimg.cn/mw690/7ef01fcajw1f911vadskbj203k03kaa0.jpg"; 24 | public static final String icon15= "http://ww4.sinaimg.cn/mw690/7ef01fcajw1f911v902o3j203k03kdfq.jpg"; 25 | public static final String icon16= "http://ww1.sinaimg.cn/mw690/7ef01fcajw1f911v7jn31j203k03kwef.jpg"; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | import android.content.ClipData; 4 | import android.content.ClipDescription; 5 | import android.databinding.DataBindingUtil; 6 | import android.os.Bundle; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.GridLayoutManager; 9 | import android.support.v7.widget.LinearLayoutManager; 10 | import android.util.Log; 11 | import android.view.DragEvent; 12 | import android.view.View; 13 | import android.widget.Toast; 14 | 15 | import com.cjj.onestep.databinding.ActivityMainBinding; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | public class MainActivity extends AppCompatActivity implements View.OnDragListener { 21 | 22 | private static final String TAG = MainActivity.class.getSimpleName(); 23 | 24 | private List mLists; 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main); 31 | 32 | binding.recycler.setLayoutManager(new GridLayoutManager(this, 3)); 33 | binding.recyclerSide.setLayoutManager(new LinearLayoutManager(this)); 34 | binding.recyclerSide.addItemDecoration(new DividerItemDecoration(this, 1)); 35 | binding.recycler.addItemDecoration(new DividerGridItemDecoration(1, 3, 36 | getResources().getColor(R.color.colorPrimary))); 37 | 38 | mLists = getData(); 39 | 40 | OneStepAdapter oneStepAdapter = new OneStepAdapter(mLists); 41 | binding.recycler.setAdapter(oneStepAdapter); 42 | oneStepAdapter.setItemLongClickListener(new OneStepAdapter.OnItemLongClickListener() { 43 | @Override 44 | public void onItemLongClick(View v, OneStepEntity entity) { 45 | View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v); 46 | 47 | ClipData.Item item = new ClipData.Item((CharSequence) v.getTag()); 48 | 49 | String[] mimeTypes = {ClipDescription.MIMETYPE_TEXT_PLAIN}; 50 | ClipData data = new ClipData(v.getTag().toString(), mimeTypes, item); 51 | 52 | v.startDrag(data, shadowBuilder, null, 0); 53 | 54 | } 55 | }); 56 | 57 | binding.recyclerSide.setAdapter(oneStepAdapter); 58 | binding.recyclerSide.setOnDragListener(this); 59 | } 60 | 61 | private List getData() { 62 | 63 | List list = new ArrayList<>(); 64 | 65 | OneStepEntity model = new OneStepEntity("锤子", IconUrls.icon0); 66 | OneStepEntity model1 = new OneStepEntity("邮件", IconUrls.icon1); 67 | OneStepEntity model2 = new OneStepEntity("笔记", IconUrls.icon2); 68 | OneStepEntity model3 = new OneStepEntity("优酷", IconUrls.icon3); 69 | OneStepEntity model4 = new OneStepEntity("UC", IconUrls.icon4); 70 | OneStepEntity model5 = new OneStepEntity("QQ音乐", IconUrls.icon5); 71 | OneStepEntity model6 = new OneStepEntity("手Q", IconUrls.icon6); 72 | OneStepEntity model7 = new OneStepEntity("微信", IconUrls.icon7); 73 | OneStepEntity model8 = new OneStepEntity("搜狗", IconUrls.icon8); 74 | OneStepEntity model9 = new OneStepEntity("新浪微博", IconUrls.icon9); 75 | OneStepEntity model10 = new OneStepEntity("爱奇艺", IconUrls.icon10); 76 | OneStepEntity model11 = new OneStepEntity("网易新闻", IconUrls.icon11); 77 | OneStepEntity model12 = new OneStepEntity("美图秀秀", IconUrls.icon12); 78 | OneStepEntity model13 = new OneStepEntity("酷狗", IconUrls.icon13); 79 | OneStepEntity model14 = new OneStepEntity("京东", IconUrls.icon14); 80 | OneStepEntity model15 = new OneStepEntity("cjj", IconUrls.icon15); 81 | OneStepEntity model16 = new OneStepEntity("cjj", IconUrls.icon16); 82 | 83 | list.add(model); 84 | list.add(model1); 85 | list.add(model2); 86 | list.add(model3); 87 | list.add(model4); 88 | list.add(model5); 89 | list.add(model6); 90 | list.add(model7); 91 | list.add(model8); 92 | list.add(model9); 93 | list.add(model10); 94 | list.add(model11); 95 | list.add(model12); 96 | list.add(model13); 97 | list.add(model14); 98 | list.add(model15); 99 | list.add(model16); 100 | 101 | return list; 102 | } 103 | 104 | 105 | @Override 106 | public boolean onDrag(View view, DragEvent dragEvent) { 107 | switch (dragEvent.getAction()) { 108 | case DragEvent.ACTION_DRAG_STARTED: 109 | Log.i(TAG, "ACTION_DRAG_STARTED"); 110 | break; 111 | 112 | case DragEvent.ACTION_DRAG_ENTERED: 113 | Log.i(TAG, "ACTION_DRAG_ENTERED"); 114 | break; 115 | 116 | case DragEvent.ACTION_DRAG_EXITED: 117 | Log.i(TAG, "ACTION_DRAG_EXITED"); 118 | break; 119 | 120 | 121 | case DragEvent.ACTION_DROP: 122 | Log.i(TAG, "ACTION_DROP"); 123 | ClipData.Item item = dragEvent.getClipData().getItemAt(0); 124 | CharSequence dragData = item.getText(); 125 | 126 | Toast.makeText(MainActivity.this, "你要分享" + dragData, Toast.LENGTH_SHORT).show(); 127 | 128 | break; 129 | 130 | case DragEvent.ACTION_DRAG_ENDED: 131 | Log.i(TAG, "ACTION_DRAG_ENDED"); 132 | break; 133 | 134 | default: 135 | break; 136 | } 137 | return true; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/OneStepAdapter.java: -------------------------------------------------------------------------------- 1 | 2 | package com.cjj.onestep; 3 | 4 | import android.databinding.DataBindingUtil; 5 | import android.databinding.ViewDataBinding; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Created by cjj on 2016/10/22. 15 | */ 16 | 17 | public class OneStepAdapter extends RecyclerView.Adapter { 18 | 19 | private List mList; 20 | 21 | private OnItemClickListener mListener; 22 | 23 | private OnItemLongClickListener mLongListener; 24 | 25 | public OneStepAdapter(List list) { 26 | mList = list; 27 | } 28 | 29 | public interface OnItemClickListener { 30 | void onItemClick(View v, OneStepEntity entity); 31 | } 32 | 33 | public interface OnItemLongClickListener { 34 | void onItemLongClick(View v, OneStepEntity entity); 35 | } 36 | 37 | public void setItemClickListener(OnItemClickListener listener) { 38 | mListener = listener; 39 | } 40 | 41 | public void setItemLongClickListener(OnItemLongClickListener longListener) { 42 | mLongListener = longListener; 43 | } 44 | 45 | @Override 46 | public BindingHolder onCreateViewHolder(ViewGroup parent, int viewType) { 47 | ViewDataBinding viewDataBinding = DataBindingUtil.inflate(LayoutInflater 48 | .from(parent.getContext()), R.layout.item_icon, parent, false); 49 | return new BindingHolder(viewDataBinding); 50 | } 51 | 52 | @Override 53 | public void onBindViewHolder(BindingHolder holder, int position) { 54 | final OneStepEntity entity = mList.get(position); 55 | holder.getBinding().setVariable(BR.entity, entity); 56 | holder.getBinding().executePendingBindings(); 57 | 58 | holder.itemView.setOnClickListener(new View.OnClickListener() { 59 | @Override 60 | public void onClick(View view) { 61 | if (mListener != null) { 62 | mListener.onItemClick(view, entity); 63 | } 64 | } 65 | }); 66 | 67 | holder.itemView.setTag(entity.title); 68 | holder.itemView.setOnLongClickListener(new View.OnLongClickListener() { 69 | @Override 70 | public boolean onLongClick(View view) { 71 | if (mLongListener != null) { 72 | mLongListener.onItemLongClick(view, entity); 73 | } 74 | return false; 75 | } 76 | }); 77 | 78 | } 79 | 80 | @Override 81 | public int getItemCount() { 82 | return mList.size(); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/OneStepEntity.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | /** 4 | * Created by cjj on 2016/10/21. 5 | */ 6 | 7 | public class OneStepEntity { 8 | 9 | public String title; 10 | public String icon; 11 | 12 | public OneStepEntity(String title, String icon) { 13 | this.title = title; 14 | this.icon = icon; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/OneStepSideBar.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.ApplicationInfo; 7 | import android.content.pm.ResolveInfo; 8 | import android.graphics.PixelFormat; 9 | import android.support.v7.widget.LinearLayoutManager; 10 | import android.support.v7.widget.RecyclerView; 11 | import android.view.DragEvent; 12 | import android.view.Gravity; 13 | import android.view.LayoutInflater; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | import android.view.WindowManager; 17 | import android.widget.ImageView; 18 | import android.widget.TextView; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * Created by cjj on 2016/10/22. 24 | */ 25 | 26 | public class OneStepSideBar { 27 | 28 | private static final String TAG = OneStepSideBar.class.getSimpleName(); 29 | 30 | private static final int FLAG_TOUCHABLE = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 31 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 32 | 33 | private static final int FLAG_NOT_TOUCHABLE = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 34 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE 35 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; 36 | 37 | private Context mContext; 38 | 39 | private View mBarViewContainer; 40 | 41 | private WindowManager mWindowManager; 42 | 43 | private WindowManager.LayoutParams mLayoutParams; 44 | 45 | public OneStepSideBar(Context context) { 46 | this.mContext = context; 47 | mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 48 | } 49 | 50 | public void show() { 51 | mBarViewContainer = View.inflate(mContext, R.layout.view_side_bar, null); 52 | 53 | RecyclerView recyclerApp = (RecyclerView) mBarViewContainer.findViewById(R.id.rv_app); 54 | recyclerApp.setLayoutManager(new LinearLayoutManager(mContext)); 55 | recyclerApp.setAdapter(new AppAdapter(mContext.getPackageManager().getInstalledApplications(0))); 56 | 57 | mLayoutParams = new WindowManager.LayoutParams(); 58 | mLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; 59 | mLayoutParams.width = 300; 60 | mLayoutParams.gravity = Gravity.RIGHT; 61 | mLayoutParams.type = WindowManager.LayoutParams.TYPE_TOAST; 62 | mLayoutParams.flags = FLAG_NOT_TOUCHABLE; 63 | mLayoutParams.format = PixelFormat.TRANSPARENT; 64 | 65 | mWindowManager.addView(mBarViewContainer, mLayoutParams); 66 | 67 | mBarViewContainer.setOnDragListener(new View.OnDragListener() { 68 | @Override 69 | public boolean onDrag(View view, DragEvent dragEvent) { 70 | switch (dragEvent.getAction()) { 71 | case DragEvent.ACTION_DRAG_STARTED: 72 | break; 73 | 74 | case DragEvent.ACTION_DRAG_ENTERED: 75 | break; 76 | case DragEvent.ACTION_DRAG_EXITED: 77 | break; 78 | 79 | case DragEvent.ACTION_DROP: 80 | break; 81 | 82 | case DragEvent.ACTION_DRAG_ENDED: 83 | break; 84 | 85 | default: 86 | break; 87 | } 88 | return true; 89 | } 90 | }); 91 | } 92 | 93 | public void openApp(ApplicationInfo item) { 94 | Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); 95 | resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); 96 | resolveIntent.setPackage(item.packageName); 97 | 98 | List resolveInfoList = mContext.getPackageManager() 99 | .queryIntentActivities(resolveIntent, 0); 100 | 101 | if (resolveInfoList != null && resolveInfoList.size() > 0) { 102 | 103 | ResolveInfo resolveInfo = resolveInfoList.get(0); 104 | String activityPackageName = resolveInfo.activityInfo.packageName; 105 | String className = resolveInfo.activityInfo.name; 106 | 107 | Intent intent = new Intent(Intent.ACTION_MAIN); 108 | intent.addCategory(Intent.CATEGORY_LAUNCHER); 109 | ComponentName componentName = new ComponentName( 110 | activityPackageName, className); 111 | 112 | intent.setComponent(componentName); 113 | 114 | mContext.startActivity(intent); 115 | } 116 | } 117 | 118 | public class AppAdapter extends RecyclerView.Adapter { 119 | 120 | private List mInfoList; 121 | 122 | public AppAdapter(List infolist) { 123 | mInfoList = infolist; 124 | } 125 | 126 | @Override 127 | public AppViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 128 | View view = LayoutInflater.from(mContext).inflate(R.layout.item_app_icon_txt, parent, false); 129 | return new AppViewHolder(view); 130 | } 131 | 132 | @Override 133 | public void onBindViewHolder(AppViewHolder holder, int position) { 134 | ApplicationInfo item = mInfoList.get(position); 135 | holder.ivIcon.setImageDrawable(item.loadIcon(mContext.getPackageManager())); 136 | } 137 | 138 | @Override 139 | public int getItemCount() { 140 | return mInfoList.size(); 141 | } 142 | 143 | public class AppViewHolder extends RecyclerView.ViewHolder { 144 | private TextView tvTitle; 145 | private ImageView ivIcon; 146 | 147 | public AppViewHolder(View itemView) { 148 | super(itemView); 149 | tvTitle = (TextView) itemView.findViewById(R.id.tv_txt); 150 | ivIcon = (ImageView) itemView.findViewById(R.id.iv_icon); 151 | } 152 | 153 | } 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /app/src/main/java/com/cjj/onestep/ViewBindingAdapter.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | import android.databinding.BindingAdapter; 4 | import android.widget.ImageView; 5 | 6 | import com.bumptech.glide.Glide; 7 | 8 | /** 9 | * Created by cjj on 2016/10/22. 10 | */ 11 | 12 | public class ViewBindingAdapter { 13 | 14 | @BindingAdapter({"imgUrl"}) 15 | public static void showImage(ImageView view, String url) { 16 | Glide.with(view.getContext()).load(url).into(view); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android-cjj/OneStep/2cda2f8bac79e9d9473f7aaeedd00eb53832ca79/app/src/main/res/drawable/icon_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 20 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_app_icon_txt.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | 13 | 21 | 22 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_side_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android-cjj/OneStep/2cda2f8bac79e9d9473f7aaeedd00eb53832ca79/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android-cjj/OneStep/2cda2f8bac79e9d9473f7aaeedd00eb53832ca79/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android-cjj/OneStep/2cda2f8bac79e9d9473f7aaeedd00eb53832ca79/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android-cjj/OneStep/2cda2f8bac79e9d9473f7aaeedd00eb53832ca79/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #555555 4 | #333333 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | OneStep 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/cjj/onestep/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.cjj.onestep; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/android-cjj/OneStep/2cda2f8bac79e9d9473f7aaeedd00eb53832ca79/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------