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;
}
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);
}
}
});
}
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;
}
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();
}
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();
}
Aggregations