Use view binding in ChannelFragment.

This commit is contained in:
Isira Seneviratne 2020-11-03 10:56:29 +05:30
parent 7682ebd245
commit 6039484a02

View file

@ -14,7 +14,6 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -28,6 +27,7 @@ import com.jakewharton.rxbinding4.view.RxView;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.database.subscription.SubscriptionEntity; import org.schabi.newpipe.database.subscription.SubscriptionEntity;
import org.schabi.newpipe.databinding.ChannelHeaderBinding; import org.schabi.newpipe.databinding.ChannelHeaderBinding;
import org.schabi.newpipe.databinding.FragmentChannelBinding;
import org.schabi.newpipe.databinding.PlaylistControlBinding; import org.schabi.newpipe.databinding.PlaylistControlBinding;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
@ -80,13 +80,11 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
private SubscriptionManager subscriptionManager; private SubscriptionManager subscriptionManager;
private FragmentChannelBinding channelBinding;
private ChannelHeaderBinding headerBinding; private ChannelHeaderBinding headerBinding;
private PlaylistControlBinding playlistControlBinding; private PlaylistControlBinding playlistControlBinding;
private MenuItem menuRssButton; private MenuItem menuRssButton;
private TextView contentNotSupportedTextView;
private TextView kaomojiTextView;
private TextView noVideosTextView;
public static ChannelFragment getInstance(final int serviceId, final String url, public static ChannelFragment getInstance(final int serviceId, final String url,
final String name) { final String name) {
@ -125,9 +123,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
@Override @Override
public void onViewCreated(final View rootView, final Bundle savedInstanceState) { public void onViewCreated(final View rootView, final Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState); super.onViewCreated(rootView, savedInstanceState);
contentNotSupportedTextView = rootView.findViewById(R.id.error_content_not_supported); channelBinding = FragmentChannelBinding.bind(rootView);
kaomojiTextView = rootView.findViewById(R.id.channel_kaomoji);
noVideosTextView = rootView.findViewById(R.id.channel_no_videos);
} }
@Override @Override
@ -141,6 +137,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
@Override @Override
public void onDestroyView() { public void onDestroyView() {
channelBinding = null;
headerBinding = null; headerBinding = null;
playlistControlBinding = null; playlistControlBinding = null;
super.onDestroyView(); super.onDestroyView();
@ -529,10 +526,10 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo>
} }
private void showContentNotSupported() { private void showContentNotSupported() {
contentNotSupportedTextView.setVisibility(View.VISIBLE); channelBinding.errorContentNotSupported.setVisibility(View.VISIBLE);
kaomojiTextView.setText("(︶︹︺)"); channelBinding.channelKaomoji.setText("(︶︹︺)");
kaomojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f); channelBinding.channelKaomoji.setTextSize(TypedValue.COMPLEX_UNIT_SP, 45f);
noVideosTextView.setVisibility(View.GONE); channelBinding.channelNoVideos.setVisibility(View.GONE);
} }
private PlayQueue getPlayQueue() { private PlayQueue getPlayQueue() {