Skip to content

Commit 5c09fc4

Browse files
committed
updated
1 parent 5dea0f1 commit 5c09fc4

8 files changed

Lines changed: 50 additions & 16 deletions

File tree

‎de.vogella.android.listactivity/src/de/vogella/android/listactivity/MyList.java‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55

66
import android.app.ListActivity;
77
import android.os.Bundle;
8+
import android.view.View;
89
import android.widget.ArrayAdapter;
10+
import android.widget.ListView;
11+
import android.widget.Toast;
912

1013
public class MyList extends ListActivity {
1114

1215
/** Called when the activity is first created. */
1316
public void onCreate(Bundle icicle) {
1417
super.onCreate(icicle);
1518
// Create an array of Strings, that will be put to our ListActivity
16-
ArrayAdapter<Model> adapter = new InteractiveArrayAdapter(this,
17-
getModel());
19+
// ArrayAdapter<Model> adapter = new InteractiveArrayAdapter(this,
20+
// getModel());
21+
ArrayAdapter<Model> adapter = new ArrayAdapter<Model>(this, android.R.layout.simple_list_item_1, getModel());
1822
setListAdapter(adapter);
1923
}
2024

@@ -33,6 +37,13 @@ private List<Model> getModel() {
3337
return list;
3438
}
3539

40+
@Override
41+
protected void onListItemClick(ListView l, View v, int position, long id) {
42+
Model item = (Model) l.getAdapter().getItem(position);
43+
Toast.makeText(this, item.getName(), Toast.LENGTH_SHORT).show();
44+
super.onListItemClick(l, v, position, id);
45+
}
46+
3647
private Model get(String s) {
3748
return new Model(s);
3849
}

‎de.vogella.android.sqlite.first/AndroidManifest.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<application android:icon="@drawable/icon" android:label="@string/app_name">
99
<activity android:name=".TestDatabase"
10-
android:label="@string/app_name">
10+
android:label="@string/app_name" android:configChanges="orientation">
1111
<intent-filter>
1212
<action android:name="android.intent.action.MAIN" />
1313
<category android:name="android.intent.category.LAUNCHER" />

‎de.vogella.android.sqlite.first/src/de/vogella/android/sqlite/first/CommentsDbAdapter.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.database.SQLException;
77
import android.database.sqlite.SQLiteDatabase;
88

9+
910
public class CommentsDbAdapter {
1011

1112
// Database fields

‎de.vogella.android.sqlite.first/src/de/vogella/android/sqlite/first/MySQLiteHelper.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import android.content.Context;
44
import android.database.sqlite.SQLiteDatabase;
5-
import android.database.sqlite.SQLiteDatabase.CursorFactory;
65
import android.database.sqlite.SQLiteOpenHelper;
76

87
public class MySQLiteHelper extends SQLiteOpenHelper {
98
private static final String DATABASE_NAME = "applicationdata";
109
private static final int DATABASE_VERSION = 1;
1110
// Database creation sql statement
12-
private static final String DATABASE_CREATE = "create table comments (_id integer primary key autoincrement, "
11+
private static final String DATABASE_CREATE = "create table comments " +
12+
"(_id integer primary key autoincrement, "
1313
+ "comment text not null);";
1414

1515
public MySQLiteHelper(Context context) {

‎de.vogella.android.sqlite.first/src/de/vogella/android/sqlite/first/TestDatabase.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import android.app.ListActivity;
66
import android.database.Cursor;
77
import android.os.Bundle;
8-
import android.view.View;
98
import android.widget.SimpleCursorAdapter;
109

1110
public class TestDatabase extends ListActivity {
@@ -38,4 +37,5 @@ protected void onPause() {
3837
db.close();
3938
super.onPause();
4039
}
40+
4141
}

‎de.vogella.gae.java.c2dm/de.vogella.gae.java.c2dm/src/de/vogella/gae/java/c2dm/ReceiveRegistration.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp)
2121

2222
public void doPost(HttpServletRequest req, HttpServletResponse resp)
2323
throws IOException {
24-
System.out.println("Register a new registration key ");
24+
// Register a new registration key
2525
String registrationId = (String) req.getParameter("registrationid");
2626
String deviceId = (String) req.getParameter("deviceid");
27-
Dao.INSTANCE.add(deviceId, registrationId);
2827
resp.setContentType("text/plain");
2928
PrintWriter writer = resp.getWriter();
30-
writer.append("Thank you for registering");
29+
if (registrationId != null && registrationId.length() > 0
30+
&& deviceId != null && deviceId.length() > 0) {
31+
Dao.INSTANCE.add(deviceId, registrationId);
32+
writer.append("Thank you for registering");
33+
} else {
34+
writer.append("Registration failed");
35+
}
3136
}
32-
3337
}

‎de.vogella.gae.java.c2dm/de.vogella.gae.java.c2dm/src/de/vogella/gae/java/c2dm/SendServlet.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
public class SendServlet extends HttpServlet{
2424

2525
private final static String AUTH = "authentication";
26+
// Evil hard code the auth_key
2627
private final static String auth_key ="DQAAAMUAAABLNakYQJ4RGzTc8mrp-7wX4NLyfwZx27o_Gyp6R3zOmVvGxNpeizMGdnorRtBUtyH3xkmHJ8NzY1hXBV9RT4q1miIjC86qZkXw6WW7qJli96bAVfSYegy4KpK7WyNHow1AM3pekYqvQLDR9CaRjuTVvH7bxryWce-sUFp1ME-p_Px1LJ_Ua8dxwbkefEhK5q6oD4rF7NzQ-bOZnW7MD-aOktqVhWcUlX7bj0uc3oVKJnQDgNcfAFmPt4NQc1c8F3o-IleEPpisUCoezuV6SJ0R";
2728

2829
private static final String UPDATE_CLIENT_AUTH = "Update-Client-Auth";
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
package de.vogella.jface.treeviewer.provider;
22

3-
import org.eclipse.jface.viewers.LabelProvider;
3+
import org.eclipse.jface.viewers.StyledCellLabelProvider;
4+
import org.eclipse.jface.viewers.StyledString;
5+
import org.eclipse.jface.viewers.ViewerCell;
6+
import org.eclipse.ui.ISharedImages;
7+
import org.eclipse.ui.PlatformUI;
48

59
import de.vogella.jface.treeviewer.model.Category;
610
import de.vogella.jface.treeviewer.model.Todo;
711

8-
public class TodoLabelProvider extends LabelProvider {
12+
public class TodoLabelProvider extends StyledCellLabelProvider {
913
@Override
10-
public String getText(Object element) {
14+
public void update(ViewerCell cell) {
15+
Object element = cell.getElement();
16+
StyledString text = new StyledString();
17+
1118
if (element instanceof Category) {
1219
Category category = (Category) element;
13-
return category.getName();
20+
text.append(category.getName());
21+
cell.setImage(PlatformUI.getWorkbench().getSharedImages()
22+
.getImage(ISharedImages.IMG_OBJ_FOLDER));
23+
text.append(" ( " +category.getTodos().size() + " ) ", StyledString.COUNTER_STYLER);
24+
} else {
25+
Todo todo = (Todo) element;
26+
text.append(todo.getSummary());
27+
cell.setImage(PlatformUI.getWorkbench().getSharedImages()
28+
.getImage(ISharedImages.IMG_OBJ_FILE));
1429
}
15-
return ((Todo) element).getSummary();
30+
cell.setText(text.toString());
31+
cell.setStyleRanges(text.getStyleRanges());
32+
super.update(cell);
1633
}
17-
}
34+
}

0 commit comments

Comments
 (0)