mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Get rid of the code change listener to fix the serializability of KeyProfile
This commit is contained in:
parent
6e68d79816
commit
6672c18399
3 changed files with 7 additions and 19 deletions
|
@ -13,7 +13,6 @@ import me.impy.aegis.helpers.TextDrawableHelper;
|
||||||
public class KeyProfile implements Serializable {
|
public class KeyProfile implements Serializable {
|
||||||
private String _code;
|
private String _code;
|
||||||
private DatabaseEntry _entry;
|
private DatabaseEntry _entry;
|
||||||
private Listener _listener;
|
|
||||||
|
|
||||||
public KeyProfile() {
|
public KeyProfile() {
|
||||||
this(new DatabaseEntry());
|
this(new DatabaseEntry());
|
||||||
|
@ -23,10 +22,6 @@ public class KeyProfile implements Serializable {
|
||||||
_entry = entry;
|
_entry = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListener(Listener listener) {
|
|
||||||
_listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatabaseEntry getEntry() {
|
public DatabaseEntry getEntry() {
|
||||||
return _entry;
|
return _entry;
|
||||||
}
|
}
|
||||||
|
@ -40,17 +35,10 @@ public class KeyProfile implements Serializable {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new UndeclaredThrowableException(e);
|
throw new UndeclaredThrowableException(e);
|
||||||
}
|
}
|
||||||
if (_listener != null) {
|
|
||||||
_listener.onRefreshCode(_code);
|
|
||||||
}
|
|
||||||
return _code;
|
return _code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextDrawable getDrawable() {
|
public TextDrawable getDrawable() {
|
||||||
return TextDrawableHelper.generate(getEntry().getName());
|
return TextDrawableHelper.generate(getEntry().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Listener {
|
|
||||||
void onRefreshCode(String code);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileHolder> im
|
||||||
for (KeyProfile profile : _keyProfiles) {
|
for (KeyProfile profile : _keyProfiles) {
|
||||||
profile.refreshCode();
|
profile.refreshCode();
|
||||||
}
|
}
|
||||||
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyProfile getKeyByID(long id) {
|
private KeyProfile getKeyByID(long id) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
|
|
||||||
public class KeyProfileHolder extends RecyclerView.ViewHolder implements KeyProfile.Listener {
|
public class KeyProfileHolder extends RecyclerView.ViewHolder {
|
||||||
private TextView _profileName;
|
private TextView _profileName;
|
||||||
private TextView _profileCode;
|
private TextView _profileCode;
|
||||||
private TextView _profileIssuer;
|
private TextView _profileIssuer;
|
||||||
|
@ -34,14 +34,12 @@ public class KeyProfileHolder extends RecyclerView.ViewHolder implements KeyProf
|
||||||
|
|
||||||
public void setData(KeyProfile profile, boolean showIssuer) {
|
public void setData(KeyProfile profile, boolean showIssuer) {
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
_profile.setListener(null);
|
|
||||||
_profile = null;
|
_profile = null;
|
||||||
_running = false;
|
_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_profile = profile;
|
_profile = profile;
|
||||||
|
|
||||||
profile.setListener(this);
|
|
||||||
_profileName.setText(profile.getEntry().getName());
|
_profileName.setText(profile.getEntry().getName());
|
||||||
_profileCode.setText(profile.getCode());
|
_profileCode.setText(profile.getCode());
|
||||||
_profileIssuer.setText("");
|
_profileIssuer.setText("");
|
||||||
|
@ -59,20 +57,21 @@ public class KeyProfileHolder extends RecyclerView.ViewHolder implements KeyProf
|
||||||
}
|
}
|
||||||
_running = true;
|
_running = true;
|
||||||
|
|
||||||
_profile.refreshCode();
|
refreshCode();
|
||||||
_uiHandler.postDelayed(new Runnable() {
|
_uiHandler.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (_running) {
|
if (_running) {
|
||||||
_profile.refreshCode();
|
refreshCode();
|
||||||
_uiHandler.postDelayed(this, _profile.getEntry().getInfo().getMillisTillNextRotation());
|
_uiHandler.postDelayed(this, _profile.getEntry().getInfo().getMillisTillNextRotation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, _profile.getEntry().getInfo().getMillisTillNextRotation());
|
}, _profile.getEntry().getInfo().getMillisTillNextRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void refreshCode() {
|
||||||
public void onRefreshCode(String otp) {
|
String otp = _profile.refreshCode();
|
||||||
|
|
||||||
// reset the progress bar
|
// reset the progress bar
|
||||||
int maxProgress = _progressBar.getMax();
|
int maxProgress = _progressBar.getMax();
|
||||||
_progressBar.setProgress(maxProgress);
|
_progressBar.setProgress(maxProgress);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue