Search in sources :

Example 6 with CommentNode

use of net.dean.jraw.models.CommentNode in project Slide by ccrama.

the class CommentSearch method onCreate.

@Override
public void onCreate(Bundle savedInstance) {
    overrideRedditSwipeAnywhere();
    super.onCreate(savedInstance);
    applyColorTheme();
    setContentView(R.layout.activity_filtercomments);
    final EditText search = (EditText) findViewById(R.id.search);
    RecyclerView rv = (RecyclerView) findViewById(R.id.vertical_content);
    final PreCachingLayoutManager mLayoutManager;
    mLayoutManager = new PreCachingLayoutManager(this);
    rv.setLayoutManager(mLayoutManager);
    ArrayList<CommentNode> comments = new ArrayList<>();
    List<CommentObject> commentsOld = DataShare.sharedComments;
    if (commentsOld != null && !commentsOld.isEmpty())
        for (CommentObject o : commentsOld) {
            if (o instanceof CommentItem)
                comments.add(o.comment);
        }
    else
        finish();
    final CommentAdapterSearch adapter = new CommentAdapterSearch(this, comments);
    rv.setAdapter(adapter);
    search.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            String result = search.getText().toString();
            adapter.setResult(result);
            adapter.getFilter().filter(result);
        }
    });
}
Also used : EditText(android.widget.EditText) ArrayList(java.util.ArrayList) CommentNode(net.dean.jraw.models.CommentNode) CommentAdapterSearch(me.ccrama.redditslide.Adapters.CommentAdapterSearch) PreCachingLayoutManager(me.ccrama.redditslide.Views.PreCachingLayoutManager) CommentObject(me.ccrama.redditslide.Adapters.CommentObject) CommentItem(me.ccrama.redditslide.Adapters.CommentItem) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

CommentNode (net.dean.jraw.models.CommentNode)6 RecyclerView (android.support.v7.widget.RecyclerView)3 Typeface (android.graphics.Typeface)2 View (android.view.View)2 FontPreferences (me.ccrama.redditslide.Visuals.FontPreferences)2 Comment (net.dean.jraw.models.Comment)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 BaseActivity (me.ccrama.redditslide.Activities.BaseActivity)1