use of org.holoeverywhere.widget.GridView in project HoloEverywhere by Prototik.
the class GridFragment method ensureGrid.
private void ensureGrid() {
if (mGrid != null) {
return;
}
View root = getView();
if (root == null) {
throw new IllegalStateException("Content view not yet created");
}
if (root instanceof GridView) {
mGrid = (GridView) root;
} else {
mStandardEmptyView = (TextView) root.findViewById(R.id.internalEmpty);
if (mStandardEmptyView == null) {
mEmptyView = root.findViewById(android.R.id.empty);
} else {
mStandardEmptyView.setVisibility(View.GONE);
}
mProgressContainer = root.findViewById(R.id.progressContainer);
mGridContainer = root.findViewById(R.id.listContainer);
View rawGridVIew = root.findViewById(android.R.id.list);
if (!(rawGridVIew instanceof GridView)) {
if (rawGridVIew == null) {
throw new RuntimeException("Your content must have a GridVIew whose id attribute is " + "'android.R.id.list'");
}
throw new RuntimeException("Content has view with id attribute 'android.R.id.list' " + "that is not a GridVIew class");
}
mGrid = (GridView) rawGridVIew;
if (mEmptyView != null) {
mGrid.setEmptyView(mEmptyView);
} else if (mEmptyText != null) {
mStandardEmptyView.setText(mEmptyText);
mGrid.setEmptyView(mStandardEmptyView);
}
}
mGridShown = true;
mGrid.setOnItemClickListener(mOnClickListener);
if (mAdapter != null) {
ListAdapter adapter = mAdapter;
mAdapter = null;
setGridAdapter(adapter);
} else {
if (mProgressContainer != null) {
setGridShown(false, false);
}
}
mHandler.post(mRequestFocus);
}
use of org.holoeverywhere.widget.GridView in project HoloEverywhere by Prototik.
the class ResolverActivity method onCreate.
protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) {
super.onCreate(savedInstanceState);
try {
mLaunchedFromUid = getPackageManager().getApplicationInfo(getPackageName(), 0).uid;
} catch (NameNotFoundException e) {
e.printStackTrace();
mLaunchedFromUid = -1;
}
mPm = getPackageManager();
mAlwaysUseOption = alwaysUseOption;
mMaxColumns = getResources().getInteger(R.integer.config_maxResolverActivityColumns);
intent.setComponent(null);
AlertController.AlertParams ap = mAlertParams;
ap.mTitle = title;
final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
mIconDpi = getLauncherLargeIconDensity(am);
mIconSize = getLauncherLargeIconSize(am);
mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList, mLaunchedFromUid);
int count = mAdapter.getCount();
if (mLaunchedFromUid < 0 || isIsolated(mLaunchedFromUid)) {
finish();
return;
} else if (count > 1) {
ap.mView = getLayoutInflater().inflate(R.layout.resolver_grid, null);
mGrid = (GridView) ap.mView.findViewById(R.id.resolver_grid);
mGrid.setAdapter(mAdapter);
mGrid.setOnItemClickListener(this);
mGrid.setOnItemLongClickListener(new ItemLongClickListener());
if (alwaysUseOption) {
mGrid.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
}
resizeGrid();
} else if (count == 1) {
startActivity(mAdapter.intentForPosition(0));
finish();
return;
} else {
ap.mMessage = getResources().getText(R.string.noApplications);
}
setupAlert();
if (alwaysUseOption) {
final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
if (buttonLayout != null) {
buttonLayout.setVisibility(View.VISIBLE);
mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
} else {
mAlwaysUseOption = false;
}
}
}
Aggregations