I'm so stupid
This commit is contained in:
parent
8ba3fecca3
commit
160b32f0e8
|
@ -10,7 +10,7 @@ android {
|
||||||
applicationId "org.joinmastodon.android"
|
applicationId "org.joinmastodon.android"
|
||||||
minSdk 23
|
minSdk 23
|
||||||
targetSdk 31
|
targetSdk 31
|
||||||
versionCode 10
|
versionCode 11
|
||||||
versionName "0.1"
|
versionName "0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,11 @@ public class CacheController{
|
||||||
this.accountID=accountID;
|
this.accountID=accountID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getHomeTimeline(String maxID, int count, Callback<List<Status>> callback){
|
public void getHomeTimeline(String maxID, int count, boolean forceReload, Callback<List<Status>> callback){
|
||||||
cancelDelayedClose();
|
cancelDelayedClose();
|
||||||
databaseThread.postRunnable(()->{
|
databaseThread.postRunnable(()->{
|
||||||
try{
|
try{
|
||||||
|
if(!forceReload){
|
||||||
SQLiteDatabase db=getOrOpenDatabase();
|
SQLiteDatabase db=getOrOpenDatabase();
|
||||||
try(Cursor cursor=db.query("home_timeline", new String[]{"json"}, maxID==null ? null : "`id`<?", maxID==null ? null : new String[]{maxID}, null, null, "`id` DESC", count+"")){
|
try(Cursor cursor=db.query("home_timeline", new String[]{"json"}, maxID==null ? null : "`id`<?", maxID==null ? null : new String[]{maxID}, null, null, "`id` DESC", count+"")){
|
||||||
if(cursor.getCount()==count){
|
if(cursor.getCount()==count){
|
||||||
|
@ -65,6 +66,7 @@ public class CacheController{
|
||||||
}catch(IOException x){
|
}catch(IOException x){
|
||||||
Log.w(TAG, "getHomeTimeline: corrupted status object in database", x);
|
Log.w(TAG, "getHomeTimeline: corrupted status object in database", x);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
new GetHomeTimeline(maxID, null, count)
|
new GetHomeTimeline(maxID, null, count)
|
||||||
.setCallback(new Callback<>(){
|
.setCallback(new Callback<>(){
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,10 +111,11 @@ public class CacheController{
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getNotifications(String maxID, int count, boolean onlyMentions, Callback<List<Notification>> callback){
|
public void getNotifications(String maxID, int count, boolean onlyMentions, boolean forceReload, Callback<List<Notification>> callback){
|
||||||
cancelDelayedClose();
|
cancelDelayedClose();
|
||||||
databaseThread.postRunnable(()->{
|
databaseThread.postRunnable(()->{
|
||||||
try{
|
try{
|
||||||
|
if(!forceReload){
|
||||||
SQLiteDatabase db=getOrOpenDatabase();
|
SQLiteDatabase db=getOrOpenDatabase();
|
||||||
try(Cursor cursor=db.query(onlyMentions ? "notifications_mentions" : "notifications_all", new String[]{"json"}, maxID==null ? null : "`id`<?", maxID==null ? null : new String[]{maxID}, null, null, "`id` DESC", count+"")){
|
try(Cursor cursor=db.query(onlyMentions ? "notifications_mentions" : "notifications_all", new String[]{"json"}, maxID==null ? null : "`id`<?", maxID==null ? null : new String[]{maxID}, null, null, "`id` DESC", count+"")){
|
||||||
if(cursor.getCount()==count){
|
if(cursor.getCount()==count){
|
||||||
|
@ -129,6 +132,7 @@ public class CacheController{
|
||||||
}catch(IOException x){
|
}catch(IOException x){
|
||||||
Log.w(TAG, "getNotifications: corrupted notification object in database", x);
|
Log.w(TAG, "getNotifications: corrupted notification object in database", x);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
new GetNotifications(maxID, count, onlyMentions ? EnumSet.complementOf(EnumSet.of(Notification.Type.MENTION)): null)
|
new GetNotifications(maxID, count, onlyMentions ? EnumSet.complementOf(EnumSet.of(Notification.Type.MENTION)): null)
|
||||||
.setCallback(new Callback<>(){
|
.setCallback(new Callback<>(){
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,17 +58,9 @@ public class HomeTimelineFragment extends StatusListFragment{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
// currentRequest=new GetHomeTimeline(offset>0 ? getMaxID() : null, null, count)
|
|
||||||
// .setCallback(new SimpleCallback<>(this){
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(List<Status> result){
|
|
||||||
// onDataLoaded(result, !result.isEmpty());
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .exec(accountID);
|
|
||||||
AccountSessionManager.getInstance()
|
AccountSessionManager.getInstance()
|
||||||
.getAccount(accountID).getCacheController()
|
.getAccount(accountID).getCacheController()
|
||||||
.getHomeTimeline(offset>0 ? getMaxID() : null, count, new SimpleCallback<>(this){
|
.getHomeTimeline(offset>0 ? getMaxID() : null, count, refreshing, new SimpleCallback<>(this){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Status> result){
|
public void onSuccess(List<Status> result){
|
||||||
onDataLoaded(result, !result.isEmpty());
|
onDataLoaded(result, !result.isEmpty());
|
||||||
|
|
|
@ -78,24 +78,9 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLoadData(int offset, int count){
|
protected void doLoadData(int offset, int count){
|
||||||
// new GetNotifications(offset>0 ? getMaxID() : null, count, types)
|
|
||||||
// .setCallback(new SimpleCallback<>(this){
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(List<Notification> result){
|
|
||||||
// if(refreshing)
|
|
||||||
// relationships.clear();
|
|
||||||
// onDataLoaded(result, !result.isEmpty());
|
|
||||||
// Set<String> needRelationships=result.stream()
|
|
||||||
// .filter(ntf->ntf.status==null && !relationships.containsKey(ntf.account.id))
|
|
||||||
// .map(ntf->ntf.account.id)
|
|
||||||
// .collect(Collectors.toSet());
|
|
||||||
// loadRelationships(needRelationships);
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .exec(accountID);
|
|
||||||
AccountSessionManager.getInstance()
|
AccountSessionManager.getInstance()
|
||||||
.getAccount(accountID).getCacheController()
|
.getAccount(accountID).getCacheController()
|
||||||
.getNotifications(offset>0 ? getMaxID() : null, count, onlyMentions, new SimpleCallback<>(this){
|
.getNotifications(offset>0 ? getMaxID() : null, count, onlyMentions, refreshing, new SimpleCallback<>(this){
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Notification> result){
|
public void onSuccess(List<Notification> result){
|
||||||
if(refreshing)
|
if(refreshing)
|
||||||
|
|
Loading…
Reference in New Issue