diff --git a/.gitignore b/.gitignore
index 4334049..9230489 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@ out
proguard_logs
*/build/*
.gradle
+.idea
+build
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index b6e1d7d..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-uservoice-android
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 217af47..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
deleted file mode 100644
index e206d70..0000000
--- a/.idea/encodings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 0b0f9f6..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/libraries/commons_codec_1_8.xml b/.idea/libraries/commons_codec_1_8.xml
deleted file mode 100644
index d5201f3..0000000
--- a/.idea/libraries/commons_codec_1_8.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/httpcore_4_0_1.xml b/.idea/libraries/httpcore_4_0_1.xml
deleted file mode 100644
index 6b9a0dc..0000000
--- a/.idea/libraries/httpcore_4_0_1.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/signpost_commonshttp4_1_2_1_2.xml b/.idea/libraries/signpost_commonshttp4_1_2_1_2.xml
deleted file mode 100644
index cdf16de..0000000
--- a/.idea/libraries/signpost_commonshttp4_1_2_1_2.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/signpost_core_1_2_1_2.xml b/.idea/libraries/signpost_core_1_2_1_2.xml
deleted file mode 100644
index 4098c2e..0000000
--- a/.idea/libraries/signpost_core_1_2_1_2.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/support_v4_19_0_1.xml b/.idea/libraries/support_v4_19_0_1.xml
deleted file mode 100644
index 617c323..0000000
--- a/.idea/libraries/support_v4_19_0_1.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 6821c00..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 8de6e1d..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
deleted file mode 100644
index 922003b..0000000
--- a/.idea/scopes/scope_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index 3b00020..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 0fc4cb9..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/UVDemo/UVDemo.iml b/UVDemo/UVDemo.iml
index 9aedb2e..8d8741a 100644
--- a/UVDemo/UVDemo.iml
+++ b/UVDemo/UVDemo.iml
@@ -1,11 +1,6 @@
-
-
-
-
-
@@ -16,23 +11,29 @@
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -54,27 +55,34 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
diff --git a/UVDemo/build.gradle b/UVDemo/build.gradle
index eefab7a..4700d07 100644
--- a/UVDemo/build.gradle
+++ b/UVDemo/build.gradle
@@ -4,7 +4,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.9.+'
+ classpath 'com.android.tools.build:gradle:0.12.+'
}
}
@@ -16,7 +16,7 @@ repositories {
android {
compileSdkVersion 19
- buildToolsVersion "19.0.3"
+ buildToolsVersion '19.1.0'
sourceSets {
main {
@@ -60,6 +60,6 @@ tasks.whenTaskAdded { theTask ->
}
dependencies {
- compile 'com.android.support:support-v4:19.0.1'
- compile project(':UserVoiceSDK')
+ compile 'com.android.support:support-v4:20.+'
+ compile project(':UserVoiceSDK')
}
diff --git a/UVDemo/project.properties b/UVDemo/project.properties
index b7188f9..346b7fc 100644
--- a/UVDemo/project.properties
+++ b/UVDemo/project.properties
@@ -12,4 +12,4 @@
# Project target.
target=android-18
-android.library.reference.1=../UserVoiceSDK
+
diff --git a/UserVoiceSDK/UserVoiceSDK.iml b/UserVoiceSDK/UserVoiceSDK.iml
index 9845ead..f5b415c 100644
--- a/UserVoiceSDK/UserVoiceSDK.iml
+++ b/UserVoiceSDK/UserVoiceSDK.iml
@@ -1,11 +1,6 @@
-
-
-
-
-
@@ -19,21 +14,26 @@
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -55,27 +55,28 @@
-
-
-
-
+
-
+
+
+
-
+
+
+
+
-
diff --git a/UserVoiceSDK/build.gradle b/UserVoiceSDK/build.gradle
index 0a830ec..2acb9b6 100644
--- a/UserVoiceSDK/build.gradle
+++ b/UserVoiceSDK/build.gradle
@@ -4,7 +4,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.9.+'
+ classpath 'com.android.tools.build:gradle:0.12.+'
}
}
@@ -16,7 +16,7 @@ repositories {
android {
compileSdkVersion 19
- buildToolsVersion "19.0.3"
+ buildToolsVersion '19.1.0'
sourceSets {
main {
@@ -29,7 +29,7 @@ android {
}
dependencies {
- compile 'com.android.support:support-v4:19.0.1'
+ compile 'com.android.support:support-v4:20.+'
compile 'commons-codec:commons-codec:1.8'
compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2'
compile 'oauth.signpost:signpost-core:1.2.1.2'
diff --git a/UserVoiceSDK/src/com/uservoice/uservoicesdk/activity/TopicActivity.java b/UserVoiceSDK/src/com/uservoice/uservoicesdk/activity/TopicActivity.java
index cf4dcc2..0506819 100644
--- a/UserVoiceSDK/src/com/uservoice/uservoicesdk/activity/TopicActivity.java
+++ b/UserVoiceSDK/src/com/uservoice/uservoicesdk/activity/TopicActivity.java
@@ -21,7 +21,8 @@
import com.uservoice.uservoicesdk.model.Article;
import com.uservoice.uservoicesdk.model.Topic;
import com.uservoice.uservoicesdk.rest.Callback;
-import com.uservoice.uservoicesdk.ui.LoadAllAdapter;
+import com.uservoice.uservoicesdk.ui.PaginatedAdapter;
+import com.uservoice.uservoicesdk.ui.PaginationScrollListener;
public class TopicActivity extends BaseListActivity implements SearchActivity {
@@ -40,7 +41,7 @@ protected void onCreate(Bundle savedInstanceState) {
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
Topic topic = Session.getInstance().getTopics().get(itemPosition);
Session.getInstance().setTopic(topic);
- ((LoadAllAdapter) getListAdapter()).reload();
+ getModelAdapter().reload();
return true;
}
});
@@ -49,14 +50,24 @@ public boolean onNavigationItemSelected(int itemPosition, long itemId) {
setTitle(null);
getListView().setDivider(null);
- setListAdapter(new LoadAllAdapter(this, R.layout.uv_text_item, new ArrayList()) {
+ setListAdapter(new PaginatedAdapter(this, R.layout.uv_text_item, new ArrayList()) {
@Override
protected void loadPage(int page, Callback> callback) {
Topic topic = Session.getInstance().getTopic();
if (topic == Topic.ALL_ARTICLES) {
- Article.loadAll(callback);
+ Article.loadPage(page, callback);
} else {
- Article.loadForTopic(topic.getId(), callback);
+ Article.loadPageForTopic(topic.getId(), page, callback);
+ }
+ }
+
+ @Override
+ public int getTotalNumberOfObjects() {
+ Topic topic = Session.getInstance().getTopic();
+ if (topic == Topic.ALL_ARTICLES) {
+ return -1; // we don't know. keep trying to load more.
+ } else {
+ return topic.getNumberOfArticles();
}
}
@@ -74,6 +85,8 @@ protected void customizeLayout(View view, Article model) {
}
});
+ getListView().setOnScrollListener(new PaginationScrollListener(getModelAdapter()));
+
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
@@ -107,4 +120,9 @@ public boolean onMenuItemSelected(int featureId, MenuItem item) {
}
return super.onMenuItemSelected(featureId, item);
}
+
+ @SuppressWarnings("unchecked")
+ public PaginatedAdapter getModelAdapter() {
+ return (PaginatedAdapter) getListAdapter();
+ }
}
diff --git a/UserVoiceSDK/src/com/uservoice/uservoicesdk/model/Article.java b/UserVoiceSDK/src/com/uservoice/uservoicesdk/model/Article.java
index ca0bf5d..8a04b1b 100644
--- a/UserVoiceSDK/src/com/uservoice/uservoicesdk/model/Article.java
+++ b/UserVoiceSDK/src/com/uservoice/uservoicesdk/model/Article.java
@@ -18,9 +18,11 @@ public class Article extends BaseModel {
private String topicName;
private int weight;
- public static void loadAll(final Callback> callback) {
+ public static void loadPage(int page, final Callback> callback) {
Map params = new HashMap();
params.put("sort", "ordered");
+ params.put("per_page", "50");
+ params.put("page", String.valueOf(page));
doGet(apiPath("/articles.json"), params, new RestTaskCallback(callback) {
@Override
public void onComplete(JSONObject result) throws JSONException {
@@ -29,9 +31,11 @@ public void onComplete(JSONObject result) throws JSONException {
});
}
- public static void loadForTopic(int topicId, final Callback> callback) {
+ public static void loadPageForTopic(int topicId, int page, final Callback> callback) {
Map params = new HashMap();
params.put("sort", "ordered");
+ params.put("per_page", "50");
+ params.put("page", String.valueOf(page));
doGet(apiPath("/topics/%d/articles.json", topicId), params, new RestTaskCallback(callback) {
@Override
public void onComplete(JSONObject result) throws JSONException {
diff --git a/UserVoiceSDK/src/com/uservoice/uservoicesdk/ui/PortalAdapter.java b/UserVoiceSDK/src/com/uservoice/uservoicesdk/ui/PortalAdapter.java
index 49bb630..2a3ef2a 100644
--- a/UserVoiceSDK/src/com/uservoice/uservoicesdk/ui/PortalAdapter.java
+++ b/UserVoiceSDK/src/com/uservoice/uservoicesdk/ui/PortalAdapter.java
@@ -93,14 +93,14 @@ public void onModel(List model) {
};
if (Session.getInstance().getConfig().getTopicId() != -1) {
- Article.loadForTopic(Session.getInstance().getConfig().getTopicId(), articlesCallback);
+ Article.loadPageForTopic(Session.getInstance().getConfig().getTopicId(), 1, articlesCallback);
} else {
Topic.loadTopics(new DefaultCallback>(context) {
@Override
public void onModel(List model) {
if (model.isEmpty()) {
Session.getInstance().setTopics(model);
- Article.loadAll(articlesCallback);
+ Article.loadPage(1, articlesCallback);
} else {
ArrayList topics = new ArrayList(model);
topics.add(Topic.ALL_ARTICLES);
diff --git a/android.iml b/android.iml
index d9c631d..0bb6048 100644
--- a/android.iml
+++ b/android.iml
@@ -1,10 +1,16 @@
+
+
+
+
+
+
+
-
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..495c503
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
diff --git a/local.properties b/local.properties
index 20cdae7..c479cb5 100644
--- a/local.properties
+++ b/local.properties
@@ -7,5 +7,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
-#Thu Apr 24 15:15:04 EDT 2014
-sdk.dir=/Applications/Android Studio.app/sdk
+#Fri Jul 18 13:31:31 EDT 2014
+sdk.dir=/Users/austin/code/vendor/adt-bundle-mac-x86_64-20131030/sdk