Search in sources :

Example 71 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project opacclient by opacapp.

the class AccountListActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    ListView lvAccounts = (ListView) findViewById(R.id.lvAccounts);
    refreshLv();
    lvAccounts.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(AccountListActivity.this, AccountEditActivity.class);
            i.putExtra(AccountEditActivity.EXTRA_ACCOUNT_ID, accounts.get(position).getId());
            i.putExtra(AccountEditActivity.EXTRA_EDITING, true);
            ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, view.getLeft(), view.getTop(), view.getWidth(), view.getHeight());
            ActivityCompat.startActivityForResult(AccountListActivity.this, i, ACCOUNT_EDIT_REQUEST_CODE, options.toBundle());
        }
    });
    lvAccounts.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            ((OpacClient) getApplication()).setAccount(accounts.get(position).getId());
            refreshLv();
            return true;
        }
    });
}
Also used : ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener)

Example 72 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project Camera-Roll-Android-App by kollerlukas.

the class MainAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    final Album album = getData().get(position);
    ((AlbumHolder) holder).setAlbum(album);
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(holder.itemView.getContext(), AlbumActivity.class);
            // intent.putExtra(AlbumActivity.ALBUM, album);
            intent.putExtra(AlbumActivity.ALBUM_PATH, album.getPath());
            if (pickPhotos()) {
                Context c = holder.itemView.getContext();
                boolean allowMultiple = false;
                if (c instanceof Activity) {
                    Activity a = (Activity) c;
                    allowMultiple = a.getIntent().getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
                }
                intent.setAction(MainActivity.PICK_PHOTOS);
                intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultiple);
            } else {
                intent.setAction(AlbumActivity.VIEW_ALBUM);
            }
            ActivityOptionsCompat options;
            Activity context = (Activity) holder.itemView.getContext();
            if (!pickPhotos()) {
                // noinspection unchecked
                options = ActivityOptionsCompat.makeSceneTransitionAnimation(context);
                context.startActivityForResult(intent, MainActivity.REFRESH_PHOTOS_REQUEST_CODE, options.toBundle());
            } else {
                View toolbar = context.findViewById(R.id.toolbar);
                options = ActivityOptionsCompat.makeSceneTransitionAnimation(context, toolbar, context.getString(R.string.toolbar_transition_name));
                context.startActivityForResult(intent, MainActivity.PICK_PHOTOS_REQUEST_CODE, options.toBundle());
            }
        }
    });
}
Also used : Context(android.content.Context) AlbumActivity(us.koller.cameraroll.ui.AlbumActivity) AlbumHolder(us.koller.cameraroll.adapter.main.viewHolder.AlbumHolder) SimpleAlbumHolder(us.koller.cameraroll.adapter.main.viewHolder.SimpleAlbumHolder) NestedRecyclerViewAlbumHolder(us.koller.cameraroll.adapter.main.viewHolder.NestedRecyclerViewAlbumHolder) Album(us.koller.cameraroll.data.models.Album) MainActivity(us.koller.cameraroll.ui.MainActivity) AlbumActivity(us.koller.cameraroll.ui.AlbumActivity) ThemeableActivity(us.koller.cameraroll.ui.ThemeableActivity) Activity(android.app.Activity) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 73 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project Camera-Roll-Android-App by kollerlukas.

the class AlbumAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
    final AlbumItem albumItem = getData().getAlbumItems().get(position);
    if (!albumItem.equals(((AlbumItemHolder) holder).getAlbumItem())) {
        ((AlbumItemHolder) holder).setAlbumItem(albumItem);
    }
    boolean selected = getSelectorManager().isItemSelected(albumItem.getPath());
    ((AlbumItemHolder) holder).setSelected(selected);
    holder.itemView.setTag(albumItem.getPath());
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (getSelectorMode()) {
                onItemSelected((AlbumItemHolder) holder);
            } else {
                Log.d("AlbumAdapter", "onClick: " + getData().getPath());
                Context context = holder.itemView.getContext();
                Intent intent = new Intent(context, ItemActivity.class);
                intent.putExtra(ItemActivity.ALBUM_ITEM, albumItem);
                intent.putExtra(ItemActivity.ALBUM_PATH, getData().getPath());
                intent.putExtra(ItemActivity.ITEM_POSITION, getData().getAlbumItems().indexOf(albumItem));
                if (Settings.getInstance(context).showAnimations()) {
                    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, holder.itemView.findViewById(R.id.image), albumItem.getPath());
                    ActivityCompat.startActivityForResult((Activity) context, intent, ItemActivity.VIEW_IMAGE, options.toBundle());
                } else {
                    ActivityCompat.startActivityForResult((Activity) context, intent, ItemActivity.VIEW_IMAGE, null);
                }
            }
        }
    });
    if (getSelectorManager().callbacksAttached()) {
        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View view) {
                if (!getSelectorMode()) {
                    setSelectorMode(true);
                    clearSelectedItemsList();
                }
                onItemSelected((AlbumItemHolder) holder);
                if (dragSelectEnabled()) {
                    // notify DragSelectTouchListener
                    boolean selected = getSelectorManager().isItemSelected(albumItem.getPath());
                    if (selected) {
                        int position = getData().getAlbumItems().indexOf(albumItem);
                        dragSelectTouchListener.startDragSelection(position);
                    }
                }
                return true;
            }
        });
    }
}
Also used : Context(android.content.Context) AlbumItemHolder(us.koller.cameraroll.adapter.album.viewHolder.AlbumItemHolder) AlbumItem(us.koller.cameraroll.data.models.AlbumItem) ItemActivity(us.koller.cameraroll.ui.ItemActivity) AlbumActivity(us.koller.cameraroll.ui.AlbumActivity) Activity(android.app.Activity) Intent(android.content.Intent) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) ItemActivity(us.koller.cameraroll.ui.ItemActivity)

Example 74 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project CustomViews by AndroidStudy233.

the class CommonFragment method gotoDetail.

@Override
public void gotoDetail() {
    Activity activity = (Activity) getContext();
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, new Pair(imageView, DetailActivity.IMAGE_TRANSITION_NAME), new Pair(address1, DetailActivity.ADDRESS1_TRANSITION_NAME), new Pair(address2, DetailActivity.ADDRESS2_TRANSITION_NAME), new Pair(address3, DetailActivity.ADDRESS3_TRANSITION_NAME), new Pair(address4, DetailActivity.ADDRESS4_TRANSITION_NAME), new Pair(address5, DetailActivity.ADDRESS5_TRANSITION_NAME), new Pair(ratingBar, DetailActivity.RATINGBAR_TRANSITION_NAME), new Pair(head1, DetailActivity.HEAD1_TRANSITION_NAME), new Pair(head2, DetailActivity.HEAD2_TRANSITION_NAME), new Pair(head3, DetailActivity.HEAD3_TRANSITION_NAME), new Pair(head4, DetailActivity.HEAD4_TRANSITION_NAME));
    Intent intent = new Intent(activity, DetailActivity.class);
    intent.putExtra(DetailActivity.EXTRA_IMAGE_URL, imageUrl);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
}
Also used : DetailActivity(com.shiqkuangsan.mycustomviews.ui.activity.api21.DetailActivity) Activity(android.app.Activity) Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Example 75 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project Tapad by berict.

the class IntentHelper method intentSharedElementWithExtra.

public void intentSharedElementWithExtra(final Activity activity, final String targetName, final int start_element_id, final String transitionName, final String extraName, final String extra, int delay, final View v) {
    final String classname = "com.bedrock.padder." + targetName;
    final Class<Object> classToLoad;
    try {
        classToLoad = (Class<Object>) Class.forName(classname);
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                if (Build.VERSION.SDK_INT >= 21) {
                    Intent intent = new Intent(activity, classToLoad);
                    intent.putExtra(extraName, extra);
                    View view = v.findViewById(start_element_id);
                    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, // The view which starts the transition
                    view, // The transitionName of the view we’re transitioning to
                    transitionName);
                    ActivityCompat.startActivity(activity, intent, options.toBundle());
                } else {
                    intentWithExtra(activity, targetName, extraName, extra, 0);
                }
            }
        }, delay);
    } catch (ClassNotFoundException e) {
        Log.i("IntentHelper", "Error, there is no such class");
    }
}
Also used : Handler(android.os.Handler) Intent(android.content.Intent) View(android.view.View) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Aggregations

ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)94 Intent (android.content.Intent)74 View (android.view.View)32 Pair (android.support.v4.util.Pair)18 RecyclerView (android.support.v7.widget.RecyclerView)15 Activity (android.app.Activity)14 ImageView (android.widget.ImageView)14 TextView (android.widget.TextView)13 OnClick (butterknife.OnClick)7 ActivityOptions (android.app.ActivityOptions)4 Context (android.content.Context)4 Bundle (android.os.Bundle)4 Handler (android.os.Handler)4 BindView (butterknife.BindView)4 CardView (android.support.v7.widget.CardView)3 Explode (android.transition.Explode)3 AdapterView (android.widget.AdapterView)3 LinearLayout (android.widget.LinearLayout)3 Uri (android.net.Uri)2 LayoutInflater (android.view.LayoutInflater)2