Search in sources :

Example 21 with File_POJO

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

the class ItemActivity method renameAlbumItem.

public void renameAlbumItem() {
    File_POJO file = new File_POJO(albumItem.getPath(), true).setName(albumItem.getName());
    Rename.Util.getRenameDialog(this, file, new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            switch(intent.getAction()) {
                case FileOperation.RESULT_DONE:
                    // refresh data
                    final Activity activity = ItemActivity.this;
                    String newFilePath = intent.getStringExtra(Rename.NEW_FILE_PATH);
                    if (newFilePath == null) {
                        return;
                    }
                    int index = newFilePath.lastIndexOf("/");
                    final String albumPath = newFilePath.substring(0, index);
                    getIntent().putExtra(ALBUM_PATH, albumPath);
                    getIntent().putExtra(ITEM_POSITION, album.getAlbumItems().indexOf(albumItem));
                    boolean hiddenFolders = Settings.getInstance(activity).getHiddenFolders();
                    new MediaProvider(activity).loadAlbums(activity, hiddenFolders, new MediaProvider.OnMediaLoadedCallback() {

                        @Override
                        public void onMediaLoaded(ArrayList<Album> albums) {
                            // reload activity
                            MediaProvider.loadAlbum(activity, albumPath, new MediaProvider.OnAlbumLoadedCallback() {

                                @Override
                                public void onAlbumLoaded(Album album) {
                                    ItemActivity.this.albumItem = null;
                                    ItemActivity.this.album = album;
                                    ItemActivity.this.onAlbumLoaded(null);
                                    // notify AlbumActivity
                                    LocalBroadcastManager.getInstance(ItemActivity.this).sendBroadcast(new Intent(AlbumActivity.ALBUM_ITEM_RENAMED));
                                }
                            });
                        }

                        @Override
                        public void timeout() {
                            finish();
                        }

                        @Override
                        public void needPermission() {
                            finish();
                        }
                    });
                    break;
                default:
                    break;
            }
        }
    }).show();
}
Also used : Context(android.content.Context) Activity(android.app.Activity) Album(us.koller.cameraroll.data.models.Album) Intent(android.content.Intent) File_POJO(us.koller.cameraroll.data.models.File_POJO) SpannableString(android.text.SpannableString) BroadcastReceiver(android.content.BroadcastReceiver) MediaProvider(us.koller.cameraroll.data.provider.MediaProvider)

Example 22 with File_POJO

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

the class ExcludePathsActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_excluded_paths);
    currentDir = new File_POJO("", false);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    recyclerView = findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerViewAdapter = new RecyclerViewAdapter(directoryChangeCallback, excludedPathChangeCallback);
    recyclerViewAdapter.notifyDataSetChanged();
    recyclerView.setAdapter(recyclerViewAdapter);
    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() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom());
                recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.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(ExcludePathsActivity.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());
                recyclerView.setPadding(recyclerView.getPaddingStart() + windowInsets[0], recyclerView.getPaddingTop(), recyclerView.getPaddingEnd() + windowInsets[2], recyclerView.getPaddingBottom() + windowInsets[3]);
                rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
    }
    // needed to achieve transparent statusBar in landscape; don't ask me why, but its working
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    // load files
    if (savedInstanceState != null && savedInstanceState.containsKey(CURRENT_DIR) && savedInstanceState.containsKey(ROOTS)) {
        roots = savedInstanceState.getParcelable(ROOTS);
        currentDir = savedInstanceState.getParcelable(CURRENT_DIR);
        recyclerViewAdapter.setFiles(currentDir);
        recyclerViewAdapter.notifyDataSetChanged();
        onPathChanged();
    } else {
        loadRoots();
    }
    Log.d("ExcludedPathsActivity", "onCreate: " + Provider.getExcludedPaths());
}
Also used : ViewGroup(android.view.ViewGroup) File_POJO(us.koller.cameraroll.data.models.File_POJO) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) WindowInsets(android.view.WindowInsets) RequiresApi(android.support.annotation.RequiresApi) ViewTreeObserver(android.view.ViewTreeObserver) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

File_POJO (us.koller.cameraroll.data.models.File_POJO)22 Intent (android.content.Intent)10 Uri (android.net.Uri)6 RecyclerView (android.support.v7.widget.RecyclerView)6 View (android.view.View)6 BroadcastReceiver (android.content.BroadcastReceiver)5 Context (android.content.Context)5 TextView (android.widget.TextView)5 SuppressLint (android.annotation.SuppressLint)3 AlertDialog (android.support.v7.app.AlertDialog)3 Album (us.koller.cameraroll.data.models.Album)3 Activity (android.app.Activity)2 DialogInterface (android.content.DialogInterface)2 Handler (android.os.Handler)2 RequiresApi (android.support.annotation.RequiresApi)2 Snackbar (android.support.design.widget.Snackbar)2 ActionBar (android.support.v7.app.ActionBar)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 Toolbar (android.support.v7.widget.Toolbar)2 SpannableString (android.text.SpannableString)2