use of android.widget.GridView in project nmid-headline by miao1007.
the class PlatformListPage method initView.
private void initView() {
View backImageView = findViewByResName("backImageView");
backImageView.setTag(android.R.string.cancel);
backImageView.setOnClickListener(this);
View okImageView = findViewByResName("okImageView");
okImageView.setTag(android.R.string.ok);
okImageView.setOnClickListener(this);
gridViewAdapter = new PlatformGridViewAdapter(activity);
gridViewAdapter.setCustomerLogos(customerLogos);
GridView gridView = (GridView) findViewByResName("gridView");
gridView.setAdapter(gridViewAdapter);
new AsyncTask<Void, Void, Platform[]>() {
@Override
protected Platform[] doInBackground(Void... params) {
return ShareSDK.getPlatformList();
}
@Override
protected void onPostExecute(Platform[] platforms) {
gridViewAdapter.setData(platforms, hiddenPlatforms);
}
}.execute();
}
use of android.widget.GridView in project dialogplus by orhanobut.
the class GridHolderTest method testOnItemClick.
@Test
public void testOnItemClick() {
GridHolder holder = getHolder();
GridView view = (GridView) holder.getInflatedView();
//there is no listener, it shouldn't crash
view.performItemClick(null, 0, 0);
//with adapter set
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new String[] { "test" });
holder.setAdapter(adapter);
view.performItemClick(null, 0, 0);
//set listener
holder.setOnItemClickListener(new OnHolderListener() {
@Override
public void onItemClick(Object item, View view, int position) {
assertThat(String.valueOf(item)).isEqualTo("test");
assertThat(position).isEqualTo(0);
assertThat(view).isNull();
}
});
view.performItemClick(null, 0, 0);
}
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 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;
}
Aggregations