How to request data from the user and write to firebase?

1

I'm starting in the development of android apps, and I'm having a doubt, I'm creating an app like tinder, where I have two types of users, the client and the advertiser, both will login through facebook, After this login I wanted the user to select his profile type (client or advertiser) and save this information along with the profile data of his facebook, but I have a hard time understanding how to do this and save this data in firebase (ja is authenticating) so that another user sees it in the list ... '

Following code for 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);

    }
} 
    
asked by anonymous 13.07.2017 / 20:43

0 answers