Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 60 additions & 1 deletion app/src/main/java/com/example/langlearn/MessageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,71 @@
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MessageActivity extends AppCompatActivity {
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

public class MessageActivity extends AppCompatActivity {
EditText text;
Button send;
Button retrieve;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
int userCount = 1;
String[] Users = new String[userCount];
text = findViewById(R.id.editTextTextMultiLine);
send = findViewById(R.id.sendButton);
retrieve = findViewById(R.id.buttonRetrieve);
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
text = findViewById(R.id.editTextTextMultiLine);
TextView textView = findViewById(R.id.textView2);
ParseObject firstObject = new ParseObject("FirstClass");
firstObject.put("Message", text.getText().toString());
firstObject.saveInBackground(e -> {
if (e != null) {
textView.setText(String.format("Fail to add data..." + e.getLocalizedMessage(), firstObject.get("Message")));
}
else {
textView.setText(String.format("Data saved is: \n %s", firstObject.get("Message")));
}
});
}
});
retrieve.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getMessage();
}
});
}

void getMessage(){
ParseQuery<ParseObject> query = ParseQuery.getQuery("FirstClass");
query.whereEqualTo("objectId", "Uv2xUdlOdi");
query.getFirstInBackground(new GetCallback<ParseObject>() {
public void done(ParseObject message, ParseException e) {
if (e == null) {
String Message = message.getString("Message");
Log.e("GFSDGSFDGFDSGFSD", "done: " + Message );
} else {
// Something is wrong
}
}
});
}



}
34 changes: 27 additions & 7 deletions app/src/main/res/layout/activity_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,34 @@
android:text="Send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.461"
app:layout_constraintHorizontal_bias="0.78"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextMultiLine"
app:layout_constraintVertical_bias="0.719" />
app:layout_constraintVertical_bias="0.403" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.022" />

<Button
android:id="@+id/buttonRetrieve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:text="debug"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/sendButton"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextMultiLine"
app:layout_constraintVertical_bias="0.0" />


<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="149dp"
tools:layout_editor_absoluteY="85dp" />
</androidx.constraintlayout.widget.ConstraintLayout>