Search in sources :

Example 11 with AsyncListView

use of org.lucasr.smoothie.AsyncListView in project Talon-for-Twitter by klinker24.

the class UserSearchFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    this.translucent = getArguments().getBoolean("translucent", false);
    this.searchQuery = getArguments().getString("search").replaceAll("@", "");
    searchQuery = searchQuery.replace(" TOP", "");
    searchQuery = searchQuery.replace(" -RT", "");
    this.onlyProfile = getArguments().getBoolean("only_profile", false);
    settings = AppSettings.getInstance(context);
    inflater = LayoutInflater.from(context);
    layout = inflater.inflate(R.layout.ptr_list_layout, null);
    mPullToRefreshLayout = (FullScreenSwipeRefreshLayout) layout.findViewById(R.id.swipe_refresh_layout);
    mPullToRefreshLayout.setFullScreen(false);
    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));
        }
    }
    listView = (AsyncListView) layout.findViewById(R.id.listView);
    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) {
                getMoreUsers(searchQuery.replace("@", ""));
            }
        }
    });
    if (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);
        }
    }
    spinner = (LinearLayout) layout.findViewById(R.id.list_progress);
    spinner.setVisibility(View.GONE);
    if (searchQuery != null && !searchQuery.equals("") && !searchQuery.contains("@")) {
        BitmapLruCache cache = App.getInstance(context).getBitmapCache();
        ArrayListLoader loader = new ArrayListLoader(cache, context);
        ItemManager.Builder builder = new ItemManager.Builder(loader);
        builder.setPreloadItemsEnabled(true).setPreloadItemsCount(10);
        builder.setThreadPoolSize(2);
        listView.setItemManager(builder.build());
    }
    doUserSearch(searchQuery);
    return layout;
}
Also used : ArrayListLoader(com.klinker.android.twitter.adapters.ArrayListLoader) ItemManager(org.lucasr.smoothie.ItemManager) FullScreenSwipeRefreshLayout(com.klinker.android.twitter.views.swipe_refresh_layout.FullScreenSwipeRefreshLayout) AbsListView(android.widget.AbsListView) 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 12 with AsyncListView

use of org.lucasr.smoothie.AsyncListView in project Talon-for-Twitter by klinker24.

the class ProfileFragment method setUpUI.

public void setUpUI(boolean fromAddon, View listHeader, View layout) {
    TextView mstatement;
    TextView mscreenname;
    AsyncListView mlistView;
    ImageView mheader;
    if (fromAddon) {
        try {
            Resources res = context.getPackageManager().getResourcesForApplication(settings.addonThemePackage);
            spinner = (ProgressBar) listHeader.findViewById(res.getIdentifier("progress_bar", "id", settings.addonThemePackage));
            verified = (TextView) listHeader.findViewById(res.getIdentifier("verified_text", "id", settings.addonThemePackage));
            tweetsBtn = (Button) listHeader.findViewById(res.getIdentifier("tweets", "id", settings.addonThemePackage));
            followersBtn = (Button) listHeader.findViewById(res.getIdentifier("followers", "id", settings.addonThemePackage));
            followingBtn = (Button) listHeader.findViewById(res.getIdentifier("following", "id", settings.addonThemePackage));
            background = (ImageView) listHeader.findViewById(res.getIdentifier("background_image", "id", settings.addonThemePackage));
            profilePicture = (ImageView) listHeader.findViewById(res.getIdentifier("profile_pic", "id", settings.addonThemePackage));
            mstatement = (TextView) listHeader.findViewById(res.getIdentifier("user_statement", "id", settings.addonThemePackage));
            mscreenname = (TextView) listHeader.findViewById(res.getIdentifier("username", "id", settings.addonThemePackage));
            mlistView = (AsyncListView) layout.findViewById(R.id.listView);
            mheader = (ImageView) listHeader.findViewById(res.getIdentifier("background_image", "id", settings.addonThemePackage));
        } catch (Exception e) {
            spinner = (ProgressBar) listHeader.findViewById(R.id.progress_bar);
            verified = (TextView) listHeader.findViewById(R.id.verified_text);
            tweetsBtn = (Button) listHeader.findViewById(R.id.tweets);
            followersBtn = (Button) listHeader.findViewById(R.id.followers);
            followingBtn = (Button) listHeader.findViewById(R.id.following);
            background = (ImageView) listHeader.findViewById(R.id.background_image);
            profilePicture = (ImageView) listHeader.findViewById(R.id.profile_pic);
            mstatement = (TextView) listHeader.findViewById(R.id.user_statement);
            mscreenname = (TextView) listHeader.findViewById(R.id.username);
            mlistView = (AsyncListView) layout.findViewById(R.id.listView);
            mheader = (ImageView) listHeader.findViewById(R.id.background_image);
        }
    } else {
        spinner = (ProgressBar) listHeader.findViewById(R.id.progress_bar);
        verified = (TextView) listHeader.findViewById(R.id.verified_text);
        tweetsBtn = (Button) listHeader.findViewById(R.id.tweets);
        followersBtn = (Button) listHeader.findViewById(R.id.followers);
        followingBtn = (Button) listHeader.findViewById(R.id.following);
        background = (ImageView) listHeader.findViewById(R.id.background_image);
        profilePicture = (ImageView) listHeader.findViewById(R.id.profile_pic);
        mstatement = (TextView) listHeader.findViewById(R.id.user_statement);
        mscreenname = (TextView) listHeader.findViewById(R.id.username);
        mlistView = (AsyncListView) layout.findViewById(R.id.listView);
        mheader = (ImageView) listHeader.findViewById(R.id.background_image);
    }
    final TextView statement = mstatement;
    final TextView screenname = mscreenname;
    final AsyncListView listView = mlistView;
    final ImageView header = mheader;
    spinner.setVisibility(View.VISIBLE);
    statement.setTextSize(settings.textSize);
    screenname.setTextSize(settings.textSize + 1);
    getData(statement, listView);
    screenname.setText("@" + screenName);
    tweetsBtn.setText(getResources().getString(R.string.tweets));
    tweetsBtn.setTextSize(settings.textSize - 1);
    tweetsBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (current != BTN_TWEET) {
                current = BTN_TWEET;
                currentFollowing = -1;
                currentFollowers = -1;
                hasMore = true;
                listView.setItemManager(builder.build());
                listView.setAdapter(timelineAdapter);
                getTimeline(thisUser, listView);
            }
        }
    });
    followersBtn.setText(getResources().getString(R.string.followers));
    followersBtn.setTextSize(settings.textSize - 1);
    followersBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (current != BTN_FOLLOWERS) {
                current = BTN_FOLLOWERS;
                hasMore = false;
                listView.setItemManager(null);
                listView.setAdapter(followersAdapter);
                getFollowers(thisUser, listView);
            }
        }
    });
    followingBtn.setText(getResources().getString(R.string.following));
    followingBtn.setTextSize(settings.textSize - 1);
    followingBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (current != BTN_FOLLOWING) {
                current = BTN_FOLLOWING;
                hasMore = false;
                listView.setItemManager(null);
                listView.setAdapter(new PeopleArrayAdapter(context, following));
                getFollowing(thisUser, listView);
            }
        }
    });
    background.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (spinner.getVisibility() == View.GONE && thisUser != null) {
                startActivity(new Intent(context, PhotoViewerActivity.class).putExtra("url", thisUser.getProfileBannerURL()));
            } else {
            // it isn't ready to be opened just yet
            }
        }
    });
    profilePicture.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (spinner.getVisibility() == View.GONE) {
                try {
                    startActivity(new Intent(context, PhotoViewerActivity.class).putExtra("url", thisUser.getOriginalProfileImageURL()).putExtra("from_cache", false));
                } catch (Exception e) {
                // this user doesn't exist...
                }
            } else {
            // it isn't ready to be opened just yet
            }
        }
    });
    canRefresh = false;
    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 && hasMore) {
                // Last item is fully visible.
                if (current == BTN_FOLLOWING && canRefresh) {
                    getFollowing(thisUser, listView);
                } else if (current == BTN_FOLLOWERS && canRefresh) {
                    getFollowers(thisUser, listView);
                } else if (current == BTN_TWEET && canRefresh) {
                    getTimeline(thisUser, listView);
                }
                canRefresh = false;
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        canRefresh = true;
                    }
                }, 4000);
            }
            if (visibleItemCount == 0)
                return;
            if (firstVisibleItem != 0)
                return;
            if (settings.translateProfileHeader) {
                header.setTranslationY(-listView.getChildAt(0).getTop() / 2);
            }
        }
    });
}
Also used : PeopleArrayAdapter(com.klinker.android.twitter.adapters.PeopleArrayAdapter) AbsListView(android.widget.AbsListView) Handler(android.os.Handler) Intent(android.content.Intent) ImageView(android.widget.ImageView) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) PhotoViewerActivity(com.klinker.android.twitter.activities.photo_viewer.PhotoViewerActivity) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Resources(android.content.res.Resources) ProgressBar(android.widget.ProgressBar) AsyncListView(org.lucasr.smoothie.AsyncListView)

Example 13 with AsyncListView

use of org.lucasr.smoothie.AsyncListView 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 14 with AsyncListView

use of org.lucasr.smoothie.AsyncListView in project Talon-for-Twitter by klinker24.

the class ListChooser method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    Utils.setUpTheme(context, settings);
    setContentView(R.layout.list_chooser);
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.lists));
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    listView = (AsyncListView) findViewById(R.id.listView);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            UserList list = arrayAdapter.getItem(i);
            Intent returnIntent = new Intent();
            returnIntent.putExtra("listId", list.getId());
            returnIntent.putExtra("listName", list.getName());
            setResult(RESULT_OK, returnIntent);
            finish();
        }
    });
    new GetLists().execute();
}
Also used : Intent(android.content.Intent) AdapterView(android.widget.AdapterView) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AdapterView(android.widget.AdapterView) UserList(twitter4j.UserList)

Example 15 with AsyncListView

use of org.lucasr.smoothie.AsyncListView in project Talon-for-Twitter by klinker24.

the class SearchChooser method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    settings = AppSettings.getInstance(this);
    Utils.setUpTheme(context, settings);
    setContentView(R.layout.list_chooser);
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.lists));
    listView = (AsyncListView) findViewById(R.id.listView);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String search = adapter.getSearch(i);
            Intent returnIntent = new Intent();
            returnIntent.putExtra("search_query", search);
            setResult(RESULT_OK, returnIntent);
            finish();
        }
    });
    new GetLists().execute();
}
Also used : AdapterView(android.widget.AdapterView) Intent(android.content.Intent) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

AsyncListView (org.lucasr.smoothie.AsyncListView)19 View (android.view.View)18 ListView (android.widget.ListView)12 ItemManager (org.lucasr.smoothie.ItemManager)10 BitmapLruCache (uk.co.senab.bitmapcache.BitmapLruCache)10 Intent (android.content.Intent)8 AbsListView (android.widget.AbsListView)8 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)8 LinearLayout (android.widget.LinearLayout)4 FullScreenSwipeRefreshLayout (com.klinker.android.twitter.views.swipe_refresh_layout.FullScreenSwipeRefreshLayout)4 ImageView (android.widget.ImageView)3 Resources (android.content.res.Resources)2 Handler (android.os.Handler)2 AdapterView (android.widget.AdapterView)2 TextView (android.widget.TextView)2 CursorListLoader (com.klinker.android.twitter.adapters.CursorListLoader)2 HoloTextView (com.klinker.android.twitter.views.text.HoloTextView)2 Context (android.content.Context)1 PackageManager (android.content.pm.PackageManager)1 Point (android.graphics.Point)1