Search in sources :

Example 1 with AlbumsAdapter

use of org.horaapps.leafpic.adapters.AlbumsAdapter in project LeafPic by HoraApps.

the class AlbumsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_albums, container, false);
    ButterKnife.bind(this, v);
    int spanCount = columnsCount();
    spacingDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getContext()), true);
    rv.setHasFixedSize(true);
    rv.addItemDecoration(spacingDecoration);
    rv.setLayoutManager(new GridLayoutManager(getContext(), spanCount));
    if (Prefs.animationsEnabled()) {
        rv.setItemAnimator(AnimationUtils.getItemAnimator(new LandingAnimator(new OvershootInterpolator(1f))));
    }
    adapter = new AlbumsAdapter(getContext(), this);
    refresh.setOnRefreshListener(this::displayAlbums);
    rv.setAdapter(adapter);
    return v;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) OvershootInterpolator(android.view.animation.OvershootInterpolator) AlbumsAdapter(org.horaapps.leafpic.adapters.AlbumsAdapter) LandingAnimator(jp.wasabeef.recyclerview.animators.LandingAnimator) BindView(butterknife.BindView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration) Nullable(android.support.annotation.Nullable)

Example 2 with AlbumsAdapter

use of org.horaapps.leafpic.adapters.AlbumsAdapter in project LeafPic by HoraApps.

the class MainActivity method initUI.

private void initUI() {
    /**
     ** TOOLBAR ***
     */
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    /**
     ** RECYCLER VIEW ***
     */
    rvAlbums = (RecyclerView) findViewById(R.id.grid_albums);
    rvMedia = ((RecyclerView) findViewById(R.id.grid_photos));
    rvAlbums.setHasFixedSize(true);
    rvAlbums.setItemAnimator(new DefaultItemAnimator());
    rvMedia.setHasFixedSize(true);
    rvMedia.setItemAnimator(new DefaultItemAnimator());
    albumsAdapter = new AlbumsAdapter(getAlbums().dispAlbums, MainActivity.this);
    albumsAdapter.setOnClickListener(albumOnClickListener);
    albumsAdapter.setOnLongClickListener(albumOnLongCLickListener);
    rvAlbums.setAdapter(albumsAdapter);
    mediaAdapter = new MediaAdapter(getAlbum().getMedia(), MainActivity.this);
    mediaAdapter.setOnClickListener(photosOnClickListener);
    mediaAdapter.setOnLongClickListener(photosOnLongClickListener);
    rvMedia.setAdapter(mediaAdapter);
    int spanCount = SP.getInt("n_columns_folders", 2);
    rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
    rvAlbums.addItemDecoration(rvAlbumsDecoration);
    rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
    spanCount = SP.getInt("n_columns_media", 3);
    rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
    rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
    rvMedia.addItemDecoration(rvMediaDecoration);
    /**
     ** SWIPE TO REFRESH ***
     */
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setColorSchemeColors(getAccentColor());
    swipeRefreshLayout.setProgressBackgroundColorSchemeColor(getBackgroundColor());
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (albumsMode) {
                getAlbums().clearSelectedAlbums();
                new PrepareAlbumTask().execute();
            } else {
                getAlbum().clearSelectedPhotos();
                new PreparePhotosTask().execute();
            }
        }
    });
    /**
     ** DRAWER ***
     */
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {

        public void onDrawerClosed(View view) {
        // Put your code here
        // materialMenu.animateIconState(MaterialMenuDrawable.IconState.BURGER);
        }

        public void onDrawerOpened(View drawerView) {
        // Put your code here
        // materialMenu.animateIconState(MaterialMenuDrawable.IconState.ARROW);
        }
    });
    /**
     ** FAB **
     */
    fabCamera = (FloatingActionButton) findViewById(R.id.fab_camera);
    fabCamera.setImageDrawable(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_camera_alt).color(Color.WHITE));
    fabCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
        }
    });
    // region TESTING
    fabCamera.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // NOTE: this is used to acquire write permission on sd with api 21
            // TODO call this one when unable to write on sd
            requestSdCardPermissions();
            return false;
        }
    });
    // endregion
    setRecentApp(getString(R.string.app_name));
    setupUI();
}
Also used : AlbumsAdapter(org.horaapps.leafpic.adapters.AlbumsAdapter) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MediaAdapter(org.horaapps.leafpic.adapters.MediaAdapter) Intent(android.content.Intent) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SearchView(android.support.v7.widget.SearchView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration)

Aggregations

CardView (android.support.v7.widget.CardView)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 AlbumsAdapter (org.horaapps.leafpic.adapters.AlbumsAdapter)2 GridSpacingItemDecoration (org.horaapps.leafpic.views.GridSpacingItemDecoration)2 Intent (android.content.Intent)1 Nullable (android.support.annotation.Nullable)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 SearchView (android.support.v7.widget.SearchView)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 ScrollView (android.widget.ScrollView)1 BindView (butterknife.BindView)1 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)1 IconicsImageView (com.mikepenz.iconics.view.IconicsImageView)1 LandingAnimator (jp.wasabeef.recyclerview.animators.LandingAnimator)1 MediaAdapter (org.horaapps.leafpic.adapters.MediaAdapter)1