Commit 0689aabb authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Remove useless Context references

parent 5e53e73c
......@@ -93,7 +93,7 @@ public class MediaLibrary {
mItemListLock = new ReentrantReadWriteLock();
}
public void loadMediaItems(Context context, boolean restart) {
public void loadMediaItems(boolean restart) {
if (restart && isWorking()) {
/* do a clean restart if a scan is ongoing */
mRestart = true;
......
......@@ -89,6 +89,8 @@ public class MainActivity extends AudioPlayerContainerActivity implements OnItem
private static final int ACTIVITY_HIDE_PROGRESSBAR = 4;
private static final int ACTIVITY_SHOW_TEXTINFO = 5;
MediaLibrary mMediaLibrary;
private SidebarAdapter mSidebarAdapter;
private HackyDrawerLayout mDrawerLayout;
private ListView mListView;
......@@ -133,7 +135,8 @@ public class MainActivity extends AudioPlayerContainerActivity implements OnItem
}
/* Load media items from database and storage */
MediaLibrary.getInstance().loadMediaItems();
mMediaLibrary = MediaLibrary.getInstance();
mMediaLibrary.loadMediaItems();
/*** Start initializing the UI ***/
......@@ -223,7 +226,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements OnItem
/* Load media items from database and storage */
if (mScanNeeded)
MediaLibrary.getInstance().loadMediaItems();
mMediaLibrary.loadMediaItems();
if (mSlidingPane.getState() == mSlidingPane.STATE_CLOSED)
mActionBar.hide();
}
......@@ -277,9 +280,9 @@ public class MainActivity extends AudioPlayerContainerActivity implements OnItem
super.onPause();
/* Check for an ongoing scan that needs to be resumed during onResume */
mScanNeeded = MediaLibrary.getInstance().isWorking();
mScanNeeded = mMediaLibrary.isWorking();
/* Stop scanning for files */
MediaLibrary.getInstance().stop();
mMediaLibrary.stop();
/* Save the tab status in pref */
SharedPreferences.Editor editor = mSettings.edit();
editor.putString("fragment", mCurrentFragment);
......@@ -491,11 +494,11 @@ public class MainActivity extends AudioPlayerContainerActivity implements OnItem
break;
// Refresh
case R.id.ml_menu_refresh:
if (!MediaLibrary.getInstance().isWorking()) {
if (!mMediaLibrary.isWorking()) {
if(current != null && current instanceof IRefreshable)
((IRefreshable) current).refresh();
else
MediaLibrary.getInstance().loadMediaItems(this, true);
mMediaLibrary.loadMediaItems(true);
}
break;
// Restore last playlist
......@@ -538,7 +541,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements OnItem
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ACTIVITY_RESULT_PREFERENCES) {
if (resultCode == PreferencesActivity.RESULT_RESCAN)
MediaLibrary.getInstance().loadMediaItems(this, true);
mMediaLibrary.loadMediaItems(true);
else if (resultCode == PreferencesActivity.RESULT_RESTART) {
Intent intent = getIntent();
finish();
......
......@@ -121,7 +121,7 @@ public class SecondaryActivity extends AudioPlayerContainerActivity {
break;
case R.id.ml_menu_refresh:
if (!MediaLibrary.getInstance().isWorking())
MediaLibrary.getInstance().loadMediaItems(this, true);
MediaLibrary.getInstance().loadMediaItems(true);
break;
}
return super.onOptionsItemSelected(item);
......
......@@ -548,7 +548,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
@Override
public void onRefresh() {
if (!MediaLibrary.getInstance().isWorking())
MediaLibrary.getInstance().loadMediaItems(getActivity(), true);
MediaLibrary.getInstance().loadMediaItems(true);
}
@Override
......
......@@ -321,7 +321,7 @@ public class MediaInfoFragment extends ListFragment {
break;
case EXIT:
fragment.getActivity().finish();
MediaLibrary.getInstance().loadMediaItems(fragment.getActivity(), true);
MediaLibrary.getInstance().loadMediaItems(true);
break;
case SHOW_SUBTITLES:
fragment.mSubtitles.setVisibility(View.VISIBLE);
......
......@@ -30,7 +30,6 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
......@@ -123,7 +122,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
mAudioController = AudioServiceController.getInstance();
mVideoAdapter = new VideoListAdapter(getActivity(), this);
mVideoAdapter = new VideoListAdapter(this);
mMediaLibrary = MediaLibrary.getInstance();
if (savedInstanceState != null)
......@@ -550,7 +549,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
@Override
public void onRefresh() {
if (getActivity()!=null && !MediaLibrary.getInstance().isWorking())
MediaLibrary.getInstance().loadMediaItems(getActivity(), true);
MediaLibrary.getInstance().loadMediaItems(true);
}
@Override
......
......@@ -36,6 +36,7 @@ import android.widget.TextView;
import org.videolan.vlc.MediaGroup;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.util.BitmapCache;
import org.videolan.vlc.util.BitmapUtil;
import org.videolan.vlc.util.Strings;
......@@ -54,12 +55,10 @@ public class VideoListAdapter extends ArrayAdapter<MediaWrapper>
private int mSortDirection = 1;
private int mSortBy = SORT_BY_TITLE;
private boolean mListMode = false;
private Context mContext;
private VideoGridFragment mFragment;
public VideoListAdapter(Context context, VideoGridFragment fragment) {
super(context, 0);
mContext = context;
public VideoListAdapter(VideoGridFragment fragment) {
super(fragment.getActivity(), 0);
mFragment = fragment;
}
......@@ -218,7 +217,7 @@ public class VideoListAdapter extends ArrayAdapter<MediaWrapper>
/* Color state */
ColorStateList titleColor = v.getResources().getColorStateList(
Util.getResourceFromAttribute(mContext, R.attr.list_title));
Util.getResourceFromAttribute(getContext(), R.attr.list_title));
holder.title.setTextColor(titleColor);
if (media instanceof MediaGroup)
......
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