У меня есть широкий спектр различных элементов, таких как кнопки и строки. Я заполнил его кодом java.
Но я хотел лучше координировать код.
Собираюсь ли я использовать класс модели или как?
И как это?
Что я могу сделать, чтобы организовать этот код наилучшим образом?
public class ListAzcarActivity extends AppCompatActivity {
public static final int REQUEST_CODE = 1;
private ToggleButton[] listBtnCheck;
private ToggleButton[] listBtnPlyStop;
private RadioGroup[] radioGroup;
private TextView[] listOfTextAzcar;
private int[] repeatEachSound;
private String[] textListAzcar;
private boolean[] selectedSound;
private int lengthListSounds;
private MediaPlayer currentPlyStopBtn;
private DataSharedPreferences soundsSharedPref;
private int oneTime;
private boolean noSelectedSound;
private int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
// whatever code is needed for initialization goes here
private RowView rowView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_azcar);
soundsSharedPref = new DataSharedPreferences(this);
new ActionBarView(this, "أذكار مع التكرار");
setResult(RESULT_CANCELED);
initiItems();
}
private void initiItems() {
lengthListSounds = 6;
oneTime = 0;
noSelectedSound = false;
currentPlyStopBtn = (MediaPlayer) MediaPlayer.create(ListAzcarActivity.this, R.raw.a1);
int[] rowView = new int[]{R.id.r1, R.id.r2, R.id.r3, R.id.r4, R.id.r5, R.id.r6};
listBtnCheck = new ToggleButton[lengthListSounds];
listBtnPlyStop = new ToggleButton[lengthListSounds];
View[] viewContainer = new View[lengthListSounds];
listOfTextAzcar = new TextView[lengthListSounds];
selectedSound = new boolean[lengthListSounds];
radioGroup = new RadioGroup[lengthListSounds];
repeatEachSound = new int[lengthListSounds];
Resources resArrayString = getResources();
textListAzcar = resArrayString.getStringArray(R.array.kind_of_azkar);
for (int i = 0; i < listBtnCheck.length; i++) {
for (int j = 0; j < lengthListSounds; j++) {
viewContainer[j] = (View) findViewById(rowView[j]);
listBtnCheck[j] = (ToggleButton) viewContainer[j].findViewById(R.id.bt_check2);
listBtnPlyStop[j] = (ToggleButton) viewContainer[j].findViewById(R.id.bt_play);
radioGroup[j] = (RadioGroup) viewContainer[j].findViewById(R.id.segmentedGroup);
listBtnCheck[j].setTag(j);
listBtnPlyStop[j].setTag(j);
radioGroup[j].setTag(j);
selectedSound[j] = noSelectedSound;
repeatEachSound[j] = oneTime;
listOfTextAzcar[j] = (TextView) viewContainer[j].findViewById(R.id._txt_kind_of_azkar);
listOfTextAzcar[j].setText(textListAzcar[j]);
}
}
}
}