use of android.widget.BaseAdapter in project chefly_android by chef-ly.
the class ShoppingListActivity method addText.
private void addText(String text) {
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
db.addItemToShoppingList(text, false);
shoppingList = db.getShoppingList();
((BaseAdapter) getListAdapter()).notifyDataSetChanged();
}
use of android.widget.BaseAdapter in project chefly_android by chef-ly.
the class ListViewFragment method onLoadFinished.
// LoaderManager callback method
@Override
public void onLoadFinished(Loader<RecipeList> loader, RecipeList data) {
Log.d(TAG + "/" + title, "Loader - OnLoadFinish");
for (RecipeInformation recipe : data) {
list.add(recipe);
}
((BaseAdapter) listView.getAdapter()).notifyDataSetChanged();
isLoading.set(false);
Log.d(TAG, "Getting more recipes from server --- Done");
}
use of android.widget.BaseAdapter in project PhotoView by bm-x.
the class PhotoBrowse method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_photo_browse);
in.setDuration(300);
out.setDuration(300);
out.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mBg.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mParent = findViewById(R.id.parent);
mBg = findViewById(R.id.bg);
mPhotoView = (PhotoView) findViewById(R.id.img);
mPhotoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
gv = (GridView) findViewById(R.id.gv);
gv.setAdapter(new BaseAdapter() {
@Override
public int getCount() {
return imgs.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
PhotoView p = new PhotoView(PhotoBrowse.this);
p.setLayoutParams(new AbsListView.LayoutParams((int) (getResources().getDisplayMetrics().density * 100), (int) (getResources().getDisplayMetrics().density * 100)));
p.setScaleType(ImageView.ScaleType.CENTER_CROP);
p.setImageResource(imgs[position]);
// 把PhotoView当普通的控件把触摸功能关掉
p.disenable();
return p;
}
});
gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
PhotoView p = (PhotoView) view;
mInfo = p.getInfo();
mPhotoView.setImageResource(imgs[position]);
mBg.startAnimation(in);
mBg.setVisibility(View.VISIBLE);
mParent.setVisibility(View.VISIBLE);
;
mPhotoView.animaFrom(mInfo);
}
});
mPhotoView.enable();
mPhotoView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBg.startAnimation(out);
mPhotoView.animaTo(mInfo, new Runnable() {
@Override
public void run() {
mParent.setVisibility(View.GONE);
}
});
}
});
}
use of android.widget.BaseAdapter in project muzei by romannurik.
the class SettingsActivity method setupAppBar.
private void setupAppBar() {
mAppBar = (Toolbar) findViewById(R.id.app_bar);
mAppBar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onNavigateUp();
}
});
final LayoutInflater inflater = LayoutInflater.from(this);
Spinner sectionSpinner = (Spinner) findViewById(R.id.section_spinner);
sectionSpinner.setAdapter(new BaseAdapter() {
@Override
public int getCount() {
return SECTION_LABELS.length;
}
@Override
public Object getItem(int position) {
return SECTION_LABELS[position];
}
@Override
public long getItemId(int position) {
return position + 1;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.settings_ab_spinner_list_item, parent, false);
}
((TextView) convertView.findViewById(android.R.id.text1)).setText(getString(SECTION_LABELS[position]));
return convertView;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.settings_ab_spinner_list_item_dropdown, parent, false);
}
((TextView) convertView.findViewById(android.R.id.text1)).setText(getString(SECTION_LABELS[position]));
return convertView;
}
});
sectionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> spinner, View view, int position, long id) {
Class<? extends Fragment> fragmentClass = SECTION_FRAGMENTS[position];
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.content_container);
if (currentFragment != null && fragmentClass.equals(currentFragment.getClass())) {
return;
}
inflateMenuFromFragment(0);
try {
Fragment newFragment = fragmentClass.newInstance();
getSupportFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).setTransitionStyle(R.style.Muzei_SimpleFadeFragmentAnimation).replace(R.id.content_container, newFragment).commitAllowingStateLoss();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void onNothingSelected(AdapterView<?> spinner) {
}
});
sectionSpinner.setSelection(mStartSection);
inflateMenuFromFragment(0);
mAppBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_get_more_sources:
FirebaseAnalytics.getInstance(SettingsActivity.this).logEvent("more_sources_open", null);
try {
Intent playStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/search?q=Muzei&c=apps")).addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
preferPackageForIntent(SettingsActivity.this, playStoreIntent, PLAY_STORE_PACKAGE_NAME);
startActivity(playStoreIntent);
} catch (ActivityNotFoundException activityNotFoundException1) {
Toast.makeText(SettingsActivity.this, R.string.play_store_not_found, Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_about:
FirebaseAnalytics.getInstance(SettingsActivity.this).logEvent("about_open", null);
startActivity(new Intent(SettingsActivity.this, AboutActivity.class));
return true;
}
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.content_container);
if (currentFragment != null && currentFragment instanceof SettingsActivityMenuListener) {
((SettingsActivityMenuListener) currentFragment).onSettingsActivityMenuItemClick(item);
}
return false;
}
});
}
use of android.widget.BaseAdapter in project AutoLoadListView by ZhaoKaiQiang.
the class ZSwipeItem method isEnabledInAdapterView.
/**
* if working in {@link android.widget.AdapterView}, we should response
* {@link android.widget.Adapter} isEnable(int position).
*
* @return true when item is enabled, else disabled.
*/
private boolean isEnabledInAdapterView() {
@SuppressWarnings("rawtypes") AdapterView adapterView = getAdapterView();
boolean enable = true;
if (adapterView != null) {
Adapter adapter = adapterView.getAdapter();
if (adapter != null) {
int p = adapterView.getPositionForView(ZSwipeItem.this);
if (adapter instanceof BaseAdapter) {
enable = ((BaseAdapter) adapter).isEnabled(p);
} else if (adapter instanceof ListAdapter) {
enable = ((ListAdapter) adapter).isEnabled(p);
}
}
}
return enable;
}
Aggregations