@ -9,7 +9,7 @@ import com.kanglai.push.entity.LocalPushChatMsg;
@@ -9,7 +9,7 @@ import com.kanglai.push.entity.LocalPushChatMsg;
import com.kanglai.push.entity.User ;
import java.lang.reflect.Type ;
import java.util.Map ;
import java.util.Hash Map ;
import java.util.Objects ;
import lombok.experimental.UtilityClass ;
@ -19,17 +19,17 @@ public class HistoryMsgUtil {
@@ -19,17 +19,17 @@ public class HistoryMsgUtil {
private User user = CacheDiskUtils . getInstance ( ) . getParcelable ( CacheConstant . USER_INFO , User . CREATOR , new User ( ) ) ;
public Map < String , LocalPushChatMsg > select ( ) {
public Hash Map< String , LocalPushChatMsg > select ( ) {
String localHistoryMsgJson = CacheDiskUtils . getInstance ( ) . getString ( user . getId ( ) . concat ( user . getUserType ( ) ) , "" ) ;
Type type = new TypeToken < Map < String , LocalPushChatMsg > > ( ) { } . getType ( ) ;
Type type = new TypeToken < Hash Map< String , LocalPushChatMsg > > ( ) { } . getType ( ) ;
return new Gson ( ) . fromJson ( localHistoryMsgJson , type ) ;
}
public void put ( String key , LocalPushChatMsg value ) {
Objects . requireNonNull ( key ) ;
String localHistoryMsgJson = CacheDiskUtils . getInstance ( ) . getString ( user . getId ( ) . concat ( user . getUserType ( ) ) , "" ) ;
Type type = new TypeToken < Map < String , LocalPushChatMsg > > ( ) { } . getType ( ) ;
Map < String , LocalPushChatMsg > localHistoryMsg = Objects . requireNonNullElse ( new Gson ( ) . fromJson ( localHistoryMsgJson , type ) , MapUtils . newHashMap ( ) ) ;
Type type = new TypeToken < Hash Map< String , LocalPushChatMsg > > ( ) { } . getType ( ) ;
Hash Map< String , LocalPushChatMsg > localHistoryMsg = Objects . requireNonNullElse ( new Gson ( ) . fromJson ( localHistoryMsgJson , type ) , MapUtils . newHashMap ( ) ) ;
localHistoryMsg . put ( key , value ) ;
String newLocalHistoryMsgJson = new Gson ( ) . toJson ( localHistoryMsg ) ;
CacheDiskUtils . getInstance ( ) . put ( user . getId ( ) . concat ( user . getUserType ( ) ) , newLocalHistoryMsgJson ) ;
@ -38,8 +38,8 @@ public class HistoryMsgUtil {
@@ -38,8 +38,8 @@ public class HistoryMsgUtil {
public void del ( String key ) {
Objects . requireNonNull ( key ) ;
String localHistoryMsgJson = CacheDiskUtils . getInstance ( ) . getString ( user . getId ( ) . concat ( user . getUserType ( ) ) , "" ) ;
Type type = new TypeToken < Map < String , LocalPushChatMsg > > ( ) { } . getType ( ) ;
Map < String , LocalPushChatMsg > localHistoryMsg = Objects . requireNonNullElse ( new Gson ( ) . fromJson ( localHistoryMsgJson , type ) , MapUtils . newHashMap ( ) ) ;
Type type = new TypeToken < Hash Map< String , LocalPushChatMsg > > ( ) { } . getType ( ) ;
Hash Map< String , LocalPushChatMsg > localHistoryMsg = Objects . requireNonNullElse ( new Gson ( ) . fromJson ( localHistoryMsgJson , type ) , MapUtils . newHashMap ( ) ) ;
localHistoryMsg . remove ( key ) ;
String newLocalHistoryMsgJson = new Gson ( ) . toJson ( localHistoryMsg ) ;
CacheDiskUtils . getInstance ( ) . put ( user . getId ( ) . concat ( user . getUserType ( ) ) , newLocalHistoryMsgJson ) ;