Search in sources :

Example 1 with BitmapLruCache

use of uk.co.senab.bitmapcache.BitmapLruCache in project Talon-for-Twitter by klinker24.

the class PeopleSearch method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);
    slug = getIntent().getStringExtra("slug");
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    setUpWindow();
    Utils.setUpPopupTheme(this, settings);
    actionBar = getActionBar();
    setContentView(R.layout.ptr_list_layout);
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    spinner = (LinearLayout) findViewById(R.id.list_progress);
    listView = (AsyncListView) findViewById(R.id.listView);
    BitmapLruCache cache = App.getInstance(context).getBitmapCache();
    ArrayListLoader loader = new ArrayListLoader(cache, context);
    ItemManager.Builder builder = new ItemManager.Builder(loader);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
    builder.setThreadPoolSize(4);
    listView.setItemManager(builder.build());
    getPeople();
}
Also used : BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) Intent(android.content.Intent)

Example 2 with BitmapLruCache

use of uk.co.senab.bitmapcache.BitmapLruCache in project Talon-for-Twitter by klinker24.

the class FavoritesActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    setUpTheme();
    setContentView(R.layout.retweets_activity);
    setUpDrawer(4, getResources().getString(R.string.favorite_tweets));
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.favorite_tweets));
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    listView = (AsyncListView) findViewById(R.id.listView);
    BitmapLruCache cache = App.getInstance(context).getBitmapCache();
    ArrayListLoader loader = new ArrayListLoader(cache, context);
    ItemManager.Builder builder = new ItemManager.Builder(loader);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
    builder.setThreadPoolSize(4);
    listView.setItemManager(builder.build());
    View viewHeader = getLayoutInflater().inflate(R.layout.ab_header, null);
    listView.addHeaderView(viewHeader, null, false);
    if (DrawerActivity.translucent) {
        if (Utils.hasNavBar(context)) {
            View footer = new View(context);
            footer.setOnClickListener(null);
            footer.setOnLongClickListener(null);
            ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context));
            footer.setLayoutParams(params);
            listView.addFooterView(footer);
            listView.setFooterDividersEnabled(false);
        }
        if (!MainActivity.isPopup) {
            View view = new View(context);
            view.setOnClickListener(null);
            view.setOnLongClickListener(null);
            ListView.LayoutParams params2 = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getStatusBarHeight(context));
            view.setLayoutParams(params2);
            listView.addHeaderView(view);
            listView.setFooterDividersEnabled(false);
        }
    }
    final boolean isTablet = getResources().getBoolean(R.bool.isTablet);
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        int mLastFirstVisibleItem = 0;

        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
        }

        @Override
        public void onScroll(AbsListView absListView, final int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            final int lastItem = firstVisibleItem + visibleItemCount;
            if (lastItem == totalItemCount && canRefresh) {
                getFavorites();
            }
            // show and hide the action bar
            if (firstVisibleItem != 0) {
                if (MainActivity.canSwitch) {
                    // used to show and hide the action bar
                    if (firstVisibleItem > mLastFirstVisibleItem) {
                        if (!landscape && !isTablet) {
                            actionBar.hide();
                        }
                    } else if (firstVisibleItem < mLastFirstVisibleItem) {
                        if (!landscape && !isTablet) {
                            actionBar.show();
                        }
                        if (translucent) {
                            statusBar.setVisibility(View.VISIBLE);
                        }
                    }
                    mLastFirstVisibleItem = firstVisibleItem;
                }
            } else {
                if (!landscape && !isTablet) {
                    actionBar.show();
                }
            }
            if (MainActivity.translucent && actionBar.isShowing()) {
                showStatusBar();
            } else if (MainActivity.translucent) {
                hideStatusBar();
            }
        }
    });
    getFavorites();
    final LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
    spinner.setVisibility(View.VISIBLE);
}
Also used : ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) AsyncListView(org.lucasr.smoothie.AsyncListView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) LinearLayout(android.widget.LinearLayout)

Example 3 with BitmapLruCache

use of uk.co.senab.bitmapcache.BitmapLruCache in project Talon-for-Twitter by klinker24.

the class RetweetActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    setUpTheme();
    setContentView(R.layout.retweets_activity);
    setUpDrawer(3, getResources().getString(R.string.retweets));
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.retweets));
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    listView = (AsyncListView) findViewById(R.id.listView);
    BitmapLruCache cache = App.getInstance(context).getBitmapCache();
    ArrayListLoader loader = new ArrayListLoader(cache, context);
    ItemManager.Builder builder = new ItemManager.Builder(loader);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
    builder.setThreadPoolSize(4);
    listView.setItemManager(builder.build());
    View viewHeader = getLayoutInflater().inflate(R.layout.ab_header, null);
    listView.addHeaderView(viewHeader, null, false);
    if (DrawerActivity.translucent) {
        if (Utils.hasNavBar(context)) {
            View footer = new View(context);
            footer.setOnClickListener(null);
            footer.setOnLongClickListener(null);
            ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context));
            footer.setLayoutParams(params);
            listView.addFooterView(footer);
            listView.setFooterDividersEnabled(false);
        }
        if (!MainActivity.isPopup) {
            View view = new View(context);
            view.setOnClickListener(null);
            view.setOnLongClickListener(null);
            ListView.LayoutParams params2 = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getStatusBarHeight(context));
            view.setLayoutParams(params2);
            listView.addHeaderView(view);
            listView.setFooterDividersEnabled(false);
        }
    }
    final boolean isTablet = getResources().getBoolean(R.bool.isTablet);
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        int mLastFirstVisibleItem = 0;

        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
        }

        @Override
        public void onScroll(AbsListView absListView, final int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            final int lastItem = firstVisibleItem + visibleItemCount;
            if (lastItem == totalItemCount && canRefresh) {
                getRetweets();
            }
            if (!landscape && !isTablet) {
                // show and hide the action bar
                if (firstVisibleItem != 0) {
                    if (MainActivity.canSwitch) {
                        // used to show and hide the action bar
                        if (firstVisibleItem > mLastFirstVisibleItem) {
                            actionBar.hide();
                        } else if (firstVisibleItem < mLastFirstVisibleItem) {
                            actionBar.show();
                        }
                        mLastFirstVisibleItem = firstVisibleItem;
                    }
                } else {
                    actionBar.show();
                }
            }
            if (MainActivity.translucent && actionBar.isShowing()) {
                showStatusBar();
            } else if (MainActivity.translucent) {
                hideStatusBar();
            }
        }
    });
    getRetweets();
}
Also used : ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) AsyncListView(org.lucasr.smoothie.AsyncListView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Example 4 with BitmapLruCache

use of uk.co.senab.bitmapcache.BitmapLruCache in project Talon-for-Twitter by klinker24.

the class NotificationUtils method getImage.

public static Bitmap getImage(Context context, String screenname) {
    BitmapLruCache mCache = App.getInstance(context).getBitmapCache();
    String url;
    try {
        url = Utils.getTwitter(context, AppSettings.getInstance(context)).showUser(screenname).getBiggerProfileImageURL();
        CacheableBitmapDrawable wrapper = mCache.get(url + "_notification");
        if (wrapper == null) {
            // The bitmap isn't cached so download from the web
            HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
            InputStream is = new BufferedInputStream(conn.getInputStream());
            Bitmap image = BitmapFactory.decodeStream(is);
            image = ImageUtils.notificationResize(context, image);
            mCache.put(url + "_notification", image);
            return image;
        } else {
            return wrapper.getBitmap();
        }
    } catch (Exception e) {
        return BitmapFactory.decodeResource(context.getResources(), R.drawable.drawer_user_dark);
    }
}
Also used : BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) Bitmap(android.graphics.Bitmap) HttpURLConnection(java.net.HttpURLConnection) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) CacheableBitmapDrawable(uk.co.senab.bitmapcache.CacheableBitmapDrawable) URL(java.net.URL)

Example 5 with BitmapLruCache

use of uk.co.senab.bitmapcache.BitmapLruCache in project Talon-for-Twitter by klinker24.

the class ProfileFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    mCache = App.getInstance(context).getBitmapCache();
    settings = AppSettings.getInstance(context);
    screenName = getArguments().getString("screen_name");
    isMyProfile = settings.myScreenName.equals(screenName);
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    inflater = LayoutInflater.from(context);
    layout = inflater.inflate(R.layout.list_fragment, null);
    LinearLayout spin = (LinearLayout) layout.findViewById(R.id.spinner);
    spin.setVisibility(View.GONE);
    AsyncListView listView = (AsyncListView) layout.findViewById(R.id.listView);
    listView.setVisibility(View.VISIBLE);
    BitmapLruCache cache = App.getInstance(context).getBitmapCache();
    ArrayListLoader loader = new ArrayListLoader(cache, context);
    builder = new ItemManager.Builder(loader);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
    builder.setThreadPoolSize(4);
    listView.setItemManager(builder.build());
    View header;
    boolean fromAddon = false;
    if (!settings.addonTheme) {
        header = inflater.inflate(R.layout.user_profile_header, null);
    } else {
        try {
            Context viewContext = null;
            Resources res = context.getPackageManager().getResourcesForApplication(settings.addonThemePackage);
            try {
                viewContext = context.createPackageContext(settings.addonThemePackage, Context.CONTEXT_IGNORE_SECURITY);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (res != null && viewContext != null) {
                int id = res.getIdentifier("user_profile_header", "layout", settings.addonThemePackage);
                header = LayoutInflater.from(viewContext).inflate(res.getLayout(id), null);
                fromAddon = true;
            } else {
                header = inflater.inflate(R.layout.user_profile_header, null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            header = inflater.inflate(R.layout.user_profile_header, null);
        }
    }
    listView.addHeaderView(header);
    listView.setAdapter(new TimelineArrayAdapter(context, new ArrayList<Status>(0)));
    followers = new ArrayList<User>();
    following = new ArrayList<User>();
    setUpUI(fromAddon, header, layout);
    return layout;
}
Also used : Context(android.content.Context) User(twitter4j.User) ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) PackageManager(android.content.pm.PackageManager) TimelineArrayAdapter(com.klinker.android.twitter.adapters.TimelineArrayAdapter) Resources(android.content.res.Resources) LinearLayout(android.widget.LinearLayout) AsyncListView(org.lucasr.smoothie.AsyncListView)

Aggregations

BitmapLruCache (uk.co.senab.bitmapcache.BitmapLruCache)21 ItemManager (org.lucasr.smoothie.ItemManager)16 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)14 AbsListView (android.widget.AbsListView)11 AsyncListView (org.lucasr.smoothie.AsyncListView)11 View (android.view.View)10 Intent (android.content.Intent)6 ListView (android.widget.ListView)6 FullScreenSwipeRefreshLayout (com.klinker.android.twitter.views.swipe_refresh_layout.FullScreenSwipeRefreshLayout)6 Bitmap (android.graphics.Bitmap)4 URL (java.net.URL)4 Point (android.graphics.Point)3 Handler (android.os.Handler)3 ViewConfiguration (android.view.ViewConfiguration)3 LinearLayout (android.widget.LinearLayout)3 HoloTextView (com.klinker.android.twitter.views.text.HoloTextView)3 BufferedInputStream (java.io.BufferedInputStream)3 InputStream (java.io.InputStream)3 Field (java.lang.reflect.Field)3 HttpURLConnection (java.net.HttpURLConnection)3