Search in sources :

Example 1 with SummaryPreference

use of com.android.settings.SummaryPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProcessStatsDetail method createDetails.

private void createDetails() {
    addPreferencesFromResource(R.xml.app_memory_settings);
    mProcGroup = (PreferenceCategory) findPreference(KEY_PROCS);
    fillProcessesSection();
    SummaryPreference summaryPreference = (SummaryPreference) findPreference(KEY_DETAILS_HEADER);
    // TODO: Find way to share this code with ProcessStatsPreference.
    boolean statsForeground = mApp.mRunWeight > mApp.mBgWeight;
    double avgRam = (statsForeground ? mApp.mRunWeight : mApp.mBgWeight) * mWeightToRam;
    float avgRatio = (float) (avgRam / mMaxMemoryUsage);
    float remainingRatio = 1 - avgRatio;
    Context context = getActivity();
    summaryPreference.setRatios(avgRatio, 0, remainingRatio);
    Formatter.BytesResult usedResult = Formatter.formatBytes(context.getResources(), (long) avgRam, Formatter.FLAG_SHORTER);
    summaryPreference.setAmount(usedResult.value);
    summaryPreference.setUnits(usedResult.units);
    long duration = Math.max(mApp.mRunDuration, mApp.mBgDuration);
    CharSequence frequency = ProcStatsPackageEntry.getFrequency(duration / (float) mTotalTime, getActivity());
    findPreference(KEY_FREQUENCY).setSummary(frequency);
    double max = Math.max(mApp.mMaxBgMem, mApp.mMaxRunMem) * mTotalScale * 1024;
    findPreference(KEY_MAX_USAGE).setSummary(Formatter.formatShortFileSize(getContext(), (long) max));
}
Also used : Context(android.content.Context) SummaryPreference(com.android.settings.SummaryPreference) Formatter(android.text.format.Formatter)

Aggregations

Context (android.content.Context)1 Formatter (android.text.format.Formatter)1 SummaryPreference (com.android.settings.SummaryPreference)1