Search in sources :

Example 1 with FeedFilter

use of de.danoeh.antennapod.core.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testComboFilter.

public void testComboFilter() throws Exception {
    String includeFilter = "Hello world";
    String excludeFilter = "dislike";
    FeedFilter filter = new FeedFilter(includeFilter, excludeFilter);
    FeedItem download = new FeedItem();
    download.setTitle("Hello everyone!");
    // because, while it has words from the include filter it also has exclude words
    FeedItem doNotDownload = new FeedItem();
    doNotDownload.setTitle("I dislike the world");
    // because it has no words from the include filter
    FeedItem doNotDownload2 = new FeedItem();
    doNotDownload2.setTitle("no words to include");
    assertTrue(filter.hasExcludeFilter());
    assertTrue(filter.hasIncludeFilter());
    assertTrue(filter.shouldAutoDownload(download));
    assertTrue(!filter.shouldAutoDownload(doNotDownload));
    assertTrue(!filter.shouldAutoDownload(doNotDownload2));
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) FeedFilter(de.danoeh.antennapod.core.feed.FeedFilter)

Example 2 with FeedFilter

use of de.danoeh.antennapod.core.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testBasicExcludeFilter.

public void testBasicExcludeFilter() throws Exception {
    String excludeFilter = "Hello";
    FeedFilter filter = new FeedFilter("", excludeFilter);
    FeedItem item = new FeedItem();
    item.setTitle("Hello world");
    FeedItem item2 = new FeedItem();
    item2.setTitle("Item2");
    assertTrue(filter.excludeOnly());
    assertTrue(!filter.includeOnly());
    assertEquals(excludeFilter, filter.getExcludeFilter());
    assertEquals("", filter.getIncludeFilter());
    assertTrue(!filter.shouldAutoDownload(item));
    assertTrue(filter.shouldAutoDownload(item2));
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) FeedFilter(de.danoeh.antennapod.core.feed.FeedFilter)

Example 3 with FeedFilter

use of de.danoeh.antennapod.core.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testNullFilter.

public void testNullFilter() throws Exception {
    FeedFilter filter = new FeedFilter();
    FeedItem item = new FeedItem();
    item.setTitle("Hello world");
    assertTrue(!filter.excludeOnly());
    assertTrue(!filter.includeOnly());
    assertEquals("", filter.getExcludeFilter());
    assertEquals("", filter.getIncludeFilter());
    assertTrue(filter.shouldAutoDownload(item));
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) FeedFilter(de.danoeh.antennapod.core.feed.FeedFilter)

Example 4 with FeedFilter

use of de.danoeh.antennapod.core.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testBasicIncludeFilter.

public void testBasicIncludeFilter() throws Exception {
    String includeFilter = "Hello";
    FeedFilter filter = new FeedFilter(includeFilter, "");
    FeedItem item = new FeedItem();
    item.setTitle("Hello world");
    FeedItem item2 = new FeedItem();
    item2.setTitle("Don't include me");
    assertTrue(!filter.excludeOnly());
    assertTrue(filter.includeOnly());
    assertEquals("", filter.getExcludeFilter());
    assertEquals(includeFilter, filter.getIncludeFilter());
    assertTrue(filter.shouldAutoDownload(item));
    assertTrue(!filter.shouldAutoDownload(item2));
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) FeedFilter(de.danoeh.antennapod.core.feed.FeedFilter)

Example 5 with FeedFilter

use of de.danoeh.antennapod.core.feed.FeedFilter in project AntennaPod by AntennaPod.

the class FeedFilterTest method testComplexExcludeFilter.

public void testComplexExcludeFilter() throws Exception {
    String excludeFilter = "Hello \"Two words\"";
    FeedFilter filter = new FeedFilter("", excludeFilter);
    FeedItem item = new FeedItem();
    item.setTitle("hello world");
    FeedItem item2 = new FeedItem();
    item2.setTitle("One three words");
    FeedItem item3 = new FeedItem();
    item3.setTitle("One two words");
    assertTrue(filter.excludeOnly());
    assertTrue(!filter.includeOnly());
    assertEquals(excludeFilter, filter.getExcludeFilter());
    assertEquals("", filter.getIncludeFilter());
    assertTrue(!filter.shouldAutoDownload(item));
    assertTrue(filter.shouldAutoDownload(item2));
    assertTrue(!filter.shouldAutoDownload(item3));
}
Also used : FeedItem(de.danoeh.antennapod.core.feed.FeedItem) FeedFilter(de.danoeh.antennapod.core.feed.FeedFilter)

Aggregations

FeedFilter (de.danoeh.antennapod.core.feed.FeedFilter)8 FeedItem (de.danoeh.antennapod.core.feed.FeedItem)6 FeedPreferences (de.danoeh.antennapod.core.feed.FeedPreferences)2 ClipData (android.content.ClipData)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 Editable (android.text.Editable)1 TextUtils (android.text.TextUtils)1 TextWatcher (android.text.TextWatcher)1 Log (android.util.Log)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)1