use of android.widget.GridView in project JamsMusicPlayer by psaravan.
the class BrowserSubListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mContext = getApplicationContext();
mApp = (Common) mContext;
mHandler = new Handler();
mDBColumnsMap = new HashMap<Integer, String>();
//Set the theme and inflate the layout.
setTheme();
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browser_sub_list);
mHeaderImagePath = getIntent().getExtras().getString("headerImagePath");
mFragmentId = getIntent().getExtras().getInt("fragmentId");
mHeaderText = getIntent().getExtras().getString("headerText");
mHeaderSubText = getIntent().getExtras().getString("subText");
mField2 = getIntent().getExtras().getString("field2");
if (mHeaderText == null || mHeaderText.isEmpty())
mHeaderText = mContext.getResources().getString(R.string.unknown_genre);
mHeaderLayout = (RelativeLayout) findViewById(R.id.browser_sub_header_layout);
mHeaderImage = (ImageView) findViewById(R.id.browser_sub_header_image);
mHeaderTextView = (TextView) findViewById(R.id.browser_sub_header_text);
mHeaderSubTextView = (TextView) findViewById(R.id.browser_sub_header_sub_text);
mListView = (ListView) findViewById(R.id.browser_sub_list_view);
mDrawerParentLayout = (RelativeLayout) findViewById(R.id.browser_sub_drawer_parent);
mDrawerLayout = (DrawerLayout) findViewById(R.id.browser_sub_drawer_root);
mNavDrawerLayout = (RelativeLayout) findViewById(R.id.nav_drawer_container);
mCurrentQueueDrawerLayout = (RelativeLayout) findViewById(R.id.current_queue_drawer_container);
mPlayAllText = (TextView) findViewById(R.id.browser_sub_play_all);
mHeaderTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
mHeaderTextView.setText(mHeaderText);
mHeaderTextView.setSelected(true);
mHeaderSubTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
mHeaderSubTextView.setText(mHeaderSubText);
mHeaderSubTextView.setSelected(true);
mPlayAllText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
mPlayAllText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int playbackRouteId = Common.PLAY_ALL_SONGS;
switch(mFragmentId) {
case Common.ARTISTS_FLIPPED_SONGS_FRAGMENT:
playbackRouteId = Common.PLAY_ALL_BY_ALBUM;
break;
case Common.ALBUM_ARTISTS_FLIPPED_SONGS_FRAGMENT:
playbackRouteId = Common.PLAY_ALL_BY_ALBUM;
break;
case Common.GENRES_FLIPPED_SONGS_FRAGMENT:
playbackRouteId = Common.PLAY_ALL_BY_ALBUM;
break;
}
mApp.getPlaybackKickstarter().initPlayback(mContext, mQuerySelection, playbackRouteId, 0, true, false);
}
});
//Apply the ListViews' dividers.
if (mApp.getCurrentTheme() == Common.DARK_THEME) {
mListView.setDivider(mContext.getResources().getDrawable(R.drawable.list_divider));
} else {
mListView.setDivider(mContext.getResources().getDrawable(R.drawable.list_divider_light));
}
mListView.setDividerHeight(1);
mDrawerParentLayout.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));
applyKitKatTranslucency();
//Load the drawer fragments.
loadDrawerFragments();
//Start the content animations as soon the activity's transition finishes.
mHandler.postDelayed(animateContent, 300);
//Start loading the GridView cursor.
AsyncRunQuery task = new AsyncRunQuery();
task.execute();
}
use of android.widget.GridView in project android by owncloud.
the class FileListListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
OCFile file = null;
LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (mFiles != null && mFiles.size() > position) {
file = mFiles.get(position);
}
// Find out which layout should be displayed
ViewType viewType;
if (parent instanceof GridView) {
if (file != null && file.isImage()) {
viewType = ViewType.GRID_IMAGE;
} else {
viewType = ViewType.GRID_ITEM;
}
} else {
viewType = ViewType.LIST_ITEM;
}
// create view only if differs, otherwise reuse
if (convertView == null || convertView.getTag() != viewType) {
switch(viewType) {
case GRID_IMAGE:
view = inflator.inflate(R.layout.grid_image, parent, false);
view.setTag(ViewType.GRID_IMAGE);
break;
case GRID_ITEM:
view = inflator.inflate(R.layout.grid_item, parent, false);
view.setTag(ViewType.GRID_ITEM);
break;
case LIST_ITEM:
view = inflator.inflate(R.layout.list_item, parent, false);
view.setTag(ViewType.LIST_ITEM);
break;
}
}
if (file != null) {
ImageView fileIcon = (ImageView) view.findViewById(R.id.thumbnail);
fileIcon.setTag(file.getFileId());
TextView fileName;
String name = file.getFileName();
LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.ListItemLayout);
linearLayout.setContentDescription("LinearLayout-" + name);
switch(viewType) {
case LIST_ITEM:
TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
TextView fileSizeSeparatorV = (TextView) view.findViewById(R.id.file_separator);
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
lastModV.setVisibility(View.VISIBLE);
lastModV.setText(DisplayUtils.getRelativeTimestamp(mContext, file.getModificationTimestamp()));
fileSizeSeparatorV.setVisibility(View.VISIBLE);
fileSizeV.setVisibility(View.VISIBLE);
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength(), mContext));
case GRID_ITEM:
// filename
fileName = (TextView) view.findViewById(R.id.Filename);
name = file.getFileName();
fileName.setText(name);
case GRID_IMAGE:
// sharedIcon
ImageView sharedIconV = (ImageView) view.findViewById(R.id.sharedIcon);
if (file.isSharedViaLink()) {
sharedIconV.setImageResource(R.drawable.shared_via_link);
sharedIconV.setVisibility(View.VISIBLE);
sharedIconV.bringToFront();
} else if (file.isSharedWithSharee() || file.isSharedWithMe()) {
sharedIconV.setImageResource(R.drawable.shared_via_users);
sharedIconV.setVisibility(View.VISIBLE);
sharedIconV.bringToFront();
} else {
sharedIconV.setVisibility(View.GONE);
}
// local state
ImageView localStateView = (ImageView) view.findViewById(R.id.localFileIndicator);
localStateView.bringToFront();
FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
OperationsServiceBinder opsBinder = mTransferServiceGetter.getOperationsServiceBinder();
// default first
localStateView.setVisibility(View.INVISIBLE);
if (//synchronizing
opsBinder != null && opsBinder.isSynchronizing(mAccount, file)) {
localStateView.setImageResource(R.drawable.ic_synchronizing);
localStateView.setVisibility(View.VISIBLE);
} else if (// downloading
downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
localStateView.setImageResource(R.drawable.ic_synchronizing);
localStateView.setVisibility(View.VISIBLE);
} else if (//uploading
uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
localStateView.setImageResource(R.drawable.ic_synchronizing);
localStateView.setVisibility(View.VISIBLE);
} else if (file.getEtagInConflict() != null) {
// conflict
localStateView.setImageResource(R.drawable.ic_synchronizing_error);
localStateView.setVisibility(View.VISIBLE);
} else if (file.isDown()) {
localStateView.setImageResource(R.drawable.ic_synced);
localStateView.setVisibility(View.VISIBLE);
}
break;
}
// For all Views
ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
checkBoxV.setVisibility(View.GONE);
view.setBackgroundColor(Color.WHITE);
AbsListView parentList = (AbsListView) parent;
if (parentList.getChoiceMode() != AbsListView.CHOICE_MODE_NONE && parentList.getCheckedItemCount() > 0) {
if (parentList.isItemChecked(position)) {
view.setBackgroundColor(mContext.getResources().getColor(R.color.selected_item_background));
checkBoxV.setImageResource(R.drawable.ic_checkbox_marked);
} else {
view.setBackgroundColor(Color.WHITE);
checkBoxV.setImageResource(R.drawable.ic_checkbox_blank_outline);
}
checkBoxV.setVisibility(View.VISIBLE);
}
// because android reuses views in listview
if (file.getAvailableOfflineStatus() == OCFile.AvailableOfflineStatus.NOT_AVAILABLE_OFFLINE) {
view.findViewById(R.id.favoriteIcon).setVisibility(View.GONE);
} else {
view.findViewById(R.id.favoriteIcon).setVisibility(View.VISIBLE);
}
// No Folder
if (!file.isFolder()) {
if (file.isImage() && file.getRemoteId() != null) {
// Thumbnail in Cache?
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(String.valueOf(file.getRemoteId()));
if (thumbnail != null && !file.needsUpdateThumbnail()) {
fileIcon.setImageBitmap(thumbnail);
} else {
// generate new Thumbnail
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, fileIcon)) {
final ThumbnailsCacheManager.ThumbnailGenerationTask task = new ThumbnailsCacheManager.ThumbnailGenerationTask(fileIcon, mStorageManager, mAccount);
if (thumbnail == null) {
thumbnail = ThumbnailsCacheManager.mDefaultImg;
}
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable = new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(), thumbnail, task);
fileIcon.setImageDrawable(asyncDrawable);
task.execute(file);
}
}
if (file.getMimetype().equalsIgnoreCase("image/png")) {
fileIcon.setBackgroundColor(mContext.getResources().getColor(R.color.background_color));
}
} else {
fileIcon.setImageResource(MimetypeIconUtil.getFileTypeIconId(file.getMimetype(), file.getFileName()));
}
} else {
// Folder
fileIcon.setImageResource(MimetypeIconUtil.getFolderTypeIconId(file.isSharedWithMe() || file.isSharedWithSharee(), file.isSharedViaLink()));
}
}
return view;
}
use of android.widget.GridView in project ListViewAnimations by nhaarman.
the class ViewAnimator method calculateAnimationDelay.
/**
* Returns the delay in milliseconds after which animation for View with position mLastAnimatedPosition + 1 should start.
*/
@SuppressLint("NewApi")
private int calculateAnimationDelay(final int position) {
int delay;
int lastVisiblePosition = mListViewWrapper.getLastVisiblePosition();
int firstVisiblePosition = mListViewWrapper.getFirstVisiblePosition();
int numberOfItemsOnScreen = lastVisiblePosition - firstVisiblePosition;
int numberOfAnimatedItems = position - 1 - mFirstAnimatedPosition;
if (numberOfItemsOnScreen + 1 < numberOfAnimatedItems) {
delay = mAnimationDelayMillis;
if (mListViewWrapper.getListView() instanceof GridView && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
int numColumns = ((GridView) mListViewWrapper.getListView()).getNumColumns();
delay += mAnimationDelayMillis * (position % numColumns);
}
} else {
int delaySinceStart = (position - mFirstAnimatedPosition) * mAnimationDelayMillis;
delay = Math.max(0, (int) (-SystemClock.uptimeMillis() + mAnimationStartMillis + mInitialDelayMillis + delaySinceStart));
}
return delay;
}
use of android.widget.GridView in project ListViewAnimations by nhaarman.
the class GridViewActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gridview);
GridView gridView = (GridView) findViewById(R.id.activity_gridview_gv);
SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(new GridViewAdapter(this));
swingBottomInAnimationAdapter.setAbsListView(gridView);
assert swingBottomInAnimationAdapter.getViewAnimator() != null;
swingBottomInAnimationAdapter.getViewAnimator().setInitialDelayMillis(INITIAL_DELAY_MILLIS);
gridView.setAdapter(swingBottomInAnimationAdapter);
assert getActionBar() != null;
getActionBar().setDisplayHomeAsUpEnabled(true);
}
use of android.widget.GridView in project SeriesGuide by UweTrottmann.
the class MoviesBaseFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(LAYOUT, container, false);
gridView = (GridView) v.findViewById(R.id.gridViewMovies);
// enable app bar scrolling out of view only on L or higher
ViewCompat.setNestedScrollingEnabled(gridView, AndroidUtils.isLollipopOrHigher());
emptyView = (TextView) v.findViewById(R.id.textViewMoviesEmpty);
gridView.setEmptyView(emptyView);
gridView.setOnItemClickListener(this);
return v;
}
Aggregations