From 7be5275664a26d42bbdd1f2391bb62d82149bee9 Mon Sep 17 00:00:00 2001 From: Petru Trimbitas Date: Mon, 27 May 2013 20:40:57 +0300 Subject: [PATCH] Fix previous commit --- .classpath | 1 + .settings/org.eclipse.jdt.core.prefs | 7 ++++ AndroidManifest.xml | 4 +++ project.properties | 1 + res/layout/eventview.xml | 2 +- res/values/strings.xml | 1 + src/ro/ieval/unical/DatabaseInteract.java | 43 ++++++++++++++++++++--- src/ro/ieval/unical/Event.java | 18 +++++++++- src/ro/ieval/unical/MySQLiteHelper.java | 6 ++-- src/ro/ieval/unical/mainActivity.java | 16 ++++++--- 10 files changed, 84 insertions(+), 15 deletions(-) diff --git a/.classpath b/.classpath index 5e6314e..5381274 100644 --- a/.classpath +++ b/.classpath @@ -4,5 +4,6 @@ + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b080d2d..8000cd6 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,11 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.6 diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 621590d..bb15f71 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -7,6 +7,8 @@ android:minSdkVersion="8" android:targetSdkVersion="17" /> + + + + \ No newline at end of file diff --git a/project.properties b/project.properties index a3ee5ab..5efbce7 100644 --- a/project.properties +++ b/project.properties @@ -12,3 +12,4 @@ # Project target. target=android-17 +android.library.reference.1=../../../../eclipse/facebook-android-sdk-3.0.1/facebook diff --git a/res/layout/eventview.xml b/res/layout/eventview.xml index e462f42..08d8cee 100644 --- a/res/layout/eventview.xml +++ b/res/layout/eventview.xml @@ -25,7 +25,7 @@ /> Unical + 148275978690487 \ No newline at end of file diff --git a/src/ro/ieval/unical/DatabaseInteract.java b/src/ro/ieval/unical/DatabaseInteract.java index dd2dde1..520eba8 100644 --- a/src/ro/ieval/unical/DatabaseInteract.java +++ b/src/ro/ieval/unical/DatabaseInteract.java @@ -1,7 +1,11 @@ package ro.ieval.unical; +import java.util.ArrayList; +import java.util.List; + import android.content.ContentValues; import android.content.Context; +import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; @@ -17,6 +21,7 @@ public class DatabaseInteract { public DatabaseInteract(Context context) { dbHelper = new MySQLiteHelper(context); + database=dbHelper.getWritableDatabase(); } public void open() throws SQLException { @@ -30,15 +35,45 @@ public class DatabaseInteract { //Insert event public void insertEvent(Event e) { ContentValues values = new ContentValues(); - values.put(allColumns[1],e.title); - values.put(allColumns[2],e.description); - values.put(allColumns[3],e.date); - values.put(allColumns[4],e.duration); + values.put(allColumns[0], e._id); + values.put(allColumns[1], e.title); + values.put(allColumns[2], e.description); + values.put(allColumns[3], e.date); + values.put(allColumns[4], e.duration); values.put(allColumns[5], e.repeat); values.put(allColumns[6], e.repeatInterval); values.put(allColumns[7], e.location); database.insert(MySQLiteHelper.Name, null, values); } //Delete event + public void deleteEvent(String id) { + database.delete(MySQLiteHelper.Name, MySQLiteHelper.ID + "=" + id, null); + } //Search event + //Get all events + public List getAllEvents() { + List events=new ArrayList(); + Cursor cursor=database.query(MySQLiteHelper.Name,allColumns,null,null,null,null,null); + + for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()) { + Event ev=cursorToEvent(cursor); + events.add(ev); + } + return events; + } + + private Event cursorToEvent(Cursor cursor) { + // TODO Auto-generated method stub + Event e = new Event(); + e._id=cursor.getString(0); + e.title=cursor.getString(1); + e.description=cursor.getString(2); + e.date=cursor.getInt(3); + e.duration=cursor.getInt(4); + if(cursor.getInt(5)==1) e.repeat=true; + else e.repeat=false; + e.repeatInterval=cursor.getInt(6); + e.location=cursor.getString(7); + return e; + } } diff --git a/src/ro/ieval/unical/Event.java b/src/ro/ieval/unical/Event.java index d508201..14f2c43 100644 --- a/src/ro/ieval/unical/Event.java +++ b/src/ro/ieval/unical/Event.java @@ -1,5 +1,9 @@ package ro.ieval.unical; + +import android.database.Cursor; + public class Event { + public String _id; public int date,duration; public boolean repeat; public int repeatInterval; @@ -7,6 +11,18 @@ public class Event { public String description; public String tags[]; public String title; - Event() { + Event(Cursor cursor) { + _id=cursor.getString(0); + title=cursor.getString(1); + description=cursor.getString(2); + date=cursor.getInt(3); + duration=cursor.getInt(4); + if(cursor.getInt(5)==1) repeat=true; + else repeat=false; + repeatInterval=cursor.getInt(6); + location=cursor.getString(7); + } + Event () { + } } diff --git a/src/ro/ieval/unical/MySQLiteHelper.java b/src/ro/ieval/unical/MySQLiteHelper.java index dc35951..ac53724 100644 --- a/src/ro/ieval/unical/MySQLiteHelper.java +++ b/src/ro/ieval/unical/MySQLiteHelper.java @@ -1,10 +1,7 @@ package ro.ieval.unical; -import java.sql.SQLClientInfoException; - import android.content.Context; import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; @@ -23,7 +20,8 @@ public class MySQLiteHelper extends SQLiteOpenHelper { private static final int dbversion=1; private static final String Database_create = "create table " + Name + "(" + - ID + " integer primary key autoincrement, " + + //ID + " integer primary key autoincrement, " + + ID + " text primary key, " + title + " text not null, " + description + " text, " + date + " integer, " + diff --git a/src/ro/ieval/unical/mainActivity.java b/src/ro/ieval/unical/mainActivity.java index 9b9960f..8faac66 100644 --- a/src/ro/ieval/unical/mainActivity.java +++ b/src/ro/ieval/unical/mainActivity.java @@ -14,6 +14,7 @@ import javax.net.ssl.HttpsURLConnection; import ro.ieval.unical.R; import com.google.gson.Gson; +import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; @@ -21,6 +22,9 @@ import android.util.Base64; import android.widget.EditText; import android.widget.TextView; +import com.facebook.*; + +import com.facebook.model.*; public class mainActivity extends android.app.Activity { Event[] getEventList() { @@ -63,11 +67,13 @@ public class mainActivity extends android.app.Activity { protected void onCreate(Bundle savedInstanceState) { // All Begins here :) // And here it began the olympic app that does olympic thing - setContentView(R.layout.eventview); + super.onCreate(savedInstanceState); + setContentView(R.layout.login); + + /*setContentView(R.layout.eventview); final TextView eventTitle= (TextView) findViewById(R.id.eventTitle); final TextView date=(TextView) findViewById(R.id.date); final TextView description=(TextView) findViewById(R.id.description); - super.onCreate(savedInstanceState); final Handler h=new Handler(); new Thread(new Runnable() { @@ -76,14 +82,14 @@ public class mainActivity extends android.app.Activity { h.post(new Runnable() { public void run() { // aici incepe + eventTitle.setText(events[0].title); date.setText((new Date(events[0].date)).toString()); description.setText(events[0].description); - //DatabaseInteract db=new DatabaseInteract(null); - //db.insertEvent(events[0]); + DatabaseInteract db=new DatabaseInteract(mainActivity.this); } }); } - }).start(); + }).start();*/ } } -- 2.39.2