package fm.jiecao.jiecaovideoplayer; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.MenuItem; import android.view.View; import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer; /** * Created by yujunkui on 16/8/29. */ public class RecyclerViewNormalActivity extends AppCompatActivity { RecyclerView recyclerView; RecyclerViewVideoAdapter adapterVideoList; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setTitle("NormalRecyclerView"); setContentView(R.layout.activity_recyclerview_content); recyclerView = (RecyclerView) findViewById(R.id.recyclerview); recyclerView.setLayoutManager(new LinearLayoutManager(this)); adapterVideoList = new RecyclerViewVideoAdapter(this); recyclerView.setAdapter(adapterVideoList); recyclerView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() { @Override public void onChildViewAttachedToWindow(View view) { } @Override public void onChildViewDetachedFromWindow(View view) { // if (JCVideoPlayerManager.getCurrentJcvdOnFirtFloor() != null) { // JCVideoPlayer videoPlayer = (JCVideoPlayer) JCVideoPlayerManager.getCurrentJcvdOnFirtFloor(); // if (((ViewGroup) view).indexOfChild(videoPlayer) != -1 && videoPlayer.currentState == JCVideoPlayer.CURRENT_STATE_PLAYING) { // JCVideoPlayer.releaseAllVideos(); // } // } } }); } @Override public void onBackPressed() { if (JCVideoPlayer.backPress()) { return; } super.onBackPressed(); } @Override protected void onPause() { super.onPause(); JCVideoPlayer.releaseAllVideos(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); break; } return super.onOptionsItemSelected(item); } }