use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class RecyclerViewFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable final Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.fragment_recyclerview, container, false);
if (mHandler == null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
mHandler = new Handler();
}
});
}
mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerview);
if (mViewPagerFragments != null && !hideBanner()) {
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
for (Fragment fragment : mViewPagerFragments) {
fragmentTransaction.remove(fragment);
}
fragmentTransaction.commit();
mViewPagerFragments.clear();
} else {
mViewPagerFragments = new ArrayList<>();
}
mViewPagerParent = mRootView.findViewById(R.id.viewpagerparent);
mViewPager = (ViewPager) mRootView.findViewById(R.id.viewpager);
mViewPager.setVisibility(View.INVISIBLE);
mViewPagerShadow = mRootView.findViewById(R.id.viewpager_shadow);
mViewPagerShadow.setVisibility(View.INVISIBLE);
mCirclePageIndicator = (CirclePageIndicator) mRootView.findViewById(R.id.indicator);
resizeBanner();
mViewPagerParent.setVisibility(View.INVISIBLE);
ViewUtils.dismissDialog(getChildFragmentManager());
mProgress = mRootView.findViewById(R.id.progress);
mAppBarLayout = ((BaseActivity) getActivity()).getAppBarLayout();
mToolBar = ((BaseActivity) getActivity()).getToolBar();
if (mAppBarLayout != null && !isForeground()) {
mAppBarLayout.postDelayed(new Runnable() {
@Override
public void run() {
if (mAppBarLayout != null && isAdded() && getActivity() != null) {
ViewCompat.setElevation(mAppBarLayout, showViewPager() && !hideBanner() ? 0 : getResources().getDimension(R.dimen.app_bar_elevation));
}
}
}, 150);
}
mTopFab = (FloatingActionButton) mRootView.findViewById(R.id.top_fab);
mBottomFab = (FloatingActionButton) mRootView.findViewById(R.id.bottom_fab);
mRecyclerView.clearOnScrollListeners();
if (showViewPager() && !hideBanner()) {
mScroller = new Scroller();
mRecyclerView.addOnScrollListener(mScroller);
}
mRecyclerView.setAdapter(mRecyclerViewAdapter == null ? mRecyclerViewAdapter = new RecyclerViewAdapter(mItems, new RecyclerViewAdapter.OnViewChangedListener() {
@Override
public void viewChanged() {
getHandler().postDelayed(new Runnable() {
@Override
public void run() {
if (isAdded() && getActivity() != null) {
adjustScrollPosition();
}
}
}, 250);
}
}) : mRecyclerViewAdapter);
mRecyclerView.setLayoutManager(mLayoutManager = getLayoutManager());
if (!Utils.DONATED && !showTopFab() && !isForeground() && getActivity() instanceof NavigationActivity && showAd() && mAdView == null) {
mAdView = new AdView();
} else {
mAdView = null;
}
mTopFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onTopFabClick();
}
});
{
Drawable drawable;
if ((drawable = getTopFabDrawable()) != null) {
mTopFab.setImageDrawable(drawable);
}
}
mBottomFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBottomFabClick();
}
});
{
Drawable drawable;
if ((drawable = getBottomFabDrawable()) != null) {
mBottomFab.setImageDrawable(drawable);
}
}
BaseFragment foregroundFragment = getForegroundFragment();
mForegroundVisible = false;
if (foregroundFragment != null) {
mForegroundParent = mRootView.findViewById(R.id.foreground_parent);
mForegroundText = (TextView) mRootView.findViewById(R.id.foreground_text);
mForegroundText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismissForeground();
}
});
getChildFragmentManager().beginTransaction().replace(R.id.foreground_content, foregroundFragment).commit();
mForegroundHeight = getResources().getDisplayMetrics().heightPixels;
}
if (itemsSize() == 0) {
mLoader = new AsyncTask<Void, Void, List<RecyclerViewItem>>() {
@Override
protected void onPreExecute() {
super.onPreExecute();
showProgress();
init();
}
@Override
protected List<RecyclerViewItem> doInBackground(Void... params) {
if (mDelay && needDelay()) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
e.printStackTrace();
}
mDelay = false;
}
if (isAdded() && getActivity() != null) {
List<RecyclerViewItem> items = new ArrayList<>();
addItems(items);
return items;
}
return null;
}
@Override
protected void onPostExecute(List<RecyclerViewItem> recyclerViewItems) {
super.onPostExecute(recyclerViewItems);
if (isCancelled() || recyclerViewItems == null)
return;
for (RecyclerViewItem item : recyclerViewItems) {
addItem(item);
}
hideProgress();
postInit();
mRecyclerView.post(new Runnable() {
@Override
public void run() {
Activity activity;
if ((activity = getActivity()) != null) {
mRecyclerView.scrollToPosition(0);
mLayoutManager.scrollToPosition(0);
mRecyclerView.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.slide_in_bottom));
}
}
});
if (savedInstanceState == null) {
mViewPager.post(new Runnable() {
@Override
public void run() {
if (getActivity() != null) {
int cx = mViewPager.getWidth();
SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mViewPager, cx / 2, 0, 0, cx);
animator.addListener(new SupportAnimator.SimpleAnimatorListener() {
@Override
public void onAnimationStart() {
super.onAnimationStart();
mViewPager.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd() {
super.onAnimationEnd();
mViewPagerShadow.setVisibility(View.VISIBLE);
}
});
animator.setDuration(400);
animator.start();
}
}
});
} else {
mViewPager.setVisibility(View.VISIBLE);
mViewPagerShadow.setVisibility(View.VISIBLE);
}
mLoader = null;
}
};
mLoader.execute();
} else {
showProgress();
init();
hideProgress();
postInit();
adjustScrollPosition();
mViewPager.setVisibility(View.VISIBLE);
mViewPagerShadow.setVisibility(View.VISIBLE);
}
return mRootView;
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class RecyclerViewFragment method onPause.
@Override
public void onPause() {
super.onPause();
mHandler.removeCallbacks(mRefresh);
for (RecyclerViewItem item : mItems) {
item.onPause();
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class LMKFragment method profileInit.
private void profileInit(List<RecyclerViewItem> items) {
TitleView profilesTitle = new TitleView();
profilesTitle.setText(getString(R.string.profile));
items.add(profilesTitle);
for (int id : sProfiles.keySet()) {
DescriptionView profile = new DescriptionView();
profile.setTitle(getString(id));
profile.setSummary(sProfiles.get(id));
profile.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
LMK.setMinFree(((DescriptionView) item).getSummary().toString(), getActivity());
refreshMinFree();
}
});
items.add(profile);
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class PathReaderFragment method load.
private void load(List<RecyclerViewItem> items) {
if (mPath == null)
return;
String path = mPath;
if (path.contains("%d")) {
path = Utils.strFormat(mPath, mMin);
}
RootFile files = new RootFile(path);
for (final RootFile file : files.listFiles()) {
final String name = file.getName();
final String value = file.readFile();
if (value != null && !value.isEmpty() && !value.contains("\n")) {
DescriptionView descriptionView = new DescriptionView();
descriptionView.setTitle(name);
descriptionView.setSummary(value);
descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
List<Integer> freqs = CPUFreq.getFreqs(mMin);
int freq = Utils.strToInt(value);
if (freqs != null && freq != 0 && freqs.contains(freq)) {
String[] values = new String[freqs.size()];
for (int i = 0; i < values.length; i++) {
values[i] = String.valueOf(freqs.get(i));
}
showArrayDialog(value, values, mPath + "/" + name, name);
} else {
showEditTextDialog(value, name);
}
}
});
items.add(descriptionView);
}
}
}
use of com.moro.mtweaks.views.recyclerview.RecyclerViewItem in project MTweaks-KernelAdiutorMOD by morogoku.
the class ScreenFragment method restoreValuesInit.
private void restoreValuesInit(List<RecyclerViewItem> items) {
ButtonView2 bv = new ButtonView2();
bv.setSummary(getString(R.string.restore_summary));
bv.setButtonText(getString(R.string.restore_button));
bv.setOnItemClickListener(new ButtonView2.OnItemClickListener() {
@Override
public void onClick(RecyclerViewItem item) {
Calibration.restoreCalibrationStockValues(getActivity());
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, new ScreenFragment()).commit();
}
});
items.add(bv);
}
Aggregations