-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,673 additions
and
59 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
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
98 changes: 98 additions & 0 deletions
98
app/src/main/java/cn/jzvd/demo/ActivityListViewAutoPlay.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,98 @@ | ||
package cn.jzvd.demo; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
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 cn.jzvd.Jzvd; | ||
import cn.jzvd.demo.CustomJzvd.AutoPlayUtils; | ||
|
||
|
||
public class ActivityListViewAutoPlay extends AppCompatActivity { | ||
RecyclerView recyclerView; | ||
AdapterRecyclerView adapterVideoList; | ||
private LinearLayoutManager mLayoutManager; | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
getSupportActionBar().setDisplayShowHomeEnabled(true); | ||
getSupportActionBar().setDisplayShowTitleEnabled(true); | ||
getSupportActionBar().setDisplayUseLogoEnabled(false); | ||
getSupportActionBar().setTitle("RecyclerView"); | ||
setContentView(R.layout.activity_recyclerview_content); | ||
|
||
recyclerView = findViewById(R.id.recyclerview); | ||
mLayoutManager = new LinearLayoutManager(this); | ||
recyclerView.setLayoutManager(mLayoutManager); | ||
|
||
adapterVideoList = new AdapterRecyclerView(this); | ||
recyclerView.setAdapter(adapterVideoList); | ||
recyclerView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() { | ||
@Override | ||
public void onChildViewAttachedToWindow(View view) { | ||
|
||
} | ||
|
||
@Override | ||
public void onChildViewDetachedFromWindow(View view) { | ||
Jzvd jzvd = view.findViewById(R.id.videoplayer); | ||
if (jzvd != null && Jzvd.CURRENT_JZVD != null && | ||
jzvd.jzDataSource.containsTheUrl(Jzvd.CURRENT_JZVD.jzDataSource.getCurrentUrl())) { | ||
if (Jzvd.CURRENT_JZVD != null && Jzvd.CURRENT_JZVD.screen != Jzvd.SCREEN_FULLSCREEN) { | ||
Jzvd.releaseAllVideos(); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | ||
@Override | ||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { | ||
super.onScrollStateChanged(recyclerView, newState); | ||
if (newState == RecyclerView.SCROLL_STATE_IDLE) { | ||
AutoPlayUtils.onScrollPlayVideo(recyclerView, R.id.videoplayer, mLayoutManager.findFirstVisibleItemPosition(), mLayoutManager.findLastVisibleItemPosition()); | ||
} | ||
} | ||
|
||
@Override | ||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | ||
super.onScrolled(recyclerView, dx, dy); | ||
if (dy != 0) { | ||
AutoPlayUtils.onScrollReleaseAllVideos(mLayoutManager.findFirstVisibleItemPosition(), mLayoutManager.findLastVisibleItemPosition(), 0.2f); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (Jzvd.backPress()) { | ||
return; | ||
} | ||
super.onBackPressed(); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
Jzvd.releaseAllVideos(); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
finish(); | ||
break; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
} |
Oops, something went wrong.