I have a recyclerview
which onClick shows a videoview
with fullscreen button..
However when i click the full screen button on the videoview.. My RecyclerView gets displayed (or created) again..
I want to display only the video in the videoview in the fullscreen mode..
The following is my Acticity OnCreate() Method :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mangal_stuti_activity);
toolbar = findViewById(R.id.toolbar);
toolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
setSupportActionBar(toolbar);
recyclerView = (findViewById(R.id.recycler_view));
mAdapter = new Adapter(this, movieList, this);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new MyDividerItemDecoration(this, LinearLayoutManager.VERTICAL,16));
recyclerView.setAdapter(mAdapter);
recyclerView.setBackgroundColor(getResources().getColor(R.color.recyclerViewBackground));
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), this.recyclerView, new RecyclerTouchListener.ClickListener()
{
public void onClick(View view, int position) {
toolbar.setVisibility(View.GONE);
playVideo();
}
public void onLongClick(View paramAnonymousView, int paramAnonymousInt) {}
}));
prepareMovieData(); // possibly this function is creating the recyclerview again when the fullScreen is called..
mVideoView = findViewById(R.id.videoView);
mYouTuDraggingView = findViewById(R.id.youtube_view);
mYouTuDraggingView.setCallback(this);
controlPanel = new YoutubeControlPanel(this);
controlPanel.setYouTuDraggingView(mYouTuDraggingView);
mVideoView.setControlPanel(controlPanel);
controlPanel.getFullScreenIv().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mYouTuDraggingView.fullScreenChange();
}
});
controlPanel.getDownIv().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toolbar.setVisibility(View.VISIBLE);
mYouTuDraggingView.fullScreenGoMin();
}
});
}
The fullScreenChange() in YouTuDraggingView class is as below:
void fullScreenChange() {
if (isLandscape()) {
isLandscapeToPortrait = true;
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
} else {
isPortraitToLandscape = true;
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
}
The mangal_stuti_activity.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
tools:context="com.amitabh.dhamma_jaagran.MangalStuti"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/recyclerViewBackground"
android:id="@+id/activity_main"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="@layout/toolbar_stuti_activities"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<com.amitabh.YouTuDraggingView
android:id="@+id/youtube_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:orientation="vertical"
android:visibility="invisible"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:id="@+id/footer_text"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="@color/colorPrimaryDark"
android:text="@string/copyright_footer"
android:textAlignment="center"
android:textColor="@color/white" />
</RelativeLayout>
</LinearLayout>
When i click the fullscreen button on the videoview.. the videoview only should show on the fullscreen.. not the recyclerview...
i think the problem might be in
mAdapter = new Adapter(this, movieList, this);
where another movieList
gets created when the videoview
enters fullscreen..
Any help regarding this would be of great help to me.. thanks in advance..