Search in sources :

Example 61 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project CloudReader by youlookwhat.

the class MovieDetailActivity method start.

/**
     * @param context      activity
     * @param positionData bean
     * @param imageView    imageView
     */
public static void start(Activity context, SubjectsBean positionData, ImageView imageView) {
    Intent intent = new Intent(context, MovieDetailActivity.class);
    intent.putExtra("bean", positionData);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(context, imageView, //与xml文件对应
    CommonUtils.getString(R.string.transition_movie_img));
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 62 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project CloudReader by youlookwhat.

the class SlideActivity method start.

/**
     * @param context      activity
     * @param positionData bean
     * @param imageView    imageView
     */
public static void start(Activity context, SubjectsBean positionData, ImageView imageView) {
    Intent intent = new Intent(context, SlideActivity.class);
    intent.putExtra("bean", positionData);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(context, imageView, //与xml文件对应
    CommonUtils.getString(R.string.transition_movie_img));
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 63 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project CloudReader by youlookwhat.

the class SlideShadeViewActivity method start.

/**
     * @param context      activity
     * @param positionData bean
     * @param imageView    imageView
     */
public static void start(Activity context, SubjectsBean positionData, ImageView imageView) {
    Intent intent = new Intent(context, SlideShadeViewActivity.class);
    intent.putExtra("bean", positionData);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(context, imageView, //与xml文件对应
    CommonUtils.getString(R.string.transition_movie_img));
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 64 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project ring-client-android by savoirfairelinux.

the class ConversationAdapter method configureForFileInfoTextMessage.

private void configureForFileInfoTextMessage(final ConversationViewHolder conversationViewHolder, final IConversationElement conversationElement) {
    if (conversationViewHolder == null || conversationElement == null) {
        return;
    }
    DataTransfer file = (DataTransfer) conversationElement;
    String timeSeparationString = computeTimeSeparationStringFromMsgTimeStamp(conversationViewHolder.itemView.getContext(), file.getDate());
    if (file.getEventCode() == DataTransferEventCode.FINISHED) {
        conversationViewHolder.mMsgDetailTxt.setText(String.format("%s - %s", timeSeparationString, FileUtils.readableFileSize(file.getTotalSize())));
    } else {
        conversationViewHolder.mMsgDetailTxt.setText(String.format("%s - %s - %s", timeSeparationString, FileUtils.readableFileSize(file.getTotalSize()), ResourceMapper.getReadableFileTransferStatus(conversationFragment.getActivity(), file.getEventCode())));
    }
    boolean showPicture = file.showPicture();
    View longPressView = showPicture ? conversationViewHolder.mPhoto : conversationViewHolder.itemView;
    longPressView.setOnCreateContextMenuListener((menu, v, menuInfo) -> {
        menu.setHeaderTitle(file.getDisplayName());
        conversationFragment.onCreateContextMenu(menu, v, menuInfo);
        MenuInflater inflater = conversationFragment.getActivity().getMenuInflater();
        inflater.inflate(R.menu.conversation_item_actions, menu);
        if (!file.isComplete())
            menu.removeItem(R.id.conv_action_download);
    });
    longPressView.setOnLongClickListener(v -> {
        mCurrentLongItem = new RecyclerViewContextMenuInfo(conversationViewHolder.getLayoutPosition(), v.getId());
        return false;
    });
    if (showPicture) {
        Context context = conversationViewHolder.mPhoto.getContext();
        File path = presenter.getDeviceRuntimeService().getConversationPath(file.getPeerId(), file.getStoragePath());
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) conversationViewHolder.mAnswerLayout.getLayoutParams();
        params.gravity = (file.isOutgoing() ? Gravity.END : Gravity.START) | Gravity.BOTTOM;
        conversationViewHolder.mAnswerLayout.setLayoutParams(params);
        LinearLayout.LayoutParams imageParams = (LinearLayout.LayoutParams) conversationViewHolder.mPhoto.getLayoutParams();
        imageParams.height = mPictureMaxSize;
        conversationViewHolder.mPhoto.setLayoutParams(imageParams);
        GlideApp.with(context).load(path).apply(PICTURE_OPTIONS).into(new ImageViewTarget<Drawable>(conversationViewHolder.mPhoto) {

            @Override
            protected void setResource(@Nullable Drawable resource) {
                ImageView view = getView();
                runJustBeforeBeingDrawn(view, () -> {
                    if (view.getDrawable() != null) {
                        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams();
                        params.height = LinearLayout.LayoutParams.WRAP_CONTENT;
                        view.setLayoutParams(params);
                    }
                });
                view.setImageDrawable(resource);
            }
        });
        ((LinearLayout) conversationViewHolder.mAnswerLayout).setGravity(file.isOutgoing() ? Gravity.END : Gravity.START);
        conversationViewHolder.mPhoto.setOnClickListener(v -> {
            Uri contentUri = FileProvider.getUriForFile(v.getContext(), ContentUriHandler.AUTHORITY_FILES, path);
            Intent i = new Intent(context, MediaViewerActivity.class);
            i.setAction(Intent.ACTION_VIEW).setDataAndType(contentUri, "image/*").setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(conversationFragment.getActivity(), conversationViewHolder.mPhoto, "picture");
            conversationFragment.startActivityForResult(i, 3006, options.toBundle());
        });
        return;
    }
    if (file.getEventCode().isError()) {
        conversationViewHolder.icon.setImageResource(R.drawable.ic_warning);
    } else {
        conversationViewHolder.icon.setImageResource(R.drawable.ic_clip_black);
    }
    conversationViewHolder.mMsgTxt.setText(file.getDisplayName());
    ((LinearLayout) conversationViewHolder.mLayout).setGravity(file.isOutgoing() ? Gravity.END : Gravity.START);
    if (file.getEventCode() == DataTransferEventCode.WAIT_HOST_ACCEPTANCE) {
        conversationViewHolder.mAnswerLayout.setVisibility(View.VISIBLE);
        conversationViewHolder.btnAccept.setOnClickListener(v -> {
            if (!presenter.getDeviceRuntimeService().hasWriteExternalStoragePermission()) {
                conversationFragment.askWriteExternalStoragePermission();
                return;
            }
            Context context = v.getContext();
            File cacheDir = context.getCacheDir();
            long spaceLeft = AndroidFileUtils.getSpaceLeft(cacheDir.toString());
            if (spaceLeft == -1L || file.getTotalSize() > spaceLeft) {
                presenter.noSpaceLeft();
                return;
            }
            context.startService(new Intent(DRingService.ACTION_FILE_ACCEPT).setClass(context.getApplicationContext(), DRingService.class).putExtra(DRingService.KEY_TRANSFER_ID, file.getDataTransferId()));
        });
        conversationViewHolder.btnRefuse.setOnClickListener(v -> {
            Context context = v.getContext();
            context.startService(new Intent(DRingService.ACTION_FILE_CANCEL).setClass(context.getApplicationContext(), DRingService.class).putExtra(DRingService.KEY_TRANSFER_ID, file.getDataTransferId()));
        });
    } else {
        conversationViewHolder.mAnswerLayout.setVisibility(View.GONE);
    }
}
Also used : Context(android.content.Context) MenuInflater(android.view.MenuInflater) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Uri(android.net.Uri) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) DataTransfer(cx.ring.model.DataTransfer) ImageView(android.widget.ImageView) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Example 65 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project AndroidNews by zhjohow.

the class NewsDetailActivity method startAction.

/**
 * 入口
 *
 * @param mContext
 * @param postId
 */
public static void startAction(Context mContext, View view, String postId, String imgUrl) {
    Intent intent = new Intent(mContext, NewsDetailActivity.class);
    intent.putExtra(AppConstant.NEWS_POST_ID, postId);
    intent.putExtra(AppConstant.NEWS_IMG_RES, imgUrl);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation((Activity) mContext, view, AppConstant.TRANSITION_ANIMATION_NEWS_PHOTOS);
        mContext.startActivity(intent, options.toBundle());
    } else {
        // 让新的Activity从一个小的范围扩大到全屏
        ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, view.getWidth() / 2, view.getHeight() / 2, 0, 0);
        ActivityCompat.startActivity((Activity) mContext, intent, options.toBundle());
    }
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) ActivityOptions(android.app.ActivityOptions)

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