Search in sources :

Example 1 with WPAlertDialogFragment

use of org.wordpress.android.widgets.WPAlertDialogFragment in project WordPress-Android by wordpress-mobile.

the class ThemeBrowserActivity method searchThemes.

public void searchThemes(String searchTerm) {
    mFetchingThemes = true;
    int page = 1;
    if (mThemeSearchFragment != null) {
        page = mThemeSearchFragment.getPage();
    }
    WordPress.getRestClientUtilsV1_2().getFreeSearchThemes(mSite.getSiteId(), THEME_FETCH_MAX, page, searchTerm, new Listener() {

        @Override
        public void onResponse(JSONObject response) {
            new FetchThemesTask().execute(response);
        }
    }, new ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError response) {
            if (response.toString().equals(AuthFailureError.class.getName())) {
                String errorTitle = getString(R.string.theme_auth_error_title);
                String errorMsg = getString(R.string.theme_auth_error_message);
                if (mIsRunning) {
                    FragmentTransaction ft = getFragmentManager().beginTransaction();
                    WPAlertDialogFragment fragment = WPAlertDialogFragment.newAlertDialog(errorMsg, errorTitle);
                    ft.add(fragment, ALERT_TAB);
                    ft.commitAllowingStateLoss();
                }
                AppLog.d(T.THEMES, getString(R.string.theme_auth_error_authenticate));
            }
            mFetchingThemes = false;
        }
    });
}
Also used : ErrorListener(com.wordpress.rest.RestRequest.ErrorListener) VolleyError(com.android.volley.VolleyError) ErrorListener(com.wordpress.rest.RestRequest.ErrorListener) Listener(com.wordpress.rest.RestRequest.Listener) FragmentTransaction(android.app.FragmentTransaction) JSONObject(org.json.JSONObject) WPAlertDialogFragment(org.wordpress.android.widgets.WPAlertDialogFragment)

Example 2 with WPAlertDialogFragment

use of org.wordpress.android.widgets.WPAlertDialogFragment in project WordPress-Android by wordpress-mobile.

the class ThemeBrowserActivity method fetchThemes.

public void fetchThemes() {
    if (mFetchingThemes) {
        return;
    }
    mFetchingThemes = true;
    int page = 1;
    if (mThemeBrowserFragment != null) {
        page = mThemeBrowserFragment.getPage();
    }
    WordPress.getRestClientUtilsV1_2().getFreeThemes(mSite.getSiteId(), THEME_FETCH_MAX, page, new Listener() {

        @Override
        public void onResponse(JSONObject response) {
            new FetchThemesTask().execute(response);
        }
    }, new ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError response) {
            if (response.toString().equals(AuthFailureError.class.getName())) {
                String errorTitle = getString(R.string.theme_auth_error_title);
                String errorMsg = getString(R.string.theme_auth_error_message);
                if (mIsRunning) {
                    FragmentTransaction ft = getFragmentManager().beginTransaction();
                    WPAlertDialogFragment fragment = WPAlertDialogFragment.newAlertDialog(errorMsg, errorTitle);
                    ft.add(fragment, ALERT_TAB);
                    ft.commitAllowingStateLoss();
                }
                AppLog.d(T.THEMES, getString(R.string.theme_auth_error_authenticate));
            } else {
                Toast.makeText(ThemeBrowserActivity.this, R.string.theme_fetch_failed, Toast.LENGTH_LONG).show();
                AppLog.d(T.THEMES, getString(R.string.theme_fetch_failed) + ": " + response.toString());
            }
            mFetchingThemes = false;
        }
    });
}
Also used : ErrorListener(com.wordpress.rest.RestRequest.ErrorListener) VolleyError(com.android.volley.VolleyError) ErrorListener(com.wordpress.rest.RestRequest.ErrorListener) Listener(com.wordpress.rest.RestRequest.Listener) FragmentTransaction(android.app.FragmentTransaction) JSONObject(org.json.JSONObject) WPAlertDialogFragment(org.wordpress.android.widgets.WPAlertDialogFragment)

Aggregations

FragmentTransaction (android.app.FragmentTransaction)2 VolleyError (com.android.volley.VolleyError)2 ErrorListener (com.wordpress.rest.RestRequest.ErrorListener)2 Listener (com.wordpress.rest.RestRequest.Listener)2 JSONObject (org.json.JSONObject)2 WPAlertDialogFragment (org.wordpress.android.widgets.WPAlertDialogFragment)2