mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-24 12:08:44 +02:00
fetch data from the database at updating the widget too
This commit is contained in:
parent
00f361ffc5
commit
87442a9515
@ -10,8 +10,10 @@ import android.graphics.Color;
|
|||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
import com.simplemobiletools.notes.activities.MainActivity;
|
import com.simplemobiletools.notes.activities.MainActivity;
|
||||||
|
import com.simplemobiletools.notes.databases.DBHelper;
|
||||||
|
|
||||||
public class MyWidgetProvider extends AppWidgetProvider {
|
public class MyWidgetProvider extends AppWidgetProvider {
|
||||||
|
private DBHelper mDb;
|
||||||
private static SharedPreferences mPrefs;
|
private static SharedPreferences mPrefs;
|
||||||
private static RemoteViews mRemoteViews;
|
private static RemoteViews mRemoteViews;
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ public class MyWidgetProvider extends AppWidgetProvider {
|
|||||||
|
|
||||||
private void initVariables(Context context) {
|
private void initVariables(Context context) {
|
||||||
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
mPrefs = context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
|
||||||
|
mDb = DBHelper.newInstance(context);
|
||||||
mRemoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
|
mRemoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
|
||||||
setupAppOpenIntent(R.id.notes_holder, context);
|
setupAppOpenIntent(R.id.notes_holder, context);
|
||||||
}
|
}
|
||||||
@ -44,7 +47,7 @@ public class MyWidgetProvider extends AppWidgetProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidget(AppWidgetManager widgetManager, int widgetId, RemoteViews remoteViews) {
|
private void updateWidget(AppWidgetManager widgetManager, int widgetId, RemoteViews remoteViews) {
|
||||||
final String text = mPrefs.getString(Constants.TEXT, "");
|
final String text = mDb.getGeneralNote().getValue();
|
||||||
remoteViews.setTextViewText(R.id.notes_view, text);
|
remoteViews.setTextViewText(R.id.notes_view, text);
|
||||||
widgetManager.updateAppWidget(widgetId, remoteViews);
|
widgetManager.updateAppWidget(widgetId, remoteViews);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user