use of com.chrishoekstra.trello.adapter.CardAdapter in project Trello-Android by chrisHoekstra.
the class BoardListActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.board_list);
// Instantiate view items
mCardList = (ListView) findViewById(R.id.card_list);
mBoardListText = (TextView) findViewById(R.id.board_list);
mAddCardEdit = (EditText) findViewById(R.id.add_card_edit);
mAddCardButton = (Button) findViewById(R.id.add_card);
mAddButton = (Button) findViewById(R.id.add);
mCancelButton = (Button) findViewById(R.id.cancel);
mAddCardLayout = (RelativeLayout) findViewById(R.id.add_card_layout);
// Instantiate models
mModel = TrelloModel.getInstance();
// Instantiate controllers
mController = TrelloController.getInstance();
// Create listeners
mOnCardsReceivedListener = new TrelloModel.OnCardsReceivedListener() {
@Override
public void onCardsRecivedEvent(TrelloModel model, String boardListId, ArrayList<CardVO> result) {
mCardAdapter = new CardAdapter(BoardListActivity.this, R.id.name, result, model);
mCardList.setAdapter(mCardAdapter);
}
};
mOnCardAddedListener = new TrelloModel.OnCardAddedListener() {
@Override
public void onCardAddedEvent(TrelloModel model, Boolean result) {
if (result) {
Toast.makeText(BoardListActivity.this, "Card added!", Toast.LENGTH_SHORT).show();
mController.getCardsByList(mBoardListId);
} else {
Toast.makeText(BoardListActivity.this, "Card addition failed!", Toast.LENGTH_SHORT).show();
}
endAddCard();
}
};
mCardList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listView, View view, int position, long id) {
Intent intent = new Intent(getParent(), CardActivity.class);
intent.putExtra(BundleKeys.CARD_ID, mCardAdapter.getItem(position).id);
intent.putExtra(BundleKeys.BOARD_LIST_ID, mBoardListId);
((TabActivityGroup) getParent()).startChildActivity("CardActivity", intent);
}
});
mAddCardButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
beginAddCard();
}
});
mCancelButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
endAddCard();
}
});
mAddButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
mController.addCard(mBoardListId, mAddCardEdit.getText().toString());
}
});
// Add listeners
mModel.addListener(mOnCardsReceivedListener);
mModel.addListener(mOnCardAddedListener);
// Get bundle extras
getBundleExtras((savedInstanceState != null) ? savedInstanceState : getIntent().getExtras());
// Instantiate activity variables
mController.getCardsByList(mBoardListId);
populateView();
}
Aggregations