2019-12-29 00:10:44 +01:00
|
|
|
package com.example.lookifyv2;
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
2020-02-23 00:20:49 +01:00
|
|
|
import android.graphics.PorterDuff;
|
2019-12-29 00:10:44 +01:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Button;
|
2020-02-25 00:05:03 +01:00
|
|
|
import android.widget.TextView;
|
2019-12-29 00:10:44 +01:00
|
|
|
|
|
|
|
public class DecodeFail extends AppCompatActivity {
|
|
|
|
|
2020-02-25 00:05:03 +01:00
|
|
|
String status;
|
2019-12-29 00:10:44 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_decode_fail);
|
|
|
|
|
2020-06-20 00:58:53 +02:00
|
|
|
//Do strzałki powrotu w górnej części ekranu.
|
2020-02-25 00:05:03 +01:00
|
|
|
assert getSupportActionBar() != null;
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
2020-06-20 00:58:53 +02:00
|
|
|
//Pobieranie informacji o rodzaju błędu od Decode i wyświetlanie odpowiedniego komunikatu w zależności od tego rodzaju.
|
2020-02-25 00:05:03 +01:00
|
|
|
Bundle extras = getIntent().getExtras();
|
|
|
|
status = extras.getString("status");
|
|
|
|
showMessage(status);
|
|
|
|
|
2020-02-27 00:15:31 +01:00
|
|
|
Button button_tryagain = findViewById(R.id.try_again_button);
|
2020-02-23 00:20:49 +01:00
|
|
|
button_tryagain.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
2019-12-29 00:10:44 +01:00
|
|
|
button_tryagain.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
openScan();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-06-20 00:58:53 +02:00
|
|
|
private void openScan(){
|
2019-12-29 00:10:44 +01:00
|
|
|
Intent intent_Scan = new Intent(this, TakePhoto.class);
|
|
|
|
startActivity(intent_Scan);
|
|
|
|
finish();
|
|
|
|
}
|
2020-02-25 00:05:03 +01:00
|
|
|
|
2020-06-20 00:58:53 +02:00
|
|
|
private void showMessage(String status){
|
2020-02-25 00:05:03 +01:00
|
|
|
if(status.equals("notfound")){
|
|
|
|
TextView message = findViewById(R.id.text_notfound);
|
|
|
|
message.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
else if(status.equals("offline")){
|
|
|
|
TextView message = findViewById(R.id.text_offline);
|
|
|
|
message.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
TextView message = findViewById(R.id.text_notindatabase);
|
|
|
|
message.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-20 00:58:53 +02:00
|
|
|
//Kliknięcie strzałki powrotu kończy activity.
|
2020-02-25 00:05:03 +01:00
|
|
|
@Override
|
|
|
|
public boolean onSupportNavigateUp(){
|
|
|
|
finish();
|
|
|
|
return true;
|
|
|
|
}
|
2019-12-29 00:10:44 +01:00
|
|
|
}
|