-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create sample activity to test activity transitions
- Loading branch information
Showing
14 changed files
with
201 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
sample/src/main/java/uk/co/senab/photoview/sample/ActivityTransitionActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* 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 uk.co.senab.photoview.sample; | ||
|
||
import android.content.Intent; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.support.v4.app.ActivityOptionsCompat; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.widget.Toast; | ||
|
||
public class ActivityTransitionActivity extends AppCompatActivity { | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_transition); | ||
|
||
RecyclerView list = (RecyclerView) 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()); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
sample/src/main/java/uk/co/senab/photoview/sample/ActivityTransitionToActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package uk.co.senab.photoview.sample; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
/** | ||
* Activity that gets transitioned to | ||
*/ | ||
public class ActivityTransitionToActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_transition_to); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
sample/src/main/java/uk/co/senab/photoview/sample/ImageAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package uk.co.senab.photoview.sample; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
/** | ||
* Image adapter | ||
*/ | ||
public class ImageAdapter extends RecyclerView.Adapter<ImageViewHolder> { | ||
|
||
Listener mListener; | ||
|
||
public ImageAdapter(Listener listener) { | ||
mListener = listener; | ||
} | ||
|
||
@Override | ||
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
ImageViewHolder holder = ImageViewHolder.inflate(parent); | ||
holder.itemView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
mListener.onImageClicked(view); | ||
} | ||
}); | ||
return holder; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(ImageViewHolder holder, int position) { | ||
|
||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return 20; | ||
} | ||
|
||
public interface Listener { | ||
void onImageClicked(View view); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
sample/src/main/java/uk/co/senab/photoview/sample/ImageViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package uk.co.senab.photoview.sample; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
/** | ||
* Image in recyclerview | ||
*/ | ||
public class ImageViewHolder extends RecyclerView.ViewHolder { | ||
|
||
public static ImageViewHolder inflate(ViewGroup parent) { | ||
View view = LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.item_image, parent, false); | ||
return new ImageViewHolder(view); | ||
} | ||
|
||
public TextView mTextTitle; | ||
|
||
public ImageViewHolder(View view) { | ||
super(view); | ||
mTextTitle = (TextView) view.findViewById(R.id.title); | ||
} | ||
|
||
private void bind(String title) { | ||
mTextTitle.setText(title); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<android.support.v7.widget.RecyclerView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/list" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<uk.co.senab.photoview.PhotoView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/iv_photo" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:transitionName="@string/transition_test" | ||
android:src="@drawable/wallpaper"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ImageView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/wallpaper"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<resources xmlns:tools="http://schemas.android.com/tools"> | ||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/blue</item> | ||
<item name="colorPrimaryDark">@color/blue_dark</item> | ||
<item name="colorAccent">@color/green</item> | ||
|
||
<!-- enable window content transitions --> | ||
<item name="android:windowActivityTransitions" tools:targetApi="lollipop">true</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="transition_test">test</string> | ||
</resources> |