use of de.mkrtchyan.recoverytools.view.SlidingTabLayout in project Rashr by DsLNeXuS.
the class BackupRestoreFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_backup_restore, container, false);
mActivity = (RashrActivity) getActivity();
mContext = root.getContext();
mPager = (ViewPager) root.findViewById(R.id.vpBackupRestore);
mAdapter = new BackupRestorePagerAdapter(getChildFragmentManager());
mPager.setAdapter(mAdapter);
SlidingTabLayout slidingTabLayout = (SlidingTabLayout) root.findViewById(R.id.stlBackupRestore);
slidingTabLayout.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
@Override
public int getIndicatorColor(int position) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = mContext.getTheme();
theme.resolveAttribute(R.attr.colorAccent, typedValue, true);
return typedValue.data;
}
@Override
public int getDividerColor(int position) {
return 0;
}
});
slidingTabLayout.setViewPager(mPager);
final FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fabCreateBackup);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isRecovery = mPager.getCurrentItem() == 0;
createBackup(isRecovery);
}
});
fab.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_add_white));
slidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (position == 0) {
if (RashrApp.DEVICE.isRecoveryDD() || RashrApp.DEVICE.isRecoveryMTD()) {
fab.setVisibility(View.VISIBLE);
} else {
fab.setVisibility(View.INVISIBLE);
}
} else {
if (RashrApp.DEVICE.isKernelDD() || RashrApp.DEVICE.isKernelMTD()) {
fab.setVisibility(View.VISIBLE);
} else {
fab.setVisibility(View.INVISIBLE);
}
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mAdapter.getRecoveryBackupFragment().getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!(RashrApp.DEVICE.isRecoveryDD() || RashrApp.DEVICE.isRecoveryMTD())) {
Toast.makeText(mContext, R.string.op_not_supported, Toast.LENGTH_SHORT).show();
} else {
showPopup(view);
}
}
});
mAdapter.getKernelBackupFragment().getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!(RashrApp.DEVICE.isKernelDD() || RashrApp.DEVICE.isKernelMTD())) {
Toast.makeText(mContext, R.string.op_not_supported, Toast.LENGTH_SHORT).show();
} else {
showPopup(view);
}
}
});
return root;
}
Aggregations