Skip to content

Commit

Permalink
初级版本无缝列表到详情
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuoSmall committed Jun 7, 2018
1 parent b009b08 commit ea10b49
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@
<activity
android:name=".switchplay.SwitchListVideoActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Theme.AppCompat.Translucent"
android:theme="@style/Theme.AppCompat.Transitions"
android:screenOrientation="portrait" />

<activity
android:name=".switchplay.SwitchDetailActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Theme.AppCompat.Translucent"
android:theme="@style/Theme.AppCompat.Transitions"
android:screenOrientation="portrait" />

<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.example.gsyvideoplayer.switchplay;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
Expand All @@ -20,6 +26,7 @@
public class SwitchDetailActivity extends AppCompatActivity {

public static final String URL = "url";
private static final String OPTION_VIEW = "view";

SwitchVideo detailPlayer;

Expand All @@ -28,6 +35,13 @@ public class SwitchDetailActivity extends AppCompatActivity {

private OrientationUtils orientationUtils;

public static void startTActivity(Activity activity, View transitionView) {
Intent intent = new Intent(activity, SwitchDetailActivity.class);
// 这里指定了共享的视图元素
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, transitionView, OPTION_VIEW);
ActivityCompat.startActivity(activity, intent, options.toBundle());
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -79,6 +93,10 @@ public void onClick(View v) {
});

detailPlayer.setSurfaceToPlay();


// 这里指定了被共享的视图元素
ViewCompat.setTransitionName(detailPlayer, OPTION_VIEW);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.gsyvideoplayer.switchplay;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
Expand Down Expand Up @@ -38,12 +39,6 @@ public void onClick(View v) {
}


public static void gotoDetail(Context context, String url) {
Intent intent = new Intent(context, SwitchDetailActivity.class);
intent.putExtra(SwitchDetailActivity.URL, url);
context.startActivity(intent);
}

public static void savePlayState(SwitchVideo switchVideo) {
sSwitchVideo = switchVideo.saveState();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.gsyvideoplayer.switchplay;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void onClick(View v) {
if (isInPlayingState()) {
SwitchUtil.savePlayState(SwitchVideo.this);
getGSYVideoManager().setLastListener(SwitchVideo.this);
SwitchUtil.gotoDetail(getContext(), mOriginUrl);
SwitchDetailActivity.startTActivity((Activity) getContext(), SwitchVideo.this);
}
}
});
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<!-- window 透明的-->
<style name="Theme.AppCompat.Transitions" parent="AppTheme">
<item name="android:windowContentTransitions">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="Theme.AppCompat.Full" parent="Theme.AppCompat.Translucent">
<item name="android:windowFullscreen">true</item>
</style>
Expand Down

0 comments on commit ea10b49

Please sign in to comment.