do not implement OnScanCompleted with activities
This commit is contained in:
parent
714b1804da
commit
d36b8142f3
|
@ -43,8 +43,7 @@ import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity
|
public class MainActivity extends AppCompatActivity
|
||||||
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener,
|
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener {
|
||||||
MediaScannerConnection.OnScanCompletedListener {
|
|
||||||
@BindView(R.id.directories_grid) GridView gridView;
|
@BindView(R.id.directories_grid) GridView gridView;
|
||||||
|
|
||||||
private static final int STORAGE_PERMISSION = 1;
|
private static final int STORAGE_PERMISSION = 1;
|
||||||
|
@ -305,7 +304,13 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
updatedFiles.add(newDir.getAbsolutePath());
|
updatedFiles.add(newDir.getAbsolutePath());
|
||||||
final String[] changedFiles = updatedFiles.toArray(new String[updatedFiles.size()]);
|
final String[] changedFiles = updatedFiles.toArray(new String[updatedFiles.size()]);
|
||||||
MediaScannerConnection.scanFile(getApplicationContext(), changedFiles, null, MainActivity.this);
|
MediaScannerConnection
|
||||||
|
.scanFile(getApplicationContext(), changedFiles, null, new MediaScannerConnection.OnScanCompletedListener() {
|
||||||
|
@Override
|
||||||
|
public void onScanCompleted(String path, Uri uri) {
|
||||||
|
scanCompleted(path);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
Utils.showToast(getApplicationContext(), R.string.rename_folder_error);
|
||||||
}
|
}
|
||||||
|
@ -379,8 +384,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void scanCompleted(final String path) {
|
||||||
public void onScanCompleted(final String path, final Uri uri) {
|
|
||||||
final File dir = new File(path);
|
final File dir = new File(path);
|
||||||
if (dir.isDirectory()) {
|
if (dir.isDirectory()) {
|
||||||
dirs = new ArrayList<>(getDirectories().values());
|
dirs = new ArrayList<>(getDirectories().values());
|
||||||
|
|
|
@ -37,8 +37,7 @@ import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class MediaActivity extends AppCompatActivity
|
public class MediaActivity extends AppCompatActivity
|
||||||
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, MediaScannerConnection.OnScanCompletedListener,
|
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener {
|
||||||
GridView.OnTouchListener {
|
|
||||||
@BindView(R.id.media_grid) GridView gridView;
|
@BindView(R.id.media_grid) GridView gridView;
|
||||||
|
|
||||||
private List<Medium> media;
|
private List<Medium> media;
|
||||||
|
@ -204,7 +203,14 @@ public class MediaActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] deletedPaths = toBeDeleted.toArray(new String[toBeDeleted.size()]);
|
final String[] deletedPaths = toBeDeleted.toArray(new String[toBeDeleted.size()]);
|
||||||
MediaScannerConnection.scanFile(this, deletedPaths, null, this);
|
MediaScannerConnection.scanFile(this, deletedPaths, null, new MediaScannerConnection.OnScanCompletedListener() {
|
||||||
|
@Override
|
||||||
|
public void onScanCompleted(String path, Uri uri) {
|
||||||
|
if (media != null && media.isEmpty()) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
toBeDeleted.clear();
|
toBeDeleted.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,13 +282,6 @@ public class MediaActivity extends AppCompatActivity
|
||||||
selectedItemsCnt = 0;
|
selectedItemsCnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScanCompleted(String path, Uri uri) {
|
|
||||||
if (media.isEmpty()) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
if (isSnackbarShown) {
|
if (isSnackbarShown) {
|
||||||
|
|
|
@ -36,8 +36,7 @@ import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
|
||||||
public class ViewPagerActivity extends AppCompatActivity
|
public class ViewPagerActivity extends AppCompatActivity
|
||||||
implements ViewPager.OnPageChangeListener, View.OnSystemUiVisibilityChangeListener, MediaScannerConnection.OnScanCompletedListener,
|
implements ViewPager.OnPageChangeListener, View.OnSystemUiVisibilityChangeListener, ViewPager.OnTouchListener {
|
||||||
ViewPager.OnTouchListener {
|
|
||||||
@BindView(R.id.undo_delete) View undoBtn;
|
@BindView(R.id.undo_delete) View undoBtn;
|
||||||
@BindView(R.id.view_pager) MyViewPager pager;
|
@BindView(R.id.view_pager) MyViewPager pager;
|
||||||
|
|
||||||
|
@ -167,7 +166,12 @@ public class ViewPagerActivity extends AppCompatActivity
|
||||||
if (file.delete()) {
|
if (file.delete()) {
|
||||||
beingDeleted = toBeDeleted;
|
beingDeleted = toBeDeleted;
|
||||||
final String[] deletedPath = new String[]{toBeDeleted};
|
final String[] deletedPath = new String[]{toBeDeleted};
|
||||||
MediaScannerConnection.scanFile(this, deletedPath, null, this);
|
MediaScannerConnection.scanFile(this, deletedPath, null, new MediaScannerConnection.OnScanCompletedListener() {
|
||||||
|
@Override
|
||||||
|
public void onScanCompleted(String path, Uri uri) {
|
||||||
|
scanCompleted();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
toBeDeleted = "";
|
toBeDeleted = "";
|
||||||
undoBtn.setVisibility(View.GONE);
|
undoBtn.setVisibility(View.GONE);
|
||||||
|
@ -385,13 +389,12 @@ public class ViewPagerActivity extends AppCompatActivity
|
||||||
adapter.updateUiVisibility(isFullScreen, pos);
|
adapter.updateUiVisibility(isFullScreen, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void scanCompleted() {
|
||||||
public void onScanCompleted(String path, Uri uri) {
|
|
||||||
beingDeleted = "";
|
beingDeleted = "";
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (media.size() <= 1) {
|
if (media != null && media.size() <= 1) {
|
||||||
reloadViewPager();
|
reloadViewPager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue