Search in sources :

Example 26 with BaseAdapter

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();
}
Also used : DatabaseHandler(com.se491.chef_ly.Databases.DatabaseHandler) BaseAdapter(android.widget.BaseAdapter)

Example 27 with BaseAdapter

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");
}
Also used : BaseAdapter(android.widget.BaseAdapter) RecipeInformation(com.se491.chef_ly.model.RecipeInformation)

Example 28 with BaseAdapter

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);
                }
            });
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) GridView(android.widget.GridView) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) PhotoView(com.bm.library.PhotoView) PhotoView(com.bm.library.PhotoView) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AdapterView(android.widget.AdapterView) BaseAdapter(android.widget.BaseAdapter)

Example 29 with BaseAdapter

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;
        }
    });
}
Also used : Spinner(android.widget.Spinner) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Fragment(android.support.v4.app.Fragment) MuzeiRendererFragment(com.google.android.apps.muzei.render.MuzeiRendererFragment) ActivityNotFoundException(android.content.ActivityNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView) BaseAdapter(android.widget.BaseAdapter) Toolbar(android.support.v7.widget.Toolbar)

Example 30 with BaseAdapter

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;
}
Also used : AdapterView(android.widget.AdapterView) Adapter(android.widget.Adapter) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter) BaseAdapter(android.widget.BaseAdapter) SuppressLint(android.annotation.SuppressLint) ListAdapter(android.widget.ListAdapter)

Aggregations

BaseAdapter (android.widget.BaseAdapter)43 View (android.view.View)22 AdapterView (android.widget.AdapterView)21 ViewGroup (android.view.ViewGroup)16 Adapter (android.widget.Adapter)15 TextView (android.widget.TextView)15 ListAdapter (android.widget.ListAdapter)8 ListView (android.widget.ListView)7 RemoteAdapterConnectionCallback (android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback)7 LayoutInflater (android.view.LayoutInflater)5 Context (android.content.Context)4 AbsListView (android.widget.AbsListView)4 RecipeInformation (com.se491.chef_ly.model.RecipeInformation)4 SuppressLint (android.annotation.SuppressLint)3 Intent (android.content.Intent)3 GridView (android.widget.GridView)3 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)3 ImageView (android.widget.ImageView)3 FlipViewController (com.aphidmobile.flip.FlipViewController)3 NumberTextView (com.aphidmobile.flip.demo.views.NumberTextView)3