修改群名称后到最后一层群名称没变

chengzhenyu 8 ans auparavant
Parent
Commettre
4946a82500

+ 1 - 0
app/src/main/java/ai/pai/client/activity/GroupRenameActivity.java

@@ -119,6 +119,7 @@ public class GroupRenameActivity extends BaseActivity implements View.OnClickLis
119 119
         GroupInfo groupInfo = DBService.getInstance(getApplicationContext()).getGroupInfoByGroupId(groupId);
120 120
         groupInfo.groupName = newGroupName;
121 121
         DBService.getInstance(getApplicationContext()).updateGroupInfo(groupInfo);
122
+        DBService.getInstance(getApplicationContext()).updateGroupPhotoListAfterRename(groupId,newGroupName);
122 123
         Toast.makeText(getApplicationContext(), R.string.group_name_modify_success,Toast.LENGTH_SHORT).show();
123 124
         Bundle bundle = new Bundle();
124 125
         bundle.putString("group_name",newGroupName);

+ 25 - 0
app/src/main/java/ai/pai/client/db/DBService.java

@@ -106,7 +106,32 @@ public class DBService {
106 106
         addNewGroup(info);
107 107
     }
108 108
 
109
+    public void updateGroupPhotoListAfterRename(String groupId,String newGroupName) {
110
+        LogHelper.d(TAG, "dbservice updateGroupPhotoListAfterRename :" + groupId);
109 111
 
112
+        SQLiteDatabase db = null;
113
+        Cursor c = null;
114
+        synchronized (DB_LOCK) {
115
+            try {
116
+                db = dbHelper.getReadableDatabase();
117
+                db.beginTransaction();
118
+                ContentValues cv = new ContentValues();
119
+                cv.put(DBHelper.PHOTO_INFO_COLUMNS.GROUP_NAME,newGroupName);
120
+                String[] args = {groupId};
121
+                db.update(DBHelper.PHOTO_INFO_TABLE,cv,DBHelper.PHOTO_INFO_COLUMNS.PHOTO_GROUP_ID + " =?",args);
122
+                db.setTransactionSuccessful();
123
+            } catch (Exception e) {
124
+                LogHelper.d(TAG, "dbservice updateGroupPhotoListAfterRename error happen " + e);
125
+            } finally {
126
+                try {
127
+                    db.endTransaction();
128
+                } catch (Exception e) {
129
+                    e.printStackTrace();
130
+                }
131
+                closeCursorAndDB(c, db);
132
+            }
133
+        }
134
+    }
110 135
     public ArrayList<GroupPhotoItem> getGroupPhotoListByGroupId(String groupId) {
111 136
         LogHelper.d(TAG, "dbservice getGroupPhotoListByGroupId :" + groupId);
112 137
         ArrayList<GroupPhotoItem> photoItems = new ArrayList<GroupPhotoItem>();