RecyclerView отображает только одно поле из базы данных пожарного магазина - PullRequest
0 голосов
/ 21 марта 2020

У меня есть приложение, в котором пользователь может добавлять в базу данных FireStore пароли, которые зашифрованы. Затем, показанный ниже в «хранилище», я добавил свои классы для данных, Adapter и Fragment для вызова всего этого. Проблема, с которой я сталкиваюсь, заключается в том, что RecyclerView отображает только заголовок, повторенный 5 раз, а не 5 разных записей. Я задавал похожий вопрос около часа go, и имена в классе данных отличались от базы данных. Однако после их изменения RecyclerView по-прежнему отображает только заголовок. Было рекомендовано задать новый вопрос, так как это новая проблема.

Если у кого-то есть какие-либо предложения, поскольку я был озадачен этим часами

FireStoreDatabase

Данные

public class UpdatePassword {
    private String title;
    private String username;
    private String password;
    private String webAddress;
    private String note;

    public UpdatePassword(){

    }

    public UpdatePassword(String title, String username, String password, String webAddress, String note){
        this.title = title;
        this.username = username;
        this.password = password;
        this.webAddress = webAddress;
        this.note = note;
    }

    public String getTitle() {
        return title;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }
    public String getWebAddress() {
        return webAddress;
    }
    public String getNote() {
        return note;
    }


    public void setTitle(String title) {
        this.title = title;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setWebAddress(String webAddress) {
        this.webAddress = webAddress;
    }

    public void setNote(String note) {
        this.note = note;
    }


}

Адаптер


    ArrayList<UpdatePassword> updateMessageList = new ArrayList<UpdatePassword>();

    private Context context;
    public String TAG = "PasswordUpdateAdapter";

    public PasswordUpdateAdapter(ArrayList<UpdatePassword> data, Context context) {
        this.updateMessageList = data;
        this.context = context;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        cairoTextView textViewTitle;
        cairoTextView textViewUsername;
        cairoTextView textViewPassword;
        cairoTextView textViewWebAddress;
        cairoTextView textViewNote;


        public ViewHolder(View itemView) {
            super(itemView);
            this.textViewTitle = itemView.findViewById(R.id.title1);
            this.textViewUsername = itemView.findViewById(R.id.user1);
            this.textViewPassword = itemView.findViewById(R.id.password1);
            this.textViewWebAddress = itemView.findViewById(R.id.webAddress1);
            this.textViewNote = itemView.findViewById(R.id.Note1);

        }
    }

    @NonNull
    @Override
    public PasswordUpdateAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.password_update_item, parent, false);
        PasswordUpdateAdapter.ViewHolder viewHolder = new PasswordUpdateAdapter.ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull PasswordUpdateAdapter.ViewHolder holder, int position) {


        holder.textViewTitle.setText(updateMessageList.get(position).getTitle());
        holder.textViewUsername.setText(updateMessageList.get(position).getUsername());
        holder.textViewPassword.setText(updateMessageList.get(position).getPassword());
        holder.textViewWebAddress.setText(updateMessageList.get(position).getWebAddress());
        holder.textViewNote.setText(updateMessageList.get(position).getNote());
    }

    @Override
    public int getItemCount() {

        return updateMessageList.size();
    }

Главный фрагмент, где все называется, я только добавил свой loadpasswords Функция здесь, где все обрабатывается, если вам нужно увидеть остальную часть класса, я был бы рад добавить остальную часть класса. Раздел расшифровки - это еще один класс, который используется для расшифровки зашифрованных строк.

 public void loadPasswords() {
        userID = firebaseAuthenti.getCurrentUser().getUid();
        fDatasebase.collection("Users")
       .whereEqualTo("uid", userID)
        .get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
            @Override
            public void onComplete(@NonNull Task<QuerySnapshot> task) {
                if (task.isSuccessful()) {
                    for(QueryDocumentSnapshot document : task.getResult()) {
                        Log.d(TAG, document.getId() + " => " + document.getData());
                        // Log.d(TAG, "DocumentSnapshot data: " + document.getData());

                        String title = (document.getString("title"));
                        String user = (document.getString("username"));
                        String pass = (document.getString("password"));
                        String web = (document.getString("webAddress"));
                        String note = (document.getString("note"));
                        String decrypt11 = null;
                        String decrypt12 = null;
                        String decrypt13 = null;
                        String decrypt14 = null;
                        String decrypt15 = null;

                        try {
                            decrypt13 = EncryptDecrypt.decryptString(title, EncryptDecrypt.Password);
                        } catch (NoSuchAlgorithmException | InvalidKeySpecException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException e) {
                            e.printStackTrace();
                        }
                        try {
                            decrypt14 = EncryptDecrypt.decryptString(user, EncryptDecrypt.Password);
                        } catch (NoSuchAlgorithmException | InvalidKeySpecException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException | InvalidKeyException e) {
                            e.printStackTrace();
                        }
                        try {
                            decrypt15 = EncryptDecrypt.decryptString(pass, EncryptDecrypt.Password);
                        } catch (NoSuchAlgorithmException | InvalidKeySpecException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException e) {
                            e.printStackTrace();
                        }
                        try {
                            decrypt12 = EncryptDecrypt.decryptString(web, EncryptDecrypt.Password);
                        } catch (NoSuchAlgorithmException | InvalidKeySpecException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException e) {
                            e.printStackTrace();
                        }
                        try {
                            decrypt11 = EncryptDecrypt.decryptString(note, EncryptDecrypt.Password);
                        } catch (NoSuchAlgorithmException | InvalidKeySpecException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException e) {
                            e.printStackTrace();
                        }


                        UpdatePassword updatePassword = new UpdatePassword(

                                decrypt13,
                                decrypt14,
                                decrypt15,
                                decrypt12,
                                decrypt11
                        );


                       recyclerList.add(updatePassword);

                    }


                        Log.d(TAG, "onComplete: " + recyclerList.size());

                        PasswordUpdateAdapter adapter = null;

                        // init
                        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
                        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                        recyclerView.setLayoutManager(linearLayoutManager);

                        // show data
                        adapter = new PasswordUpdateAdapter(recyclerList, getContext());
                        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
                        recyclerView.setAdapter(adapter);
                        adapter.notifyDataSetChanged();


                } else {
                    Log.d(TAG, "No such document");
                }
            }

        });


    }
**Logcat**

I only added what was relevant, I can see im getting an Error where it says no adapter is attached so it skips layout, could that be the problem? 


D/ViewRootImpl@6e11b77[HomeScreen]: ViewPostImeInputStage processPointer 1

D/TextView: setTypeface with style : 0

E/RecyclerView: No adapter attached; skipping layout

D/ConnectivityManager: requestNetwork; CallingUid : 10206, CallingPid : 22972

W/DynamiteModule: Local module descriptor class for providerinstaller not found.

I/DynamiteModule: Considering local module providerinstaller:0 and remote module 

providerinstaller:0

W/ProviderInstaller: Failed to load providerinstaller module: No acceptable

module found. Local version is 0 and remote version is 0.

V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 286 native methods...
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
W/art: Before Android 4.1, method double java.util.concurrent.ThreadLocalRandom.internalNextDouble(double, double) would have incorrectly overridden the package-private method in java.util.Random
    Before Android 4.1, method int java.util.concurrent.ThreadLocalRandom.internalNextInt(int, int) would have incorrectly overridden the package-private method in java.util.Random
    Before Android 4.1, method long java.util.concurrent.ThreadLocalRandom.internalNextLong(long, long) would have incorrectly overridden the package-private method in java.util.Random
D/ConnectivityManager: requestNetwork; CallingUid : 10206, CallingPid : 22972
D/Constraints: 8Rd16JbVbBmMM3xBQAdp => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=yems/wB6G57oVSznKZOR9g32fiyn6miyDxdwIjt8lVKkTT/by86ySXCso8yhHuXvrA==
    , title=QX/qp+CbI6cWdH1gBq0PHRTK/kbivnN1jjin/1qAQ6d6aqvUU6FUxhyAqQ2Uul/LIg==
    , webAddress=l/Uq3aGcN8vavm255HCJDCtrbv+/XC8UXEHqqQe9Pb0bCrjJxKDJUYsFnxCZjLsW3Q==
    , username=L9IbR9sVwsOQgNsJHq7X1nsXbQS3JZBoGqbfyfNHZXuVZurujuj/abiFDzGsMgSqvw==
    , note=zD0j1sKb0qxoOZoABKCWpwHzWRR9W1BEIgFFBjYSu2Wi05k0YwsBfiBZK2xp5UcZaA==
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@6b456a9
    LhKx7jID2OHLkmmGv4D5 => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=rJGd5OQFs2M8y/uELrIyTipK+TwrX4A6IOogdH81f5Mx25kGavtjugTFVMVVLdOGwA==
    , title=3S3ierspO3xSps0+SKUrdmEzauhRcRsF+p20B2O2BxBAraPSytN4L/Ex6sgl0tmAAw==
    , webAddress=QAFGNyG0XjrhxKsFMt8qj11vwcweCfh6gyqbnLDI60zFyszFTa227OLOhh2aWxsBRg==
    , username=P5WNMyf0OxphF179Ylj34drwG7FCvavoR2BgfCMEFOG5qmNVj4Hp4WQxpt4sZM/DLA==
    , note=Z71/zA1DTUD7Hfm6kw1E2gbTupqO2qj158gXcNLLIputHUGASe+5ovDdQF5vn/HUAg==
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@ce6942e
    V34Ak6zOsTfXb08vGNIl => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=2NRoSJwESl9CeW9LtoVyBBIyPI1FK1r8i5t/Wuc67yRgrVks1YEcgRvt/QcsvIB732VAOECl
    , title=d6H19vyYTyZf7X0nVZyivEB31SHOXPjIxAPrlrqJhwoupfULXqPvZOw589i+Lu4hY8FJ+3ys
    , webAddress=uOCcrpbQ7gDT6BYc5F8UJlsVlgyxlTdksxNkmiXH6sc3TLHwo8gbGMJClaJoUlSafx9dQWAI
    , username=FFx5TsSM5mzYRLqGgR5XB+HNH0iRGBrYDod2tjYMOSqACJ0zAU+W7MvWPJdEWXzsnuGYDkGQ
    , note=+7qDYUs2uZlw3do7bQavtpCwSSMnJJGHVUCThPh2pWDgE8K59/K+xOe6AFG106kSBQ2Dfyhw
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@8e74bcf
    Ws2BeAB6FSOIF8gZYSd4 => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=mr0sYg3jLLHqf5bIhJM4Vi5sEqoRiz9kUrkxOA9AwUGgzik10Gg+XTk+gE7WywTEfw==
    , title=oNMXGRDzMOpRcJfNKxAv6g5zGexwo2Rv/cuf1jUwCD5EIXjJOTu7FfeWhqEeYRDoFA==
    , webAddress=LFbS+leT7zfPyDLd3rzdWYO1Wo+ezkAjYQGWYOh6BNUo2tIMpIjsmdPoeeBTvvtxDQ==
    , username=Y4f38c0isctGC1sfJqVdAvP93Z1Sl+HscnVgQ2sRamipquvycNrJqqaC4C2hKsncoQ==
    , note=hcEKWDPYP+zEOI6JWS7cwQagSoO5ymjIeXW7drjWvS78SNLSEGybXOGhh/FR4H5iVw==
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@4ae895c
    cCv81SFbEoUaCZDfBRla => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=2c9+o5srEx41TtMotjrtvu0o+6RAJbr7lf+8MgkrBYjujn/Dqix3Hil2zNeBcgIqPjs=
    , title=h5sVPZ9u98SUyRMDmcX0rmw3Q7ugtLD8ppjbl8fyfiD3pVoxbqtN4qwUon+kLgN/pZw=
    , webAddress=ymVIThYBbMJAHWb2xyzIvNRsBHMGDmzuGT4mxt1bLREU0yB5qLJwAlM5J2iBg99rkcU=
    , username=0BCzdm8LjvNODPwQBnJ2a3AU/rflRIOo660K2V42dGoBvK66f1I4Se2mKm4/nm0uC8w=
    , note=CKw7uGKHA0DfzvLXmP5JRQSdJUTELWEv1jYuONgLFiV6+2MCeXHXeG29bgbkpStTmiQ=
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@552b465
    dUIkamfzG5OYbkvr8dAl => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=KySEibZNHzAa0rCKsxohXTB73ehHUNtxzA6F+UNsKUxEA+STUgIjt9+eJ3zvRPLiqliFZKQ=
    , title=h6hjnTYrM+WhWMIZe14dO3lHhlg7H7X9oq4ABUiCn4fmirZHZfyXJLt2yMvPHWHnvDn43pM=
    , webAddress=GhqTp51+4OUxXnnd8bRd32XpTkdjlzDncR/rWtBBpHUj621pjRDmsHgPHFyciCq8alY7ztk=
    , username=6ENlVw2qk4OOFUzq/G2qYJ0pfn+yaZH45rS4HEJ5K1TKx6UroxSxHJbrDW4C5C7xOKw1k/0=
    , note=CXgH+AzJwvPu8iSebJQlIvuSo84d0CSvbwzo2rfQQOVfTV5WCzCaqIf2M0nripbe++bN0Vc=
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@24bc53a
D/Constraints: dXQYUloVoLbAZUCUj9IT => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=MlgOhU0VDjmQDOJSIrHqxCdsp4s0Rt59sbgC6WJZm888LhkBGA8llNoRRTAcqP5pGg==
    , title=deEt5uoVHtLAJIHobIOg6LnhdYNWF7tqKKBYYdqsjffLs1IaoPcP/MuTagJrSr6Jyg==
    , webAddress=Nu7/YC3CsFtCtBEzSX7Ikh3AhXKwaCvaw2EjRlMpusanRX6vQy6L73jy7FZlp2zspA==
    , username=DjOZkp4dbCMkc+C6VBXO9uuCtNfc+FmD4OJO+Fggr4XBjz+NAmodFU6HOkWsB0M1iw==
    , note=EDfRj0cq0ASI0bXHfi361fCpgxEYntLA0swD1pS6ENDeDdEjqHPGlRFTWUKfyQMBFQ==
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@536d5eb
    eMTlDjBbDs2XIMy67IS5 => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=7tTADKdSaOX+HEszCbNydeUn7PW9Y16Q/9zS4dAvDTbDCkapDx08dkq/ic3J0vAdnQ==
    , title=aEiMA+iCvwGMw2YyjuPcxTvoEfMtey7whMkUTWlCwxOqD18eHp1vu0Fl9I7fIJWXfQ==
    , webAddress=RpR+joJXJtCvfI8RJsh6nUdnjGbbiAKUXiNbACxy7g79CkoFVURLQgghhNWmscCgFw==
    , username=pOK13w8x5Tgwt3joFqANCwJEg8jUE/CJ/PvipAZ6Tynxe1T5P5nHvHq9gF3wtQwynw==
    , note=qj3VT6XlqqhFsHMKDbTc8jJx52DU1Z7CuffKz/odlhQ/2srEwoAnSYHAsfgfPe2J8A==
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@c48df48
D/Constraints: hNunE1McwtdrIgxgfjtg => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=7C1TI+ueHvWp1hh+fQ572fNw+GrfrX7diGkdLpvQRV+Q9VlU3LSz7QEQ2w1J+5tE5x0kJg==
    , title=w861/oWKEacA+vgjN6fDt5/Oj0UqaKslFttSc18subklNsXU8/q63D+YjDPi4HRFRc+Ohg==
    , webAddress=JjeW0BBlS3+gq5SmHV9vtI0QVEZCf3+9P+jN3RO3S/CstrwgX2oO8bMIZqd3ogv5KQvUlg==
    , username=Uj3QDBUUnAeVNeL+tkuq9U5ANO3Bv1rMBo/eYVG8IQ7ui66VqbFjte+gyF0TVQDQAdeSVg==
    , note=TBYZJ7PceMzTK9B0X0gVl02RxxXRbkmPT0dqvNJxg9ZcXxQ5TMC7PqAZdeUPFJOvNrcZYQ==
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@8bf31e1
D/Constraints: rB7NnVystQ1x94O5zi2z => {uid=cMxWK94jp5Rumuj7VvHD3ZhYSe73, password=WUr1vxH/aI3ePumADKJYNqaTpB16OQy4lYcq740itaUBXiBCNp19GIC/L4W67TYTwq9dVgI=
    , title=L4IRaIXqVvwzPPdxN1OS0jF7/PQmjr1GSbI7/nxvR2Dm5cGYKZclP4gRW2Z1aI3msebA11c=
    , webAddress=BtXaJM6yC08U9E6ma4WdRyi580TU5aekcEDY6OutDfeu9lKybVp1aWlEACRe1XZmAMYH2T0=
    , username=lHMbtbbpHlcetlWOLlysQ2E3xKfhsFCxHFgQ4l4Ky3ucfXHkV1uGeoXszwtEzoMzZsFLXJ4=
    , note=VztjJApYReJGukHfQd9fc/cxOQfP3Adaph+EXgC8Ld8kNHjn0jhYZJKAryhEx3te+bfo2X8=
    }
D/Constraints: onComplete2: fv017739.PasswordProtect.UpdatePassword@fa0fb06
D/Constraints: onComplete: [fv017739.PasswordProtect.UpdatePassword@6b456a9, fv017739.PasswordProtect.UpdatePassword@ce6942e, fv017739.PasswordProtect.UpdatePassword@8e74bcf, fv017739.PasswordProtect.UpdatePassword@4ae895c, fv017739.PasswordProtect.UpdatePassword@552b465, fv017739.PasswordProtect.UpdatePassword@24bc53a, fv017739.PasswordProtect.UpdatePassword@536d5eb, fv017739.PasswordProtect.UpdatePassword@c48df48, fv017739.PasswordProtect.UpdatePassword@8bf31e1, fv017739.PasswordProtect.UpdatePassword@fa0fb06]
V/FA: Inactivity, disconnecting from the service
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
    setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
    setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
    setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
    setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
    setTypeface with style : 0
D/TextView: setTypeface with style : 0
D/TextView: setTypeface with style : 0
I/art: Do partial code cache collection, code=47KB, data=60KB
I/art: After code cache collection, code=46KB, data=59KB
    Increasing code cache capacity to 256KB
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...