PhotoView/sample/src/main/java/bou/amine/apps/photoviewproject/ActivityTransitionActivity.java
2023-01-14 22:50:03 +01:00

61 lines
2.3 KiB
Java
Executable File

/*******************************************************************************
* Copyright 2011, 2012 Chris Banes.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package bou.amine.apps.photoviewproject;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityOptionsCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class ActivityTransitionActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transition);
RecyclerView list = findViewById(R.id.list);
list.setLayoutManager(new GridLayoutManager(this, 2));
ImageAdapter imageAdapter = new ImageAdapter(new ImageAdapter.Listener() {
@Override
public void onImageClicked(View view) {
transition(view);
}
});
list.setAdapter(imageAdapter);
}
private void transition(View view) {
if (Build.VERSION.SDK_INT < 21) {
Toast.makeText(ActivityTransitionActivity.this, "21+ only, keep out", Toast.LENGTH_SHORT).show();
} else {
Intent intent = new Intent(ActivityTransitionActivity.this, ActivityTransitionToActivity.class);
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(ActivityTransitionActivity.this, view, getString(R.string.transition_test));
startActivity(intent, options.toBundle());
}
}
}