From 614a3663511a0197c8e41057544489e6c687015d Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 25 Nov 2020 03:15:00 +0800 Subject: [PATCH] update --- .../nas_music_player/containers/MusicContainer.java | 11 +++++------ .../views/Fragments/MusicLibsFragment.java | 5 ++++- .../nas_music_player/views/PlayLibsActivity.java | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/yutou/nas_music_player/containers/MusicContainer.java b/app/src/main/java/com/yutou/nas_music_player/containers/MusicContainer.java index c2696cc..19c0424 100644 --- a/app/src/main/java/com/yutou/nas_music_player/containers/MusicContainer.java +++ b/app/src/main/java/com/yutou/nas_music_player/containers/MusicContainer.java @@ -17,10 +17,9 @@ import com.yutou.nas_music_player.tools.StringUtil; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.Random; import java.util.Timer; import java.util.TimerTask; @@ -384,10 +383,7 @@ public class MusicContainer { } } updateLibsMap(); - if (initInterface != null) { - initInterface.init(); - initInterface = null; - } + } } @@ -416,6 +412,9 @@ public class MusicContainer { albumMapList.put(musicData.getAlbum(),album); artistMapList.put(musicData.getArtist(),artist); } + if(initInterface!=null) + initInterface.init(); + initInterface=null; } public MusicData findMusic(String md5,List list) { for (MusicData data : list) { diff --git a/app/src/main/java/com/yutou/nas_music_player/views/Fragments/MusicLibsFragment.java b/app/src/main/java/com/yutou/nas_music_player/views/Fragments/MusicLibsFragment.java index a67c2bb..ce01db0 100644 --- a/app/src/main/java/com/yutou/nas_music_player/views/Fragments/MusicLibsFragment.java +++ b/app/src/main/java/com/yutou/nas_music_player/views/Fragments/MusicLibsFragment.java @@ -2,6 +2,7 @@ package com.yutou.nas_music_player.views.Fragments; import android.content.Context; import android.os.Bundle; +import android.util.ArrayMap; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -25,7 +26,7 @@ public class MusicLibsFragment extends Fragment { private Context context; private View view; private IndexFastScrollRecyclerView recyclerView; - private int model=1; + private int model=0; public MusicLibsFragment(){ } @@ -43,6 +44,8 @@ public class MusicLibsFragment extends Fragment { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view=inflater.inflate(R.layout.fragment_music_libs,null); int id = FragmentPagerItem.getPosition(getArguments()); + if(map==null) + map=new HashMap<>(); if (!map.containsKey(id)) { map.put(id, this); } diff --git a/app/src/main/java/com/yutou/nas_music_player/views/PlayLibsActivity.java b/app/src/main/java/com/yutou/nas_music_player/views/PlayLibsActivity.java index 6edb3d5..e44e41f 100644 --- a/app/src/main/java/com/yutou/nas_music_player/views/PlayLibsActivity.java +++ b/app/src/main/java/com/yutou/nas_music_player/views/PlayLibsActivity.java @@ -190,6 +190,8 @@ public class PlayLibsActivity extends AppCompatActivity { super.onDestroy(); browserHelper.onStop(); browserHelper = null; + MusicLibsFragment.map.clear(); + MusicLibsFragment.map=null; finish(); }