Commit 14289609 authored by Meg Ford's avatar Meg Ford

finish the loadMore button

parent 081a55e3
......@@ -80,6 +80,7 @@ const OffsetController = new Lang.Class({
this._offset = 0;
this._itemCount = 0;
this._context = context;
CurrentEndIdx = _OFFSET_STEP;
},
// to be called to load more files into the listview
......@@ -97,12 +98,6 @@ const OffsetController = new Lang.Class({
this._offset = 0;
},
getItemCount: function() {
this._itemCount = MainWindow.list.getItemCount();
log("itemCount");
log(this._itemCount);
},
getRemainingFiles: function() {
return (this._itemCount - (this._offset + _OFFSET_STEP));
},
......@@ -115,14 +110,11 @@ const OffsetController = new Lang.Class({
return this._offset;
},
setEndIdx: function() {
getEndIdx: function() {
this.totItems = MainWindow.list.getItemCount();
log(this.totItems);
this.ensureCount = this._offset + _OFFSET_STEP - 1;
log(this.ensureCount);
this.getItemCount();
if (this.ensureCount < this.totItems) {
this.endIdx = this.ensureCount;
if (CurrentEndIdx < this.totItems) {
this.endIdx = CurrentEndIdx;
log(this.endIdx);
} else {
this.endIdx = this.totItems - 1;
......@@ -130,7 +122,12 @@ const OffsetController = new Lang.Class({
}
CurrentEndIdx = this.endIdx;
this.getcidx();
return CurrentEndIdx;
},
increaseEndIdxStep: function() {
CurrentEndIdx += _OFFSET_STEP;
},
getcidx: function() {
......
......@@ -175,16 +175,9 @@ const Listview = new Lang.Class({
_setDiscover: function() {
this._controller = MainWindow.offsetController;
this.totItems = this.getItemCount();
this.startIdx = this._controller.getOffset();
this.startIdx = 0;
log("this.startIdx" + this.startIdx);
this.ensureCount = this.startIdx + this._controller.getOffsetStep() - 1; ;
if (this.ensureCount < this.totItems)
this.endIdx = this.ensureCount;
else
this.endIdx = this.totItems - 1;
this.endIdx = this._controller.getEndIdx();
this.idx = this.startIdx;
this._runDiscover();
return false;
......@@ -258,7 +251,6 @@ const Listview = new Lang.Class({
} else {
this._discoverer.stop();
log("this.listType discovering" + listType);
MainWindow.offsetController.setEndIdx();
if (listType == ListType.NEW) {
MainWindow.view.listBoxAdd();
......@@ -275,23 +267,28 @@ const Listview = new Lang.Class({
setListTypeNew: function() {
listType = ListType.NEW;
},
},
setListTypeRefresh: function() {
listType = ListType.REFRESH;
},
_onDirChanged: function(dirMonitor, file1, file2, eventType) {
log("eventType" + eventType);
if (eventType == Gio.FileMonitorEvent.DELETED ||
(eventType == Gio.FileMonitorEvent.CHANGES_DONE_HINT && MainWindow.recordPipeline == MainWindow.RecordPipelineStates.STOPPED)) {
stopVal = EnumeratorState.ACTIVE;
allFilesInfo.length = 0;
fileInfo.length = 0;
log(stopVal + "this._stopVal");
listType = ListType.REFRESH;
log("this.listType" + listType);
log("this.currentlyEnumerating " + currentlyEnumerating);
if(currentlyEnumerating == CurrentlyEnumerating.FALSE) {
currentlyEnumerating = CurrentlyEnumerating.TRUE;
MainWindow.view.listBoxRefresh();
}
stopVal = EnumeratorState.ACTIVE;
allFilesInfo.length = 0;
fileInfo.length = 0;
log(stopVal + "this._stopVal");
this.setListTypeRefresh();
log("this.listType" + listType);
log("this.currentlyEnumerating " + currentlyEnumerating);
if (currentlyEnumerating == CurrentlyEnumerating.FALSE) {
currentlyEnumerating = CurrentlyEnumerating.TRUE;
MainWindow.view.listBoxRefresh();
}
}
if (eventType == Gio.FileMonitorEvent.CREATED)
......@@ -348,11 +345,11 @@ const Listview = new Lang.Class({
return allFilesInfo;
},
getEndIdx: function() {
log(this.endIdx);
log("endidx");
/*getEndIdx: function() {
log(this.endIdx);
log("endidx");
return this.endIdx;
}
} */
});
......@@ -43,18 +43,20 @@ let fileUtil = null;
let grid = null;
let groupGrid;
let list = null;
let loadMoreButton = null;
let offsetController = null;
let path = null;
let play = null;
let previousSelRow = null;
let recordPipeline = null;
let recordButton = null;
let selectable = null;
let previousSelRow = null;
let setVisibleID = null;
let UpperBoundVal = 182;
let view = null;
let volumeValue = [];
let wave = null;
let UpperBoundVal = 182;
const ActiveArea = {
RECORD: 0,
......@@ -160,6 +162,7 @@ const MainView = new Lang.Class({
},
_addListviewPage: function(name) {
fileUtil = new FileUtil.FileUtil();
list = new Listview.Listview();
list.setListTypeNew();
list.enumerateDirectory();
......@@ -296,19 +299,16 @@ const MainView = new Lang.Class({
this._scrolledWin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
this._scrolledWin.get_style_context().add_class('view');
this.scrollbar = this._scrolledWin.get_vadjustment();
this.scrollbar.set_upper(UpperBoundVal);
this.scrollbar.connect("value_changed", Lang.bind(this,
function() {
this.currentBound = this.scrollbar.get_value();
log(this.currentBound + "this.currentBound");
log(UpperBoundVal + "this.lowerBound");
if (UpperBoundVal == this.currentBound && this.loadMoreButton == null)
UpperBoundVal = this.scrollbar.upper - this.scrollbar.page_size;
if (UpperBoundVal == this.currentBound && loadMoreButton == null) {
this.addLoadMoreButton();
else if (UpperBoundVal != this.currentBound && this.loadMoreButton) {
this.loadMoreButton.destroy();
this.loadMoreButton = null;
} else if (UpperBoundVal != this.currentBound && loadMoreButton) {
loadMoreButton.destroy();
loadMoreButton = null;
}
}));
......@@ -326,7 +326,7 @@ const MainView = new Lang.Class({
}));
this.listBox.show();
this._startIdx = offsetController.getOffset();
this._startIdx = 0;
log(this._startIdx);
log("start");
this._endIdx = offsetController.getcidx();
......@@ -502,17 +502,27 @@ const MainView = new Lang.Class({
},
addLoadMoreButton: function() {
this.loadMoreButton = new LoadMoreButton();
//this.loadMoreButton.connect('clicked', Lang.bind(this, this.loadMoreButton.onLoadMore));
this.groupGrid.add(this.loadMoreButton);
this.loadMoreButton.show();
loadMoreButton = new LoadMoreButton();
loadMoreButton.connect('clicked', Lang.bind(this, loadMoreButton.onLoadMore));
this.groupGrid.add(loadMoreButton);
loadMoreButton.show();
},
listBoxRefresh: function() {
previousSelRow = null;
this.listBox.set_selection_mode(Gtk.SelectionMode.NONE);
fileUtil = new FileUtil.FileUtil();
list.enumerateDirectory();
this.listBox.set_selection_mode(Gtk.SelectionMode.SINGLE);
//this.listBox.set_selection_mode(Gtk.SelectionMode.SINGLE);
},
listBoxLoadMore: function() {
loadMoreButton.destroy();
loeadMoreButton = null;
this.listBox.set_selection_mode(Gtk.SelectionMode.NONE);
offsetController.increaseEndIdxStep();
list.setListTypeRefresh();
list._setDiscover();
this.listBox.set_selection_mode(Gtk.SelectionMode.SINGLE);
},
scrolledWinDelete: function() {
......@@ -749,6 +759,6 @@ const LoadMoreButton = new Lang.Class({
//offsetController.increaseOffset();
UpperBoundVal += 182;
view.scrollbar.set_upper(UpperBoundVal);
//view.listBoxRefresh();
view.listBoxLoadMore();
}
});
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