├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── example │ │ └── administrator │ │ └── animationview │ │ ├── AutoPullAdapter.java │ │ ├── AutoPullRecyclerView.java │ │ ├── WordActivity.java │ │ └── WordView.java │ └── res │ ├── anim │ ├── card_flip_left_in.xml │ ├── card_flip_left_out.xml │ ├── card_flip_right_in.xml │ ├── card_flip_right_out.xml │ └── loading.xml │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── a.png │ ├── arrow_right_grey_back.png │ ├── hhh.png │ ├── ic_launcher_background.xml │ ├── images.png │ ├── play.png │ └── search.png │ ├── layout │ ├── activity_atv_word_view.xml │ ├── activity_kong.xml │ ├── activity_layout.xml │ ├── activity_word.xml │ ├── item_rv_diving_line.xml │ └── item_ry_word.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── 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 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordView 2 | 一个基于 recyclerView 实现的自定义歌词控件 3 | 在使用时只需要使用 wordView.setList(wordList,timeList) 即可使用。 4 | 结合 seekBar 需要使用 setChangeTime(int time) 方法设置时间来使控件移动。 5 | 使用 setOnclickListener() 监听点击歌词返回的时间,从而调用 seekBar. 6 | 7 | 示例: 8 | worldRelativeLayout.setList(mWordList, mTimeList); 9 | 10 | worldRelativeLayout.setOnClickListener(new OnClickListener() { 11 | @Override 12 | public void onClickListener(int time) { 13 | Log.d("ppp","点击"); 14 | Toast.makeText(WordActivity.this,time+":",Toast.LENGTH_SHORT).show(); 15 | } 16 | }); 17 | 18 | seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 19 | @Override 20 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) { 21 | 22 | } 23 | 24 | @Override 25 | public void onStartTrackingTouch(SeekBar seekBar) { 26 | 27 | } 28 | 29 | @Override 30 | public void onStopTrackingTouch(SeekBar seekBar) { 31 | int progress = seekBar.getProgress(); // 获取当前进度 32 | worldRelativeLayout.setChangeTime(progress); 33 | } 34 | }); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.example.administrator.animationview" 7 | minSdkVersion 19 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 28 | implementation 'com.android.support:recyclerview-v7:26.1.0' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/animationview/AutoPullAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.animationview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import java.util.List; 12 | 13 | /** 歌词适配器 14 | * Created by ${Learning_Yeachlz} on 2018-03-15. 15 | */ 16 | 17 | public class AutoPullAdapter extends RecyclerView.Adapter { 18 | private List mWordList ; 19 | private Context mContext; 20 | private ViewGroup group ; 21 | private int mHighLightPosition; 22 | private String mOrdinaryColor = "#696969"; 23 | private int mOrdinarySize = 14; 24 | private int mHighLightSize = 16; 25 | private String mHighLightColor = "#FF3030"; 26 | 27 | public AutoPullAdapter(Context context,List wordList){ 28 | mWordList = wordList; 29 | mContext = context; 30 | } 31 | 32 | @Override 33 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 34 | group = parent; 35 | View view = LayoutInflater.from(mContext).inflate(R.layout.item_ry_word,parent,false); 36 | ViewGroup.LayoutParams lp = view.getLayoutParams(); 37 | lp.height = getItemHeight(); 38 | return new ViewHolder(view); 39 | } 40 | 41 | @Override 42 | public void onBindViewHolder(ViewHolder holder, int position) { 43 | String word = mWordList.get(position); 44 | holder.textView.setText(word); 45 | 46 | try { 47 | if (!isHighLight(position)) { 48 | holder.textView.setTextSize(mOrdinarySize); 49 | holder.textView.setTextColor(Color.parseColor(mOrdinaryColor)); 50 | 51 | } else if (isHighLight(position)) { 52 | holder.textView.setTextSize(mHighLightSize); 53 | holder.textView.setTextColor(Color.parseColor(mHighLightColor)); 54 | } 55 | }catch ( Exception e){ 56 | e.printStackTrace(); 57 | } 58 | 59 | } 60 | 61 | 62 | @Override 63 | public int getItemCount() { 64 | return mWordList.size(); 65 | } 66 | class ViewHolder extends RecyclerView.ViewHolder { 67 | private TextView textView; 68 | 69 | public ViewHolder(View itemView) { 70 | super(itemView); 71 | textView = itemView.findViewById(R.id.item_rv_tv_word); 72 | } 73 | } 74 | 75 | 76 | /** 获取歌词高度 77 | * @return 78 | */ 79 | private int getItemHeight(){ 80 | int itemHeight = group.getMeasuredHeight()/9; 81 | return itemHeight; 82 | } 83 | 84 | /** 判断是否高亮 85 | * @param position 86 | * @return 87 | */ 88 | private boolean isHighLight(int position){ 89 | return mHighLightPosition == position; 90 | } 91 | 92 | 93 | /** 改变歌词高亮位置 94 | * @param position 95 | */ 96 | public void hightLightItem(int position){ 97 | mHighLightPosition = position; 98 | notifyItemChanged(position-1); 99 | notifyItemChanged(position); 100 | } 101 | 102 | 103 | /** 改变歌词高亮的位置 104 | * @param lastPostion 105 | * @param currentPosition 106 | */ 107 | public void changeToHighLight(int lastPostion,int currentPosition){ 108 | mHighLightPosition = currentPosition; 109 | notifyItemChanged(lastPostion); 110 | notifyItemChanged(currentPosition); 111 | } 112 | 113 | public void setmHighLightSize(int size){ 114 | mHighLightSize = size; 115 | } 116 | 117 | public void setmOrdinarySize(int size){ 118 | mOrdinarySize = size; 119 | } 120 | 121 | public void setHightLightColor(String color){ 122 | mHighLightColor = color; 123 | } 124 | 125 | public void setmOrdinaryColor(String color){ 126 | mOrdinaryColor = color; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/animationview/AutoPullRecyclerView.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.animationview; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.util.AttributeSet; 8 | import android.util.Log; 9 | import android.view.MotionEvent; 10 | 11 | import java.lang.ref.WeakReference; 12 | import java.util.List; 13 | 14 | /** 自动滑动的 recyclerView 15 | * Created by ${Learning_Yeachlz} on 2018-03-15. 16 | */ 17 | 18 | public class AutoPullRecyclerView extends RecyclerView { 19 | 20 | private List timeList ; 21 | 22 | private static WeakReference weakReference; 23 | private AutoPullWork autoPullWork; 24 | private AutoBackWork autoBackWork; 25 | 26 | private int currentWord = 4 ; 27 | private static int height; 28 | private static int type = 0; 29 | private int wordLength; 30 | private int lastWord ; 31 | 32 | private boolean isDownAndMove = true; 33 | private boolean comeToPlay = false; 34 | private boolean running = true; 35 | private boolean canRun = true; 36 | 37 | 38 | private Context context ; 39 | 40 | 41 | public AutoPullRecyclerView(Context context) { 42 | super(context); 43 | this.context = context; 44 | autoPullWork = new AutoPullWork(this); 45 | autoBackWork = new AutoBackWork(); 46 | } 47 | 48 | 49 | 50 | public AutoPullRecyclerView(Context context, @Nullable AttributeSet attrs) throws NoSuchFieldException, IllegalAccessException { 51 | super(context, attrs); 52 | this.context = context; 53 | autoPullWork = new AutoPullWork(this); 54 | autoBackWork = new AutoBackWork(); 55 | } 56 | 57 | 58 | public AutoPullRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { 59 | super(context, attrs, defStyleAttr); 60 | this.context = context; 61 | autoPullWork = new AutoPullWork(this); 62 | autoBackWork = new AutoBackWork(); 63 | } 64 | 65 | 66 | /** 67 | * 歌词自动滑动到特定位置任务 68 | */ 69 | private static class AutoBackWork implements Runnable{ 70 | 71 | @Override 72 | public void run() { 73 | 74 | AutoPullRecyclerView autoPullRecyclerView = weakReference.get(); 75 | LinearLayoutManager linearLayoutManager = (LinearLayoutManager) autoPullRecyclerView.getLayoutManager(); 76 | int firtPosition = linearLayoutManager.findFirstVisibleItemPosition(); 77 | int lastPosition = linearLayoutManager.findLastVisibleItemPosition(); 78 | 79 | if (firtPosition>autoPullRecyclerView.currentWord){ 80 | autoPullRecyclerView.smoothScrollBy(0, -(firtPosition - autoPullRecyclerView.currentWord + 5) * height); 81 | Log.d("kkk2","滑动1"); 82 | }else if(firtPosition+9>autoPullRecyclerView.currentWord){ 83 | if (firtPosition+3>autoPullRecyclerView.currentWord){ 84 | int top = autoPullRecyclerView.getChildAt(autoPullRecyclerView.currentWord-firtPosition).getTop(); 85 | autoPullRecyclerView.smoothScrollBy(0, -(4*height-top)); //-- 86 | Log.d("kkk2","滑动2"); 87 | }else{ 88 | int top = autoPullRecyclerView.getChildAt(autoPullRecyclerView.currentWord-firtPosition).getTop(); 89 | autoPullRecyclerView.smoothScrollBy(0,top-(4*height)); //++ 90 | Log.d("kkk2","滑动3"); 91 | } 92 | }else { 93 | autoPullRecyclerView.smoothScrollBy(0, (autoPullRecyclerView.currentWord - lastPosition + 5) * height); 94 | Log.d("kkk2","滑动4"); 95 | } 96 | 97 | if (type==2){ 98 | autoPullRecyclerView.currentWord = autoPullRecyclerView.currentWord+1; 99 | } 100 | if (type!=2) { 101 | type = 1; 102 | } 103 | } 104 | 105 | 106 | } 107 | 108 | 109 | /** 110 | * 歌词按照时间自动滑动 111 | */ 112 | private static class AutoPullWork implements Runnable { 113 | public AutoPullWork(AutoPullRecyclerView autoPullRecyclerView) { 114 | weakReference = new WeakReference(autoPullRecyclerView); 115 | } 116 | @Override 117 | public void run() { 118 | AutoPullRecyclerView autoPullRecyclerView = weakReference.get(); 119 | if (autoPullRecyclerView.currentWord + 1 < autoPullRecyclerView.wordLength+6||type==3||type==2) { 120 | Log.d("uuu",autoPullRecyclerView.currentWord+":"+autoPullRecyclerView.wordLength); 121 | LinearLayoutManager linearLayoutManager = (LinearLayoutManager)autoPullRecyclerView.getLayoutManager(); 122 | int firtPosition = linearLayoutManager.findFirstVisibleItemPosition(); 123 | int top = autoPullRecyclerView.getChildAt(0).getTop(); 124 | if (type==1||type==3||type==2) { 125 | if (autoPullRecyclerView != null && autoPullRecyclerView.running && autoPullRecyclerView.canRun) { 126 | height = autoPullRecyclerView.getMeasuredHeight() / 9; 127 | Log.d("ooo", height + ""); 128 | AutoPullAdapter autoPullAdapter = (AutoPullAdapter) autoPullRecyclerView.getAdapter(); 129 | 130 | if (type==1) { 131 | autoPullRecyclerView.smoothScrollBy(0, autoPullRecyclerView.getMeasuredHeight() / 9); 132 | Log.d("mmm","type==1&&!autoPullRecyclerView.comeToPlay"); 133 | } 134 | 135 | if (type==3&&autoPullRecyclerView.comeToPlay){ 136 | type = 1; 137 | if (-top>height/2){ 138 | autoPullAdapter.changeToHighLight(autoPullRecyclerView.lastWord,firtPosition+5); 139 | autoPullRecyclerView.currentWord = firtPosition+5; 140 | }else { 141 | autoPullAdapter.changeToHighLight(autoPullRecyclerView.lastWord,firtPosition+4); 142 | autoPullRecyclerView.currentWord = firtPosition+4; 143 | } 144 | autoPullRecyclerView.comeToPlay = false; 145 | Log.d("mmm1",type+"这里3"); 146 | }else if (type==2){ 147 | autoPullAdapter.changeToHighLight(autoPullRecyclerView.lastWord,autoPullRecyclerView.currentWord); 148 | type=1; 149 | Log.d("mmm1",type+"这里2"); 150 | }else { 151 | autoPullAdapter.changeToHighLight(autoPullRecyclerView.currentWord-1,autoPullRecyclerView.currentWord); 152 | Log.d("mmm1",type+"这里1"); 153 | } 154 | 155 | 156 | autoPullRecyclerView.currentWord = autoPullRecyclerView.currentWord + 1; 157 | Log.d("mmm","putong"); 158 | 159 | if(autoPullRecyclerView.currentWord>=autoPullRecyclerView.wordLength+4){ 160 | autoPullRecyclerView.postDelayed(autoPullRecyclerView.autoPullWork,2000); 161 | Log.d("uuu",autoPullRecyclerView.currentWord+""); 162 | }else { 163 | autoPullRecyclerView.postDelayed(autoPullRecyclerView.autoPullWork, autoPullRecyclerView.timeList.get(autoPullRecyclerView.currentWord - 4) - autoPullRecyclerView.timeList.get(autoPullRecyclerView.currentWord - 5)); 164 | 165 | Log.d("uuu", autoPullRecyclerView.timeList.get(autoPullRecyclerView.currentWord - 4) + ":" + autoPullRecyclerView.timeList.get(autoPullRecyclerView.currentWord - 5) + ""); 166 | int a = autoPullRecyclerView.currentWord - 3; 167 | int b = autoPullRecyclerView.currentWord - 4; 168 | 169 | Log.d("uuu", autoPullRecyclerView.timeList.size() + ":" + a + ":" + b); 170 | } 171 | } 172 | } 173 | } 174 | } 175 | } 176 | 177 | 178 | /** 179 | * 开始滑动 180 | */ 181 | public void start(){ 182 | if (running){ 183 | stop(); 184 | } 185 | canRun =true; 186 | running = true; 187 | type = 1; 188 | postDelayed(autoPullWork,timeList.get(0)); 189 | } 190 | 191 | public void stop(){ 192 | running = false; 193 | removeCallbacks(autoPullWork); 194 | } 195 | 196 | 197 | 198 | @Override 199 | public boolean onTouchEvent(MotionEvent e) { 200 | switch (e.getAction()){ 201 | case MotionEvent.ACTION_DOWN: 202 | if (isDownAndMove) { 203 | type=3; 204 | isDownAndMove = false; 205 | Log.d("kkkk","recyclerview+down"); 206 | } 207 | break; 208 | case MotionEvent.ACTION_UP: 209 | Log.d("kkkk","recyclerview+up"); 210 | removeCallbacks(autoBackWork); 211 | postDelayed(autoBackWork,4000); 212 | isDownAndMove = true; 213 | break; 214 | default: 215 | break; 216 | } 217 | return super.onTouchEvent(e); 218 | } 219 | 220 | /** 221 | * 点击歌词滑动 222 | */ 223 | public void setComeToPlay(){ 224 | type =3; 225 | comeToPlay = true; 226 | lastWord = currentWord-1; 227 | removeCallbacks(autoPullWork); 228 | post(autoPullWork); 229 | } 230 | 231 | /** 设置歌词时间相应歌词滑动 232 | * @param time 233 | */ 234 | public void setChangeTime(int time){ 235 | type =2; 236 | if (time<=timeList.get(0)){ 237 | removeCallbacks(autoPullWork); 238 | removeCallbacks(autoBackWork); 239 | lastWord = currentWord; 240 | currentWord = 3; 241 | post(autoBackWork); 242 | postDelayed(autoPullWork,timeList.get(0)-time); 243 | }else if (time>=timeList.get(timeList.size()-1)){ 244 | removeCallbacks(autoPullWork); 245 | removeCallbacks(autoBackWork); 246 | lastWord = currentWord; 247 | currentWord = wordLength+3; 248 | post(autoPullWork); 249 | postDelayed(autoBackWork,2000); 250 | }else { 251 | removeCallbacks(autoPullWork); 252 | removeCallbacks(autoBackWork); 253 | int position = 0; 254 | for (int i=0;itimeList.get(i)&&time timeList,int wordLength){ 273 | this.timeList = timeList; 274 | this.wordLength = wordLength; 275 | } 276 | 277 | } 278 | 279 | 280 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/animationview/WordActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.animationview; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.util.Log; 7 | import android.widget.SeekBar; 8 | import android.widget.Toast; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by ${Learning_Yeachlz} on 2018-03-15. 15 | */ 16 | 17 | public class WordActivity extends Activity { 18 | private WordView worldRelativeLayout; 19 | @Override 20 | protected void onCreate(@Nullable Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | setContentView(R.layout.activity_layout); 23 | 24 | SeekBar seekBar = (SeekBar)findViewById(R.id.seekbar); 25 | seekBar.setMax(46265); 26 | 27 | worldRelativeLayout = (WordView) findViewById(R.id.wordview); 28 | 29 | List mWordList = new ArrayList<>(); 30 | mWordList.add("许嵩"); //790 31 | mWordList.add("半城烟沙"); //4200 32 | mWordList.add("词/曲/制作人/演唱:许嵩"); //6420 33 | mWordList.add("和声编写/和声:许嵩"); //8620 34 | mWordList.add("录音/混音:许嵩"); //10960 35 | mWordList.add("有些爱像断线纸鸢 结局悲余手中线"); //12240 36 | mWordList.add("有些恨像是一个圈 冤冤相报不了结"); //14570 37 | mWordList.add("只为了完成一个夙愿 还将付出几多鲜血"); //16940 38 | mWordList.add("忠义之言 自欺欺人的谎言"); //18990 39 | mWordList.add("有些情入苦难回绵 窗间月夕夕成玦"); //21270 40 | mWordList.add("有些仇心藏却无言 腹化风雪为刀剑"); //24550 41 | mWordList.add("只为了完成一个夙愿 荒乱中邪正如何辨"); //28970 42 | mWordList.add("飞沙狼烟将乱我 徒有悲添"); //31941 43 | mWordList.add("半城烟沙 兵临池下"); //32337 44 | mWordList.add("金戈铁马 替谁争天下"); //34753 45 | mWordList.add("一将成 万骨枯 多少白发送走黑发"); //36587 46 | mWordList.add("半城烟沙 随风而下"); //39998 47 | mWordList.add("手中还有 一缕牵挂"); //40261 48 | mWordList.add("只盼归田卸甲 还能捧回你沏的茶 "); //43261 49 | 50 | 51 | 52 | List mTimeList = new ArrayList<>(); 53 | mTimeList.add(790); 54 | mTimeList.add(4200); 55 | mTimeList.add(6420); 56 | mTimeList.add(8620); 57 | mTimeList.add(10960); 58 | mTimeList.add(12240); 59 | mTimeList.add(14570); 60 | mTimeList.add(16940); 61 | mTimeList.add(18990); 62 | mTimeList.add(21270); 63 | mTimeList.add(24550); 64 | mTimeList.add(28970); 65 | mTimeList.add(31941); 66 | mTimeList.add(32337); 67 | mTimeList.add(34753); 68 | mTimeList.add(36587); 69 | mTimeList.add(39998); 70 | mTimeList.add(43261); 71 | mTimeList.add(46261); 72 | 73 | worldRelativeLayout.setList(mWordList, mTimeList); 74 | worldRelativeLayout.setOnClickListener(new OnClickListener() { 75 | @Override 76 | public void onClickListener(int time) { 77 | Log.d("ppp","点击"); 78 | Toast.makeText(WordActivity.this,time+":",Toast.LENGTH_SHORT).show(); 79 | } 80 | }); 81 | 82 | seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 83 | @Override 84 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) { 85 | 86 | } 87 | 88 | @Override 89 | public void onStartTrackingTouch(SeekBar seekBar) { 90 | 91 | } 92 | 93 | @Override 94 | public void onStopTrackingTouch(SeekBar seekBar) { 95 | int progress = seekBar.getProgress(); // 获取当前进度 96 | worldRelativeLayout.setChangeTime(progress); 97 | } 98 | }); 99 | 100 | } 101 | } 102 | 103 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/administrator/animationview/WordView.java: -------------------------------------------------------------------------------- 1 | package com.example.administrator.animationview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.graphics.drawable.Drawable; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.util.AttributeSet; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.widget.RelativeLayout; 12 | import android.widget.TextView; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * 19 | * Created by ${Learning_Yeachlz} on 2018-03-20. 20 | */ 21 | 22 | public class WordView extends RelativeLayout { 23 | private TextView mTvTime; 24 | private RelativeLayout view ; 25 | private View mDivderLine; 26 | private AutoPullRecyclerView autoPullRecyclerView; 27 | 28 | private AutoPullAdapter autoPullAdapter; 29 | private LinearLayoutManager linearLayoutManager ; 30 | 31 | private List mTimeList ; 32 | private List mWordList ; 33 | 34 | private Context context; 35 | 36 | private boolean show = false; 37 | private int mCurrentTime; 38 | 39 | private com.example.administrator.animationview.OnClickListener onClickListener; 40 | 41 | /** 初始化类 42 | * @param context 43 | */ 44 | public WordView(Context context) { 45 | super(context); 46 | this.context = context; 47 | } 48 | 49 | public WordView(Context context, AttributeSet attrs) { 50 | super(context, attrs); 51 | this.context = context; 52 | } 53 | 54 | public WordView(Context context, AttributeSet attrs, int defStyleAttr) { 55 | super(context, attrs, defStyleAttr); 56 | this.context = context; 57 | } 58 | 59 | 60 | /** 歌词点击事件设置 61 | * @param onClickListener 62 | */ 63 | public void setOnClickListener(com.example.administrator.animationview.OnClickListener onClickListener) { 64 | this.onClickListener = onClickListener; 65 | } 66 | 67 | 68 | /**初始化内容 69 | * @param context 70 | */ 71 | private void initView(Context context) { 72 | View.inflate(context, R.layout.activity_atv_word_view, WordView.this); 73 | autoPullRecyclerView = (AutoPullRecyclerView) this.findViewById(R.id.auto_word); 74 | 75 | view = (RelativeLayout) this.findViewById(R.id.divide_line); 76 | view.setVisibility(GONE); 77 | 78 | mTvTime = (TextView) this.findViewById(R.id.time1); 79 | mDivderLine = (View) this.findViewById(R.id.divide_line1); 80 | 81 | 82 | List wordList = new ArrayList<>(); 83 | wordList.add(""); 84 | wordList.add(""); 85 | wordList.add(""); 86 | wordList.add(""); 87 | wordList.addAll(mWordList); 88 | wordList.add(""); 89 | wordList.add(""); 90 | wordList.add(""); 91 | wordList.add(""); 92 | 93 | 94 | autoPullRecyclerView.setTimeList(mTimeList, mWordList.size()); 95 | autoPullAdapter = new AutoPullAdapter(context,wordList); 96 | linearLayoutManager = new LinearLayoutManager(context); 97 | autoPullRecyclerView.setLayoutManager(linearLayoutManager); 98 | autoPullRecyclerView.setAdapter(autoPullAdapter); 99 | autoPullRecyclerView.start(); 100 | 101 | autoPullRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { 102 | @Override 103 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 104 | 105 | if (show) { 106 | showTime(); 107 | } 108 | } 109 | }); 110 | } 111 | 112 | 113 | /** 114 | * 简单加多几行空格让歌词中间显示 115 | * @return 116 | */ 117 | 118 | 119 | /** 120 | * 根据位移显示时间 121 | */ 122 | private void showTime(){ 123 | int height = autoPullRecyclerView.getMeasuredHeight() / 9; 124 | int top = autoPullRecyclerView.getChildAt(1).getTop(); 125 | int currentPosition = linearLayoutManager.findFirstVisibleItemPosition(); 126 | int position; 127 | if (top > height / 2) { 128 | position = currentPosition; 129 | } else { 130 | position = currentPosition + 1; 131 | } 132 | String Minute = null; 133 | String Second = null; 134 | int minute = mTimeList.get(position) / 1000 / 60; // 转换时间格式 135 | int second = mTimeList.get(position) / 1000 % 60; 136 | mCurrentTime = mTimeList.get(position); 137 | if (minute < 10) { 138 | Minute = "0" + minute; 139 | } else { 140 | Minute = minute + ""; 141 | } 142 | if (second < 10) { 143 | Second = "0" + second; 144 | } else { 145 | Second = second + ""; 146 | } 147 | mTvTime.setText(Minute + ":" + Second); 148 | } 149 | 150 | 151 | 152 | 153 | 154 | /** 155 | * 手指离开过一段时间消失 156 | */ 157 | Runnable runnable = new Runnable() { 158 | @Override 159 | public void run() { 160 | view.setVisibility(GONE); 161 | show = false; 162 | } 163 | }; 164 | 165 | /** 166 | * 设置 歌词列表和相应的时间列表 167 | * @param mWordList 168 | * @param mTimeList 169 | */ 170 | public void setList(List mWordList,List mTimeList){ 171 | this.mWordList = mWordList; 172 | this.mTimeList = mTimeList; 173 | initView(context); 174 | } 175 | 176 | /** 设置控件背景 177 | * @param drawable 178 | */ 179 | public void setBackGround(Drawable drawable){ 180 | try { 181 | autoPullRecyclerView.setBackground(drawable); 182 | }catch (Exception e){ 183 | e.printStackTrace(); 184 | } 185 | 186 | } 187 | 188 | /** 设置 歌词高亮颜色 189 | * @param color 190 | */ 191 | public void setHighLightColor(String color){ 192 | autoPullAdapter.setHightLightColor(color); 193 | } 194 | 195 | /** 设置普通歌词颜色 196 | * @param color 197 | */ 198 | public void setOrdinaryColor(String color){ 199 | autoPullAdapter.setmOrdinaryColor(color); 200 | } 201 | 202 | /** 设置 高亮字体大小 203 | * @param size 204 | */ 205 | public void setHighLightSize(int size){ 206 | autoPullAdapter.setmHighLightSize(size); 207 | } 208 | 209 | /**设置 普通字体大小 210 | * @param size 211 | */ 212 | public void setOrdinarySize(int size){ 213 | autoPullAdapter.setmOrdinarySize(size); 214 | } 215 | 216 | /** 设置中间线颜色 217 | * @param color 218 | */ 219 | public void setDivderLineColor(String color){ 220 | try { 221 | mDivderLine.setBackgroundColor(Color.parseColor(color)); 222 | }catch (Exception e){ 223 | e.printStackTrace(); 224 | } 225 | 226 | } 227 | 228 | /** 输入时间歌词做出相应改变 229 | * @param time 230 | */ 231 | public void setChangeTime(int time){ 232 | autoPullRecyclerView.setChangeTime(time); 233 | } 234 | 235 | /** 设置显示时间颜色 236 | * @param color 237 | */ 238 | public void setTimeColor(String color){ 239 | try { 240 | mTvTime.setTextColor(Color.parseColor(color)); 241 | }catch (Exception e){ 242 | e.printStackTrace(); 243 | } 244 | } 245 | 246 | 247 | 248 | 249 | /** 事件分发机制 250 | * @param ev 251 | * @return 252 | */ 253 | @Override 254 | public boolean dispatchTouchEvent(MotionEvent ev) { 255 | switch (ev.getAction()){ 256 | case MotionEvent.ACTION_DOWN: 257 | performClick(); 258 | view.setVisibility(VISIBLE); 259 | show = true; 260 | view.setOnClickListener(new OnClickListener() { 261 | @Override 262 | public void onClick(View view) { 263 | autoPullRecyclerView.setComeToPlay(); 264 | onClickListener.onClickListener(mCurrentTime); 265 | } 266 | }); 267 | break; 268 | case MotionEvent.ACTION_UP: 269 | view.removeCallbacks(runnable); 270 | view.postDelayed(runnable,4000); 271 | break; 272 | default: 273 | break; 274 | } 275 | return super.dispatchTouchEvent(ev); 276 | } 277 | } 278 | 279 | -------------------------------------------------------------------------------- /app/src/main/res/anim/card_flip_left_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/anim/card_flip_left_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/anim/card_flip_right_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/card_flip_right_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/anim/loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/drawable/a.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_right_grey_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/drawable/arrow_right_grey_back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/hhh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/drawable/hhh.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/drawable/images.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/drawable/play.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/drawable/search.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_atv_word_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 16 | 23 | 32 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_kong.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 11 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_word.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_rv_diving_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 12 | 21 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_ry_word.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AnimationView 3 | suotu 4 | huilai 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /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/Yeahlz/WordView/4360860264480b77e42d8931db970e61bb997bac/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jan 31 14:36:47 CST 2018 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-4.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 | --------------------------------------------------------------------------------