mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-11 01:40:59 +00:00
Use view binding in LicenseFragment.
This commit is contained in:
parent
910d22daa6
commit
7c581ec108
@ -7,13 +7,14 @@ import android.view.MenuInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.databinding.FragmentLicensesBinding;
|
||||||
|
import org.schabi.newpipe.databinding.ItemSoftwareComponentBinding;
|
||||||
import org.schabi.newpipe.util.ShareUtils;
|
import org.schabi.newpipe.util.ShareUtils;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -67,43 +68,42 @@ public class LicenseFragment extends Fragment {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGroup container,
|
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||||
|
@Nullable final ViewGroup container,
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
final View rootView = inflater.inflate(R.layout.fragment_licenses, container, false);
|
final FragmentLicensesBinding binding = FragmentLicensesBinding
|
||||||
final ViewGroup softwareComponentsView = rootView.findViewById(R.id.software_components);
|
.inflate(inflater, container, false);
|
||||||
|
|
||||||
final View licenseLink = rootView.findViewById(R.id.app_read_license);
|
binding.appReadLicense.setOnClickListener(v -> {
|
||||||
licenseLink.setOnClickListener(v -> {
|
|
||||||
activeLicense = StandardLicenses.GPL3;
|
activeLicense = StandardLicenses.GPL3;
|
||||||
compositeDisposable.add(LicenseFragmentHelper.showLicense(getActivity(),
|
compositeDisposable.add(LicenseFragmentHelper.showLicense(getActivity(),
|
||||||
StandardLicenses.GPL3));
|
StandardLicenses.GPL3));
|
||||||
});
|
});
|
||||||
|
|
||||||
for (final SoftwareComponent component : softwareComponents) {
|
for (final SoftwareComponent component : softwareComponents) {
|
||||||
final View componentView = inflater
|
final ItemSoftwareComponentBinding componentBinding = ItemSoftwareComponentBinding
|
||||||
.inflate(R.layout.item_software_component, container, false);
|
.inflate(inflater, container, false);
|
||||||
final TextView softwareName = componentView.findViewById(R.id.name);
|
componentBinding.name.setText(component.getName());
|
||||||
final TextView copyright = componentView.findViewById(R.id.copyright);
|
componentBinding.copyright.setText(getString(R.string.copyright,
|
||||||
softwareName.setText(component.getName());
|
|
||||||
copyright.setText(getString(R.string.copyright,
|
|
||||||
component.getYears(),
|
component.getYears(),
|
||||||
component.getCopyrightOwner(),
|
component.getCopyrightOwner(),
|
||||||
component.getLicense().getAbbreviation()));
|
component.getLicense().getAbbreviation()));
|
||||||
|
|
||||||
componentView.setTag(component);
|
final View root = componentBinding.getRoot();
|
||||||
componentView.setOnClickListener(v -> {
|
root.setTag(component);
|
||||||
|
root.setOnClickListener(v -> {
|
||||||
activeLicense = component.getLicense();
|
activeLicense = component.getLicense();
|
||||||
compositeDisposable.add(LicenseFragmentHelper.showLicense(getActivity(),
|
compositeDisposable.add(LicenseFragmentHelper.showLicense(getActivity(),
|
||||||
component.getLicense()));
|
component.getLicense()));
|
||||||
});
|
});
|
||||||
softwareComponentsView.addView(componentView);
|
binding.softwareComponents.addView(root);
|
||||||
registerForContextMenu(componentView);
|
registerForContextMenu(root);
|
||||||
}
|
}
|
||||||
if (activeLicense != null) {
|
if (activeLicense != null) {
|
||||||
compositeDisposable.add(LicenseFragmentHelper.showLicense(getActivity(),
|
compositeDisposable.add(LicenseFragmentHelper.showLicense(getActivity(),
|
||||||
activeLicense));
|
activeLicense));
|
||||||
}
|
}
|
||||||
return rootView;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user