Search in sources :

Example 16 with ReaderTag

use of org.wordpress.android.models.ReaderTag in project WordPress-Android by wordpress-mobile.

the class ReaderTagTable method addOrUpdateTags.

private static void addOrUpdateTags(ReaderTagList tagList) {
    if (tagList == null || tagList.size() == 0) {
        return;
    }
    SQLiteStatement stmt = null;
    try {
        stmt = ReaderDatabase.getWritableDb().compileStatement("INSERT OR REPLACE INTO tbl_tags (tag_slug, tag_display_name, tag_title, tag_type, endpoint) VALUES (?1,?2,?3,?4,?5)");
        for (ReaderTag tag : tagList) {
            stmt.bindString(1, tag.getTagSlug());
            stmt.bindString(2, tag.getTagDisplayName());
            stmt.bindString(3, tag.getTagTitle());
            stmt.bindLong(4, tag.tagType.toInt());
            stmt.bindString(5, tag.getEndpoint());
            stmt.execute();
        }
    } finally {
        SqlUtils.closeStatement(stmt);
    }
}
Also used : ReaderTag(org.wordpress.android.models.ReaderTag) SQLiteStatement(android.database.sqlite.SQLiteStatement)

Example 17 with ReaderTag

use of org.wordpress.android.models.ReaderTag in project WordPress-Android by wordpress-mobile.

the class ReaderTagTable method getTagFromCursor.

private static ReaderTag getTagFromCursor(Cursor c) {
    if (c == null) {
        throw new IllegalArgumentException("null tag cursor");
    }
    String tagSlug = c.getString(c.getColumnIndex("tag_slug"));
    String tagDisplayName = c.getString(c.getColumnIndex("tag_display_name"));
    String tagTitle = c.getString(c.getColumnIndex("tag_title"));
    String endpoint = c.getString(c.getColumnIndex("endpoint"));
    ReaderTagType tagType = ReaderTagType.fromInt(c.getInt(c.getColumnIndex("tag_type")));
    return new ReaderTag(tagSlug, tagDisplayName, tagTitle, endpoint, tagType);
}
Also used : ReaderTagType(org.wordpress.android.models.ReaderTagType) ReaderTag(org.wordpress.android.models.ReaderTag)

Example 18 with ReaderTag

use of org.wordpress.android.models.ReaderTag in project WordPress-Android by wordpress-mobile.

the class ReaderTagStrip method addTag.

private void addTag(@NonNull final String tagName) {
    String tagDisplayName = mNumTags > 0 ? ", " + ReaderUtils.makeHashTag(tagName) : ReaderUtils.makeHashTag(tagName);
    // inflate a new textView to show this tag
    LayoutInflater inflater = LayoutInflater.from(getContext());
    TextView txtTag = (TextView) inflater.inflate(R.layout.reader_tag_strip_label, mView, false);
    txtTag.setText(tagDisplayName);
    mView.addView(txtTag);
    mNumTags++;
    // show all posts with this tag when clicked
    txtTag.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ReaderTag tag = ReaderUtils.createTagFromTagName(tagName, ReaderTagType.FOLLOWED);
            ReaderActivityLauncher.showReaderTagPreview(v.getContext(), tag);
        }
    });
}
Also used : ReaderTag(org.wordpress.android.models.ReaderTag) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

ReaderTag (org.wordpress.android.models.ReaderTag)18 ReaderTagList (org.wordpress.android.models.ReaderTagList)5 View (android.view.View)4 TextView (android.widget.TextView)3 JSONObject (org.json.JSONObject)3 Context (android.content.Context)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 SQLiteStatement (android.database.sqlite.SQLiteStatement)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ReaderSiteHeaderView (org.wordpress.android.ui.reader.views.ReaderSiteHeaderView)2 SQLException (android.database.SQLException)1 ActionBar (android.support.v7.app.ActionBar)1 SearchView (android.support.v7.widget.SearchView)1 Toolbar (android.support.v7.widget.Toolbar)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 AdapterView (android.widget.AdapterView)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ImageView (android.widget.ImageView)1 VolleyError (com.android.volley.VolleyError)1