Search in sources :

Example 21 with BaseAdapter

use of android.widget.BaseAdapter in project chefly_android by chef-ly.

the class ListViewFragment method setList.

public void setList(RecipeList newList, boolean goToTop) {
    list.clear();
    for (RecipeInformation r : newList) {
        list.add(r);
    }
    ((BaseAdapter) listView.getAdapter()).notifyDataSetChanged();
    if (goToTop) {
        listView.setSelectionAfterHeaderView();
    }
}
Also used : BaseAdapter(android.widget.BaseAdapter) RecipeInformation(com.se491.chef_ly.model.RecipeInformation)

Example 22 with BaseAdapter

use of android.widget.BaseAdapter in project chefly_android by chef-ly.

the class ListViewFragment method removeFavorite.

public void removeFavorite(RecipeInformation r) {
    int index = list.indexOf(r);
    if (index > 0) {
        list.get(index).setFavorite(false);
    } else {
        Log.d(TAG + "/" + title, "Remove Favorite index -> " + index);
        for (RecipeInformation rec : list) {
            Log.d(TAG + "/" + title, "ID -> " + rec.getId());
        }
    }
    ((BaseAdapter) listView.getAdapter()).notifyDataSetChanged();
}
Also used : BaseAdapter(android.widget.BaseAdapter) RecipeInformation(com.se491.chef_ly.model.RecipeInformation)

Example 23 with BaseAdapter

use of android.widget.BaseAdapter in project android_frameworks_base by crdroidandroid.

the class AppWidgetHostView method viewDataChanged.

/**
     * Process data-changed notifications for the specified view in the specified
     * set of {@link RemoteViews} views.
     */
void viewDataChanged(int viewId) {
    View v = findViewById(viewId);
    if ((v != null) && (v instanceof AdapterView<?>)) {
        AdapterView<?> adapterView = (AdapterView<?>) v;
        Adapter adapter = adapterView.getAdapter();
        if (adapter instanceof BaseAdapter) {
            BaseAdapter baseAdapter = (BaseAdapter) adapter;
            baseAdapter.notifyDataSetChanged();
        } else if (adapter == null && adapterView instanceof RemoteAdapterConnectionCallback) {
            // If the adapter is null, it may mean that the RemoteViewsAapter has not yet
            // connected to its associated service, and hence the adapter hasn't been set.
            // In this case, we need to defer the notify call until it has been set.
            ((RemoteAdapterConnectionCallback) adapterView).deferNotifyDataSetChanged();
        }
    }
}
Also used : RemoteAdapterConnectionCallback(android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback) AdapterView(android.widget.AdapterView) Adapter(android.widget.Adapter) BaseAdapter(android.widget.BaseAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) BaseAdapter(android.widget.BaseAdapter)

Example 24 with BaseAdapter

use of android.widget.BaseAdapter in project MadMax by deviz92.

the class GroupExpensesActivity method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // setContentView(R.layout.activity_group_expenses);
    final String IDGroup;
    Intent intent = getIntent();
    // if starting activity from itself (adding a new expense)
    if (intent.getBooleanExtra("addExpenseToGroup", true)) {
        IDGroup = intent.getStringExtra("IDGroup");
        String description = intent.getStringExtra("description");
        String amount = intent.getStringExtra("amount");
        String currency = intent.getStringExtra("currency");
        // expenses.put(String.valueOf(i), new Expense(String.valueOf(i), description + " " + currency + " " + amount, (double) i+1));
        Group group = MainActivity.getCurrentUser().getUserGroups().get(IDGroup);
        expenses = group.getExpenses();
    // todo a cosa serve questa expense?? quale utente la fa?
    /*Expense e = new Expense(
                    String.valueOf(expenses.size()), description, null, Double.valueOf(amount),
                    currency, String.valueOf(R.drawable.expense6), "urlBill", false, group.getID(), null, false
            );*/
    // save the new expense
    // expenses.put(String.valueOf(expenses.size()), e);
    // GroupsActivity.users.get(0).addExpense(e);
    // GroupsActivity.myself.addExpense(e);
    // todo mettere addExpenseFirebase
    } else // if starting activity from GroupActivity (tapping on a group for showing details)
    {
        IDGroup = intent.getStringExtra("IDGroup");
        Group group = MainActivity.getCurrentUser().getUserGroups().get(IDGroup);
        expenses = group.getExpenses();
    }
    // then show group expenses list
    // todo getting IDGroup from the intent from GroupsActivity
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(GroupExpensesActivity.this, NewExpenseActivity.class);
            intent.putExtra("IDGroup", IDGroup);
            intent.putExtra("callingActivity", "GroupExpensesActivity");
            intent.putExtra("newPending", false);
            GroupExpensesActivity.this.startActivity(intent);
            finish();
            GroupExpensesActivity.this.startActivity(intent);
        /*Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();*/
        }
    });
    /*        //Button to go to group info
        Button groupInfoButton = (Button) findViewById(R.id.infobutton);
        groupInfoButton.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view) {

                Context context = GroupExpensesActivity.this;
                Class destinationActivity = GroupInfoActivity.class;
                Intent intent = new Intent(context, destinationActivity);
                intent.putExtra("groupID", IDGroup);
                intent.putExtra("caller", "GroupExpensesActivity");
                startActivity(intent);

            }
        });*/
    // todo when we'll use Firebase -> retrieve expenses HashMap with IDGroup received from GroupsActivity
    ListView lv = (ListView) findViewById(R.id.expenses);
    // for putting data inside the list view I need an adapter
    BaseAdapter a = new BaseAdapter() {

        @Override
        public int getCount() {
            return expenses.size();
        }

        @Override
        public Object getItem(int position) {
            return expenses.get(String.valueOf(position));
        }

        // not changed
        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // if it's the first time I create the view
            if (convertView == null) {
                // LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                LayoutInflater inflater = LayoutInflater.from(GroupExpensesActivity.this);
                // last parameter is very important: for now we don't want to attach our view to the parent view
                convertView = inflater.inflate(R.layout.list_item, parent, false);
            }
            Expense expense = expenses.get(String.valueOf(position));
            ImageView photo = (ImageView) convertView.findViewById(R.id.img_photo);
            TextView description = (TextView) convertView.findViewById(R.id.tv_sender);
            TextView amount = (TextView) convertView.findViewById(R.id.tv_balance);
            if (expense.getExpensePhoto() != null)
                photo.setImageResource(Integer.parseInt(expense.getExpensePhoto()));
            description.setText(expense.getDescription());
            String amountString = expense.getAmount() + " " + expense.getCurrency();
            amount.setText(amountString);
            return convertView;
        }
    };
    lv.setAdapter(a);
}
Also used : ViewGroup(android.view.ViewGroup) Group(com.polito.mad17.madmax.entities.Group) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) ListView(android.widget.ListView) Expense(com.polito.mad17.madmax.entities.Expense) NewExpenseActivity(com.polito.mad17.madmax.activities.expenses.NewExpenseActivity) LayoutInflater(android.view.LayoutInflater) FloatingActionButton(android.support.design.widget.FloatingActionButton) TextView(android.widget.TextView) ImageView(android.widget.ImageView) BaseAdapter(android.widget.BaseAdapter)

Example 25 with BaseAdapter

use of android.widget.BaseAdapter in project xabber-android by redsolution.

the class PreferencesFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    BaseAdapter adapter = (BaseAdapter) getPreferenceScreen().getRootAdapter();
    adapter.notifyDataSetChanged();
    PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
}
Also used : BaseAdapter(android.widget.BaseAdapter)

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