Java Code Examples for org.litepal.LitePal#findAll()

The following examples show how to use org.litepal.LitePal#findAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryBasicTest.java    From LitePal with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindAll() {
	List<Book> expectBooks = getBooks(null, null, null, null, null, null, null);
	List<Book> realBooks = LitePal.findAll(Book.class);
	assertEquals(expectBooks.size(), realBooks.size());
	for (int i = 0; i < expectBooks.size(); i++) {
		Book expectBook = expectBooks.get(i);
		Book realBook = realBooks.get(i);
		assertEquals(expectBook.getId(), realBook.getId());
		assertEquals(expectBook.getBookName(), realBook.getBookName());
		assertEquals(expectBook.getPages(), realBook.getPages());
		assertEquals(expectBook.getPrice(), realBook.getPrice());
		assertEquals(expectBook.getArea(), realBook.getArea());
		assertEquals(expectBook.getIsbn(), realBook.getIsbn());
		assertEquals(expectBook.getLevel(), realBook.getLevel());
		assertEquals(expectBook.isPublished(), realBook.isPublished());
		assertTrue(realBook.isSaved());
	}
}
 
Example 2
Source File: PlayerService.java    From Yuan-SxMusic with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    Log.d(TAG, "onCreate: true");
    mListType = FileUtil.getSong().getListType();
    if (mListType == Constant.LIST_TYPE_ONLINE) {
        mSongList = LitePal.findAll(OnlineSong.class);
    } else if (mListType == Constant.LIST_TYPE_LOCAL) {
        mLocalSongList = LitePal.findAll(LocalSong.class);
    } else if (mListType == Constant.LIST_TYPE_LOVE) {
        mLoveList = LitePal.findAll(Love.class);
    } else if (mListType == Constant.LIST_TYPE_HISTORY) {
        mHistoryList = orderHistoryList(LitePal.findAll(HistorySong.class));
        //保证最近播放列表一开始总是第一个
        Song song = FileUtil.getSong();
        song.setPosition(0);
        FileUtil.saveSong(song);
    }else if(mListType == Constant.LIST_TYPE_DOWNLOAD){
        mDownloadList = orderDownloadList(DownloadUtil.getSongFromFile(Api.STORAGE_SONG_FILE));
    }

    //开启前台服务
    startForeground(NOTIFICATION_ID,getNotification("随心跳动,开启你的音乐旅程!"));
}
 
Example 3
Source File: PlayerService.java    From Yuan-SxMusic with Apache License 2.0 6 votes vote down vote up
private void saveLocalSongInfo(int current) {
    //将歌曲的信息保存起来
    mLocalSongList = LitePal.findAll(LocalSong.class);
    Song song = new Song();
    LocalSong localSong = mLocalSongList.get(current);
    song.setPosition(current);
    song.setSongName(localSong.getName());
    song.setSinger(localSong.getSinger());
    song.setDuration(localSong.getDuration());
    song.setUrl(localSong.getUrl());
    song.setImgUrl(localSong.getPic());
    song.setSongId(localSong.getSongId());
    song.setQqId(localSong.getQqId());
    song.setOnline(false);
    song.setListType(Constant.LIST_TYPE_LOCAL);
    FileUtil.saveSong(song);
}
 
Example 4
Source File: ShowFeedFolderListDialogTask.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<String> doInBackground(Void... voids) {

    feedFolders = LitePal.findAll(FeedFolder.class);
    List<String> list = new ArrayList<>();
    for (int i = 0;i < feedFolders.size(); i++){
        list.add(feedFolders.get(i).getName());
    }


    return list;
}
 
Example 5
Source File: SearchHistoryFragment.java    From Yuan-SxMusic with Apache License 2.0 5 votes vote down vote up
private void changeList(){
    mSearchHistoryList.clear();
    mTempList = LitePal.findAll(SearchHistory.class);
    if(mTempList.size()==0){
        mRecycler.setVisibility(View.INVISIBLE);
    }else{
        mRecycler.setVisibility(View.VISIBLE);
    }
    for(int i=mTempList.size()-1;i>=0;i--){
        SearchHistory searchHistory = mTempList.get(i);
        mSearchHistoryList.add(searchHistory);
    }
}
 
Example 6
Source File: DownloadingFragment.java    From Yuan-SxMusic with Apache License 2.0 5 votes vote down vote up
private void resetDownloadInfoList(){
    mDownloadInfoList.clear();
    List<DownloadInfo> temp = LitePal.findAll(DownloadInfo.class,true);
    if(temp.size()!=0){
        mDownloadInfoList.addAll(temp);
    }

}
 
Example 7
Source File: DbHelperImp.java    From WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getAllHistoryRecord() {
    List<HistoryRecord> historyRecords = LitePal.findAll(HistoryRecord.class);
    if(CommonUtil.isEmptyList(historyRecords)) return null;
    List<String> histories = new ArrayList<>();
    for(HistoryRecord historyRecord : historyRecords) histories.add(historyRecord.getRecord());
    return histories;
}
 
Example 8
Source File: PlayerService.java    From Yuan-SxMusic with Apache License 2.0 5 votes vote down vote up
private void saveOnlineSongInfo(int current) {
    mSongList = LitePal.findAll(OnlineSong.class);
    Song song = new Song();
    song.setPosition(current);
    song.setSongId(mSongList.get(current).getSongId());
    song.setSongName(mSongList.get(current).getName());
    song.setSinger(mSongList.get(current).getSinger());
    song.setDuration(mSongList.get(current).getDuration());
    song.setUrl(mSongList.get(current).getUrl());
    song.setImgUrl(mSongList.get(current).getPic());
    song.setOnline(true);
    song.setListType(Constant.LIST_TYPE_ONLINE);
    song.setMediaId(mSongList.get(current).getMediaId());
    FileUtil.saveSong(song);
}
 
Example 9
Source File: FeedListShadowPopupView.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate() {
    super.onCreate();
    recyclerView = findViewById(R.id.recycler_view);
    //加载list
    feedFolders = LitePal.findAll(FeedFolder.class);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(linearLayoutManager);
    adapter = new FeedFolderListMainAdapter(feedFolders);
    adapter.bindToRecyclerView(recyclerView);

}
 
Example 10
Source File: TaskManagerHtml.java    From pe-protector-moe with GNU General Public License v3.0 5 votes vote down vote up
@JavascriptInterface
public String onRefresh() {
    List<MapConfigBean> list = LitePal
            .findAll(MapConfigBean.class);
    List<String> name = new ArrayList<>();
    for (MapConfigBean bean : list) {
        name.add(bean.name);
    }
    return JSON.toJSONString(name);
}
 
Example 11
Source File: ShowFeedFolderListDialogTask.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<String> doInBackground(Void... voids) {

    feedFolders = LitePal.findAll(FeedFolder.class);
    List<String> list = new ArrayList<>();
    for (int i = 0;i < feedFolders.size(); i++){
        list.add(feedFolders.get(i).getName());
    }


    return list;
}
 
Example 12
Source File: FeedListShadowPopupView.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate() {
    super.onCreate();
    recyclerView = findViewById(R.id.recycler_view);
    //加载list
    feedFolders = LitePal.findAll(FeedFolder.class);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(linearLayoutManager);
    adapter = new FeedFolderListMainAdapter(feedFolders);
    adapter.bindToRecyclerView(recyclerView);

}
 
Example 13
Source File: DbHelperImpl.java    From Yuan-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getAllHistory() {
    List<History> historyList = LitePal.findAll(History.class);
    if(CommonUtils.isEmptyList(historyList)) return null;
    List<String> histories = new ArrayList<>();
    for(int i=historyList.size()-1;i>=0;i--){
        histories.add(historyList.get(i).getKey());
    }
    return histories;
}
 
Example 14
Source File: TimingService.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
/**
     * 方式三:采用AlarmManager机制
     */
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        if (intent!=null){
            boolean isNewAlarm = intent.getBooleanExtra("isNewAlarm",false);//是否需要重新设置定时器

            this.interval = UserPreference.queryValueByKey(UserPreference.tim_interval,"-1");
            int is_open = Integer.parseInt(UserPreference.queryValueByKey(UserPreference.tim_is_open,"0"));

            startForeground(2,createNotice("后台更新守护服务","当看到该通知说明服务正常周期运行,否则表示服务运行失败"));

            if (this.interval.equals("-1")){
                stopForeground(true);
                stopSelf();
            }else {
                //TODO: 如果已经启动了定时器,当打开应用的时候,不应该再次重新设置定时器
                //初始化参数
                int temp = Integer.parseInt(this.interval);//分钟
                AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
                long triggerAtTime = SystemClock.elapsedRealtime() + temp*60*1000;//每隔temp分钟执行一次
//            long triggerAtTime = SystemClock.elapsedRealtime() + 30*1000;//每隔30s执行一次
                Intent intent2 = new Intent(this, AutoUpdateReceiver.class);
                //如果存在这个pendingIntent 则复用

                PendingIntent pi = null;

                if (isNewAlarm){
                    PendingIntent.getBroadcast(this, 0, intent2, PendingIntent.FLAG_CANCEL_CURRENT);//重新创建定时器
                }else {
                    PendingIntent.getBroadcast(this, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);//复用之前的定时器
                }

                // pendingIntent 为发送广播
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    //android 6.0以上
                    manager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), pi);
                } else{
                    manager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi);
                }

                //执行任务
                if (is_open == 1){//说明是定时器启动的,只有定时器启动这个service才会执行请求数据的任务
                    UserPreference.updateOrSaveValueByKey(UserPreference.tim_is_open,"0");

                    ALog.d("执行定时任务" + DateUtil.getNowDateStr());
                    List<Feed> feedList = LitePal.findAll(Feed.class);

                    //初始化参数
                    this.okNum = 0;
                    this.num =feedList.size();
                    this.feedItemNum = LitePal.count(FeedItem.class);

                    for (int i = 0;i < feedList.size();i++){
                        //改为线程池调用
                        RequestFeedListDataTask task = new RequestFeedListDataTask(new RequestDataCallback() {
                            @Override
                            public void onSuccess(List<FeedItem> feedItemList) {
                                //主线程
                                updateUI();
                            }
                        });

                        mNotificationManager.notify(1,createNotice("后台更新:开始获取数据中……",0));
                        ExecutorService mExecutor = Executors.newCachedThreadPool();
                        task.executeOnExecutor(mExecutor,feedList.get(i));
                    }

                }
            }

        }
         return super.onStartCommand(intent, flags, startId);
    }
 
Example 15
Source File: WeatherActivity.java    From DongWeather with Apache License 2.0 4 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    Log.d(TAG, "onStart: ");
    //这里也可以写在onActivityResult活动回调函数里面
    if (INMODE == INMODE_DIRECT) {
        //直接进入城市添加的,重新初始化导航页
        initGuideView();
    }
    if (!ChooseAreaActivity.isBackFromOnItem){
        if (!ChooseAreaActivity.isBackFormBackBtn && INMODE == INMODE_INDIRECT) {
            //判断是否是从添加城市间接返回的,是的话执行下列操作
            Log.d(TAG, "onStart: in");
            SharedPreferences shared = getSharedPreferences("data", MODE_PRIVATE);
            SharedPreferences.Editor editor = getSharedPreferences("data", MODE_PRIVATE).edit();
            //从城市管理间接添加城市时返回执行这里
            String weatherId = shared.getString("weatherID", "");
            if (weatherId != null) {
                if (weatherId.equals("")) {
                    Log.d(TAG, "onStart: data is null");
                } else {
                    selectedCountisList = LitePal.findAll(SelectedCounty.class);
                    if (!isLocationCountyRemove && null != locationCountyWeatherId) {
                        //如果定位城市存在且未删除,则添加定位城市
                        SelectedCounty selectedCounty = new SelectedCounty();
                        selectedCounty.setWeatherId(locationCountyWeatherId);
                        selectedCountisList.add(0, selectedCounty);
                    }
                    initGuideView();
                    LayoutInflater layoutInflater = getLayoutInflater();
                    viewList.add(viewList.size(), (View) layoutInflater.inflate(R.layout.weather_fragment, null));
                    pagerAdapter.notifyDataSetChanged();
                    vp.setCurrentItem(viewList.size() - 1);
                    currentPosition = viewList.size() - 1;
                    requestWeatherAsync(weatherId);
                    //使页面切换时不重复加载
                    vp.setOffscreenPageLimit(viewList.size());
                }
            }
            editor.clear();
        }
    }
    ChooseAreaActivity.isBackFormBackBtn = false;
    ChooseAreaActivity.isBackFromOnItem = false;
    //待解决的问题,因为create之后必须点击才会加载后面的页数,
    //但是传来的position又不能放到后面加载,所以出现问题了
    //设置从窗口传来的定位
    if (widgetStartPosition >= 0 && widgetStartPosition < viewList.size()) {
        //判断是否定位成功
        if (locationCountyWeatherId != null && locationCountyWeatherName != null){
            vp.setCurrentItem(widgetStartPosition + 1);
            currentPosition = widgetStartPosition + 1;
        } else {
            vp.setCurrentItem(widgetStartPosition);
            currentPosition = widgetStartPosition;
        }
        //防止被多次定页
        widgetStartPosition = -1;
    }
}
 
Example 16
Source File: QueryBasicTest.java    From LitePal with Apache License 2.0 4 votes vote down vote up
@Test
public void testFindMul() {
	short isbn1 = 30017;
	Book book1 = new Book();
	book1.setArea(1.5f);
	book1.setBookName("Android Second Line");
	book1.setIsbn(isbn1);
	book1.setLevel('B');
	book1.setPages(434);
	book1.setPrice(40.99);
	book1.setPublished(true);
	book1.save();
	short isbn2 = 30014;
	Book book2 = new Book();
	book2.setArea(8.8f);
	book2.setBookName("Android Third Line");
	book2.setIsbn(isbn2);
	book2.setLevel('C');
	book2.setPages(411);
	book2.setPrice(35.99);
	book2.setPublished(false);
	book2.save();
	List<Book> bookList = LitePal.findAll(Book.class, book1.getId(), book2.getId());
	assertEquals(2, bookList.size());
	for (Book book : bookList) {
		if (book.getId() == book1.getId()) {
			assertEquals(1.5f, book.getArea());
			assertEquals("Android Second Line", book.getBookName());
			assertEquals(isbn1, book.getIsbn());
			assertEquals('B', book.getLevel());
			assertTrue(434 == book.getPages());
			assertEquals(40.99, book.getPrice());
			assertTrue(book.isPublished());
			assertTrue(book.isSaved());
			continue;
		} else if (book.getId() == book2.getId()) {
			assertEquals(8.8f, book.getArea());
			assertEquals("Android Third Line", book.getBookName());
			assertEquals(isbn2, book.getIsbn());
			assertEquals('C', book.getLevel());
			assertTrue(411 == book.getPages());
			assertEquals(35.99, book.getPrice());
			assertFalse(book.isPublished());
			assertTrue(book.isSaved());
			continue;
		}
		fail();
	}
}
 
Example 17
Source File: PoetryActivity.java    From PoetryWeather with Apache License 2.0 4 votes vote down vote up
/**
 * swipeRecycleView处理
 */
private void showSwipeRecycleView() {
    //初始化自定义诗词列表
    poetryDbList = LitePal.findAll(PoetryDb.class);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    ownPoetryAdapter = new OwnPoetryAdapter(poetryDbList);

    //获取手机屏幕高度
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int width = dm.widthPixels;
    recyclerView.addItemDecoration(new DefaultItemDecoration(getResources().getColor(R.color.gray),width,1));
    //滑动菜单
    SwipeMenuCreator mSwipeMenuCreator = new SwipeMenuCreator() {
        @Override
        public void onCreateMenu(SwipeMenu swipeLeftMenu, SwipeMenu swipeRightMenu, int viewType) {
            int height = ViewGroup.LayoutParams.MATCH_PARENT;
            SwipeMenuItem editItem = new SwipeMenuItem(PoetryActivity.this)
                    .setText("编辑")
                    .setWidth(200)
                    .setHeight(height)
                    .setTextSize(16)
                    .setBackground(R.color.bluishWhite);
            SwipeMenuItem deleteItem = new SwipeMenuItem(PoetryActivity.this)
                    .setText("删除")
                    .setTextColorResource(R.color.qmui_config_color_white)
                    .setWidth(200)
                    .setHeight(height)
                    .setTextSize(16)
                    .setBackground(R.color.qmui_config_color_red);
            swipeLeftMenu.addMenuItem(editItem);
            swipeRightMenu.addMenuItem(deleteItem);
        }
    };
    //设置监听
    SwipeMenuItemClickListener mMenuItemClickListener = new SwipeMenuItemClickListener() {
        @Override
        public void onItemClick(SwipeMenuBridge menuBridge) {
            menuBridge.closeMenu();
            // 左侧还是右侧菜单。
            int direction = menuBridge.getDirection();
            // RecyclerView的Item的position。
            int adapterPosition = menuBridge.getAdapterPosition();
            // 菜单在RecyclerView的Item中的Position。
            int menuPosition = menuBridge.getPosition();
            Log.d(TAG, "onItemClick: 位置"+adapterPosition);
            if (direction == SwipeMenuRecyclerView.LEFT_DIRECTION) {
                Intent intent = new Intent(PoetryActivity.this, AddAndEditPoetryActivity.class);
                intent.putExtra("addOrEdit","edit");
                int editId = poetryDbList.get(adapterPosition).getPoetryDb_id();
                intent.putExtra("editId",editId+"");
                startActivity(intent);
            } else if (direction == SwipeMenuRecyclerView.RIGHT_DIRECTION) {
                final boolean[] isCancle = {false};
                Handler handler = new Handler();
                Snackbar.make(recyclerView,"正在删除该条诗词数据",Snackbar.LENGTH_SHORT)
                        .setAction("取消", new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                isCancle[0] = true;
                                Toast.makeText(PoetryActivity.this,"已取消删除",Toast.LENGTH_SHORT).show();
                            }
                        }).show();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (!isCancle[0]) {
                            int deleteId = poetryDbList.get(adapterPosition).getPoetryDb_id();
                            LitePal.deleteAll(PoetryDb.class, "poetryDb_id = ?", String.valueOf(deleteId));
                            poetryDbList.remove(adapterPosition);
                            ownPoetryAdapter.notifyItemRemoved(adapterPosition);
                        }
                    }
                },1800);

            }

        }
    };
    recyclerView.setSwipeMenuCreator(mSwipeMenuCreator);
    recyclerView.setSwipeMenuItemClickListener(mMenuItemClickListener);
    recyclerView.setAdapter(ownPoetryAdapter);
}
 
Example 18
Source File: CollectionTabLayoutTask.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected Void doInBackground(Void... voids) {

    List<CollectionFolder> list = LitePal.findAll(CollectionFolder.class);


    //标题列表


    for (CollectionFolder collectionFolder : list) {
        pageTitleList.add(collectionFolder.getName());
         CollectionListFragment fragment = CollectionListFragment.newInstance(collectionFolder.getId(), activity);
        fragmentList.add(fragment);
    }

    return null;

}
 
Example 19
Source File: TimingService.java    From Focus with GNU General Public License v3.0 4 votes vote down vote up
/**
     * 方式三:采用AlarmManager机制
     */
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        if (intent!=null){
            boolean isNewAlarm = intent.getBooleanExtra("isNewAlarm",false);//是否需要重新设置定时器

            this.interval = UserPreference.queryValueByKey(UserPreference.tim_interval,"-1");
            int is_open = Integer.parseInt(UserPreference.queryValueByKey(UserPreference.tim_is_open,"0"));

            startForeground(2,createNotice("后台更新守护服务","当看到该通知说明服务正常周期运行,否则表示服务运行失败"));

            if (this.interval.equals("-1")){
                stopForeground(true);
                stopSelf();
            }else {
                //TODO: 如果已经启动了定时器,当打开应用的时候,不应该再次重新设置定时器
                //初始化参数
                int temp = Integer.parseInt(this.interval);//分钟
                AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
                long triggerAtTime = SystemClock.elapsedRealtime() + temp*60*1000;//每隔temp分钟执行一次
//            long triggerAtTime = SystemClock.elapsedRealtime() + 30*1000;//每隔30s执行一次
                Intent intent2 = new Intent(this, AutoUpdateReceiver.class);
                //如果存在这个pendingIntent 则复用

                PendingIntent pi = null;

                if (isNewAlarm){
                    PendingIntent.getBroadcast(this, 0, intent2, PendingIntent.FLAG_CANCEL_CURRENT);//重新创建定时器
                }else {
                    PendingIntent.getBroadcast(this, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);//复用之前的定时器
                }

                // pendingIntent 为发送广播
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    //android 6.0以上
                    manager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), pi);
                } else{
                    manager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi);
                }

                //执行任务
                if (is_open == 1){//说明是定时器启动的,只有定时器启动这个service才会执行请求数据的任务
                    UserPreference.updateOrSaveValueByKey(UserPreference.tim_is_open,"0");

                    ALog.d("执行定时任务" + DateUtil.getNowDateStr());
                    List<Feed> feedList = LitePal.findAll(Feed.class);

                    //初始化参数
                    this.okNum = 0;
                    this.num =feedList.size();
                    this.feedItemNum = LitePal.count(FeedItem.class);

                    for (int i = 0;i < feedList.size();i++){
                        //改为线程池调用
                        RequestFeedListDataTask task = new RequestFeedListDataTask(new RequestDataCallback() {
                            @Override
                            public void onSuccess(List<FeedItem> feedItemList) {
                                //主线程
                                updateUI();
                            }
                        });

                        mNotificationManager.notify(1,createNotice("后台更新:开始获取数据中……",0));
                        ExecutorService mExecutor = Executors.newCachedThreadPool();
                        task.executeOnExecutor(mExecutor,feedList.get(i));
                    }

                }
            }

        }
         return super.onStartCommand(intent, flags, startId);
    }
 
Example 20
Source File: PlayerService.java    From Yuan-SxMusic with Apache License 2.0 4 votes vote down vote up
/**
 * 播放音乐
 *
 * @param
 */

public void play(int listType) {
    try {
        mListType = listType;
        if (mListType == Constant.LIST_TYPE_ONLINE) {
            mSongList = LitePal.findAll(OnlineSong.class);
            EventBus.getDefault().post(new SongAlbumEvent());
        } else if (mListType == Constant.LIST_TYPE_LOCAL) {
            mLocalSongList = LitePal.findAll(LocalSong.class);
            EventBus.getDefault().post(new SongLocalEvent()); //发送本地歌曲改变事件
        } else if (mListType == Constant.LIST_TYPE_LOVE) {
            mLoveList = orderList(LitePal.findAll(Love.class));
            EventBus.getDefault().post(new SongCollectionEvent(true));//发送歌曲改变事件
        } else if (mListType == Constant.LIST_TYPE_HISTORY) {
            EventBus.getDefault().post(new SongHistoryEvent());  //发送随机歌曲改变事件
        }else if(mListType == Constant.LIST_TYPE_DOWNLOAD){
            mDownloadList =orderDownloadList(DownloadUtil.getSongFromFile(Api.STORAGE_SONG_FILE));
            EventBus.getDefault().post(new SongDownloadedEvent()); //发送下载歌曲改变的消息
        }
        mCurrent = FileUtil.getSong().getPosition();
        mediaPlayer.reset();//把各项参数恢复到初始状态
        if (mListType == Constant.LIST_TYPE_LOCAL) {
            mediaPlayer.setDataSource(mLocalSongList.get(mCurrent).getUrl());
            startPlay();
        } else if (mListType == Constant.LIST_TYPE_ONLINE) {
            getSongUrl(mSongList.get(mCurrent).getSongId());
        } else if (mListType == Constant.LIST_TYPE_LOVE) {
            mediaPlayer.setDataSource(mLoveList.get(mCurrent).getUrl());
            startPlay();
        } else if(mListType == Constant.LIST_TYPE_HISTORY){
            mediaPlayer.setDataSource(mHistoryList.get(mCurrent).getUrl());
            startPlay();
        }else if(mListType == Constant.LIST_TYPE_DOWNLOAD){
            Log.d(TAG, "play: "+mDownloadList.get(mCurrent).getUrl());
            mediaPlayer.setDataSource(mDownloadList.get(mCurrent).getUrl());
            startPlay();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}