Search in sources :

Example 16 with Album

use of us.koller.cameraroll.data.models.Album in project Camera-Roll-Android-App by kollerlukas.

the class ItemActivity method onCreate.

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item);
    MediaProvider.checkPermission(this);
    view_only = getIntent().getBooleanExtra(VIEW_ONLY, false);
    if (!view_only && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && showAnimations()) {
        if (savedInstanceState == null) {
            postponeEnterTransition();
        }
        setEnterSharedElementCallback(sharedElementCallback);
        getWindow().getSharedElementEnterTransition().addListener(transitionListener);
    }
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    bottomBar = findViewById(R.id.bottom_bar);
    if (view_only) {
        ImageView delete = findViewById(R.id.delete_button);
        ((View) delete.getParent()).setVisibility(View.GONE);
        ImageView edit = findViewById(R.id.edit_button);
        ((View) edit.getParent()).setVisibility(View.GONE);
    }
    final ViewGroup rootView = findViewById(R.id.root_view);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

            @Override
            @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
            public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
                toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom());
                bottomBar.setPadding(bottomBar.getPaddingStart() + insets.getSystemWindowInsetLeft(), bottomBar.getPaddingTop(), bottomBar.getPaddingEnd() + insets.getSystemWindowInsetRight(), bottomBar.getPaddingBottom() + insets.getSystemWindowInsetBottom());
                // clear this listener so insets aren't re-applied
                rootView.setOnApplyWindowInsetsListener(null);
                return insets.consumeSystemWindowInsets();
            }
        });
    } else {
        rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                // hacky way of getting window insets on pre-Lollipop
                int[] screenSize = Util.getScreenSize(ItemActivity.this);
                int[] windowInsets = new int[] { Math.abs(screenSize[0] - rootView.getLeft()), Math.abs(screenSize[1] - rootView.getTop()), Math.abs(screenSize[2] - rootView.getRight()), Math.abs(screenSize[3] - rootView.getBottom()) };
                toolbar.setPadding(toolbar.getPaddingStart() + windowInsets[0], toolbar.getPaddingTop() + windowInsets[1], toolbar.getPaddingEnd() + windowInsets[2], toolbar.getPaddingBottom());
                bottomBar.setPadding(bottomBar.getPaddingStart() + windowInsets[0], bottomBar.getPaddingTop(), bottomBar.getPaddingEnd() + windowInsets[2], bottomBar.getPaddingBottom() + windowInsets[3]);
                rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
    // needed to achieve transparent navBar
    setSystemUiFlags();
    if (!view_only) {
        String path;
        if (savedInstanceState != null && savedInstanceState.containsKey(ALBUM_PATH)) {
            path = savedInstanceState.getString(ALBUM_PATH);
        } else {
            path = getIntent().getStringExtra(ALBUM_PATH);
        }
        Log.d("ItemActivity", "loadAlbum() " + path);
        MediaProvider.loadAlbum(this, path, new MediaProvider.OnAlbumLoadedCallback() {

            @Override
            public void onAlbumLoaded(Album album) {
                Log.d("ItemActivity", "onAlbumLoaded()");
                ItemActivity.this.album = album;
                ItemActivity.this.onAlbumLoaded(savedInstanceState);
            }
        });
    } else {
        album = getIntent().getExtras().getParcelable(ALBUM);
        onAlbumLoaded(savedInstanceState);
    }
}
Also used : ViewGroup(android.view.ViewGroup) Album(us.koller.cameraroll.data.models.Album) SpannableString(android.text.SpannableString) ImageView(android.widget.ImageView) View(android.view.View) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) RecyclerView(android.support.v7.widget.RecyclerView) WindowInsets(android.view.WindowInsets) MediaProvider(us.koller.cameraroll.data.provider.MediaProvider) RequiresApi(android.support.annotation.RequiresApi) ImageView(android.widget.ImageView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) ViewTreeObserver(android.view.ViewTreeObserver) ActionBar(android.support.v7.app.ActionBar)

Example 17 with Album

use of us.koller.cameraroll.data.models.Album in project Camera-Roll-Android-App by kollerlukas.

the class ItemActivity method getDefaultLocalBroadcastReceiver.

@Override
public BroadcastReceiver getDefaultLocalBroadcastReceiver() {
    return new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            switch(intent.getAction()) {
                case FileOperation.RESULT_DONE:
                    int type = intent.getIntExtra(FileOperation.TYPE, FileOperation.EMPTY);
                    if (type == FileOperation.MOVE) {
                        ArrayList<String> movedFilesPaths = intent.getStringArrayListExtra(Move.MOVED_FILES_PATHS);
                        for (int i = 0; i < movedFilesPaths.size(); i++) {
                            String path = movedFilesPaths.get(i);
                            // notify AlbumActivity
                            LocalBroadcastManager.getInstance(ItemActivity.this).sendBroadcast(new Intent(AlbumActivity.ALBUM_ITEM_REMOVED).putExtra(ALBUM_ITEM_PATH, path));
                            ItemActivity.this.setResult(RESULT_OK);
                            finish();
                        }
                    }
                    break;
                case DATA_CHANGED:
                    final int albumItemIndex = album.getAlbumItems().indexOf(albumItem);
                    String albumPath = getIntent().getStringExtra(ALBUM_PATH);
                    MediaProvider.loadAlbum(ItemActivity.this, albumPath, new MediaProvider.OnAlbumLoadedCallback() {

                        @Override
                        public void onAlbumLoaded(Album album) {
                            if (album == null) {
                                Toast.makeText(ItemActivity.this, "Error: Album null", Toast.LENGTH_SHORT).show();
                                finish();
                                return;
                            }
                            int index = albumItemIndex;
                            ItemActivity.this.album = album;
                            if (index >= album.getAlbumItems().size()) {
                                index = album.getAlbumItems().size() - 1;
                            }
                            if (index >= 0) {
                                ((ItemAdapter) viewPager.getAdapter()).setAlbum(album);
                                albumItem = album.getAlbumItems().get(index);
                                viewPager.getAdapter().notifyDataSetChanged();
                                viewPager.setCurrentItem(index);
                                final ActionBar actionBar = getSupportActionBar();
                                if (actionBar != null) {
                                    actionBar.setTitle(albumItem.getName());
                                }
                                ItemAdapter adapter = (ItemAdapter) viewPager.getAdapter();
                                ViewHolder viewHolder = adapter.findViewHolderByTag(albumItem.getPath());
                                if (viewHolder != null) {
                                    onShowViewHolder(viewHolder);
                                } else {
                                    ((ItemAdapter) viewPager.getAdapter()).addOnInstantiateItemCallback(new ViewPagerOnInstantiateItemCallback() {

                                        @Override
                                        public boolean onInstantiateItem(ViewHolder viewHolder) {
                                            if (viewHolder.albumItem.getPath().equals(albumItem.getPath())) {
                                                onShowViewHolder(viewHolder);
                                                return false;
                                            }
                                            return true;
                                        }
                                    });
                                }
                            } else {
                                finish();
                            }
                        }
                    });
                    break;
                default:
                    break;
            }
        }
    };
}
Also used : Context(android.content.Context) Album(us.koller.cameraroll.data.models.Album) Intent(android.content.Intent) SpannableString(android.text.SpannableString) BroadcastReceiver(android.content.BroadcastReceiver) ViewHolder(us.koller.cameraroll.adapter.item.viewHolder.ViewHolder) MediaProvider(us.koller.cameraroll.data.provider.MediaProvider) ActionBar(android.support.v7.app.ActionBar) ItemAdapter(us.koller.cameraroll.adapter.item.ItemAdapter)

Example 18 with Album

use of us.koller.cameraroll.data.models.Album in project Camera-Roll-Android-App by kollerlukas.

the class MainActivity method refreshPhotos.

public void refreshPhotos() {
    if (mediaProvider != null) {
        mediaProvider.onDestroy();
        mediaProvider = null;
    }
    snackbar = Snackbar.make(findViewById(R.id.root_view), R.string.loading, Snackbar.LENGTH_INDEFINITE);
    Util.showSnackbar(snackbar);
    final MediaProvider.OnMediaLoadedCallback callback = new MediaProvider.OnMediaLoadedCallback() {

        @Override
        public void onMediaLoaded(final ArrayList<Album> albums) {
            final ArrayList<Album> albumsWithVirtualDirs = MediaProvider.getAlbumsWithVirtualDirectories(MainActivity.this);
            if (albums != null) {
                MainActivity.this.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        MainActivity.this.albums = albumsWithVirtualDirs;
                        recyclerViewAdapter.setData(albumsWithVirtualDirs);
                        snackbar.dismiss();
                        if (mediaProvider != null) {
                            mediaProvider.onDestroy();
                        }
                        mediaProvider = null;
                    }
                });
            }
        }

        @Override
        public void timeout() {
            // handle timeout
            snackbar.dismiss();
            snackbar = Snackbar.make(findViewById(R.id.root_view), R.string.loading_failed, Snackbar.LENGTH_INDEFINITE);
            snackbar.setAction(getString(R.string.retry), new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (mediaProvider != null) {
                        mediaProvider.onDestroy();
                    }
                    refreshPhotos();
                    snackbar.dismiss();
                }
            });
            Util.showSnackbar(snackbar);
            if (mediaProvider != null) {
                mediaProvider.onDestroy();
            }
            mediaProvider = null;
        }

        @Override
        public void needPermission() {
            snackbar.dismiss();
        }
    };
    mediaProvider = new MediaProvider(this);
    mediaProvider.loadAlbums(MainActivity.this, hiddenFolders, callback);
}
Also used : MediaProvider(us.koller.cameraroll.data.provider.MediaProvider) ArrayList(java.util.ArrayList) Album(us.koller.cameraroll.data.models.Album) View(android.view.View) FastScrollerRecyclerView(us.koller.cameraroll.ui.widget.FastScrollerRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ParallaxImageView(us.koller.cameraroll.ui.widget.ParallaxImageView)

Example 19 with Album

use of us.koller.cameraroll.data.models.Album in project Camera-Roll-Android-App by kollerlukas.

the class AlbumActivity method onCreate.

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_album);
    pick_photos = getIntent().getAction() != null && getIntent().getAction().equals(MainActivity.PICK_PHOTOS);
    allowMultiple = getIntent().getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
    MediaProvider.checkPermission(this);
    setExitSharedElementCallback(mCallback);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setEnterTransition(new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER).addTransition(new Slide(Gravity.BOTTOM)).addTransition(new Fade()).setInterpolator(new AccelerateDecelerateInterpolator()));
        getWindow().setReturnTransition(new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER).addTransition(new Slide(Gravity.BOTTOM)).addTransition(new Fade()).setInterpolator(new AccelerateDecelerateInterpolator()));
    }
    final ViewGroup swipeBackView = findViewById(R.id.swipeBackView);
    if (swipeBackView instanceof SwipeBackCoordinatorLayout) {
        ((SwipeBackCoordinatorLayout) swipeBackView).setOnSwipeListener(this);
    }
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (!pick_photos) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) ContextCompat.getDrawable(AlbumActivity.this, R.drawable.back_to_cancel_avd);
            // mutating avd to reset it
            drawable.mutate();
            toolbar.setNavigationIcon(drawable);
        } else {
            toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white);
        }
        Drawable navIcon = toolbar.getNavigationIcon();
        if (navIcon != null) {
            navIcon = DrawableCompat.wrap(navIcon);
            DrawableCompat.setTint(navIcon.mutate(), textColorSecondary);
            toolbar.setNavigationIcon(navIcon);
        }
    } else {
        if (actionBar != null) {
            actionBar.setTitle(allowMultiple ? getString(R.string.pick_photos) : getString(R.string.pick_photo));
        }
        toolbar.setNavigationIcon(R.drawable.ic_clear_white);
        Drawable navIcon = toolbar.getNavigationIcon();
        if (navIcon != null) {
            navIcon = DrawableCompat.wrap(navIcon);
            DrawableCompat.setTint(navIcon.mutate(), accentTextColor);
            toolbar.setNavigationIcon(navIcon);
        }
        Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
        Util.colorToolbarOverflowMenuIcon(toolbar, accentTextColor);
    }
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (recyclerViewAdapter != null && recyclerViewAdapter.isSelectorModeActive()) {
                recyclerViewAdapter.cancelSelectorMode(null);
            } else {
                onBackPressed();
            }
        }
    });
    recyclerView = findViewById(R.id.recyclerView);
    final int columnCount = Settings.getInstance(this).getColumnCount(this);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, columnCount);
    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerViewAdapter = new AlbumAdapter(this, recyclerView, album, pick_photos);
    recyclerView.setAdapter(recyclerViewAdapter);
    float albumGridSpacing = getResources().getDimension(R.dimen.album_grid_spacing);
    ((FastScrollerRecyclerView) recyclerView).addOuterGridSpacing((int) (albumGridSpacing / 2));
    recyclerView.addItemDecoration(new GridMarginDecoration((int) albumGridSpacing));
    if (savedInstanceState != null && savedInstanceState.containsKey(RECYCLER_VIEW_SCROLL_STATE)) {
        recyclerView.getLayoutManager().onRestoreInstanceState(savedInstanceState.getParcelable(RECYCLER_VIEW_SCROLL_STATE));
    }
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        // private float scrollY = 0.0f;
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (recyclerViewAdapter.isSelectorModeActive() || pick_photos) {
                return;
            }
            float translationY = toolbar.getTranslationY() - dy;
            if (-translationY > toolbar.getHeight()) {
                translationY = -toolbar.getHeight();
                if (theme.elevatedToolbar()) {
                    toolbar.setActivated(true);
                }
            } else if (translationY > 0) {
                translationY = 0;
                if (theme.elevatedToolbar() && !recyclerView.canScrollVertically(-1)) {
                    toolbar.setActivated(false);
                }
            }
            toolbar.setTranslationY(translationY);
            // animate statusBarIcon color
            if (theme.darkStatusBarIcons()) {
                float animatedValue = (-translationY) / toolbar.getHeight();
                if (animatedValue > 0.9f) {
                    Util.setLightStatusBarIcons(findViewById(R.id.root_view));
                } else {
                    Util.setDarkStatusBarIcons(findViewById(R.id.root_view));
                }
            }
        }
    });
    final FloatingActionButton fab = findViewById(R.id.fab);
    if (!pick_photos) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Drawable d = ContextCompat.getDrawable(this, R.drawable.ic_delete_avd);
            fab.setImageDrawable(d);
        } else {
            fab.setImageResource(R.drawable.ic_delete_white);
        }
    } else {
        fab.setImageResource(R.drawable.ic_send_white);
    }
    Drawable d = fab.getDrawable();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        d.setTint(accentTextColor);
    } else {
        d = DrawableCompat.wrap(d);
        DrawableCompat.setTint(d.mutate(), accentTextColor);
    }
    fab.setImageDrawable(d);
    fab.setScaleX(0.0f);
    fab.setScaleY(0.0f);
    final ViewGroup rootView = findViewById(R.id.root_view);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

            @Override
            @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
            public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
                toolbar.setPadding(toolbar.getPaddingStart(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd(), toolbar.getPaddingBottom());
                ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
                toolbarParams.leftMargin += insets.getSystemWindowInsetLeft();
                toolbarParams.rightMargin += insets.getSystemWindowInsetRight();
                toolbar.setLayoutParams(toolbarParams);
                recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop() + insets.getSystemWindowInsetTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom());
                fab.setTranslationY(-insets.getSystemWindowInsetBottom());
                fab.setTranslationX(-insets.getSystemWindowInsetRight());
                rootView.setOnApplyWindowInsetsListener(null);
                return insets.consumeSystemWindowInsets();
            }
        });
    } else {
        rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                // hacky way of getting window insets on pre-Lollipop
                // somewhat works...
                int[] screenSize = Util.getScreenSize(AlbumActivity.this);
                int[] windowInsets = new int[] { Math.abs(screenSize[0] - rootView.getLeft()), Math.abs(screenSize[1] - rootView.getTop()), Math.abs(screenSize[2] - rootView.getRight()), Math.abs(screenSize[3] - rootView.getBottom()) };
                toolbar.setPadding(toolbar.getPaddingStart(), toolbar.getPaddingTop() + windowInsets[1], toolbar.getPaddingEnd(), toolbar.getPaddingBottom());
                ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
                toolbarParams.leftMargin += windowInsets[0];
                toolbarParams.rightMargin += windowInsets[2];
                toolbar.setLayoutParams(toolbarParams);
                recyclerView.setPadding(recyclerView.getPaddingStart() + windowInsets[0], recyclerView.getPaddingTop() + windowInsets[1], recyclerView.getPaddingEnd() + windowInsets[2], recyclerView.getPaddingBottom() + windowInsets[3]);
                recyclerView.scrollToPosition(0);
                fab.setTranslationX(-windowInsets[2]);
                fab.setTranslationY(-windowInsets[3]);
                rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
    // onNewIntent(getIntent());
    // needed for transparent statusBar
    setSystemUiFlags();
    // load album
    String path;
    if (savedInstanceState != null && savedInstanceState.containsKey(ALBUM_PATH)) {
        path = savedInstanceState.getString(ALBUM_PATH);
    } else {
        path = getIntent().getStringExtra(ALBUM_PATH);
    }
    MediaProvider.loadAlbum(this, path, new MediaProvider.OnAlbumLoadedCallback() {

        @Override
        public void onAlbumLoaded(Album album) {
            AlbumActivity.this.album = album;
            AlbumActivity.this.onAlbumLoaded(savedInstanceState);
        }
    });
}
Also used : VirtualAlbum(us.koller.cameraroll.data.models.VirtualAlbum) Album(us.koller.cameraroll.data.models.Album) WindowInsets(android.view.WindowInsets) TransitionSet(android.transition.TransitionSet) Slide(android.transition.Slide) SwipeBackCoordinatorLayout(us.koller.cameraroll.ui.widget.SwipeBackCoordinatorLayout) GridMarginDecoration(us.koller.cameraroll.ui.widget.GridMarginDecoration) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) FloatingActionButton(android.support.design.widget.FloatingActionButton) FastScrollerRecyclerView(us.koller.cameraroll.ui.widget.FastScrollerRecyclerView) ViewTreeObserver(android.view.ViewTreeObserver) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar) ViewGroup(android.view.ViewGroup) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) View(android.view.View) FastScrollerRecyclerView(us.koller.cameraroll.ui.widget.FastScrollerRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) GridLayoutManager(android.support.v7.widget.GridLayoutManager) MediaProvider(us.koller.cameraroll.data.provider.MediaProvider) RequiresApi(android.support.annotation.RequiresApi) FastScrollerRecyclerView(us.koller.cameraroll.ui.widget.FastScrollerRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ColorFade(us.koller.cameraroll.util.animators.ColorFade) Fade(android.transition.Fade) AlbumAdapter(us.koller.cameraroll.adapter.album.AlbumAdapter)

Example 20 with Album

use of us.koller.cameraroll.data.models.Album in project Camera-Roll-Android-App by kollerlukas.

the class BaseActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    // registering RemovableStorage...Receiver here so only the visible activity receives the broadcast
    removableStoragePermissionRequestBroadcastReceiver = getRemovableStoragePermissionRequestBroadcastReceiver();
    if (removableStoragePermissionRequestBroadcastReceiver != null) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(FileOperation.NEED_REMOVABLE_STORAGE_PERMISSION);
        broadcastReceivers.add(removableStoragePermissionRequestBroadcastReceiver);
        LocalBroadcastManager.getInstance(this).registerReceiver(removableStoragePermissionRequestBroadcastReceiver, filter);
    }
    if (MediaProvider.dataChanged) {
        MediaProvider.dataChanged = false;
        Settings s = Settings.getInstance(this);
        boolean hiddenFolders = s.getHiddenFolders();
        MediaProvider provider = new MediaProvider(this);
        provider.loadAlbums(this, hiddenFolders, new MediaProvider.OnMediaLoadedCallback() {

            @Override
            public void onMediaLoaded(ArrayList<Album> albums) {
                LocalBroadcastManager manager = LocalBroadcastManager.getInstance(BaseActivity.this);
                manager.sendBroadcast(new Intent().setAction(DATA_CHANGED));
            }

            @Override
            public void timeout() {
            }

            @Override
            public void needPermission() {
                MediaProvider.checkPermission(BaseActivity.this);
            }
        });
    }
}
Also used : IntentFilter(android.content.IntentFilter) MediaProvider(us.koller.cameraroll.data.provider.MediaProvider) Album(us.koller.cameraroll.data.models.Album) Intent(android.content.Intent) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) Settings(us.koller.cameraroll.data.Settings)

Aggregations

Album (us.koller.cameraroll.data.models.Album)21 MediaProvider (us.koller.cameraroll.data.provider.MediaProvider)8 Intent (android.content.Intent)7 RecyclerView (android.support.v7.widget.RecyclerView)7 View (android.view.View)6 ArrayList (java.util.ArrayList)6 VirtualAlbum (us.koller.cameraroll.data.models.VirtualAlbum)5 Context (android.content.Context)4 Settings (us.koller.cameraroll.data.Settings)4 Activity (android.app.Activity)3 BroadcastReceiver (android.content.BroadcastReceiver)3 Uri (android.net.Uri)3 RequiresApi (android.support.annotation.RequiresApi)3 ActionBar (android.support.v7.app.ActionBar)3 SpannableString (android.text.SpannableString)3 AlbumItem (us.koller.cameraroll.data.models.AlbumItem)3 FastScrollerRecyclerView (us.koller.cameraroll.ui.widget.FastScrollerRecyclerView)3 Cursor (android.database.Cursor)2 Handler (android.os.Handler)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2