Search in sources :

Example 6 with TermModel

use of org.wordpress.android.fluxc.model.TermModel in project WordPress-Android by wordpress-mobile.

the class SelectCategoriesActivity method saveAndFinish.

private void saveAndFinish() {
    Bundle bundle = new Bundle();
    updateSelectedCategoryList();
    List<TermModel> categories = new ArrayList<>();
    for (Long categoryRemoteId : mSelectedCategories) {
        categories.add(mTaxonomyStore.getCategoryByRemoteId(mSite, categoryRemoteId));
    }
    bundle.putSerializable("selectedCategories", new ArrayList<>(categories));
    Intent mIntent = new Intent();
    mIntent.putExtras(bundle);
    setResult(RESULT_OK, mIntent);
    finish();
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Intent(android.content.Intent) TermModel(org.wordpress.android.fluxc.model.TermModel)

Example 7 with TermModel

use of org.wordpress.android.fluxc.model.TermModel in project WordPress-Android by wordpress-mobile.

the class SelectCategoriesActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (data != null) {
        final Bundle extras = data.getExtras();
        switch(requestCode) {
            case ACTIVITY_REQUEST_CODE_ADD_CATEGORY:
                if (resultCode == RESULT_OK) {
                    TermModel newCategory = (TermModel) extras.getSerializable(AddCategoryActivity.KEY_CATEGORY);
                    // Save selected categories
                    updateSelectedCategoryList();
                    mListScrollPositionManager.saveScrollOffset();
                    mSwipeToRefreshHelper.setRefreshing(true);
                    RemoteTermPayload payload = new RemoteTermPayload(newCategory, mSite);
                    mDispatcher.dispatch(TaxonomyActionBuilder.newPushTermAction(payload));
                    break;
                }
        }
    }
}
Also used : Bundle(android.os.Bundle) TermModel(org.wordpress.android.fluxc.model.TermModel) RemoteTermPayload(org.wordpress.android.fluxc.store.TaxonomyStore.RemoteTermPayload)

Aggregations

TermModel (org.wordpress.android.fluxc.model.TermModel)7 Bundle (android.os.Bundle)4 ArrayList (java.util.ArrayList)4 Intent (android.content.Intent)2 View (android.view.View)2 Button (android.widget.Button)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 AppCompatButton (android.support.v7.widget.AppCompatButton)1 LongSparseArray (android.util.LongSparseArray)1 LayoutInflater (android.view.LayoutInflater)1 AdapterView (android.widget.AdapterView)1 EditText (android.widget.EditText)1 Spinner (android.widget.Spinner)1 TextView (android.widget.TextView)1 NetworkImageView (com.android.volley.toolbox.NetworkImageView)1 Date (java.util.Date)1 List (java.util.List)1 RemoteTermPayload (org.wordpress.android.fluxc.store.TaxonomyStore.RemoteTermPayload)1 CategoryNode (org.wordpress.android.models.CategoryNode)1