use of org.wordpress.android.models.Theme in project WordPress-Android by wordpress-mobile.
the class WordPressDB method getTheme.
public Theme getTheme(String blogId, String themeId) {
String[] columns = { COLUMN_NAME_ID, Theme.ID, Theme.AUTHOR, Theme.SCREENSHOT, Theme.AUTHOR_URI, Theme.DEMO_URI, Theme.NAME, Theme.STYLESHEET, Theme.PRICE, Theme.IS_CURRENT };
String[] selection = { blogId, themeId };
Cursor cursor = db.query(THEMES_TABLE, columns, Theme.BLOG_ID + "=? AND " + Theme.ID + "=?", selection, null, null, null);
if (cursor.moveToFirst()) {
String id = cursor.getString(cursor.getColumnIndex(Theme.ID));
String author = cursor.getString(cursor.getColumnIndex(Theme.AUTHOR));
String screenshot = cursor.getString(cursor.getColumnIndex(Theme.SCREENSHOT));
String authorURI = cursor.getString(cursor.getColumnIndex(Theme.AUTHOR_URI));
String demoURI = cursor.getString(cursor.getColumnIndex(Theme.DEMO_URI));
String name = cursor.getString(cursor.getColumnIndex(Theme.NAME));
String stylesheet = cursor.getString(cursor.getColumnIndex(Theme.STYLESHEET));
String price = cursor.getString(cursor.getColumnIndex(Theme.PRICE));
boolean isCurrent = cursor.getInt(cursor.getColumnIndex(Theme.IS_CURRENT)) > 0;
Theme theme = new Theme(id, author, screenshot, authorURI, demoURI, name, stylesheet, price, blogId, isCurrent);
cursor.close();
return theme;
} else {
cursor.close();
return null;
}
}
use of org.wordpress.android.models.Theme in project WordPress-Android by wordpress-mobile.
the class ThemeBrowserActivity method activateTheme.
private void activateTheme(final String themeId) {
final String newThemeId = themeId;
WordPress.getRestClientUtils().setTheme(mSite.getSiteId(), themeId, new Listener() {
@Override
public void onResponse(JSONObject response) {
WordPress.wpDB.setCurrentTheme(String.valueOf(mSite.getSiteId()), newThemeId);
Theme newTheme = WordPress.wpDB.getTheme(String.valueOf(mSite.getSiteId()), newThemeId);
Map<String, Object> themeProperties = new HashMap<>();
themeProperties.put(THEME_ID, themeId);
AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.THEMES_CHANGED_THEME, mSite, themeProperties);
if (!isFinishing()) {
showAlertDialogOnNewSettingNewTheme(newTheme);
fetchCurrentTheme();
}
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), R.string.theme_activation_error, Toast.LENGTH_SHORT).show();
}
});
}
use of org.wordpress.android.models.Theme in project WordPress-Android by wordpress-mobile.
the class ThemeWebActivity method openTheme.
public static void openTheme(Activity activity, SiteModel site, String themeId, ThemeWebActivityType type, boolean isCurrentTheme) {
Theme currentTheme = WordPress.wpDB.getTheme(String.valueOf(site.getSiteId()), themeId);
if (currentTheme == null) {
ToastUtils.showToast(activity, R.string.could_not_load_theme);
return;
}
String url = getUrl(site, currentTheme, type, currentTheme.isPremium());
if (type == ThemeWebActivityType.PREVIEW) {
// Do not open the Customizer with the in-app browser.
// Customizer may need to access local files (mostly pictures) on the device storage,
// and our internal webview doesn't handle this feature yet.
// Ref: https://github.com/wordpress-mobile/WordPress-Android/issues/4934
ActivityLauncher.openUrlExternal(activity, url);
} else {
openWPCOMURL(activity, url, currentTheme, site, isCurrentTheme);
}
}
Aggregations