Skip to content

Commit

Permalink
Commit 19
Browse files Browse the repository at this point in the history
- Okay wideget works now, honest to god.
- Killed myself over Admin Suite again.
- Admin suite overhaul almost done, need to make pretty.
  • Loading branch information
DigitalJesus committed Jun 18, 2019
1 parent b2d7735 commit 03e6f3e
Show file tree
Hide file tree
Showing 20 changed files with 1,088 additions and 454 deletions.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".CellEditor"></activity>
<activity android:name=".EditTimetable" />

<receiver android:name=".NextClassWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Expand All @@ -19,8 +22,6 @@
android:resource="@xml/next_class_widget_info" />
</receiver>

<activity android:name=".CellEditor" />
<activity android:name=".AdminEditClass" />
<activity android:name=".AdminEditor" />
<activity
android:name=".LoginActivity"
Expand Down
45 changes: 0 additions & 45 deletions app/src/main/java/com/example/assessment1/AdminEditClass.java

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/java/com/example/assessment1/AdminEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int selectedStudentID = (studentIDList[position]);
Intent intent = new Intent(AdminEditor.this, AdminEditClass.class);
Intent intent = new Intent(AdminEditor.this, EditTimetable.class);
intent.putExtra("studentID", selectedStudentID);
startActivity(intent);
dbHelper.close();
Expand Down
109 changes: 20 additions & 89 deletions app/src/main/java/com/example/assessment1/CellEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,108 +2,39 @@

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import android.widget.EditText;
import android.widget.TextView;

public class CellEditor extends AppCompatActivity {

private static final String TAG = "CELLEDITOR";
// private Map<Integer, Map<Integer, String>> mapList;
// private Map<Integer, String> dataMap;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cell_editor);
DBHelper dbHelper = new DBHelper(this);

//Import Selections from previous classes.
Bundle extras = getIntent().getExtras();
assert extras != null;
int selectedStudentID = extras.getInt("studentID");
String selectedClass = extras.getString("className");

//Get Data for each cell from DB
final String[] idList = dbHelper.queryCellDetails("_id", selectedStudentID, selectedClass);
for (int i = 0; i < idList.length; i++) {
Log.d(TAG, idList[i]);
}
final String[] dayList = dbHelper.queryCellDetails("day", selectedStudentID, selectedClass);
final String[] timeList = dbHelper.queryCellDetails("startTime", selectedStudentID, selectedClass);
final String[] durationList = dbHelper.queryCellDetails("cellDuration", selectedStudentID, selectedClass);
final String[] roomList = dbHelper.queryCellDetails("classRoom", selectedStudentID, selectedClass);
String cellID = extras.getString("id");

//dataMap = new Map<Integer, String>;

//Init. ListView and CustomObject
ListView listView = findViewById(R.id.listView_cell_editor);
final ArrayList<CustomArrayObject> objects = new ArrayList<>();

//For each List item, add to the custom object the four data point for each cell
for (int i = 0; i < dayList.length; i++) {
CustomArrayObject item1 = new CustomArrayObject(Integer.parseInt(idList[i]), dayList[i], timeList[i], durationList[i], roomList[i]);
objects.add(item1);
}
DBHelper dbHelper = new DBHelper(this);

//Display the list using the custom adapter
CustomAdapter customAdapter = new CustomAdapter(this, objects);
listView.setAdapter(customAdapter);
Cell cell = dbHelper.getSingleRecord(cellID);

TextView cellid_ = findViewById(R.id.cellID);
TextView studentID = findViewById(R.id.studentID);

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.d(TAG, "onItemClick: "+objects.get(position).getId_());
}
});
EditText className = findViewById(R.id.className);
EditText roomName = findViewById(R.id.roomName);
EditText day = findViewById(R.id.dayofClass);
EditText startTime = findViewById(R.id.startTime);
EditText duration = findViewById(R.id.duration);

//Be kind, rewind.
dbHelper.close();
cellid_.setText(Integer.toString(cell.getRecordID()));
studentID.setText(Integer.toString(cell.getStudentID()));
className.setText(cell.getClassName());
roomName.setText(cell.getClassRoom());
day.setText(Integer.toString(cell.getDay()));
startTime.setText(Integer.toString(cell.getStartTime()));
duration.setText(Integer.toString(cell.getDuration()));
}

// I tried so hard.
// private void saveData() {
// DBHelper dbHelper = new DBHelper(this);
// int mapSize = Objects.requireNonNull(mapList.get(0)).size() +
// Objects.requireNonNull(mapList.get(1)).size() +
// Objects.requireNonNull(mapList.get(2)).size() +
// Objects.requireNonNull(mapList.get(3)).size();
//
// for (int i = 0; i < mapSize; i++) {
// Iterator<Map.Entry<Integer, String>> itr = mapList.get(i).entrySet().iterator();
// while (itr.hasNext()) {
// Map.Entry<Integer, String> entry = itr.next();
// switch (i) {
// case 0:
// dbHelper.updateRow(entry.getKey(), Integer.parseInt(entry.getValue()), null, -1, -1);
// break;
// case 1:
// dbHelper.updateRow(entry.getKey(), -1, null, Integer.parseInt(entry.getValue()), -1);
// break;
// case 2:
// dbHelper.updateRow(entry.getKey(), -1, null, -1, Integer.parseInt(entry.getValue()));
// break;
// case 3:
// dbHelper.updateRow(entry.getKey(), -1, entry.getValue(), -1, -1);
// break;
// }
// }
// }
// }
//
// public void tempData(int id_, Editable s, int type) {
// dataMap.put(id_, s.toString());
// mapList.put(type, dataMap);
// }
}
}
137 changes: 0 additions & 137 deletions app/src/main/java/com/example/assessment1/CustomAdapter.java

This file was deleted.

Loading

0 comments on commit 03e6f3e

Please sign in to comment.