use of android.widget.AbsListView in project Talon-for-Twitter by klinker24.
the class ChoosenListActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);
context = this;
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
settings = AppSettings.getInstance(this);
if (settings.advanceWindowed) {
setUpWindow();
}
Utils.setUpPopupTheme(this, settings);
actionBar = getActionBar();
actionBar.setTitle(getResources().getString(R.string.lists));
setContentView(R.layout.ptr_list_layout);
if (!settings.isTwitterLoggedIn) {
Intent login = new Intent(context, LoginActivity.class);
startActivity(login);
finish();
}
mPullToRefreshLayout = (FullScreenSwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
spinner = (LinearLayout) findViewById(R.id.list_progress);
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) 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) {
getLists();
}
}
});
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());
listName = getIntent().getStringExtra("list_name");
listId = Long.parseLong(getIntent().getStringExtra("list_id"));
actionBar.setTitle(listName);
getLists();
Utils.setActionBar(context);
}
use of android.widget.AbsListView in project Talon-for-Twitter by klinker24.
the class ProfileMentionsFragment 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);
this.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 && hasMore) {
getMore();
}
}
});
doSearch();
return layout;
}
use of android.widget.AbsListView in project boilerplate by koush.
the class ScrollingToolbarLayout method enableToolbarScrollOff.
public void enableToolbarScrollOff(final IHeaderRecyclerView headerRecyclerView, final Fragment fragment, int statusBarColor) {
scrollOffEnabled = true;
int extra;
View paddingView;
if (getChildCount() == 3)
paddingView = getChildAt(0);
else
paddingView = getChildAt(getChildCount() - 1);
if (paddingView.getLayoutParams().height > 0) {
extra = paddingView.getLayoutParams().height;
} else {
// apparently this is the max size allowed
final int SIZE_MAX = 1073741823;
paddingView.measure(MeasureSpec.makeMeasureSpec(SIZE_MAX, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(SIZE_MAX, MeasureSpec.AT_MOST));
extra = paddingView.getMeasuredHeight();
}
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, extra);
FrameLayout frameLayout = new FrameLayout(getContext());
frameLayout.setLayoutParams(lp);
headerRecyclerView.addHeaderView(0, frameLayout);
headerRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView absListView, int scrollState) {
// when scrolling stops, and the toolbar is only partially scrolled off, force to scroll bar in completely
if (scrollState != RecyclerView.SCROLL_STATE_IDLE)
return;
if (absListView.getChildCount() < 1)
return;
int firstVisibleItem = headerRecyclerView.findFirstVisibleItemPosition();
if (firstVisibleItem != 0)
return;
final View toolbarContainer = getChildAt(getChildCount() - 1);
if (toolbarContainer.getTranslationY() <= -toolbarContainer.getHeight() || (existingToolbarYAnimation != null && existingToolbarYEnd <= toolbarContainer.getHeight()))
return;
toolbarScrollIn();
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (recyclerView.getChildCount() < 1)
return;
if (fragment != null && !fragment.getUserVisibleHint())
return;
// cancelToolbarScroll();
final View firstView = recyclerView.getChildAt(0);
final View toolbarContainer = getChildAt(getChildCount() - 1);
final View backdrop;
if (getChildCount() == 3)
backdrop = getChildAt(0);
else
backdrop = null;
final int toolbarHeight = toolbarContainer.getHeight();
int firstVisibleItem = headerRecyclerView.findFirstVisibleItemPosition();
if (backdrop != null) {
int newBackdropHeight;
int backdropHeight = getResources().getDimensionPixelSize(R.dimen.icon_list_drawer_activity_backdrop_height);
if (firstVisibleItem >= 1) {
newBackdropHeight = toolbarHeight;
} else {
newBackdropHeight = firstView.getTop() + backdropHeight;
}
newBackdropHeight = Math.max(newBackdropHeight, toolbarHeight);
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) backdrop.getLayoutParams();
lp.height = newBackdropHeight;
// another option is to use y translation to not do parallax
backdrop.setLayoutParams(lp);
if (newBackdropHeight / (float) backdropHeight < .5f) {
toolbarFadeToPrimary();
} else {
toolbarFadeToTranslucent(statusBarColor);
}
}
if (firstVisibleItem == 0) {
int remainder = firstView.getHeight() + firstView.getTop();
// if there's less than toolbar height left, start scrolling off.
if (remainder < toolbarHeight) {
remainder = toolbarHeight - remainder;
if (existingToolbarYAnimation == null) {
float diff = -remainder - toolbarContainer.getTranslationY();
if (false && Math.abs(diff) > toolbarHeight / 4) {
if (toolbarContainer.getTranslationY() < -remainder) {
// scrolling down
toolbarScrollIn();
} else {
// scrolling up
toolbarScrollOut();
}
} else {
toolbarContainer.setTranslationY(-remainder);
}
}
if (backdrop != null)
backdrop.setTranslationY(-remainder);
} else {
cancelToolbarScroll();
toolbarContainer.setTranslationY(0);
// toolbarScrollIn();
if (backdrop != null)
backdrop.setTranslationY(0);
}
return;
}
if (firstVisibleItem == 1) {
cancelToolbarScroll();
toolbarContainer.setTranslationY(-toolbarHeight);
} else {
toolbarScrollOut();
}
if (backdrop != null)
backdrop.setTranslationY(-toolbarHeight);
}
});
if (getChildCount() == 3)
toolbarFadeToTranslucent(statusBarColor);
}
use of android.widget.AbsListView in project robotium by RobotiumTech.
the class Scroller method scroll.
/**
* Scrolls up and down.
*
* @param direction the direction in which to scroll
* @param allTheWay <code>true</code> if the view should be scrolled to the beginning or end,
* <code>false</code> to scroll one page up or down.
* @return {@code true} if more scrolling can be done
*/
@SuppressWarnings("unchecked")
public boolean scroll(int direction, boolean allTheWay) {
ArrayList<View> viewList = RobotiumUtils.removeInvisibleViews(viewFetcher.getAllViews(true));
ArrayList<View> filteredViews = RobotiumUtils.filterViewsToSet(new Class[] { ListView.class, ScrollView.class, GridView.class, WebView.class }, viewList);
List<View> scrollableSupportPackageViews = viewFetcher.getScrollableSupportPackageViews(true);
for (View viewToScroll : scrollableSupportPackageViews) {
filteredViews.add(viewToScroll);
}
View view = viewFetcher.getFreshestView(filteredViews);
if (view == null) {
return false;
}
if (view instanceof AbsListView) {
return scrollList((AbsListView) view, direction, allTheWay);
}
if (view instanceof WebView) {
return scrollWebView((WebView) view, direction, allTheWay);
}
if (allTheWay) {
scrollViewAllTheWay(view, direction);
return false;
} else {
return scrollView(view, direction);
}
}
use of android.widget.AbsListView in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ListDialogPreference method onPrepareDialogBuilder.
@Override
protected void onPrepareDialogBuilder(Builder builder, DialogInterface.OnClickListener listener) {
super.onPrepareDialogBuilder(builder, listener);
final Context context = getContext();
final int dialogLayout = getDialogLayoutResource();
final View picker = LayoutInflater.from(context).inflate(dialogLayout, null);
final ListPreferenceAdapter adapter = new ListPreferenceAdapter();
final AbsListView list = (AbsListView) picker.findViewById(android.R.id.list);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
if (callChangeListener((int) id)) {
setValue((int) id);
}
final Dialog dialog = getDialog();
if (dialog != null) {
dialog.dismiss();
}
}
});
// Set initial selection.
final int selectedPosition = getIndexForValue(mValue);
if (selectedPosition != AbsListView.INVALID_POSITION) {
list.setSelection(selectedPosition);
}
builder.setView(picker);
builder.setPositiveButton(null, null);
}
Aggregations