Classe TipoSenhaActivity
package br.com.inforsoftcom.securitypassword;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class TipoSenhaActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tipo_senha);
//Botão tipo Email
Button botaoEmail = (Button) findViewById(R.id.Tipo_E_mail);
assert botaoEmail != null;
botaoEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, pswgenericoActivity.class);
//Envirando URL pela intent vaiProTipoSenha
String url_txt = "@mipmap/tipo_email";
Bundle bundle = new Bundle();
bundle.putString("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
//Botão tipo Computador
Button botaoComputador = (Button) findViewById(R.id.Tipo_PC);
assert botaoComputador != null;
botaoComputador.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, pswgenericoActivity.class);
//Envirando URL pela intent vaiProTipoSenha
String url_txt = "@mipmap/tipo_pc";
Bundle bundle = new Bundle();
bundle.putString("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
//Botão tipo servidor
Button botaoServidor = (Button) findViewById(R.id.Tipo_Servidor);
assert botaoServidor != null;
botaoServidor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, FormularioActivity.class);
//Envirando URL pela intent vaiProTipoSenha
String url_txt = "@mipmap/tipo_servidor";
Bundle bundle = new Bundle();
bundle.putString("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
//Botão tipo Jogo
Button botaoJogo = (Button) findViewById(R.id.Tipo_Jogo);
assert botaoJogo != null;
botaoJogo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, pswgenericoActivity.class);
//Envirando URL pela intent vaiProTipoSenha
String url_txt = "@mipmap/tipo_jogo";
Bundle bundle = new Bundle();
bundle.putString("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
//Botão tipo Pasta
Button botaoPasta = (Button) findViewById(R.id.Tipo_Pasta);
assert botaoPasta != null;
botaoPasta.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, pswgenericoActivity.class);
//Envirando URL pela intent vaiProTipoSenha
String url_txt = "@mipmap/tipo_pasta";
Bundle bundle = new Bundle();
bundle.putString("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
//Botão tipo Sistema
Button botaoSistema = (Button) findViewById(R.id.Tipo_Sistema);
assert botaoSistema != null;
botaoSistema.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, pswgenericoActivity.class);
//Envirando URL pela intent vaiProTipoSenha
String url_txt = "@mipmap/tipo_sistema";
Bundle bundle = new Bundle();
bundle.putString("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
//Botão tipo Rede Socias
Button botaoRedeSociais = (Button) findViewById(R.id.Tipo_Redes_socias);
assert botaoRedeSociais != null;
botaoRedeSociais.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, pswgenericoActivity.class);
//Envirando URL pela intent vaiProTipoSenha
String url_txt = "@mipmap/tipo_redes_sociais";
Bundle bundle = new Bundle();
bundle.putString("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
//Botão tipo Outros
Button botaoOutros = (Button) findViewById(R.id.Tipo_Outros);
assert botaoOutros != null;
botaoOutros.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent vaiProTipoSenha = new Intent(TipoSenhaActivity.this, pswgenericoActivity.class);
//Envirando URL pela intent vaiProTipoSenha
int url_txt = R.mipmap.tipo_jogo;
Bundle bundle = new Bundle();
bundle.putInt("url_txt", url_txt);
vaiProTipoSenha.putExtras(bundle);
startActivity(vaiProTipoSenha);
}
});
}
}
Classe FormularioActivity
package br.com.inforsoftcom.securitypassword;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import br.com.inforsoftcom.securitypassword.DAO.SecurityDAO;
import br.com.inforsoftcom.securitypassword.password.Password;
public class FormularioActivity extends AppCompatActivity {
//private SectionsPagerAdapter mSectionsPagerAdapter;
private FormularioHelp pegaDadosFormulario;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_formulario);
pegaDadosFormulario = new FormularioHelp(this);
Intent intent = getIntent();
Password password = (Password) intent.getSerializableExtra("password");
if (password != null) {
pegaDadosFormulario.Preencheformulariopsw(password);
}
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
//Botão Salvar do Formulario
Button botaoSalvar = (Button) findViewById(R.id.formulario_salva);
assert botaoSalvar != null;
botaoSalvar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(v.getId() == R.id.formulario_salva){
ConfirmaSenha();
}
}
});
}
private void ConfirmaSenha() {
EditText servidor = (EditText) findViewById(R.id.formulario_servidor);
EditText ip = (EditText) findViewById(R.id.formulario_IP);
EditText login = (EditText) findViewById(R.id.formulario_Login);
EditText senha = (EditText) findViewById(R.id.formulario_Senha);
EditText senha_conf = (EditText) findViewById(R.id.formulario_Senha_conf);
EditText loginRoot = (EditText) findViewById(R.id.formulario_Login_root);
EditText senhaRoot = (EditText) findViewById(R.id.formulario_Senha_root);
EditText senhaRootConf = (EditText) findViewById(R.id.formulario_Senha_root_conf);
EditText url_caminho = (EditText) findViewById(R.id.psw_url);
String serviorstr = servidor.getText().toString();
String ipstr = ip.getText().toString();
String loginstr = login.getText().toString();
String senhastr = senha.getText().toString();
String senha_confstr = senha_conf.getText().toString();
String loginRootstr = loginRoot.getText().toString();
String senhaRootstr = senhaRoot.getText().toString();
String senhaRoot_confstr = senhaRootConf.getText().toString();
int url_caminhostr = url_caminho.getId();
if(senhastr.equals(senha_confstr) && senhaRootstr.equals(senhaRoot_confstr)){
//insert nova senha
Password p = new Password();
p.setNome(serviorstr);
p.setIp(ipstr);
p.setLogin(loginstr);
p.setSenha(senhastr);
p.setLoginRoot(loginRootstr);
p.setSenhaRoot(senhaRootstr);
p.setUrl_caminho(url_caminhostr);
inserePassword();
Toast toast = Toast.makeText(FormularioActivity.this, "Senhas " + p.getNome() + " salva com sucesso!", Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 200);
toast.show();
}else{
Toast toast = Toast.makeText(FormularioActivity.this, "Senhas não correspondem!", Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 200);
toast.show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_formulario, menu);
return true;
}
//Botão salvar no canto superior na Action_Bar
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_formulario_ok:
ConfirmaSenha();
}
return super.onOptionsItemSelected(item);
}
//Metodo responsavel por inserir novo registro de password
private void inserePassword() {
//Instancia Password
Password password = pegaDadosFormulario.pegaPassword();
// Aqui instancia o DAO e insere o novo password no banco
SecurityDAO dao = new SecurityDAO(this);
if (password.getId() == 0) {
dao.insere(password);
} else {
dao.altera(password);
Toast toast = Toast.makeText(FormularioActivity.this, "Alteraçõe em " + password.getNome() + " Salva com Sucesso", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 200);
toast.show();
}
Intent vaiProTipoSenha = new Intent(FormularioActivity.this, HomeActivity.class);
startActivity(vaiProTipoSenha);
dao.close();
finish();
}
}
Classe SafeAdpter
package br.com.inforsoftcom.securitypassword.adpter;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import br.com.inforsoftcom.securitypassword.R;
import br.com.inforsoftcom.securitypassword.password.Password;
/**
* Created by TI on 16/07/2016.
*/
public class SafeAdpter extends BaseAdapter {
private final List<Password> passwords;
private final Context context;
public SafeAdpter(Context context, List<Password> passwords) {
this.context = context;
this.passwords = passwords;
}
@Override
public int getCount() {
return passwords.size();
}
@Override
public Object getItem(int position) {
return passwords.get(position);
}
@Override
public long getItemId(int position) {
return passwords.get(position).getId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Password password = passwords.get(position);
View view = convertView;
LayoutInflater inflater = LayoutInflater.from(context);
if (convertView == null) {
view = inflater.inflate(R.layout.item_lista_home, parent, false);
}
TextView CampoNome = (TextView) view.findViewById(R.id.item_listanome);
CampoNome.setText(password.getNome());
TextView CampoUsuario = (TextView) view.findViewById(R.id.item_listaLogin);
CampoUsuario.setText(password.getLogin());
ImageView CampoImagem = (ImageView) view.findViewById(R.id.Imagem_lista_home);
int CaminhoDaFoto = password.getUrl_caminho();
if (CaminhoDaFoto > 0) {
//Esta e a linha 65 que reclama no erro.
CampoImagem.setImageResource(CaminhoDaFoto);
CampoImagem.setScaleType(ImageView.ScaleType.FIT_XY);
}
return view;
}
}
Classe Password
package br.com.inforsoftcom.securitypassword.password;
import java.io.Serializable;
/**
* Created by Wolney on 27/04/2016.
*/
public class Password implements Serializable{
//Pegando os dados digitados
private long id;
private String nome;
private String ip;
private String login;
private String senha;
private String loginRoot;
private String senhaRoot;
private int url_caminho;
public Password() {
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getLoginRoot() {
return loginRoot;
}
public void setLoginRoot(String loginRoot) {
this.loginRoot = loginRoot;
}
public String getSenhaRoot() {
return senhaRoot;
}
public void setSenhaRoot(String senhaRoot) {
this.senhaRoot = senhaRoot;
}
public int getUrl_caminho() { return url_caminho; }
public void setUrl_caminho(int url_caminho) {
this.url_caminho = url_caminho;
}
@Override
public String toString() {
return getId()+" - "+getNome();
}
}
Mensagem de erro completa
--------- beginning of crash
08-12 11:18:29.084 2947-2947/br.com.inforsoftcom.securitypassword E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.inforsoftcom.securitypassword, PID: 2947
android.content.res.Resources$NotFoundException: Resource "br.com.inforsoftcom.securitypassword:id/psw_url" (7f0c0083) is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=2 r=0x7f0c0083}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2602)
at android.content.res.Resources.loadDrawable(Resources.java:2540)
at android.content.res.Resources.getDrawable(Resources.java:806)
at android.support.v7.widget.ResourcesWrapper.getDrawable(ResourcesWrapper.java:133)
at android.content.Context.getDrawable(Context.java:458)
at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:201)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:66)
at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:71)
at br.com.inforsoftcom.securitypassword.adpter.SafeAdpter.getView(SafeAdpter.java:69)
at android.widget.AbsListView.obtainView(AbsListView.java:2346)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1280)
at android.widget.ListView.onMeasure(ListView.java:1188)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:668)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:735)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
at android.view.View.measure(View.java:18788)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
at android.view.View.measure(View.java:18788)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Ch