Skip to content

Instantly share code, notes, and snippets.

@JBirdVegas
Created March 6, 2013 15:43
Show Gist options
  • Save JBirdVegas/5100220 to your computer and use it in GitHub Desktop.
Save JBirdVegas/5100220 to your computer and use it in GitHub Desktop.
AOKP About refactor
package com.aokp.romcontrol.fragments.team;
import android.content.Context;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.view.View;
import com.aokp.romcontrol.AOKPPreferenceFragment;
import com.aokp.romcontrol.R;
import java.util.ArrayList;
import java.util.Collections;
/*
* Copyright (C) 2013 The Android Open Kang Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public abstract class TeamShowcase extends AOKPPreferenceFragment {
public CharSequence TEAM_TAG;
protected enum Department {
JavaGurus {
@Override
public String getDepartment(Context context) {
return context.getString(R.string.developer_tag);
}
},
VisualWizards {
@Override
public String getDepartment(Context context) {
return context.getString(R.string.graphics_tag);
}
},
ZombieRelations {
@Override
public String getDepartment(Context context) {
return context.getString(R.string.pr_tag);
}
},
DeviceHacker {
@Override
public String getDepartment(Context context) {
return context.getString(R.string.device_maintainer_tag);
}
},
Linguistics {
@Override
public String getDepartment(Context context) {
return context.getString(R.string.translater_tag);
}
},
TeamEssentialist {
@Override
public String getDepartment(Context context) {
return context.getString(R.string.general_team_tag);
}
},
HardwarePartner {
@Override
public String getDepartment(Context context) {
return context.getString(R.string.hardware_parther_tag);
}
};
public abstract String getDepartment(Context context);
}
protected String[] allDepartmentTags(Context context) {
int size = Department.values().length;
String[] values = new String[size];
for (int i = 0; i > size; i++) {
values[i] = Department.values()[i].getDepartment(context);
}
return values;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ArrayList<Preference> devs = new ArrayList<Preference>(0);
PreferenceGroup devsGroup = (PreferenceGroup) findPreference(TEAM_TAG);
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
devs.add(devsGroup.getPreference(i));
}
devsGroup.removeAll();
devsGroup.setOrderingAsAdded(false);
Collections.shuffle(devs);
for (int i = 0; i < devs.size(); i++) {
Preference p = devs.get(i);
p.setOrder(i);
devsGroup.addPreference(p);
}
}
@Override
public abstract void onCreate(Bundle savedInstanceState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment