I have a problem so I have a problem.
enter image description here In the Scan Activity, QR Codes are scanned and the card data is generated, then when the value is matched, we go to the next activity where we are shown the next value. Click on the Next button and go to our list of data. Ask how to get from the ScanActivity.class Activity card data and add a list
piece of code from ScanActitivty.java
if (!p.matcher(decodedBarcodeValue).matches()) {
showAlterDialog("Błędny QR Kod", "Podany kod QR code jest błędny. Zeskanuj go ponownie.");
} else {
Matcher m = p.matcher(decodedBarcodeValue);
while (m.find()) {
daneKarty[index] = m.group(1);
index++;
}
if (daneKarty.length < 6) {
showAlterDialog("Błędny QR Kod", "Podany Kod jest nieprawidłowy");
}
sciezka3 = daneKarty[0];
base32 = daneKarty[1];
nameCard = daneKarty[2];
intervalTotp = daneKarty[3];
passwordHotp = daneKarty[4];
expirationDate = daneKarty[5];
if (intervalTotp.equals("")) {
intervalTotp = "60";
}
try {
OTP = generateOTP(base32, uuidDevice);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Base32 code = new Base32();
byte secret[] = code.decode(OTP);
try {
hotpValue = Hotp.generateHotp(secret, hotp_counter, 6);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
if (hotpValue.equals(passwordHotp)) {
Intent intent = new Intent(ScanQrCodeActivity.this, Stage3Activity.class);
intent.putExtra(EXTRA_MESSAGE, hotpValue);
startActivityForResult(intent, REQUEST_CODE);
} else {
showAlterDialog("Błędny QR Kod", "Podany Kod jest nieprawidłowy");
}
Stage3Activity.class
public class Stage3Activity extends AppCompatActivity {
private String hotpValueString;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stage3);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_restart);
hotpValueString = getIntent().getStringExtra("hotpValume");
Typeface custom_fonts = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Regular.ttf");
Typeface custom_fonts2 = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Bold.ttf");
TextView title_activity = (TextView) findViewById(R.id.stage3TileActivity);
title_activity.setTypeface(custom_fonts);
TextView stageOneText = (TextView) findViewById(R.id.stageOneText);
stageOneText.setTypeface(custom_fonts);
TextView stageTwoText = (TextView) findViewById(R.id.stageTwoText);
stageTwoText.setTypeface(custom_fonts);
TextView stageThreeText = (TextView) findViewById(R.id.stageThreeText);
stageThreeText.setTypeface(custom_fonts);
TextView messageView = (TextView) findViewById(R.id.QuestionTextView);
messageView.setTypeface(custom_fonts);
TextView valueHotp = (TextView) findViewById(R.id.valueHotpTextView);
valueHotp.setTypeface(custom_fonts2);
valueHotp.setText(hotpValueString);
TextView yesButton = (TextView) findViewById(R.id.yesButton);
yesButton.setTypeface(custom_fonts);
yesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Stage3Activity.this, MainActivity.class);
startActivity(intent);
}
});
}
MainActivity.class
public class MainActivity extends AppCompatActivity {
public List<Card> cardList = new ArrayList<>();
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
}
private RecyclerView cardRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Typeface custom_fonts = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Regular.ttf");
cardRecyclerView = (RecyclerView) findViewById(R.id.cardViewRecycleView);
mLayoutManager = new LinearLayoutManager(this);
cardRecyclerView.setLayoutManager(mLayoutManager);
// title application
TextView title_app = (TextView) findViewById(R.id.toolbar_title);
title_app.setTypeface(custom_fonts);
}
class Class
public class Card {
private String nameCard;
private String dateCard;
private String dateExpiration;
public Card(String nameCard, String dateCard, String dateExpiration) {
this.nameCard = nameCard;
this.dateCard = dateCard;
this.dateExpiration = dateExpiration;
}
public String getNameCard() {
return nameCard;
}
public void setNameCard(String nameCard) {
this.nameCard = nameCard;
}
public String getDateCard() {
return dateCard;
}
public void setDateCard(String dateCard) {
this.dateCard = dateCard;
}
public String getDateExpiration() {
return dateExpiration;
}
public void setDateExpiration(String dateExpiration) {
this.dateExpiration = dateExpiration;
}
}
CardAdapter.class
public class CardAdapter extends RecyclerView.Adapter<CardAdapter.CardViewHolder> {
private List<Card> cardsList = new ArrayList<>();
private Card card;
public CardAdapter( List<Card> cardsList) {
this.cardsList = cardsList;
}
//dodaj obiekt do listy
private void addItem(int position, Card card) {
cardsList.add(position, card);
notifyItemChanged(position);
}
public class CardViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public CardView cardview;
public TextView nameCard, dateText, setDateText, dateExpirationText, setDateExpirationText;
public ImageView mImageButton;
Typeface custom_fonts = Typeface.createFromAsset(itemView.getContext().getAssets(), "fonts/OpenSans-Regular.ttf");
public CardViewHolder(View itemView) {
super(itemView);
// name Card
nameCard = (TextView) itemView.findViewById(R.id.nameCard);
nameCard.setTypeface(custom_fonts);
//data add Card
setDateText = (TextView) itemView.findViewById(R.id.setDateText);
setDateText.setTypeface(custom_fonts);
dateText = (TextView) itemView.findViewById(R.id.dateText);
dateText.setTypeface(custom_fonts);
mImageButton = (ImageView) itemView.findViewById(R.id.garbageDelete);
//data expiration date
dateExpirationText = (TextView) itemView.findViewById(R.id.dateExpiration);
dateExpirationText.setTypeface(custom_fonts);
//
setDateExpirationText = (TextView) itemView.findViewById(R.id.setDateExpirationText);
setDateExpirationText.setTypeface(custom_fonts);
cardview = (CardView) itemView.findViewById(R.id.cardView);
cardview.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Context context = itemView.getContext();
Intent intent = new Intent(context, CardDetailsActivity.class);
context.startActivity(intent);
}
}
@Override
public CardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.
from(parent.getContext()).
inflate(R.layout.item_cardview, parent, false);
return new CardViewHolder(itemView);
}
@Override
public void onBindViewHolder(final CardViewHolder holder, final int position) {
Card Card = cardsList.get(position);
holder.nameCard.setText(Card.getNameCard());
holder.dateText.setText(R.string.data_dodania);
holder.setDateText.setText(Card.getDateCard());
holder.mImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showPopupMenu(holder.mImageButton, position);
}
});
}