Example usage for android.os Process setThreadPriority

List of usage examples for android.os Process setThreadPriority

Introduction

In this page you can find the example usage for android.os Process setThreadPriority.

Prototype

public static final native void setThreadPriority(int priority)
        throws IllegalArgumentException, SecurityException;

Source Link

Document

Set the priority of the calling thread, based on Linux priorities.

Usage

From source file:biz.varkon.shelvesom.provider.music.MusicUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {//  w ww .ja  v  a  2 s  .c  o m
            final String musicId = mQueue.take();

            final Long lastCheck = sLastChecks.get(musicId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(musicId, System.currentTimeMillis());

            final MusicStore.Music music = MusicManager.findMusic(mResolver, musicId, null);

            if (music == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(music);

            if (music.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (musicCoverUpdated(music, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(musicId);

                final Bitmap bitmap = Preferences.getBitmapForManager(music);

                ImportUtilities.addCoverToCache(music.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = musicId;
                mResolver.update(MusicStore.Music.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.movies.MoviesUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {/*  ww w  .j a va 2s .com*/
            final String movieId = mQueue.take();

            final Long lastCheck = sLastChecks.get(movieId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(movieId, System.currentTimeMillis());

            final MoviesStore.Movie movie = MoviesManager.findMovie(mResolver, movieId, null);

            if (movie == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(movie);

            if (movie.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (movieCoverUpdated(movie, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(movieId);

                final Bitmap bitmap = Preferences.getBitmapForManager(movie);

                ImportUtilities.addCoverToCache(movie.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = movieId;
                mResolver.update(MoviesStore.Movie.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.gadgets.GadgetsUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {/*from   www  .j  a  va  2s.co  m*/
            final String gadgetId = mQueue.take();

            final Long lastCheck = sLastChecks.get(gadgetId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(gadgetId, System.currentTimeMillis());

            final GadgetsStore.Gadget gadget = GadgetsManager.findGadget(mResolver, gadgetId, null);

            if (gadget == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(gadget);

            if (gadget.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (gadgetCoverUpdated(gadget, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(gadgetId);

                final Bitmap bitmap = Preferences.getBitmapForManager(gadget);

                ImportUtilities.addCoverToCache(gadget.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = gadgetId;
                mResolver.update(GadgetsStore.Gadget.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.apparel.ApparelUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {/*from   w ww  . j  a v  a 2 s .c  o m*/
            final String apparelId = mQueue.take();

            final Long lastCheck = sLastChecks.get(apparelId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(apparelId, System.currentTimeMillis());

            final ApparelStore.Apparel apparel = ApparelManager.findApparel(mResolver, apparelId, null);

            if (apparel == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(apparel);

            if (apparel.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (apparelCoverUpdated(apparel, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(apparelId);

                final Bitmap bitmap = Preferences.getBitmapForManager(apparel);

                ImportUtilities.addCoverToCache(apparel.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = apparelId;
                mResolver.update(ApparelStore.Apparel.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.software.SoftwareUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {//w w w  .j  a  v a2s.c o  m
            final String softwareId = mQueue.take();

            final Long lastCheck = sLastChecks.get(softwareId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(softwareId, System.currentTimeMillis());

            final SoftwareStore.Software software = SoftwareManager.findSoftware(mResolver, softwareId, null);

            if (software == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(software);

            if (software.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (softwareCoverUpdated(software, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(softwareId);

                final Bitmap bitmap = Preferences.getBitmapForManager(software);

                ImportUtilities.addCoverToCache(software.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = softwareId;
                mResolver.update(SoftwareStore.Software.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.books.BooksUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {/*from  w ww.  j  a va 2 s .c  o  m*/
            final String bookId = mQueue.take();

            final Long lastCheck = sLastChecks.get(bookId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(bookId, System.currentTimeMillis());

            final BooksStore.Book book = BooksManager.findBook(mResolver, bookId, null);

            if (book == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(book);

            if (book.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (bookCoverUpdated(book, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(bookId);

                final Bitmap bitmap = Preferences.getBitmapForManager(book);

                ImportUtilities.addCoverToCache(book.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = bookId;
                mResolver.update(BooksStore.Book.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.comics.ComicsUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {/*from   ww  w .  ja  va  2  s. c o m*/
            final String comicId = mQueue.take();

            final Long lastCheck = sLastChecks.get(comicId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(comicId, System.currentTimeMillis());

            final ComicsStore.Comic comic = ComicsManager.findComic(mResolver, comicId, null);

            if (comic == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(comic);

            if (comic.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (comicCoverUpdated(comic, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(comicId);

                final Bitmap bitmap = Preferences.getBitmapForManager(comic);

                ImportUtilities.addCoverToCache(comic.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = comicId;
                mResolver.update(ComicsStore.Comic.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.videogames.VideoGamesUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {//from w w  w . j  ava2 s  .  c o m
            final String videogameId = mQueue.take();

            final Long lastCheck = sLastChecks.get(videogameId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(videogameId, System.currentTimeMillis());

            final VideoGamesStore.VideoGame videogame = VideoGamesManager.findVideoGame(mResolver, videogameId,
                    null);

            if (videogame == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(videogame);

            if (videogame.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (videogameCoverUpdated(videogame, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(videogameId);

                final Bitmap bitmap = Preferences.getBitmapForManager(videogame);

                ImportUtilities.addCoverToCache(videogame.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = videogameId;
                mResolver.update(VideoGamesStore.VideoGame.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:biz.varkon.shelvesom.provider.boardgames.BoardGamesUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {/*w  w w .j a  v  a  2 s  .  c o  m*/
            final String boardgameId = mQueue.take();

            final Long lastCheck = sLastChecks.get(boardgameId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(boardgameId, System.currentTimeMillis());

            final BoardGamesStore.BoardGame boardgame = BoardGamesManager.findBoardGame(mResolver, boardgameId,
                    null);

            if (boardgame == null)
                continue;

            final String imgURL = Preferences.getImageURLForUpdater(boardgame);

            if (boardgame.getLastModified() == null || imgURL == null) {
                continue;
            }

            if (boardgameCoverUpdated(boardgame, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(boardgameId);

                final Bitmap bitmap = Preferences.getBitmapForManager(boardgame);

                ImportUtilities.addCoverToCache(boardgame.getInternalId(), bitmap);

                if (bitmap != null)
                    bitmap.recycle();

                mValues.put(BaseItem.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = boardgameId;
                mResolver.update(BoardGamesStore.BoardGame.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}

From source file:com.androidrocks.bex.provider.BooksUpdater.java

public void run() {
    Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    final ImageUtilities.ExpiringBitmap expiring = new ImageUtilities.ExpiringBitmap();

    while (!mStopped) {
        try {/*from w  w w.  j a  v a  2 s . c  om*/
            final String bookId = mQueue.take();

            final Long lastCheck = sLastChecks.get(bookId);
            if (lastCheck != null && (lastCheck + ONE_DAY) >= System.currentTimeMillis()) {
                continue;
            }
            sLastChecks.put(bookId, System.currentTimeMillis());

            final BooksStore.Book book = BooksManager.findBook(mResolver, bookId);
            if (book.getLastModified() == null || book.getImageUrl(BooksStore.ImageSize.TINY) == null) {
                continue;
            }

            if (bookCoverUpdated(book, expiring) && expiring.lastModified != null) {
                ImageUtilities.deleteCachedCover(bookId);
                final Bitmap bitmap = book.loadCover(BooksStore.ImageSize.TINY);
                ImportUtilities.addBookCoverToCache(book, bitmap);

                mValues.put(BooksStore.Book.LAST_MODIFIED, expiring.lastModified.getTimeInMillis());
                mArguments[0] = bookId;
                mResolver.update(BooksStore.Book.CONTENT_URI, mValues, mSelection, mArguments);
            }

            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore
        }
    }
}