use of ru.sash0k.thriftbox.MainActivity in project Thrift-box by Sash0k.
the class InputFragment method onActivityCreated.
// ============================================================================
@Override
public void onActivityCreated(Bundle state) {
super.onActivityCreated(state);
final Activity context = getActivity();
Toolbar toolbar = (Toolbar) context.findViewById(R.id.toolbar);
valueTV = (TextView) toolbar.findViewById(R.id.enter_value);
valueTV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view instanceof TextView && ((TextView) view).length() != 0) {
showCommentDialog(commentTV.getText());
}
}
});
commentTV = (TextView) context.findViewById(R.id.comment_value);
commentTV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showCommentDialog(((TextView) view).getText());
}
});
categories = (Categories) context.findViewById(R.id.categories);
if (state != null) {
categories.setSelected(state.getInt(DB.CATEGORY));
valueTV.setText(state.getCharSequence(DB.VALUE));
CharSequence comment = state.getCharSequence(DB.COMMENT);
commentTV.setText(comment);
}
FloatingActionButton fab = (FloatingActionButton) context.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
enterValue(context);
}
});
// обработка длинного нажатия
ImageButton clear = (ImageButton) context.findViewById(R.id.del);
clear.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
((MainActivity) context).clearAnimation(view);
return true;
}
});
}
use of ru.sash0k.thriftbox.MainActivity in project Thrift-box by Sash0k.
the class InputFragment method enterValue.
// ============================================================================
private void enterValue(Context context) {
if (valueTV != null) {
final String textValue = valueTV.getText().toString();
final int value = Utils.parseCurrency(textValue);
if (value > 0) {
final String comment = commentTV.getText().toString();
new DB(context).insertItem(context, value, categories.getSelected(), comment);
Toast.makeText(context, ((MainActivity) context).parseRouble(getString(R.string.enter_value_done) + " " + textValue + Utils.ROUBLE + " " + comment), Toast.LENGTH_SHORT).show();
cleanValues();
Utils.updateWidgets(context);
} else
Toast.makeText(context, getString(R.string.enter_value_invalid), Toast.LENGTH_SHORT).show();
}
}
Aggregations