Commit f9ce8443 authored by a-j.towse's avatar a-j.towse

fixed dbconnection error

parent 544c033c
...@@ -43,7 +43,6 @@ public class DBConnector extends SQLiteOpenHelper { ...@@ -43,7 +43,6 @@ public class DBConnector extends SQLiteOpenHelper {
private static final String COLUMN_TIXRIVERBANK = "tixRiverBank"; private static final String COLUMN_TIXRIVERBANK = "tixRiverBank";
private static final String COLUMN_TIXINCIRC = "tixInCirc"; private static final String COLUMN_TIXINCIRC = "tixInCirc";
private static final String COLUMN_TIXOUTCIRC = "tixOutCirc"; private static final String COLUMN_TIXOUTCIRC = "tixOutCirc";
private static final String COLUMN_TIXOUTCIRCP = "tixOutCircP";
//Constructor method - create DB //Constructor method - create DB
public DBConnector(Context context, SQLiteDatabase.CursorFactory factory) { public DBConnector(Context context, SQLiteDatabase.CursorFactory factory) {
...@@ -141,15 +140,13 @@ public class DBConnector extends SQLiteOpenHelper { ...@@ -141,15 +140,13 @@ public class DBConnector extends SQLiteOpenHelper {
play6.put(COLUMN_TIXOUTCIRC, "8,13"); play6.put(COLUMN_TIXOUTCIRC, "8,13");
play6.put(COLUMN_TIXSTAND, "10,10"); play6.put(COLUMN_TIXSTAND, "10,10");
SQLiteDatabase database = this.getWritableDatabase(); //Create DB access object
db.insert(TABLE_PERFORMANCES, null, play1); //Store play details db.insert(TABLE_PERFORMANCES, null, play1); //Store play details
db.insert(TABLE_PERFORMANCES, null, play2); //Store play details db.insert(TABLE_PERFORMANCES, null, play2); //Store play details
db.insert(TABLE_PERFORMANCES, null, play3); //Store play details db.insert(TABLE_PERFORMANCES, null, play3); //Store play details
db.insert(TABLE_PERFORMANCES, null, play4); //Store play details db.insert(TABLE_PERFORMANCES, null, play4); //Store play details
db.insert(TABLE_PERFORMANCES, null, play5); //Store play details db.insert(TABLE_PERFORMANCES, null, play5); //Store play details
db.insert(TABLE_PERFORMANCES, null, play6); //Store play details db.insert(TABLE_PERFORMANCES, null, play6); //Store play details
db.close();
} }
...@@ -252,7 +249,7 @@ public class DBConnector extends SQLiteOpenHelper { ...@@ -252,7 +249,7 @@ public class DBConnector extends SQLiteOpenHelper {
} }
//Upgrade DB (to satisfy extends f SQLiteOpenHelper //Upgrade DB (to satisfy extends f SQLiteOpenHelper)
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
...@@ -260,4 +257,3 @@ public class DBConnector extends SQLiteOpenHelper { ...@@ -260,4 +257,3 @@ public class DBConnector extends SQLiteOpenHelper {
} }
...@@ -39,13 +39,12 @@ public class LoginActivity extends AppCompatActivity { ...@@ -39,13 +39,12 @@ public class LoginActivity extends AppCompatActivity {
Intent intent = new Intent(this, MainActivity.class); Intent intent = new Intent(this, MainActivity.class);
//create bundle to pass current username //create bundle to pass current username
Bundle currentUserBundle = new Bundle(); Bundle currentUserBundle = new Bundle();
currentUserBundle.putString("currentUser",username.getText().toString()); currentUserBundle.putString("currentUser", username.getText().toString());
//add bundle to intent //add bundle to intent
intent.putExtras(currentUserBundle); intent.putExtras(currentUserBundle);
//start intent //start intent
startActivity(intent); startActivity(intent);
} } else
else
Toast.makeText(this, "Username / Password not recognised", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Username / Password not recognised", Toast.LENGTH_SHORT).show();
} }
......
...@@ -29,20 +29,24 @@ public class MainActivity extends AppCompatActivity { ...@@ -29,20 +29,24 @@ public class MainActivity extends AppCompatActivity {
TextView usernameTextView = (TextView) findViewById(R.id.usernameTextView); TextView usernameTextView = (TextView) findViewById(R.id.usernameTextView);
usernameTextView.setText(currentUser); usernameTextView.setText(currentUser);
performanceList = new ArrayList<>(); /* performanceList = new ArrayList<>();
RecyclerView recyclerObj = findViewById(R.id.performanceRecycler); RecyclerView recyclerObj = findViewById(R.id.performanceRecycler);
recyclerObj.setLayoutManager(new LinearLayoutManager(this)); recyclerObj.setLayoutManager(new LinearLayoutManager(this));
adapter = new performanceRecAdapter(this, performanceList); adapter = new performanceRecAdapter(this, performanceList);
recyclerObj.setAdapter(adapter); recyclerObj.setAdapter(adapter);
for () //Connect to DB
performanceList.add(performanceList.size(), new IdleData("Test1 ")); DBConnector connector = new DBConnector(this, null);
this.adapter.notifyItemInserted(this.adapter.getItemCount()); ArrayList performanceInfoList = connector.getPerformanceInfo();
performanceList.add(performanceList.size(), new IdleData("Test2 "));
this.adapter.notifyItemInserted(this.adapter.getItemCount()); for (int i = 0;i<performanceInfoList.size();i++) {
performanceList.add(performanceList.size(), new IdleData("Test3 ")); performanceList.add(performanceList.size(),
new IdleData(performanceInfoList.get(i).toString()));
this.adapter.notifyItemInserted(this.adapter.getItemCount()); this.adapter.notifyItemInserted(this.adapter.getItemCount());
}*/
} }
public void logOutBtn(View view) { public void logOutBtn(View view) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment