save works
This commit is contained in:
@@ -100,7 +100,7 @@ public class Pref {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldShowAd() {
|
public static boolean shouldShowAd() {
|
||||||
if (isFirstDay() && !BuildConfig.DEBUG) {
|
if (isFirstDay()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String adShowingMode = def().getString(getString(R.string.key_ad_showing_mode), "Default");
|
String adShowingMode = def().getString(getString(R.string.key_ad_showing_mode), "Default");
|
||||||
|
|||||||
@@ -30,49 +30,60 @@ public class Explorer {
|
|||||||
this(explorerProvider, cacheSize, EventBus.getDefault());
|
this(explorerProvider, cacheSize, EventBus.getDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyChildrenChanged(ExplorerPage itemGroup) {
|
public void notifyChildrenChanged(ExplorerPage page) {
|
||||||
clearCache(itemGroup);
|
clearCache(page);
|
||||||
mEventBus.post(new ExplorerChangeEvent(itemGroup));
|
mEventBus.post(new ExplorerChangeEvent(page, CHILDREN_CHANGE, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyItemChanged(ExplorerItem oldItem, ExplorerItem newItem) {
|
public void notifyItemChanged(ExplorerItem oldItem, ExplorerItem newItem) {
|
||||||
ExplorerPage itemGroup = getParentFromCache(oldItem);
|
ExplorerPage parent = getParent(oldItem);
|
||||||
if (itemGroup != null) {
|
ExplorerPage cachedParent = getFromCache(parent);
|
||||||
itemGroup.updateChild(oldItem, newItem);
|
if (cachedParent != null) {
|
||||||
|
cachedParent.updateChild(oldItem, newItem);
|
||||||
}
|
}
|
||||||
mEventBus.post(new ExplorerChangeEvent(oldItem.getParent(), CHANGE, oldItem, newItem));
|
mEventBus.post(new ExplorerChangeEvent(parent, CHANGE, oldItem, newItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExplorerPage getParentFromCache(ExplorerItem item) {
|
private ExplorerPage getFromCache(ExplorerPage parent) {
|
||||||
if (mExplorerPageLruCache == null) {
|
if(mExplorerPageLruCache == null || parent == null){
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ExplorerPage parent = item.getParent();
|
|
||||||
if (parent == null) {
|
|
||||||
if (item instanceof ExplorerFileItem) {
|
|
||||||
PFile parentFile = ((ExplorerFileItem) item).getFile().getParentFile();
|
|
||||||
return parentFile == null ? null : mExplorerPageLruCache.get(parentFile.getPath());
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return mExplorerPageLruCache.get(parent.getPath());
|
return mExplorerPageLruCache.get(parent.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ExplorerPage getParentFromCache(ExplorerItem item) {
|
||||||
|
return getFromCache(getParent(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void notifyItemRemoved(ExplorerItem item) {
|
public void notifyItemRemoved(ExplorerItem item) {
|
||||||
ExplorerPage itemGroup = getParentFromCache(item);
|
ExplorerPage parent = getParent(item);
|
||||||
if (itemGroup != null) {
|
ExplorerPage cachedParent = getFromCache(parent);
|
||||||
itemGroup.removeChild(item);
|
if (cachedParent != null) {
|
||||||
|
cachedParent.removeChild(item);
|
||||||
}
|
}
|
||||||
mEventBus.post(new ExplorerChangeEvent(item.getParent(), REMOVE, item));
|
mEventBus.post(new ExplorerChangeEvent(parent, REMOVE, item));
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExplorerPage getParent(ExplorerItem item) {
|
||||||
|
ExplorerPage parent = item.getParent();
|
||||||
|
if (parent == null) {
|
||||||
|
if (item instanceof ExplorerFileItem) {
|
||||||
|
PFile parentFile = ((ExplorerFileItem) item).getFile().getParentFile();
|
||||||
|
return new ExplorerDirPage(parentFile, null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyItemCreated(ExplorerItem item) {
|
public void notifyItemCreated(ExplorerItem item) {
|
||||||
ExplorerPage itemGroup = getParentFromCache(item);
|
ExplorerPage parent = getParent(item);
|
||||||
if (itemGroup != null) {
|
ExplorerPage cachedParent = getFromCache(parent);
|
||||||
itemGroup.addChild(item);
|
if (cachedParent != null) {
|
||||||
|
cachedParent.addChild(item);
|
||||||
}
|
}
|
||||||
mEventBus.post(new ExplorerChangeEvent(item.getParent(), CREATE, item));
|
mEventBus.post(new ExplorerChangeEvent(parent, CREATE, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -6,16 +6,13 @@ public class ExplorerChangeEvent {
|
|||||||
public static final int CREATE = 1;
|
public static final int CREATE = 1;
|
||||||
public static final int CHANGE = 2;
|
public static final int CHANGE = 2;
|
||||||
public static final int ALL = 3;
|
public static final int ALL = 3;
|
||||||
|
public static final int CHILDREN_CHANGE = 4;
|
||||||
|
|
||||||
private final int mAction;
|
private final int mAction;
|
||||||
private final ExplorerItem mItem;
|
private final ExplorerItem mItem;
|
||||||
private final ExplorerItem mNewItem;
|
private final ExplorerItem mNewItem;
|
||||||
private final ExplorerPage mPage;
|
private final ExplorerPage mPage;
|
||||||
|
|
||||||
public ExplorerChangeEvent(ExplorerPage page) {
|
|
||||||
this(page, CHANGE, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExplorerChangeEvent(ExplorerPage parent, int action, ExplorerItem oldItem, ExplorerItem newItem) {
|
public ExplorerChangeEvent(ExplorerPage parent, int action, ExplorerItem oldItem, ExplorerItem newItem) {
|
||||||
mAction = action;
|
mAction = action;
|
||||||
mPage = parent;
|
mPage = parent;
|
||||||
|
|||||||
@@ -220,10 +220,8 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onExplorerChange(ExplorerChangeEvent event) {
|
public void onExplorerChange(ExplorerChangeEvent event) {
|
||||||
if (event.getAction() == ExplorerChangeEvent.ALL
|
if ((event.getAction() == ExplorerChangeEvent.ALL)
|
||||||
|| (event.getAction() == ExplorerChangeEvent.CHANGE &&
|
|| mCurrentPageState.page.getPath().equals(event.getPage().getPath())) {
|
||||||
mCurrentPageState.page.getPath().equals(event.getPage().getPath()))
|
|
||||||
|| (event.getAction() == Explorer)) {
|
|
||||||
loadItemList();
|
loadItemList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,14 +460,14 @@ public class ExplorerView extends ThemeColorSwipeRefreshLayout implements SwipeR
|
|||||||
PopupMenu popupMenu = new PopupMenu(getContext(), mOptions);
|
PopupMenu popupMenu = new PopupMenu(getContext(), mOptions);
|
||||||
popupMenu.inflate(R.menu.menu_script_options);
|
popupMenu.inflate(R.menu.menu_script_options);
|
||||||
Menu menu = popupMenu.getMenu();
|
Menu menu = popupMenu.getMenu();
|
||||||
if(!mExplorerItem.isExecutable()){
|
if (!mExplorerItem.isExecutable()) {
|
||||||
menu.removeItem(R.id.run_repeatedly);
|
menu.removeItem(R.id.run_repeatedly);
|
||||||
menu.removeItem(R.id.more);
|
menu.removeItem(R.id.more);
|
||||||
}
|
}
|
||||||
if(!mExplorerItem.canDelete()){
|
if (!mExplorerItem.canDelete()) {
|
||||||
menu.removeItem(R.id.delete);
|
menu.removeItem(R.id.delete);
|
||||||
}
|
}
|
||||||
if(!mExplorerItem.canRename()){
|
if (!mExplorerItem.canRename()) {
|
||||||
menu.removeItem(R.id.rename);
|
menu.removeItem(R.id.rename);
|
||||||
}
|
}
|
||||||
popupMenu.setOnMenuItemClickListener(ExplorerView.this);
|
popupMenu.setOnMenuItemClickListener(ExplorerView.this);
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ public class MyScriptListFragment extends ViewPagerFragment implements BackPress
|
|||||||
case 2:
|
case 2:
|
||||||
new ScriptOperations(getContext(), mExplorerView, mExplorerView.getCurrentPage())
|
new ScriptOperations(getContext(), mExplorerView, mExplorerView.getCurrentPage())
|
||||||
.importFile();
|
.importFile();
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ProjectConfigActivity_.intent(getContext())
|
ProjectConfigActivity_.intent(getContext())
|
||||||
.extra(ProjectConfigActivity.EXTRA_PARENT_DIRECTORY, mExplorerView.getCurrentPage().getPath())
|
.extra(ProjectConfigActivity.EXTRA_PARENT_DIRECTORY, mExplorerView.getCurrentPage().getPath())
|
||||||
|
|||||||
Reference in New Issue
Block a user