Jun 23, 2008

(SQLite) Good Add-ons of SQLite for Firefox

There is a good tool of SQLite which is an Add-ons of Firefox, it allows to consult database's informations.

Here is the link : https://addons.mozilla.org/en-US/firefox/addon/5817

Jun 10, 2008

(Android) Is this a problem of BaseAdapter?

I created a object of ListView and my own LinearLayout for each row. The first row contains each column's name, so when i refresh this ListView, the first row don't change, so i pass the first row's value to a variable, and use clear() to remove all my ListView's element, and then add the variable in the ListView. I thought what i should do is create new LinearLayout and add them in ListView, with notifyDataSetChanged() method the ListView should be refreshed.

A problem comes, in the "refreshed" ListView there isn't new values, the values displayed are the first row which contains all column's name and the first row of value which should be deleted by the below clear().

I checked the list in the adapter of ListView, all the new values didn't added in the adapter's list. I can't figure out what is going on here.

The solution i found right now is after clear all the items, create a new adapter like adapter = new MyAdapter(this), and don't forget reset this adapter in the ListView.

Jun 5, 2008

(Java) How to stop a thread without Thread.stop()

The stop() method is deprecated, for example:

private Thread blinker;

public void start() {
blinker = new Thread(this);
blinker.start();
}

public void stop() {
blinker.stop(); // UNSAFE!
}

public void run() {
Thread thisThread = Thread.currentThread();
while (true) {
try {
thisThread.sleep(interval);
} catch (InterruptedException e){
}
repaint();
}
}

Why is Thread.stop deprecated?

Because it is inherently unsafe. Stopping a thread causes it to unlock all the monitors that it has locked. (The monitors are unlocked as the ThreadDeath exception propagates up the stack.) If any of the objects previously protected by these monitors were in an inconsistent state, other threads may now view these objects in an inconsistent state. Such objects are said to be damaged. When threads operate on damaged objects, arbitrary behavior can result. This behavior may be subtle and difficult to detect, or it may be pronounced. Unlike other unchecked exceptions, ThreadDeath kills threads silently; thus, the user has no warning that his program may be corrupted. The corruption can manifest itself at any time after the actual damage occurs, even hours or days in the future. (From java.sun.com)

To replace this method, here is an example:

private volatile Thread blinker;

public void stop() {
blinker = null;
}

public void run() {
Thread thisThread = Thread.currentThread();
while (blinker == thisThread) {
try {
thisThread.sleep(interval);
} catch (InterruptedException e){
}
repaint();
}
}

Jun 3, 2008

(Android) Google I/O '08 Keynote: Client, Connectivity, and the Cloud (1)



Speakers :

Vic Gundotra - Engineering VP
Allen Hurff, MySpace
Steve Horowitz - Android (mobile platform - cool demo) [0:22]
Kevin Gibbs - App Engine [0:33]
Mark Lucovsky - GData and AJAX API's [0:44]
Bruce Johnson - GWT Google Web Toolkit [0.55]
David Glazer - Open Social [1:09]
Nat Brown, iLike

Jun 2, 2008

(Android) How to get screen size

WindowManager a = this.getWindowManager();
Display v = a.getDefaultDisplay();
String s = "Height: " + v.getHeight();
String b = "Widtht: " + v.getWidth();