Search in sources :

Example 11 with AlbumItem

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

the class AlbumActivity method onActivityReenter.

@Override
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void onActivityReenter(int requestCode, Intent data) {
    super.onActivityReenter(requestCode, data);
    Log.d("AlbumActivity", "onActivityReenter: " + this);
    if (data != null) {
        sharedElementReturnPosition = data.getIntExtra(EXTRA_CURRENT_ALBUM_POSITION, -1);
        if (sharedElementReturnPosition > -1 && album != null && sharedElementReturnPosition < album.getAlbumItems().size()) {
            AlbumItem albumItem = album.getAlbumItems().get(sharedElementReturnPosition);
            albumItem.isSharedElement = true;
            postponeEnterTransition();
            recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

                @Override
                public void onLayoutChange(View v, int l, int t, int r, int b, int oL, int oT, int oR, int oB) {
                    recyclerView.removeOnLayoutChangeListener(this);
                    startPostponedEnterTransition();
                }
            });
            recyclerView.scrollToPosition(sharedElementReturnPosition);
        }
    }
/*super.onActivityReenter(requestCode, data);*/
}
Also used : AlbumItem(us.koller.cameraroll.data.models.AlbumItem) View(android.view.View) FastScrollerRecyclerView(us.koller.cameraroll.ui.widget.FastScrollerRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) RequiresApi(android.support.annotation.RequiresApi)

Example 12 with AlbumItem

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

the class AlbumActivity method setPhotosResult.

public void setPhotosResult() {
    final AlbumItem[] selected_items = SelectorModeManager.createAlbumItemArray(recyclerViewAdapter.cancelSelectorMode(this));
    Intent intent = new Intent("us.koller.RESULT_ACTION");
    if (allowMultiple) {
        ClipData clipData = createClipData(selected_items);
        intent.setClipData(clipData);
    } else {
        intent.setData(selected_items[0].getUri(this));
    }
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    setResult(RESULT_OK, intent);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        finishAfterTransition();
    } else {
        finish();
    }
}
Also used : AlbumItem(us.koller.cameraroll.data.models.AlbumItem) Intent(android.content.Intent) ClipData(android.content.ClipData)

Example 13 with AlbumItem

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

the class AlbumActivity method removeAlbumItem.

private void removeAlbumItem(String path) {
    Log.d("AlbumActivity", "removeAlbumItem() called with: path = [" + path + "]");
    int index = -1;
    for (int i = 0; i < album.getAlbumItems().size(); i++) {
        AlbumItem albumItem = album.getAlbumItems().get(i);
        if (albumItem.getPath().equals(path)) {
            index = i;
            break;
        }
    }
    Log.d("AlbumActivity", "removeAlbumItem: " + index);
    if (index > -1) {
        album.getAlbumItems().remove(index);
    }
    recyclerViewAdapter.notifyDataSetChanged();
    if (album.getAlbumItems().size() == 0) {
        finish();
    }
}
Also used : AlbumItem(us.koller.cameraroll.data.models.AlbumItem)

Aggregations

AlbumItem (us.koller.cameraroll.data.models.AlbumItem)13 View (android.view.View)6 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 Album (us.koller.cameraroll.data.models.Album)4 Uri (android.net.Uri)3 ArrayList (java.util.ArrayList)3 Video (us.koller.cameraroll.data.models.Video)3 Activity (android.app.Activity)2 Context (android.content.Context)2 Cursor (android.database.Cursor)2 RequiresApi (android.support.annotation.RequiresApi)2 AlbumActivity (us.koller.cameraroll.ui.AlbumActivity)2 FastScrollerRecyclerView (us.koller.cameraroll.ui.widget.FastScrollerRecyclerView)2 ClipData (android.content.ClipData)1 DialogInterface (android.content.DialogInterface)1 Bitmap (android.graphics.Bitmap)1 Handler (android.os.Handler)1 NonNull (android.support.annotation.NonNull)1 Snackbar (android.support.design.widget.Snackbar)1