forked from uncleleonfan/FanChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
029225d
commit 473137a
Showing
13 changed files
with
190 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/com/itheima/leon/qqdemo/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/itheima/leon/qqdemo/database/Contact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.itheima.leon.qqdemo.database; | ||
|
||
import org.greenrobot.greendao.annotation.Entity; | ||
import org.greenrobot.greendao.annotation.Id; | ||
import org.greenrobot.greendao.annotation.Generated; | ||
|
||
/** | ||
* 创建者: Leon | ||
* 创建时间: 2016/10/21 17:47 | ||
* 描述: TODO | ||
*/ | ||
@Entity | ||
public class Contact { | ||
public static final String TAG = "Contact"; | ||
@Id(autoincrement = true) | ||
private Long id; | ||
|
||
private String username; | ||
|
||
@Generated(hash = 1642963851) | ||
public Contact(Long id, String username) { | ||
this.id = id; | ||
this.username = username; | ||
} | ||
|
||
@Generated(hash = 672515148) | ||
public Contact() { | ||
} | ||
|
||
public Long getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getUsername() { | ||
return this.username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/itheima/leon/qqdemo/database/DatabaseManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.itheima.leon.qqdemo.database; | ||
|
||
import android.content.Context; | ||
import android.database.sqlite.SQLiteDatabase; | ||
|
||
import com.itheima.leon.qqdemo.app.Constant; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* 创建者: Leon | ||
* 创建时间: 2016/10/21 18:57 | ||
* 描述: TODO | ||
*/ | ||
public class DatabaseManager { | ||
public static final String TAG = "DatabaseManager"; | ||
|
||
private static DatabaseManager sInstance; | ||
private DaoSession mDaoSession; | ||
|
||
|
||
public static DatabaseManager getInstance() { | ||
if (sInstance == null) { | ||
synchronized (DatabaseManager.class) { | ||
if (sInstance == null) { | ||
sInstance = new DatabaseManager(); | ||
} | ||
} | ||
} | ||
return sInstance; | ||
} | ||
|
||
public void init(Context context) { | ||
DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(context, Constant.Database.DATABASE_NAME, null); | ||
SQLiteDatabase writableDatabase = devOpenHelper.getWritableDatabase(); | ||
DaoMaster daoMaster = new DaoMaster(writableDatabase); | ||
mDaoSession = daoMaster.newSession(); | ||
} | ||
|
||
public void saveContact(String userName) { | ||
Contact contact = new Contact(); | ||
contact.setUsername(userName); | ||
mDaoSession.getContactDao().save(contact); | ||
} | ||
|
||
public List<String> queryAllContacts() { | ||
List<Contact> list = mDaoSession.getContactDao().queryBuilder().list(); | ||
ArrayList<String> contacts = new ArrayList<String>(); | ||
for (int i = 0; i < list.size(); i++) { | ||
String contact = list.get(i).getUsername(); | ||
contacts.add(contact); | ||
} | ||
return contacts; | ||
} | ||
|
||
public void deleteAllContacts() { | ||
ContactDao contactDao = mDaoSession.getContactDao(); | ||
contactDao.deleteAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ public class AddFriendItem { | |
|
||
public String timestamp; | ||
|
||
public String isAdded; | ||
public boolean isAdded; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters