Commit d5c93e7e authored by fallenstardust's avatar fallenstardust

只由mainActivity初始化一次

parent c02040ac
...@@ -278,9 +278,7 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView ...@@ -278,9 +278,7 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
//设置当前卡组 //设置当前卡组
setCurDeck(rs); setCurDeck(rs);
//设置收藏夹 //设置收藏夹
ConfigManager systemConf = DataManager.openConfig(mSettings.getSystemConfig()); SparseArray<Card> id = mCardLoader.readCards(ConfigManager.mLines);
systemConf.read();
SparseArray<Card> id = mCardLoader.readCards(systemConf.mLines);
if (id != null) { if (id != null) {
for (int i = 0; i < id.size(); i++) for (int i = 0; i < id.size(); i++)
Favorite.add(id.valueAt(i)); Favorite.add(id.valueAt(i));
...@@ -356,9 +354,10 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView ...@@ -356,9 +354,10 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
} }
} }
} }
@Override @Override
public void onSearchResult(List<Card> cardInfos, boolean isHide) { public void onSearchResult(List<Card> cardInfos, boolean isHide) {
super.onSearchResult(cardInfos,isHide); super.onSearchResult(cardInfos, isHide);
if (!isHide) if (!isHide)
showResult(false); showResult(false);
} }
......
...@@ -32,6 +32,8 @@ import cn.garymb.ygomobile.utils.FileUtils; ...@@ -32,6 +32,8 @@ import cn.garymb.ygomobile.utils.FileUtils;
import cn.garymb.ygomobile.utils.IOUtils; import cn.garymb.ygomobile.utils.IOUtils;
import cn.garymb.ygomobile.utils.NetUtils; import cn.garymb.ygomobile.utils.NetUtils;
import cn.garymb.ygomobile.utils.YGOUtil; import cn.garymb.ygomobile.utils.YGOUtil;
import ocgcore.ConfigManager;
import ocgcore.DataManager;
import static cn.garymb.ygomobile.Constants.ACTION_RELOAD; import static cn.garymb.ygomobile.Constants.ACTION_RELOAD;
import static cn.garymb.ygomobile.Constants.NETWORK_IMAGE; import static cn.garymb.ygomobile.Constants.NETWORK_IMAGE;
...@@ -55,6 +57,8 @@ public class MainActivity extends HomeActivity { ...@@ -55,6 +57,8 @@ public class MainActivity extends HomeActivity {
private ImageUpdater mImageUpdater; private ImageUpdater mImageUpdater;
private boolean enableStart; private boolean enableStart;
public ConfigManager favConf = DataManager.openConfig(AppsSettings.get().getSystemConfig());
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -64,6 +68,8 @@ public class MainActivity extends HomeActivity { ...@@ -64,6 +68,8 @@ public class MainActivity extends HomeActivity {
// ActivityCompat.requestPermissions(this, PERMISSIONS, 0); // ActivityCompat.requestPermissions(this, PERMISSIONS, 0);
//资源复制 //资源复制
checkRes(); checkRes();
//加载收藏夹
favConf.read();
} }
@SuppressLint({"StringFormatMatches", "StringFormatInvalid"}) @SuppressLint({"StringFormatMatches", "StringFormatInvalid"})
......
...@@ -211,12 +211,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -211,12 +211,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
} }
} }
//设置收藏夹
ConfigManager systemConf = DataManager.openConfig(mSettings.getSystemConfig());
systemConf.read();
//systemConf.setFontSize(mSettings.getFontSize());//已弃用
systemConf.close();
//如果是新版本 //如果是新版本
if (needsUpdate) { if (needsUpdate) {
//复制卡组 //复制卡组
......
...@@ -175,9 +175,6 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -175,9 +175,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
} catch (Exception e) { } catch (Exception e) {
} }
ConfigManager configManager = DataManager.openConfig(mSettings.getSystemConfig());
//configManager.setFontSize(size);//已弃用
configManager.close();
} }
if (preference instanceof CheckBoxPreference) { if (preference instanceof CheckBoxPreference) {
CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference; CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference;
......
...@@ -15,7 +15,7 @@ import cn.garymb.ygomobile.utils.IOUtils; ...@@ -15,7 +15,7 @@ import cn.garymb.ygomobile.utils.IOUtils;
public class ConfigManager implements Closeable { public class ConfigManager implements Closeable {
public List<Integer> mLines = new ArrayList<>(); public static List<Integer> mLines = new ArrayList<>();
private File file; private File file;
ConfigManager(File file) { ConfigManager(File file) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment