Access with a spinner to a list created in Realm in Android Studio (Java)

I tell you: I have a form with realm through which I can register items. Well, now I would like to be able to access this list of registered items for me to show them in a spinner, but I have no idea how I could do it. Let's see if you can help me out.

Edit:

I have managed to access the list with the following code:

                package com.isaac.appet;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.isaac.appet.HomeFragment.HomeFragment;
import com.isaac.appet.HomeFragment.Pets;

import java.util.List;

import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmResults;

public class AlarmsFormActivity extends AppCompatActivity {

    Spinner spPetLst;

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity_alarms_form);

        spPetLst = findViewById (R.id.spPetLst);

        Realm realm = Realm.getDefaultInstance ();
        RealmResults realmResults = realm.where (Pets.class) .findAll ();
        List documents = realm.copyFromRealm (realmResults);
        ArrayAdapter adapter = new ArrayAdapter <> (this, android.R.layout.simple_list_item_1, documents);
        spPetLst.setAdapter (adapter);


    }
}

But it shows me the name of the package, with number and such, and I want you to show me only the name of the element that I assigned in that field. How can I do this?

Thank you.

A greeting.

java – How do you properly configure elasticsearch 7.1.1 with spring boot 2.15?

I am using Elasticsearch 7.1.1 with spring-boot 2.1.5. I downloaded Elasticsearch and executed it. When I start the spring project I receive an error. He isError loading Elasticsearch nodes: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes is available: [{#transport#-1}{rsi4dYt_RuOBGCdwUH3Cgg}{127.0.0.1}{127.0.0.1:9200}]"How can I function properly?

I used these configurations.

spring.elasticsearch.jest.multi-threaded = true
spring.main.allow-bean-definition-overriding = true
spring.data.elasticsearch.cluster-nodes = localhost: 9200
spring.data.elasticsearch.repositories.enabled = true
spring.elasticsearch.jest.uris = http: // localhost: 9200
spring.elasticsearch.jest.connection-timeout = 3s
spring.elasticsearch.rest.uris = http: // localhost: 9200
spring.data.elasticsearch.cluster-name = elasticsearch

Y

@Configuration
@EnableElasticsearchRepositories (basePackages =
"com.example.elasticsearch.repository")
public class ElasticSearchConfiguration {
@Bean
public client client () launches UnknownHostException {
Configuration settings = Settings.builder ()
.put ("client.transport.sniff", true)
.put ("cluster.name", "elasticsearch"). build ();
@SuppressWarnings ("resource")
TransportClient Client = new PreBuiltTransportClient (configuration)
.addTransportAddress (new
TransportAddress (InetAddress.getByName ("127.0.0.1"), 9200));

return client
}

@Bean
Public ElasticsearchOperations elasticsearchTemplate () throws
UnknownHostException {
returns the new ElasticsearchTemplate (client ());
}
}

java – Why is the marker placed in the wrong coordinates?

I want to make a program that puts a marker where the phone is. In the case, I put the latitude and longitude of a city in Greenland, but the value of the final location is (37.42342342342342, -122.08395287867832), the coordinates of the Google places. What do I need to put in my program?

@ Override
public void onMapReady (GoogleMap googleMap) {

mMap = googleMap;
manager = (LocationManager) getSystemService (Service.LOCATION_SERVICE);
String test = manager.getBestProvider (criteria, false);
Log.i ("test", "" + test);
provider = LocationServices.getFusedLocationProviderClient (this); // Necessary to start the provider

@SuppressLint ("MissingPermission") Task task = provider.getLastLocation ();
task.addOnSuccessListener (this, new OnSuccessListener() {} ()
@ Override
public void onSuccess (Location location) {
if (location! = null) {}

length = location.getLongitude ();
latitude = location.getLatitude ();
Log.i ("test", "pos" + latitude + "" + length);
LatLng sydney = new LatLng (latitude, longitude);
("Marker in Sydney").) (.).
mMap.moveCamera (CameraUpdateFactory.newLatLng (Sydney));
}} else {// Apparently, the location is not null
Toast.makeText (getApplicationContext (), "ERROR!", Toast.LENGTH_LONG) .show ();
}
}
});

java – Make a modified MySQL DB on different computers at the same time – APPLY FOR HELP

I need your help. I created a Java application in netbeans that records some data in a MySQL database. The program works well and correctly, but the problem is:

If I put the application on another computer and execute it on these 2 different computers, the first one can register and modify the data in a database, the second one seems to be in ONLY-READ mode. You can only read and refer to tables. extracting data from DB but all the buttons that allow you to add data in the same table in the same database do not work. Can you help me understand how I can make databases and tables editable on different machines at the same time?

The first computer also works as a server, and the second connects to db using the IP address of the first host. Obviously, the first computer must be on.

TY.
Carlo b.

How to load Parse-server images that are stored as a file and display them in custom ListView in Android-Studio using Java?

I need help to load the stored images as a file in the analysis server and display them in listView

I have some images stored in an analysis server as a file, I find them using the analysis query along with the name (String) and I show them in a custom list view, the names are displayed correctly in the list but the images are shuffled . Probably because the images that are loaded first obtain the lowest index.

Custom list Adapter:

com.xyz.abcd package;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;


The public class ListAdapter extends BaseAdapter {

Contextual context;
Private final string [] values;
Private final bitmap[] images;

Public ListAdapter (context context, string [] values, bitmap [] images) {
// super (context, R.layout.single_list_app_item, utilsArrayList);
this.context = context;
this.values ​​= values;
this.images = images;
}

@Cancel
public int getCount () {
return.length values;
}

@Cancel
public object getItem (int i) {
return i;
}

@Cancel
public long getItemId (int i) {
return i;
}

@NonNull
@Cancel
public View getView (int position, @Nullable View convertView, @NonNull ViewGroup parent) {


ViewHolder viewHolder;

Final result of the view;

if (convertView == null) {

viewHolder = new ViewHolder ();
LayoutInflater inflater = LayoutInflater.from (context);
convertView = inflater.inflate (R.layout.custom_list, parent, false);
viewHolder.txtName = (TextView) convertView.findViewById (R.id.aNametxt);
viewHolder.icon = (ImageView) convertView.findViewById (R.id.appIconIV);

result = convertView;

convertView.setTag (viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag ();
result = convertView;
}

viewHolder.txtName.setText (values[position]);
try {
viewHolder.icon.setImageBitmap (images[position]);
} catch (exception e) {
e.printStackTrace ();
}

return convertView;
}

private static class ViewHolder {

TextView txtName;
ImageView icon;

}

}


This is the query:

ParseQuery query = new ParseQuery ("userData");
query.whereContains ("Name", queryValues[0]);
query.whereEqualTo ("Gender", queryValues[1]);
query.whereContains ("Hair", queryValues[2]);
query.whereContains ("Eyes", queryValues[3]);
query.whereContains ("Height", queryValues[4]);
query.whereNotEqualTo ("Username", ParseUser.getCurrentUser (). getUsername ());
query.addAscendingOrder ("Name");

query.findInBackground (new FindCallback () {
@Cancel
public vacuum made (list list, exception of ParseException e) {

}

@Cancel
public vacuum made (Object o, Tirable tirable) {
yes (arrojable == null) {

List  list = (List) or;

for (ParseObject object: list) {
username.add (object.getString ("Username"));
name.add (object.getString ("Name"));
age.add (object.getInt ("Age"));
facebook.add (object.getString ("Facebook"));
instagram.add (object.getString ("Instagram"));
snapchat.add (object.getString ("Snapchat"));
whatsapp.add (object.getString ("Whatsapp"));
heat.add (object.getInt ("Heat"));
sem.add (object.getString ("Sem"));
likes.add (object.getInt ("I like it"));

File ParseFile = object.getParseFile ("ProfilePicture");
file.getDataInBackground (new GetDataCallback () {
@Cancel
public vacuum made (byte[] bytes, ParseException e) {
if (e == null && bytes! = null) {
Bitmap bitmap = BitmapFactory.decodeByteArray (bytes, 0, bytes.length); // the image is downloaded here
images.add (bitmap); // added to arrayList

Rope[] NAMES = new chain[name.size()];
NAMES = name. Array (NAMES);

Bitmap[] IMAGES = new bitmap[images.size()];
IMAGES = images.toArray (IMAGES); // ArrayList is converted to a bitmap array

lAdapter = new ListAdapter (searchResults.this, NAMES, IMAGES); // the array of names and images is passed to the adapter as arrays

ResultsList.setAdapter (lAdapter); // the adapter is configured

myInstance.dismiss (); // Load bar dismisses

}plus{
Log.i ("Error", e.toString ());
}
}
});

}


}plus{
Toast.makeText (searchResults.this, "Check connection", Toast.LENGTH_SHORT) .show ();
myInstance.dismiss ();
}
}
});

How do I get the list to display correctly in order with the images in those positions?

How do I implement Java animations correctly?

This is what I have until now.

// Inside the animations class
public vacuum update () {
timer + = System.currentTimeMillis () - lastTime;
lastTime = System.currentTimeMillis ();

yes (timer> speed) {
Playing = true;
index ++;

timer = 0;
if (index> = frames.length) {
index = 0;
Playing = false;
}
}

} // Getters and setters down

In the main state

                @Cancel
public vacuum update () {
Ability.update ();
if (AttackP.isPlaying ()) {
AttackP.update ();

}

// get
Health check ();
getMousePosition ();
}

                if (turn == true) {// Only run when it's the players' turn
if (MousePressed &&! AttackP.isPlaying () &&! AttackingP) {
// if left clicking when animations are not playing and when AttackingP is false
buttonCheck (g); // following
} else if (! MousePressed) {// set Fake Attack when the mouse is not pressed
AttackingP = false;
}

Private verification button (Graphics g) {
yes (mousex<501&&MouseX>420 && MouseY<531&&MouseY>500) {// if the mouse is in this button

AttackingP = true;
StartAnimation (g);

}

                Empty private StartAnimation (Graphics g) {

g.drawImage (getCurrentAnimationFrame (), 175,0,512 / 2,512 / 2, null); // play animation
BossHealth- = 5;
turn = false;

}

public BufferedImage getCurrentAnimationFrame () {
returns AttackP.getCurrentFrame ();
}

The problem is that when I press the button, the animation only shows 1 frame, not the others in the Buffer Image matrix.

Help appreciated, I've been stuck in this part for 2 days now.

java – Minimizing the path of a file

I have a simple program that "minimizes" a file path. Minimize simply means replacing unnecessary file entries with entries that mean the same thing:

  • route1 / route2 /../ route3 is replaced by route1 / route3
  • route1 /./ route2 is replaced by route1 / route2

I achieved this using regular expressions and it seems to cover all cases, but it also feels very slow and I have a hunch that I might be prone to infinite loops:

final static private pattern ONE_DOT = Pattern.compile ("/\./");
static final private pattern TWO_DOTS = Pattern.compile ("[^/]+ / \ \ ./? ");

Public static chain minimize (Final chain in) {
String tmp = en;
while (! stringIsMinimized (tmp)) {
tmp = ONE_DOT.matcher (tmp) .replaceAll ("/");
tmp = TWO_DOTS.matcher (tmp) .replaceAll ("");
}
returns tmp;
}

public Boolean static stringIsMinimized (final string chain) {
return! (ONE_DOT.matcher (str) .find () || TWO_DOTS.matcher (str) .find ());
}

java – Return JSON Object of an API

I have an error when trying to return a json object resulting from previously entered data, follow the code:

try {
JsonObject json = new JsonObject ();

ArrayList params = new ArrayList ();
params.add (idProfissional);
params.add (idOoccupacao);

dbSpeciality db = new dbSpeciality (sqlHelper);
ResultSet rsSpecialty = db.getProfissionalUnity (params);

if (rsSpeciality! = null) {
while (rsEspecialidad.next ()) {

json.addProperty ("IdUnity", rsEspecialidad.getInt ("IdUnidad"));
json.addProperty ("name", rsSpeciality.getString ("unit"));
json.addProperty ("Endereco", rsEspecialidad.getString ("Endereco"));
json.addProperty ("Working Timetable", rsSpeciality.getString ("Working Timetable"));

}
} Else {

json.addProperty ("success", Boolean.FALSE);
json.addProperty ("msg", "No record found.");

}

return json.toString ();

} catch (Exception e) {
(in the event that this is not the case).
}

the return comes as follows:


        

HTTP Status 401 - Authorization Token not sent.

kind Report status

message Authorization token not sent.

description This request requires HTTP authentication.


Apache Tomcat / 8.0.15

Note: I do not have any authentication currently, it is in production phase.

java – LibGDX – scenario, camera, viewport, batch (spritebatch), projectionmatrix, tiledmap, what is the connection between these concepts

Currently my game has

3 stages:

-A stage

stage -entity

stage

2 cameras:

-hudcamera (for ui)

-mapcamera (for map)

2 lots:

-spritebatch to render particles

-batch of the tiledmaprenderer (used in map and entitystage)

3 views:

-for entity on stage

-for stage ui

-for the tile map stage

I am very confused at this point about how all these components are connected. All my game works, except when I resize the main menu screen, the particles on my next screen are drawn in the wrong position. Which means that the size change information does not reach the particle box.

I feel that the reason why I have many problems to debug it is because I do not understand how they relate to each other.
Can anyone help me clarify this structure?

java – Android problem with loopback background

I'm doing some kind of clone for FlappyBird, but with some adjustments.

I'm trying to have an animated background running endless times. I already have the image reflected so that the flow is as clear as possible. The problem is that the game itself (my GameView class) has no XML design, so I can not use the usual way with the following code:

                                ImageView bg1 = findViewById (R.id.bg1);
ImageView bg2 = findViewById (R.id.bg2);

ValueAnimator animator = ValueAnimator.ofFloat (0.0f, 1.0f);
animator.setRepeatCount (ValueAnimator.INFINITE);
animator.setInterpolator (new LinearInterpolator ());
animator.setDuration (10000L);
animator.addUpdateListener (new ValueAnimator.AnimatorUpdateListener () {
@Cancel
public void onAnimationUpdate (animation ValueAnimator) {
final float prog = (float) animation.getAnimatedValue ();
final float wid = bg1.getWidth ();
final floating translation X = wid * prog;
bg1.setTranslationX (translationX);
bg2.setTranslationX (translationX-wid);
}
});
animator.start ();

Is there any way to change ImageView to Bitmap (could not find an alternative to ImageView's setTranslationX)?
If not, is it possible to relate the class to a certain XML design without using setContentView () (my class does not retransmit or change any XML design)?

Thanks in advance!