Commit 7a1bcd66 authored by Donald's avatar Donald

fix hide/unhide album

parent f268f39d
......@@ -95,11 +95,11 @@ public class AlbumsActivity extends AppCompatActivity {
@Override
public void onResume() {
checkPermissions();
albums.clearSelectedAlbums();
updateSelectedStuff();
invalidateOptionsMenu();
checkPermissions();
adapt.notifyDataSetChanged();
super.onResume();
}
......@@ -163,8 +163,6 @@ public class AlbumsActivity extends AppCompatActivity {
break;
case 2: //hidden
hidden = true;
//albums.loadPreviewHiddenAlbums();
//adapt.notifyDataSetChanged();
checkPermissions();
break;
case 6: //settings
......@@ -410,6 +408,7 @@ public class AlbumsActivity extends AppCompatActivity {
if (hidden) {
albums.loadPreviewHiddenAlbums();
//albums.LogAlbums();
}
else {
// db.updatePhotos();
......
......@@ -3,6 +3,7 @@ package com.leafpic.app.Base;
import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.util.Log;
import com.leafpic.app.utils.string;
import java.io.File;
......@@ -123,6 +124,14 @@ public class HandlingAlbums {
public void hideAlbum(Album a) {
hideAlbum(a.Path);
HiddenPhotosHandler db = new HiddenPhotosHandler(context);
MadiaStoreHandler mediaStoreHandler = new MadiaStoreHandler(context);
for (Photo photo : mediaStoreHandler.getAlbumPhotos(a)) {
photo.FolderPath = a.Path;
db.addPhoto(photo);
}
db.close();
dispAlbums.remove(a);
}
......@@ -141,6 +150,29 @@ public class HandlingAlbums {
}
}
public void hideAlbum(String path, ArrayList<Photo> ph) {
File dirName = new File(path);
File file = new File(dirName, ".nomedia");
if (!file.exists()) {
try {
FileOutputStream out = new FileOutputStream(file);
out.flush();
out.close();
scanFile(new String[]{file.getAbsolutePath()});
HiddenPhotosHandler db = new HiddenPhotosHandler(context);
for (Photo photo : ph) {
photo.FolderPath = dirName.getAbsolutePath();
db.addPhoto(photo);
}
db.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void renameAlbum(String olderPath, String name) {
try {
File from = new File(olderPath);
......@@ -164,6 +196,18 @@ public class HandlingAlbums {
db.close();
}
public void unHideSelectedAlbums() {
for (Album selectedAlbum : selectedAlbums)
unHideAlbum(selectedAlbum);
clearSelectedAlbums();
}
public void unHideAlbum(Album a) {
unHideAlbum(a.Path);
dispAlbums.remove(a);
}
public void unHideAlbum(String path) {
HiddenPhotosHandler db = new HiddenPhotosHandler(context);
......@@ -179,6 +223,16 @@ public class HandlingAlbums {
}
}
dispAlbums.remove(getAlbum(path));
db.close();
}
public void LogAlbums() {
for (Album dispAlbum : dispAlbums) {
Log.wtf("asdasd", dispAlbum.Path);
for (Photo photo : dispAlbum.photos) {
Log.d("asdasdasdasd", photo.Path);
}
}
}
/*************
......@@ -186,19 +240,6 @@ public class HandlingAlbums {
**************/
public void unHideSelectedAlbums() {
/*for (Album selectedAlbum : selectedAlbums)
unHideAlbum(selectedAlbum);
clearSelectedAlbums();*/
}
public void unHideAlbum(Album a) {
unHideAlbum(a.Path);
dispAlbums.remove(a);
}
public void excludeSelectedAlbums() {
......
......@@ -138,14 +138,6 @@ public class HandlingPhotos implements Parcelable {
return last_position_selecte;
}
public int selectPhoto(Photo a, boolean val) {
Photo x = photos.get(photos.indexOf(a));
x.setSelected(val);
if (val) selectedPhotos.add(x);
else selectedPhotos.remove(x);
return last_position_selecte;
}
public void deleteSelectedPhotos() {
for (Photo photo : selectedPhotos)
deletePhoto(photo);
......
......@@ -121,7 +121,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
if (cursor.moveToFirst()) {
do contactList.add(new Album(
string.quoteReverse(cursor.getString(0)),
string.getBucketNamebyImagePath(string.quoteReverse(cursor.getString(0))),
string.getBucketNamebyBucketPath(string.quoteReverse(cursor.getString(0))),
true, getHiddenPhotosCountByAlbum(cursor.getString(0))));
while (cursor.moveToNext());
}
......
......@@ -24,6 +24,7 @@ import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.InputType;
import android.transition.Slide;
import android.util.Log;
import android.view.*;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -308,7 +309,8 @@ public class PhotosActivity extends AppCompatActivity {
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
albums.hideAlbum(photos.FolderPath);
Log.wtf("asdasdasdas", photos.FolderPath);
albums.hideAlbum(photos.FolderPath, photos.photos);
finish();
}
})
......
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