use of com.chrishoekstra.trello.model.TrelloModel in project Trello-Android by chrisHoekstra.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Instantiate view items
mTokenEdit = (EditText) findViewById(R.id.token);
mLinkText = (TextView) findViewById(R.id.request_token_link);
// Instantiate models
mModel = TrelloModel.getInstance();
// Instantiate controllers
mController = TrelloController.getInstance();
// Create listeners
mOnUserDataReceivedListener = new TrelloModel.OnUserDataReceivedListener() {
@Override
public void onUserDataReceived(TrelloModel model, Boolean result) {
if (result != null) {
Intent intent = new Intent(MainActivity.this, TrelloTabActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
dismissDialog(DIALOG_PROGRESS);
finish();
} else {
dismissDialog(DIALOG_PROGRESS);
showDialog(DIALOG_LOGIN_ERROR);
}
}
};
findViewById(R.id.proceed).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog(DIALOG_PROGRESS);
String token = mTokenEdit.getText().toString();
mController.setToken(token);
mController.getUserData();
mPrefsEditor.putString(TOKEN, token);
mPrefsEditor.commit();
}
});
// Add listeners
mModel.addListener(mOnUserDataReceivedListener);
// Instantiate activity variables
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mPrefsEditor = mPrefs.edit();
String token = mPrefs.getString(TOKEN, "");
if (!token.equals("")) {
showDialog(DIALOG_PROGRESS);
mController.setToken(token);
mController.getUserData();
} else {
mLinkText.setText(mController.getRequestLink());
}
}
use of com.chrishoekstra.trello.model.TrelloModel in project Trello-Android by chrisHoekstra.
the class BoardActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.board);
// Instantiate view items
mBoardListsList = (ListView) findViewById(R.id.board_lists_list);
mBoardText = (TextView) findViewById(R.id.board);
// Instantiate models
mModel = TrelloModel.getInstance();
// Instantiate controllers
mController = TrelloController.getInstance();
// Create listeners
mOnBoardListsReceivedListener = new TrelloModel.OnBoardListsReceivedListener() {
@Override
public void onBoardListReceviedEvent(TrelloModel model, String boardId, ArrayList<BoardListVO> result) {
if (boardId.equals(mBoardId)) {
mBoardListAdapter = new BoardListAdapter(BoardActivity.this, R.id.name, result);
mBoardListsList.setAdapter(mBoardListAdapter);
}
}
};
mBoardListsList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> listView, View view, int position, long id) {
Intent intent = new Intent(getParent(), BoardListActivity.class);
intent.putExtra(BundleKeys.BOARD_ID, mBoardId);
intent.putExtra(BundleKeys.BOARD_LIST_ID, mBoardListAdapter.getItem(position).id);
((TabActivityGroup) getParent()).startChildActivity("BoardListActivity", intent);
}
});
// Add listeners
mModel.addListener(mOnBoardListsReceivedListener);
// Get bundle extras
getBundleExtras((savedInstanceState != null) ? savedInstanceState : getIntent().getExtras());
// Instantiate activity variables
mController.getListsByBoard(mBoardId);
populateView();
}
use of com.chrishoekstra.trello.model.TrelloModel 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