@Override public void handleMessage(Message msg) { if (msg.what == 1) { mAdapter = new MusicFolderAdapter( SelectFolderActivity.this, mPathList, mFolderPathInDB, 2, getApplicationContext()); } else { mPathList = MusicUtils.getPathList(SelectFolderActivity.this); String[] folderPathinDB = MusicUtils.getFolderPath(SelectFolderActivity.this); if (mFolderPathInDB != null && mFolderPathInDB.size() != 0) { mFolderPathInDB.clear(); } if (mPathList != null && folderPathinDB != null) { if (folderPathinDB.length > 0) { for (int i = 0; i < folderPathinDB.length; i++) { mFolderPathInDB.add(folderPathinDB[i]); } } else { for (int i = 0; i < mPathList.size(); i++) { mFolderPathInDB.add(mPathList.get(i)); } } mAdapter = new MusicFolderAdapter( SelectFolderActivity.this, mPathList, mFolderPathInDB, mIsOuter, getApplicationContext()); } } if (mAdapter != null) { mList.setAdapter(mAdapter); mAdapter.notifyDataSetChanged(); } setupNoSongsView(); if (MusicUtils.sService != null && Artistactionbar != null) { Artistactionbar.setMediaService(MusicUtils.sService); } }
@Override protected void onDestroy() { mAdapter = null; if (Artistactionbar != null) { Artistactionbar.destroyNowplaying(); } if (mIsOuter == 1) { unregisterReceiver(mScanListener); } if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); bitmap = null; } ExitApplication exit = (ExitApplication) getApplication(); exit.removeActivity(this); System.gc(); super.onDestroy(); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); ExitApplication exit = (ExitApplication) getApplication(); exit.addActivity(this); Intent intent = this.getIntent(); mIsOuter = intent.getIntExtra("isOuter", 0); if (mIsOuter == 1) { requestWindowFeature(Window.FEATURE_NO_TITLE); setTheme(android.R.style.Theme_Holo_Light_NoActionBar); setContentView(R.layout.alltracklist); Artistactionbar = (NowPlayingController) findViewById(R.id.nowplaying_track); Artistactionbar.setActivity(this); if (MusicUtils.sService != null && Artistactionbar != null) { Artistactionbar.setMediaService(MusicUtils.sService); } mList = (ListView) findViewById(R.id.select_folder_list); mList.setCacheColorHint(0); mList.setDivider(null); mList.setOnCreateContextMenuListener(this); mNoSongsPaddingTop = getResources().getDimensionPixelOffset(R.dimen.no_songs_padding_top); setupNoSongsView(); IntentFilter f = new IntentFilter(); f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED); f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); f.addAction(Intent.ACTION_MEDIA_UNMOUNTED); f.addAction(Intent.ACTION_MEDIA_SHARED); f.addDataScheme("file"); registerReceiver(mScanListener, f); } else { setTheme(R.style.SpiltActionTheme); setContentView(R.layout.select_folder); this.setTitle(R.string.select_folder); mList = (ListView) findViewById(R.id.select_folder_list); mList.setCacheColorHint(0); } if (mIsOuter == 1) { mLinear = (LinearLayout) findViewById(R.id.linear_trackpage); mLinear.post( new Runnable() { public void run() { // TODO Auto-generated method stub Bitmap back = MusicUtils.getDefaultBg(getApplicationContext(), 0); MusicUtils.setBackground(new WeakReference<View>(mLinear), back); } }); } if (mIsOuter != 1) { mActionMode = startSupportActionMode(new SFCallBack(SelectFolderActivity.this)); setAdapter(); } }