1
I’m starting in the development of android apps, and I’m having a doubt, I’m creating (le-se trying) an app like Tinder, where I have two types of users, the customer and the advertiser, both will log in through facebook, after this login I wanted the user to select his profile type (client or advertiser) and save this information along with his facebook profile data, however I’m having trouble understanding how to do this and save this data in firebase (already authenticating) for another user to see it in the list...`
Follows code of the Profile class
public class Perfil extends AppCompatActivity {
AccessToken accessToken;
String nome;
String genero;
String id;
String caminhoImagem;
ImageView imagemUsuario;
TextView textoNomeUsuario;
TextView sexoUsuario;
Switch switchCliente, switchAnunciante;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_perfil);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
imagemUsuario = (ImageView) findViewById(R.id.imagemPerfil);
textoNomeUsuario = (TextView) findViewById(R.id.nomePerfil);
sexoUsuario = (TextView) findViewById(R.id.sexoPerfil);
switchCliente = (Switch) findViewById(R.id.switchCliente);
switchCliente.setChecked(true);
switchCliente.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked) {
switchAnunciante.setChecked(false);
} else {
switchAnunciante.setChecked(true);
}
}
});
switchAnunciante = (Switch) findViewById(R.id.switchAnunciante);
switchAnunciante.setChecked(false);
switchAnunciante.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (isChecked) {
switchCliente.setChecked(false);
} else {
switchCliente.setChecked(true);
}
}
});
}
@Override
protected void onStart() {
super.onStart();
accessToken = AccessToken.getCurrentAccessToken();
if (accessToken == null) {
finish();
}
GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
try {
nome = object.getString("name");
genero = object.getString("gender");
id = object.getString("id");
textoNomeUsuario.setText(nome);
caminhoImagem = "https://graph.facebook.com/" + object.getString("id") + "/picture?type=large";
Glide.with(Perfil.this).load(caminhoImagem).into(imagemUsuario);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,gender");
request.setParameters(parameters);
request.executeAsync();
}
public void onClick(View view) {
if (switchCliente.isChecked()) {
goAnuncios();
}
if (switchAnunciante.isChecked()) {
goPagamento();
}
}
public void goPagamento() {
Intent pagamento = new Intent(this, Cadastro.class);
startActivity(pagamento);
}
public void goAnuncios() {
Intent anuncios = new Intent(this, MainActivity.class);
startActivity(anuncios);
}
}
You speak of Firebase, but I see no reference to Firebase in your code
– Rosário Pereira Fernandes