Search in sources :

Example 16 with BitmapLruCache

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

the class ProfileFavoritesFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    screenName = getArguments().getString("screen_name");
    settings = AppSettings.getInstance(context);
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    inflater = LayoutInflater.from(context);
    layout = inflater.inflate(R.layout.list_fragment, null);
    listView = (AsyncListView) layout.findViewById(R.id.listView);
    spinner = (LinearLayout) layout.findViewById(R.id.spinner);
    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());
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

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

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            final int lastItem = firstVisibleItem + visibleItemCount;
            if (lastItem == totalItemCount && canRefresh) {
                getMore();
            }
        }
    });
    doSearch();
    return layout;
}
Also used : BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) AbsListView(android.widget.AbsListView)

Example 17 with BitmapLruCache

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

the class UserListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, null);
    settings = AppSettings.getInstance(context);
    View layout = LayoutInflater.from(context).inflate(R.layout.ptr_list_layout, container, false);
    changeNoRetweetersText(layout);
    mPullToRefreshLayout = (FullScreenSwipeRefreshLayout) layout.findViewById(R.id.swipe_refresh_layout);
    mPullToRefreshLayout.setOnRefreshListener(new FullScreenSwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            onRefreshStarted();
        }
    });
    if (settings.addonTheme) {
        mPullToRefreshLayout.setColorScheme(settings.accentInt, SwipeProgressBar.COLOR2, settings.accentInt, SwipeProgressBar.COLOR3);
    } else {
        if (settings.theme != AppSettings.THEME_LIGHT) {
            mPullToRefreshLayout.setColorScheme(context.getResources().getColor(R.color.app_color), SwipeProgressBar.COLOR2, context.getResources().getColor(R.color.app_color), SwipeProgressBar.COLOR3);
        } else {
            mPullToRefreshLayout.setColorScheme(context.getResources().getColor(R.color.app_color), getResources().getColor(R.color.light_ptr_1), context.getResources().getColor(R.color.app_color), getResources().getColor(R.color.light_ptr_2));
        }
    }
    spinner = (LinearLayout) layout.findViewById(R.id.list_progress);
    noContent = (LinearLayout) layout.findViewById(R.id.no_content);
    listView = (AsyncListView) layout.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());
    tweetId = getArguments().getLong("id", 0);
    onRefreshStarted();
    return layout;
}
Also used : BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) FullScreenSwipeRefreshLayout(com.klinker.android.twitter.views.swipe_refresh_layout.FullScreenSwipeRefreshLayout) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View)

Example 18 with BitmapLruCache

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

the class NotificationUtils method getIcon.

public static Bitmap getIcon(Context context, int[] unreadCount, String screenname) {
    int homeTweets = unreadCount[0];
    int mentionsTweets = unreadCount[1];
    int dmTweets = unreadCount[2];
    boolean customPic = (mentionsTweets == 1 && homeTweets == 0 && dmTweets == 0) || (dmTweets == 1 && homeTweets == 0 && mentionsTweets == 0);
    if (screenname != null && customPic) {
        BitmapLruCache mCache = App.getInstance(context).getBitmapCache();
        Log.v("notifications_talon", "in screenname");
        String url;
        try {
            url = Utils.getTwitter(context, AppSettings.getInstance(context)).showUser(screenname).getBiggerProfileImageURL();
            CacheableBitmapDrawable wrapper = mCache.get(url + "_notification");
            Log.v("notifications_talon", "got wrapper");
            if (wrapper == null) {
                Log.v("notifications_talon", "wrapper null");
                URL mUrl = new URL(url);
                Bitmap image = BitmapFactory.decodeStream(mUrl.openConnection().getInputStream());
                image = ImageUtils.notificationResize(context, image);
                mCache.put(url + "_notification", image);
                return image;
            } else {
                return wrapper.getBitmap();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_icon);
}
Also used : BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) Bitmap(android.graphics.Bitmap) CacheableBitmapDrawable(uk.co.senab.bitmapcache.CacheableBitmapDrawable) URL(java.net.URL)

Example 19 with BitmapLruCache

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

the class ConversationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    settings = AppSettings.getInstance(getActivity());
    tweetId = getArguments().getLong("tweet_id", 0l);
    isRunning = true;
    layout = inflater.inflate(R.layout.conversation_fragment, null, false);
    final AsyncListView replyList = (AsyncListView) layout.findViewById(R.id.listView);
    final LinearLayout progressSpinner = (LinearLayout) layout.findViewById(R.id.list_progress);
    final HoloTextView none = (HoloTextView) layout.findViewById(R.id.no_conversation);
    none.setText(getResources().getString(R.string.no_tweets));
    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);
    replyList.setItemManager(builder.build());
    getReplies(replyList, tweetId, progressSpinner, none);
    return layout;
}
Also used : BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) HoloTextView(com.klinker.android.twitter.views.text.HoloTextView) LinearLayout(android.widget.LinearLayout) AsyncListView(org.lucasr.smoothie.AsyncListView)

Example 20 with BitmapLruCache

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

the class DirectMessageConversation method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);
    countHandler = new Handler();
    context = this;
    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
    // Ignore
    }
    if (settings.advanceWindowed) {
        setUpWindow();
    }
    Utils.setUpPopupTheme(this, settings);
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.lists));
    setContentView(R.layout.dm_conversation);
    attachImage = (ImageView) findViewById(R.id.attached_image);
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    listView = (AsyncListView) findViewById(R.id.listView);
    sendButton = (ImageButton) findViewById(R.id.send_button);
    composeBar = (HoloEditText) findViewById(R.id.tweet_content);
    charRemaining = (HoloTextView) findViewById(R.id.char_remaining);
    charRemaining.setVisibility(View.GONE);
    BitmapLruCache cache = App.getInstance(context).getBitmapCache();
    CursorListLoader loader = new CursorListLoader(cache, context);
    ItemManager.Builder builder = new ItemManager.Builder(loader);
    builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50);
    builder.setThreadPoolSize(4);
    listView.setItemManager(builder.build());
    listName = getIntent().getStringExtra("screenname");
    actionBar.setTitle(getIntent().getStringExtra("name"));
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    new GetList().execute();
    charRemaining.setText(AppSettings.getInstance(this).tweetCharacterCount - composeBar.getText().length() + "");
    composeBar.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            countHandler.removeCallbacks(getCount);
            countHandler.postDelayed(getCount, 300);
        }
    });
    sendButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String status = composeBar.getText().toString();
            new SendDirectMessage().execute(status);
            composeBar.setText("");
            attachImage.setVisibility(View.GONE);
            Toast.makeText(context, getString(R.string.sending), Toast.LENGTH_SHORT).show();
        }
    });
    Utils.setActionBar(context);
}
Also used : CursorListLoader(com.klinker.android.twitter.adapters.CursorListLoader) ItemManager(org.lucasr.smoothie.ItemManager) Handler(android.os.Handler) Intent(android.content.Intent) ImageView(android.widget.ImageView) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) HoloTextView(com.klinker.android.twitter.views.text.HoloTextView) TwitterException(twitter4j.TwitterException) IOException(java.io.IOException) Point(android.graphics.Point) ViewConfiguration(android.view.ViewConfiguration) Field(java.lang.reflect.Field) BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) ColorDrawable(android.graphics.drawable.ColorDrawable) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

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