use of com.spazedog.lib.rootfw3.extenders.MemoryExtender.MemStat in project mounts2sd by SpazeDog.
the class FragmentTabConfigure method onDialogCreateView.
@Override
public View onDialogCreateView(String tag, LayoutInflater inflater, ViewGroup container, final Bundle extra) {
ViewGroup placeholder = (ViewGroup) inflater.inflate(R.layout.inflate_dialog_placeholder, container, false);
String selectorType = extra.getString("type");
String selectorValue = extra.getString("value");
String[] selectorEnabledValues = getEnabledSelectorValues(extra.getInt("viewId"));
Integer selectorNamesId = getResources().getIdentifier("selector_" + selectorType + "_names", "array", getActivity().getPackageName());
Integer selectorValuesId = getResources().getIdentifier("selector_" + selectorType + "_values", "array", getActivity().getPackageName());
Integer selectorCommentsId = getResources().getIdentifier("selector_" + selectorType + "_comments", "array", getActivity().getPackageName());
if (selectorNamesId != 0 && selectorValuesId != 0) {
String[] selectorNames = getResources().getStringArray(selectorNamesId);
String[] selectorValues = getResources().getStringArray(selectorValuesId);
String[] selectorComments = selectorCommentsId != 0 ? getResources().getStringArray(selectorCommentsId) : new String[selectorNames.length];
for (int i = 0; i < selectorNames.length; i++) {
ViewGroup itemView = (ViewGroup) inflater.inflate(R.layout.inflate_selector_item, (ViewGroup) placeholder, false);
Boolean enabled = true;
if (selectorEnabledValues != null) {
for (int x = 0; x < selectorEnabledValues.length; x++) {
if (selectorEnabledValues[x].equals(selectorValues[i])) {
enabled = true;
break;
}
enabled = false;
}
}
if (selectorType.equals("threshold")) {
selectorComments[i] = Common.convertPrifix((mPreferences.deviceConfig.size_storage_data() * (Double.parseDouble(selectorValues[i]) / 100)));
} else if (selectorType.equals("zram")) {
if (oMemoryUsage == null) {
RootFW rootfw = Root.initiate();
MemStat memstat = rootfw.memory().getUsage();
oMemoryUsage = memstat != null ? memstat.memTotal().doubleValue() : 0D;
Root.release();
}
selectorComments[i] = Common.convertPrifix((oMemoryUsage * (Double.parseDouble(selectorValues[i]) / 100)));
}
((TextView) itemView.findViewById(R.id.item_name)).setText(selectorNames[i]);
if (selectorComments[i] != null && !selectorComments[i].equals("")) {
((TextView) itemView.findViewById(R.id.item_description)).setText(selectorComments[i]);
}
itemView.setSelected(selectorValues[i].equals(selectorValue));
itemView.setEnabled(enabled);
itemView.setTag(selectorValues[i]);
itemView.setOnTouchListener(new ViewEventHandler(new ViewClickListener() {
@Override
public void onViewClick(View v) {
extra.putString("value", (String) v.getTag());
ViewGroup view = (ViewGroup) v.getParent();
for (int i = 0; i < view.getChildCount(); i++) {
View child = view.getChildAt(i);
if (child == v) {
child.setSelected(true);
} else {
child.setSelected(false);
}
}
}
}));
if (i > 0) {
inflater.inflate(R.layout.inflate_dialog_divider, placeholder);
}
placeholder.addView(itemView);
}
}
return placeholder;
}
Aggregations