Refactoring
This commit is contained in:
parent
4b710a77df
commit
ae0cbad342
5 changed files with 17 additions and 17 deletions
|
@ -21,7 +21,7 @@ public class NewsReaderApplication extends Application {
|
|||
|
||||
public void initImageLoader() {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
int diskCacheSize = Integer.parseInt(preferences.getString(SettingsActivity.SP_MAX_CACHE_SIZE,"1000"))*1024*1024;
|
||||
int diskCacheSize = Integer.parseInt(preferences.getString(SettingsActivity.SP_MAX_CACHE_SIZE,"500"))*1024*1024;
|
||||
if(ImageLoader.getInstance().isInited())
|
||||
ImageLoader.getInstance().destroy();
|
||||
DisplayImageOptions imageOptions = new DisplayImageOptions.Builder().
|
||||
|
|
|
@ -555,7 +555,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
|
||||
((EditTextPreference) preference).getDialog().dismiss();
|
||||
|
||||
CheckForUnsycedChangesInDatabaseAndResetDatabase(_mActivity);
|
||||
checkForUnsycedChangesInDatabaseAndResetDatabase(_mActivity);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -587,7 +587,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
}
|
||||
|
||||
|
||||
public static void CheckForUnsycedChangesInDatabaseAndResetDatabase(final Context context) {
|
||||
public static void checkForUnsycedChangesInDatabaseAndResetDatabase(final Context context) {
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
|
||||
boolean resetDatabase = true;
|
||||
if(dbConn.areThereAnyUnsavedChangesInDatabase())
|
||||
|
|
|
@ -34,7 +34,6 @@ import de.luhmer.owncloudnewsreader.helper.ImageDownloadFinished;
|
|||
public class GetImageThreaded extends Thread
|
||||
{
|
||||
private static final String TAG = "GetImageAsyncTask";
|
||||
//private static int count = 0;
|
||||
|
||||
private URL WEB_URL_TO_FILE;
|
||||
private ImageDownloadFinished imageDownloadFinished;
|
||||
|
|
|
@ -326,7 +326,7 @@ public class DatabaseConnectionOrm {
|
|||
}
|
||||
|
||||
public LazyList<RssItem> getAllItemsWithIdHigher(long id) {
|
||||
return daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Id.ge(id)).listLazyUncached();
|
||||
return daoSession.getRssItemDao().queryBuilder().where(RssItemDao.Properties.Id.ge(id)).listLazy();
|
||||
}
|
||||
|
||||
public void updateRssItem(RssItem rssItem) {
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import de.greenrobot.dao.query.LazyList;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.async_tasks.GetImageThreaded;
|
||||
|
@ -56,7 +57,7 @@ public class DownloadImagesService extends IntentService {
|
|||
|
||||
private int NOTIFICATION_ID = 1;
|
||||
private NotificationManager notificationManager;
|
||||
private NotificationCompat.Builder NotificationDownloadImages;
|
||||
private NotificationCompat.Builder mNotificationDownloadImages;
|
||||
|
||||
private int maxCount;
|
||||
//private int total_size = 0;
|
||||
|
@ -86,7 +87,7 @@ public class DownloadImagesService extends IntentService {
|
|||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if(NotificationDownloadImages != null)
|
||||
if(mNotificationDownloadImages != null)
|
||||
{
|
||||
if(maxCount == 0)
|
||||
notificationManager.cancel(NOTIFICATION_ID);
|
||||
|
@ -101,9 +102,6 @@ public class DownloadImagesService extends IntentService {
|
|||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(this);
|
||||
Notification notify = BuildNotification();
|
||||
|
||||
//if(linksFavIcons.size() > 0)
|
||||
//notificationManager.notify(NOTIFICATION_ID, notify);
|
||||
|
||||
List<Feed> feedList = dbConn.getListOfFeeds();
|
||||
FavIconHandler favIconHandler = new FavIconHandler(this);
|
||||
for(Feed feed : feedList) {
|
||||
|
@ -124,12 +122,13 @@ public class DownloadImagesService extends IntentService {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
((LazyList)rssItemList).close();
|
||||
|
||||
maxCount = links.size();
|
||||
|
||||
if (maxCount > 0)
|
||||
if (maxCount > 0) {
|
||||
notificationManager.notify(NOTIFICATION_ID, notify);
|
||||
}
|
||||
|
||||
linksToImages.addAll(links);
|
||||
|
||||
|
@ -169,13 +168,13 @@ public class DownloadImagesService extends IntentService {
|
|||
Intent intentNewsReader = new Intent(this, NewsReaderListActivity.class);
|
||||
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intentNewsReader, 0);
|
||||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationDownloadImages = new NotificationCompat.Builder(this)
|
||||
mNotificationDownloadImages = new NotificationCompat.Builder(this)
|
||||
.setContentTitle("ownCloud News Reader")
|
||||
.setContentText("Downloading Images for offline usage")
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentIntent(pIntent);
|
||||
|
||||
Notification notify = NotificationDownloadImages.build();
|
||||
Notification notify = mNotificationDownloadImages.build();
|
||||
|
||||
//Hide the notification after its selected
|
||||
notify.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
|
@ -200,9 +199,11 @@ public class DownloadImagesService extends IntentService {
|
|||
notificationManager.cancel(NOTIFICATION_ID);
|
||||
RemoveOldImages();
|
||||
} else {
|
||||
NotificationDownloadImages.setProgress(maxCount, count+1, false);
|
||||
NotificationDownloadImages.setContentText("Downloading Images for offline usage - " + (count+1) + "/" + maxCount);
|
||||
notificationManager.notify(NOTIFICATION_ID, NotificationDownloadImages.build());
|
||||
mNotificationDownloadImages
|
||||
.setContentText("Downloading Images for offline usage - " + (count + 1) + "/" + maxCount)
|
||||
.setProgress(maxCount, count + 1, false);
|
||||
|
||||
notificationManager.notify(NOTIFICATION_ID, mNotificationDownloadImages.build());
|
||||
|
||||
StartNextDownloadInQueue();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue