use of de.djuelg.neuronizer.storage.TodoListRepositoryImpl in project Neuronizer by djuelg.
the class TodoListAppWidgetProvider method createRemoteViews.
private static RemoteViews createRemoteViews(Context context, int appWidgetId, String repositoryName, String uuid) {
Optional<TodoList> todoList = new TodoListRepositoryImpl(repositoryName).getTodoListById(uuid);
String title = todoList.isPresent() ? todoList.get().getTitle() : context.getResources().getString(R.string.widget_empty);
// Pending intent, used to start correct fragment from widget button
Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(KEY_SWITCH_FRAGMENT, KEY_TODO_LIST);
intent.putExtra(KEY_WIDGET_REPOSITORY, repositoryName);
intent.putExtra(KEY_UUID, uuid);
intent.putExtra(KEY_TITLE, title);
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// RemoteView setup fro WidgetListFactory
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_todo_list);
remoteViews.setOnClickPendingIntent(R.id.widget_todo_list_bar_container, pendingIntent);
remoteViews.setOnClickPendingIntent(R.id.widget_todo_list_bar_button, pendingIntent);
remoteViews.setTextViewText(R.id.widget_todo_list_bar_title, title);
return remoteViews;
}
use of de.djuelg.neuronizer.storage.TodoListRepositoryImpl in project Neuronizer by djuelg.
the class TodoListAppWidgetConfigure method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setResult(RESULT_CANCELED);
setContentView(R.layout.activity_widget_configure);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
repositoryName = sharedPreferences.getString(KEY_PREF_ACTIVE_REPO, FALLBACK_REALM);
List<TodoList> list = new TodoListRepositoryImpl(repositoryName).getAll();
radioGroup = findViewById(R.id.widget_config_radio_group);
todoLists = list.toArray(new TodoList[list.size()]);
radioButtons = new RadioButton[todoLists.length];
createRadioButtons();
}
Aggregations