Search in sources :

Example 1 with Query

use of com.bumptech.glide.samples.flickr.api.Query in project glide by bumptech.

the class FlickrSearchActivity method onCreate.

/**
   * Called when the activity is first created.
   */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
    backgroundThread = new HandlerThread("BackgroundThumbnailHandlerThread");
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());
    setContentView(R.layout.flickr_search_activity);
    searching = findViewById(R.id.searching);
    searchLoading = findViewById(R.id.search_loading);
    searchTerm = (TextView) findViewById(R.id.search_term);
    Resources res = getResources();
    ViewPager pager = (ViewPager) findViewById(R.id.view_pager);
    pager.setPageMargin(res.getDimensionPixelOffset(R.dimen.page_margin));
    pager.setAdapter(new FlickrPagerAdapter(getSupportFragmentManager()));
    Api.get(this).registerSearchListener(queryListener);
    if (savedInstanceState != null) {
        Query savedQuery = savedInstanceState.getParcelable(STATE_QUERY);
        if (savedQuery != null) {
            executeQuery(savedQuery);
        }
    } else {
        executeQuery(RecentQuery.get());
    }
    int smallGridSize = res.getDimensionPixelSize(R.dimen.small_photo_side);
    int mediumGridSize = res.getDimensionPixelSize(R.dimen.medium_photo_side);
    int listHeightSize = res.getDimensionPixelSize(R.dimen.flickr_list_item_height);
    int screenWidth = getScreenWidth();
    if (savedInstanceState == null) {
        // Weight values determined experimentally by measuring the number of incurred GCs while
        // scrolling through the various photo grids/lists.
        Glide.get(this).preFillBitmapPool(new PreFillType.Builder(smallGridSize).setWeight(1), new PreFillType.Builder(mediumGridSize).setWeight(1), new PreFillType.Builder(screenWidth / 2, listHeightSize).setWeight(6));
    }
}
Also used : StrictMode(android.os.StrictMode) HandlerThread(android.os.HandlerThread) Query(com.bumptech.glide.samples.flickr.api.Query) SearchQuery(com.bumptech.glide.samples.flickr.api.SearchQuery) RecentQuery(com.bumptech.glide.samples.flickr.api.RecentQuery) Handler(android.os.Handler) Resources(android.content.res.Resources) ViewPager(android.support.v4.view.ViewPager)

Example 2 with Query

use of com.bumptech.glide.samples.flickr.api.Query in project glide by bumptech.

the class FlickrSearchActivity method executeSearch.

private void executeSearch(String searchString) {
    Query query = TextUtils.isEmpty(searchString) ? null : new SearchQuery(searchString);
    executeQuery(query);
}
Also used : SearchQuery(com.bumptech.glide.samples.flickr.api.SearchQuery) Query(com.bumptech.glide.samples.flickr.api.Query) SearchQuery(com.bumptech.glide.samples.flickr.api.SearchQuery) RecentQuery(com.bumptech.glide.samples.flickr.api.RecentQuery)

Aggregations

Query (com.bumptech.glide.samples.flickr.api.Query)2 RecentQuery (com.bumptech.glide.samples.flickr.api.RecentQuery)2 SearchQuery (com.bumptech.glide.samples.flickr.api.SearchQuery)2 Resources (android.content.res.Resources)1 Handler (android.os.Handler)1 HandlerThread (android.os.HandlerThread)1 StrictMode (android.os.StrictMode)1 ViewPager (android.support.v4.view.ViewPager)1