diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 8f266bb..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-bin/*
-gen/*
-bin
-gen/
-.proguard-project.txt
-.project
-lint.xml
-.settings/*
-.settings/
diff --git a/.project b/.project
new file mode 100644
index 0000000..b1ba60c
--- /dev/null
+++ b/.project
@@ -0,0 +1,33 @@
+
+
+ WidgetListView2
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..2a09c40
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bin/AndroidManifest.xml b/bin/AndroidManifest.xml
new file mode 100644
index 0000000..2a09c40
--- /dev/null
+++ b/bin/AndroidManifest.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bin/WidgetListView1.apk b/bin/WidgetListView1.apk
new file mode 100644
index 0000000..47b8121
Binary files /dev/null and b/bin/WidgetListView1.apk differ
diff --git a/bin/WidgetListView2.apk b/bin/WidgetListView2.apk
new file mode 100644
index 0000000..67891ea
Binary files /dev/null and b/bin/WidgetListView2.apk differ
diff --git a/bin/classes.dex b/bin/classes.dex
new file mode 100644
index 0000000..5c42ceb
Binary files /dev/null and b/bin/classes.dex differ
diff --git a/bin/classes/com/wordpress/laaptu/BuildConfig.class b/bin/classes/com/wordpress/laaptu/BuildConfig.class
new file mode 100644
index 0000000..9ab7d04
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/BuildConfig.class differ
diff --git a/bin/classes/com/wordpress/laaptu/ConfigActivity.class b/bin/classes/com/wordpress/laaptu/ConfigActivity.class
new file mode 100644
index 0000000..06c00e4
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/ConfigActivity.class differ
diff --git a/bin/classes/com/wordpress/laaptu/ListItem.class b/bin/classes/com/wordpress/laaptu/ListItem.class
new file mode 100644
index 0000000..12b1296
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/ListItem.class differ
diff --git a/bin/classes/com/wordpress/laaptu/ListProvider.class b/bin/classes/com/wordpress/laaptu/ListProvider.class
new file mode 100644
index 0000000..9b97293
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/ListProvider.class differ
diff --git a/bin/classes/com/wordpress/laaptu/MainActivity.class b/bin/classes/com/wordpress/laaptu/MainActivity.class
new file mode 100644
index 0000000..f062800
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/MainActivity.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$attr.class b/bin/classes/com/wordpress/laaptu/R$attr.class
new file mode 100644
index 0000000..56ccc1b
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$attr.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$dimen.class b/bin/classes/com/wordpress/laaptu/R$dimen.class
new file mode 100644
index 0000000..41138f8
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$dimen.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$drawable.class b/bin/classes/com/wordpress/laaptu/R$drawable.class
new file mode 100644
index 0000000..bbac6ac
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$drawable.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$id.class b/bin/classes/com/wordpress/laaptu/R$id.class
new file mode 100644
index 0000000..1c4db1a
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$id.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$layout.class b/bin/classes/com/wordpress/laaptu/R$layout.class
new file mode 100644
index 0000000..2f75441
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$layout.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$menu.class b/bin/classes/com/wordpress/laaptu/R$menu.class
new file mode 100644
index 0000000..20a5ab2
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$menu.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$string.class b/bin/classes/com/wordpress/laaptu/R$string.class
new file mode 100644
index 0000000..131df7f
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$string.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$style.class b/bin/classes/com/wordpress/laaptu/R$style.class
new file mode 100644
index 0000000..493c447
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$style.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R$xml.class b/bin/classes/com/wordpress/laaptu/R$xml.class
new file mode 100644
index 0000000..06d2078
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R$xml.class differ
diff --git a/bin/classes/com/wordpress/laaptu/R.class b/bin/classes/com/wordpress/laaptu/R.class
new file mode 100644
index 0000000..3303b43
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/R.class differ
diff --git a/bin/classes/com/wordpress/laaptu/RemoteFetchService$1.class b/bin/classes/com/wordpress/laaptu/RemoteFetchService$1.class
new file mode 100644
index 0000000..720648d
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/RemoteFetchService$1.class differ
diff --git a/bin/classes/com/wordpress/laaptu/RemoteFetchService.class b/bin/classes/com/wordpress/laaptu/RemoteFetchService.class
new file mode 100644
index 0000000..4a68fa5
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/RemoteFetchService.class differ
diff --git a/bin/classes/com/wordpress/laaptu/WidgetProvider.class b/bin/classes/com/wordpress/laaptu/WidgetProvider.class
new file mode 100644
index 0000000..626d40c
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/WidgetProvider.class differ
diff --git a/bin/classes/com/wordpress/laaptu/WidgetService.class b/bin/classes/com/wordpress/laaptu/WidgetService.class
new file mode 100644
index 0000000..e8c493a
Binary files /dev/null and b/bin/classes/com/wordpress/laaptu/WidgetService.class differ
diff --git a/bin/dexedLibs/android-query.0.25.10-9d16671148d8b8a51720a61c4cc2814e.jar b/bin/dexedLibs/android-query.0.25.10-9d16671148d8b8a51720a61c4cc2814e.jar
new file mode 100644
index 0000000..c7cfd0c
Binary files /dev/null and b/bin/dexedLibs/android-query.0.25.10-9d16671148d8b8a51720a61c4cc2814e.jar differ
diff --git a/bin/dexedLibs/android-support-v4-28f9e81560ee23ce9c847d217d621843.jar b/bin/dexedLibs/android-support-v4-28f9e81560ee23ce9c847d217d621843.jar
new file mode 100644
index 0000000..29ef85f
Binary files /dev/null and b/bin/dexedLibs/android-support-v4-28f9e81560ee23ce9c847d217d621843.jar differ
diff --git a/bin/dexedLibs/android-support-v4-605ba7bc48144a50eb225ad7e7e5b351.jar b/bin/dexedLibs/android-support-v4-605ba7bc48144a50eb225ad7e7e5b351.jar
new file mode 100644
index 0000000..e6a0351
Binary files /dev/null and b/bin/dexedLibs/android-support-v4-605ba7bc48144a50eb225ad7e7e5b351.jar differ
diff --git a/bin/dexedLibs/annotations-bb7578f9e478038bc8d68f76bedd1fa5.jar b/bin/dexedLibs/annotations-bb7578f9e478038bc8d68f76bedd1fa5.jar
new file mode 100644
index 0000000..d3fcdcb
Binary files /dev/null and b/bin/dexedLibs/annotations-bb7578f9e478038bc8d68f76bedd1fa5.jar differ
diff --git a/bin/jarlist.cache b/bin/jarlist.cache
new file mode 100644
index 0000000..0565465
--- /dev/null
+++ b/bin/jarlist.cache
@@ -0,0 +1,3 @@
+# cache for current jar dependency. DO NOT EDIT.
+# format is
+# Encoding is UTF-8
diff --git a/bin/res/drawable-hdpi/ic_launcher.png b/bin/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..efa7c5f
Binary files /dev/null and b/bin/res/drawable-hdpi/ic_launcher.png differ
diff --git a/bin/res/drawable-hdpi/widget_preview.png b/bin/res/drawable-hdpi/widget_preview.png
new file mode 100644
index 0000000..38e36ad
Binary files /dev/null and b/bin/res/drawable-hdpi/widget_preview.png differ
diff --git a/bin/res/drawable-mdpi/ic_launcher.png b/bin/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..ec27f2e
Binary files /dev/null and b/bin/res/drawable-mdpi/ic_launcher.png differ
diff --git a/bin/res/drawable-xhdpi/ic_launcher.png b/bin/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..92fc57d
Binary files /dev/null and b/bin/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/bin/res/drawable-xxhdpi/ic_launcher.png b/bin/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b6f8f4e
Binary files /dev/null and b/bin/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/bin/resources.ap_ b/bin/resources.ap_
new file mode 100644
index 0000000..c802f2e
Binary files /dev/null and b/bin/resources.ap_ differ
diff --git a/gen/com/wordpress/laaptu/BuildConfig.java b/gen/com/wordpress/laaptu/BuildConfig.java
new file mode 100644
index 0000000..429b131
--- /dev/null
+++ b/gen/com/wordpress/laaptu/BuildConfig.java
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.wordpress.laaptu;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
\ No newline at end of file
diff --git a/gen/com/wordpress/laaptu/R.java b/gen/com/wordpress/laaptu/R.java
new file mode 100644
index 0000000..e3c3c4c
--- /dev/null
+++ b/gen/com/wordpress/laaptu/R.java
@@ -0,0 +1,83 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.wordpress.laaptu;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class dimen {
+ /** Default screen margins, per the Android Design guidelines.
+
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+
+ */
+ public static final int activity_horizontal_margin=0x7f050000;
+ public static final int activity_vertical_margin=0x7f050001;
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ public static final int widget_preview=0x7f020001;
+ }
+ public static final class id {
+ public static final int action_settings=0x7f090006;
+ public static final int content=0x7f090003;
+ public static final int empty_view=0x7f090005;
+ public static final int heading=0x7f090002;
+ public static final int imageView=0x7f090001;
+ public static final int listViewWidget=0x7f090004;
+ public static final int widgetStartButton=0x7f090000;
+ }
+ public static final class layout {
+ public static final int activity_main=0x7f030000;
+ public static final int configactivity=0x7f030001;
+ public static final int list_row=0x7f030002;
+ public static final int widget_layout=0x7f030003;
+ }
+ public static final class menu {
+ public static final int main=0x7f080000;
+ }
+ public static final class string {
+ public static final int action_settings=0x7f060001;
+ public static final int app_name=0x7f060000;
+ public static final int empty_string=0x7f060003;
+ public static final int hello_world=0x7f060002;
+ public static final int start_widget=0x7f060004;
+ }
+ public static final class style {
+ /**
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+
+
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+
+
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+
+ API 11 theme customizations can go here.
+
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+
+ API 14 theme customizations can go here.
+ */
+ public static final int AppBaseTheme=0x7f070000;
+ /** Application theme.
+ All customizations that are NOT specific to a particular API-level can go here.
+ */
+ public static final int AppTheme=0x7f070001;
+ }
+ public static final class xml {
+ public static final int widgetinfo=0x7f040000;
+ }
+}
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
new file mode 100644
index 0000000..a18cbb4
Binary files /dev/null and b/ic_launcher-web.png differ
diff --git a/libs/android-query.0.25.10.jar b/libs/android-query.0.25.10.jar
new file mode 100644
index 0000000..0744916
Binary files /dev/null and b/libs/android-query.0.25.10.jar differ
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
new file mode 100644
index 0000000..428bdbc
Binary files /dev/null and b/libs/android-support-v4.jar differ
diff --git a/proguard-project.txt b/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/project.properties b/project.properties
new file mode 100644
index 0000000..0f507e5
--- /dev/null
+++ b/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-12
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..288b665
Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ
diff --git a/res/drawable-hdpi/widget_preview.png b/res/drawable-hdpi/widget_preview.png
new file mode 100644
index 0000000..1ce705d
Binary files /dev/null and b/res/drawable-hdpi/widget_preview.png differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..6ae570b
Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..d4fb7cd
Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..85a6081
Binary files /dev/null and b/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
new file mode 100644
index 0000000..168c9b8
--- /dev/null
+++ b/res/layout/activity_main.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/res/layout/configactivity.xml b/res/layout/configactivity.xml
new file mode 100644
index 0000000..1e58b31
--- /dev/null
+++ b/res/layout/configactivity.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
diff --git a/res/layout/list_row.xml b/res/layout/list_row.xml
new file mode 100644
index 0000000..5d46451
--- /dev/null
+++ b/res/layout/list_row.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/widget_layout.xml b/res/layout/widget_layout.xml
new file mode 100644
index 0000000..39a7b3b
--- /dev/null
+++ b/res/layout/widget_layout.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/menu/main.xml b/res/menu/main.xml
new file mode 100644
index 0000000..c002028
--- /dev/null
+++ b/res/menu/main.xml
@@ -0,0 +1,9 @@
+
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..44f01db
--- /dev/null
+++ b/res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..61e3fa8
--- /dev/null
+++ b/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+
+
+
+ 128dp
+
+
diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml
new file mode 100644
index 0000000..3c02242
--- /dev/null
+++ b/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml
new file mode 100644
index 0000000..157f60c
--- /dev/null
+++ b/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..55c1e59
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..9dda732
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,10 @@
+
+
+
+ WidgetListView1
+ Settings
+ Hello world!
+ Empty View
+ Lauch Widget
+
+
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644
index 0000000..6ce89c7
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/widgetinfo.xml b/res/xml/widgetinfo.xml
new file mode 100644
index 0000000..aab0fb6
--- /dev/null
+++ b/res/xml/widgetinfo.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/src/com/wordpress/laaptu/ConfigActivity.java b/src/com/wordpress/laaptu/ConfigActivity.java
new file mode 100644
index 0000000..1b10592
--- /dev/null
+++ b/src/com/wordpress/laaptu/ConfigActivity.java
@@ -0,0 +1,67 @@
+package com.wordpress.laaptu;
+
+import android.app.Activity;
+import android.appwidget.AppWidgetManager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+
+public class ConfigActivity extends Activity implements OnClickListener {
+
+ private int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.configactivity);
+
+ assignAppWidgetId();
+ findViewById(R.id.widgetStartButton).setOnClickListener(this);
+ }
+
+ /**
+ * Widget configuration activity,always receives appwidget Id appWidget Id =
+ * unique id that identifies your widget analogy : same as setting view id
+ * via @+id/viewname on layout but appwidget id is assigned by the system
+ * itself
+ */
+ private void assignAppWidgetId() {
+ Bundle extras = getIntent().getExtras();
+ if (extras != null)
+ appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
+ AppWidgetManager.INVALID_APPWIDGET_ID);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.widgetStartButton)
+ startWidget();
+ }
+
+ /**
+ * This method right now displays the widget and starts a Service to fetch
+ * remote data from Server
+ */
+ private void startWidget() {
+
+ // this intent is essential to show the widget
+ // if this intent is not included,you can't show
+ // widget on homescreen
+ Intent intent = new Intent();
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ setResult(Activity.RESULT_OK, intent);
+
+ // start your service
+ // to fetch data from web
+ Intent serviceIntent = new Intent(this, RemoteFetchService.class);
+ serviceIntent
+ .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ startService(serviceIntent);
+
+ // finish this activity
+ this.finish();
+
+ }
+
+}
diff --git a/src/com/wordpress/laaptu/ListItem.java b/src/com/wordpress/laaptu/ListItem.java
new file mode 100644
index 0000000..28e3a24
--- /dev/null
+++ b/src/com/wordpress/laaptu/ListItem.java
@@ -0,0 +1,6 @@
+package com.wordpress.laaptu;
+
+public class ListItem {
+ public String heading,content,imageUrl;
+
+}
diff --git a/src/com/wordpress/laaptu/ListProvider.java b/src/com/wordpress/laaptu/ListProvider.java
new file mode 100644
index 0000000..932f623
--- /dev/null
+++ b/src/com/wordpress/laaptu/ListProvider.java
@@ -0,0 +1,97 @@
+package com.wordpress.laaptu;
+
+import java.util.ArrayList;
+
+import android.appwidget.AppWidgetManager;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.RemoteViews;
+import android.widget.RemoteViewsService.RemoteViewsFactory;
+
+/**
+ * If you are familiar with Adapter of ListView,this is the same as adapter
+ * with few changes
+ * here it now takes RemoteFetchService ArrayList for data
+ * which is a static ArrayList
+ * and this example won't work if there are multiple widgets and
+ * they update at same time i.e they modify RemoteFetchService ArrayList at same
+ * time.
+ * For that use Database or other techniquest
+ */
+public class ListProvider implements RemoteViewsFactory {
+ private ArrayList listItemList = new ArrayList();
+ private Context context = null;
+ private int appWidgetId;
+
+ public ListProvider(Context context, Intent intent) {
+ this.context = context;
+ appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
+ AppWidgetManager.INVALID_APPWIDGET_ID);
+
+ populateListItem();
+ }
+
+ private void populateListItem() {
+ if(RemoteFetchService.listItemList !=null )
+ listItemList = (ArrayList) RemoteFetchService.listItemList
+ .clone();
+ else
+ listItemList = new ArrayList();
+
+ }
+
+ @Override
+ public int getCount() {
+ return listItemList.size();
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ /*
+ *Similar to getView of Adapter where instead of View
+ *we return RemoteViews
+ *
+ */
+ @Override
+ public RemoteViews getViewAt(int position) {
+ final RemoteViews remoteView = new RemoteViews(
+ context.getPackageName(), R.layout.list_row);
+ ListItem listItem = listItemList.get(position);
+ remoteView.setTextViewText(R.id.heading, listItem.heading);
+ remoteView.setTextViewText(R.id.content, listItem.content);
+
+ return remoteView;
+ }
+
+
+ @Override
+ public RemoteViews getLoadingView() {
+ return null;
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return 1;
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return true;
+ }
+
+ @Override
+ public void onCreate() {
+ }
+
+ @Override
+ public void onDataSetChanged() {
+ }
+
+ @Override
+ public void onDestroy() {
+ }
+
+}
diff --git a/src/com/wordpress/laaptu/MainActivity.java b/src/com/wordpress/laaptu/MainActivity.java
new file mode 100644
index 0000000..1655c80
--- /dev/null
+++ b/src/com/wordpress/laaptu/MainActivity.java
@@ -0,0 +1,22 @@
+package com.wordpress.laaptu;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/src/com/wordpress/laaptu/RemoteFetchService.java b/src/com/wordpress/laaptu/RemoteFetchService.java
new file mode 100644
index 0000000..0078112
--- /dev/null
+++ b/src/com/wordpress/laaptu/RemoteFetchService.java
@@ -0,0 +1,106 @@
+package com.wordpress.laaptu;
+
+import java.util.ArrayList;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.app.Service;
+import android.appwidget.AppWidgetManager;
+import android.content.Intent;
+import android.os.IBinder;
+import android.util.Log;
+
+import com.androidquery.AQuery;
+import com.androidquery.callback.AjaxCallback;
+import com.androidquery.callback.AjaxStatus;
+
+public class RemoteFetchService extends Service {
+
+ private int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
+ private AQuery aquery;
+ private String remoteJsonUrl = "http://laaptu.files.wordpress.com/2013/07/widgetlist.key";
+
+ public static ArrayList listItemList;
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ /*
+ * Retrieve appwidget id from intent it is needed to update widget later
+ * initialize our AQuery class
+ */
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID))
+ appWidgetId = intent.getIntExtra(
+ AppWidgetManager.EXTRA_APPWIDGET_ID,
+ AppWidgetManager.INVALID_APPWIDGET_ID);
+ aquery = new AQuery(getBaseContext());
+ fetchDataFromWeb();
+ return super.onStartCommand(intent, flags, startId);
+ }
+
+ /**
+ * method which fetches data(json) from web aquery takes params
+ * remoteJsonUrl = from where data to be fetched String.class = return
+ * format of data once fetched i.e. in which format the fetched data be
+ * returned AjaxCallback = class to notify with data once it is fetched
+ */
+ private void fetchDataFromWeb() {
+ aquery.ajax(remoteJsonUrl, String.class, new AjaxCallback() {
+ @Override
+ public void callback(String url, String result, AjaxStatus status) {
+ processResult(result);
+ super.callback(url, result, status);
+ }
+ });
+ }
+
+ /**
+ * Json parsing of result and populating ArrayList as per json
+ * data retrieved from the string
+ */
+ private void processResult(String result) {
+ Log.i("Resutl",result);
+ listItemList = new ArrayList();
+ try {
+ JSONArray jsonArray = new JSONArray(result);
+ int length = jsonArray.length();
+ for (int i = 0; i < length; i++) {
+ JSONObject jsonObject = jsonArray.getJSONObject(i);
+ ListItem listItem = new ListItem();
+ listItem.heading = jsonObject.getString("heading");
+ listItem.content = jsonObject.getString("content");
+ listItem.imageUrl = jsonObject.getString("imageUrl");
+ Log.i("Heading",listItem.heading);
+ Log.i("Content",listItem.content);
+ Log.i("imageUrl",listItem.imageUrl);
+ listItemList.add(listItem);
+ }
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ populateWidget();
+ }
+
+ /**
+ * Method which sends broadcast to WidgetProvider
+ * so that widget is notified to do necessary action
+ * and here action == WidgetProvider.DATA_FETCHED
+ */
+ private void populateWidget() {
+
+ Intent widgetUpdateIntent = new Intent();
+ widgetUpdateIntent.setAction(WidgetProvider.DATA_FETCHED);
+ widgetUpdateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
+ appWidgetId);
+ sendBroadcast(widgetUpdateIntent);
+
+ this.stopSelf();
+ }
+}
diff --git a/src/com/wordpress/laaptu/WidgetProvider.java b/src/com/wordpress/laaptu/WidgetProvider.java
new file mode 100644
index 0000000..aeb96d4
--- /dev/null
+++ b/src/com/wordpress/laaptu/WidgetProvider.java
@@ -0,0 +1,81 @@
+package com.wordpress.laaptu;
+
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProvider;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.widget.RemoteViews;
+
+public class WidgetProvider extends AppWidgetProvider {
+
+ // String to be sent on Broadcast as soon as Data is Fetched
+ // should be included on WidgetProvider manifest intent action
+ // to be recognized by this WidgetProvider to receive broadcast
+ public static final String DATA_FETCHED = "com.wordpress.laaptu.DATA_FETCHED";
+
+ /*
+ * this method is called every 30 mins as specified on widgetinfo.xml this
+ * method is also called on every phone reboot from this method nothing is
+ * updated right now but instead RetmoteFetchService class is called this
+ * service will fetch data,and send broadcast to WidgetProvider this
+ * broadcast will be received by WidgetProvider onReceive which in turn
+ * updates the widget
+ */
+ @Override
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager,
+ int[] appWidgetIds) {
+ final int N = appWidgetIds.length;
+ for (int i = 0; i < N; i++) {
+ Intent serviceIntent = new Intent(context, RemoteFetchService.class);
+ serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
+ appWidgetIds[i]);
+ context.startService(serviceIntent);
+ }
+ super.onUpdate(context, appWidgetManager, appWidgetIds);
+ }
+
+ private RemoteViews updateWidgetListView(Context context, int appWidgetId) {
+
+ // which layout to show on widget
+ RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
+ R.layout.widget_layout);
+
+ // RemoteViews Service needed to provide adapter for ListView
+ Intent svcIntent = new Intent(context, WidgetService.class);
+ // passing app widget id to that RemoteViews Service
+ svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
+ // setting a unique Uri to the intent
+ // don't know its purpose to me right now
+ svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
+ // setting adapter to listview of the widget
+ remoteViews.setRemoteAdapter(appWidgetId, R.id.listViewWidget,
+ svcIntent);
+ // setting an empty view in case of no data
+ remoteViews.setEmptyView(R.id.listViewWidget, R.id.empty_view);
+ return remoteViews;
+ }
+
+ /*
+ * It receives the broadcast as per the action set on intent filters on
+ * Manifest.xml once data is fetched from RemotePostService,it sends
+ * broadcast and WidgetProvider notifies to change the data the data change
+ * right now happens on ListProvider as it takes RemoteFetchService
+ * listItemList as data
+ */
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ super.onReceive(context, intent);
+ if (intent.getAction().equals(DATA_FETCHED)) {
+ int appWidgetId = intent.getIntExtra(
+ AppWidgetManager.EXTRA_APPWIDGET_ID,
+ AppWidgetManager.INVALID_APPWIDGET_ID);
+ AppWidgetManager appWidgetManager = AppWidgetManager
+ .getInstance(context);
+ RemoteViews remoteViews = updateWidgetListView(context, appWidgetId);
+ appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
+ }
+
+ }
+
+}
diff --git a/src/com/wordpress/laaptu/WidgetService.java b/src/com/wordpress/laaptu/WidgetService.java
new file mode 100644
index 0000000..1aa285f
--- /dev/null
+++ b/src/com/wordpress/laaptu/WidgetService.java
@@ -0,0 +1,22 @@
+package com.wordpress.laaptu;
+
+import android.appwidget.AppWidgetManager;
+import android.content.Intent;
+import android.widget.RemoteViewsService;
+
+public class WidgetService extends RemoteViewsService {
+ /*
+ * So pretty simple just defining the Adapter of the listview
+ * here Adapter is ListProvider
+ * */
+
+ @Override
+ public RemoteViewsFactory onGetViewFactory(Intent intent) {
+ int appWidgetId = intent.getIntExtra(
+ AppWidgetManager.EXTRA_APPWIDGET_ID,
+ AppWidgetManager.INVALID_APPWIDGET_ID);
+
+ return (new ListProvider(this.getApplicationContext(), intent));
+ }
+
+}