use of org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper in project AnyMemo by helloworld1.
the class ShareScreen method onClick.
@Override
public void onClick(View v) {
try {
String dbpath = dbnameView.getText().toString();
Log.v(TAG, dbpath);
if (v == saveButton || v == savePrevButton) {
AnyMemoDBOpenHelper helper = AnyMemoDBOpenHelperManager.getHelper(this, dbpath);
CardDao cardDao = helper.getCardDao();
try {
Card card = new Card();
card.setQuestion(questionView.getText().toString());
card.setAnswer(answerView.getText().toString());
card.setNote(noteView.getText().toString());
card.setCategory(new Category());
card.setLearningData(new LearningData());
cardDao.createCard(card);
if (v == savePrevButton) {
Intent myIntent = new Intent(this, PreviewEditActivity.class);
/* This should be the newly created id */
myIntent.putExtra("id", card.getId());
myIntent.putExtra(PreviewEditActivity.EXTRA_DBPATH, dbpath);
startActivity(myIntent);
}
finish();
} finally {
AnyMemoDBOpenHelperManager.releaseHelper(helper);
}
} else if (v == cancelButton) {
finish();
} else if (v == dbnameView) {
Intent myIntent = new Intent(this, FileBrowserActivity.class);
myIntent.putExtra(FileBrowserActivity.EXTRA_FILE_EXTENSIONS, ".db");
startActivityForResult(myIntent, ACTIVITY_FB);
}
} catch (Exception e) {
AMGUIUtility.displayError(this, getString(R.string.error_text), "", e);
}
}
use of org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper in project AnyMemo by helloworld1.
the class WidgetRemoteViewsFactory method getViewAt.
public RemoteViews getViewAt(int position) {
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
if (position < allPath.length) {
AnyMemoDBOpenHelper helper = AnyMemoDBOpenHelperManager.getHelper(mContext, allPath[position]);
CardDao dao = helper.getCardDao();
String dbName = FilenameUtils.getName(allPath[position]);
long totalCount = dao.getTotalCount(null);
long revCount = dao.getScheduledCardCount(null);
long newCount = dao.getNewCardCount(null);
String detail = mContext.getString(R.string.stat_total) + totalCount + " " + mContext.getString(R.string.stat_new) + newCount + " " + mContext.getString(R.string.stat_scheduled) + revCount;
rv.setTextViewText(R.id.widget_db_name, dbName);
rv.setTextViewText(R.id.widget_db_detail, detail);
Intent fillInIntent = new Intent();
fillInIntent.putExtra(StudyActivity.EXTRA_DBPATH, allPath[position]);
rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);
}
return rv;
}
Aggregations