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());
}
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());
}
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());
}
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);
}
}
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());
}
}
Aggregations