[Solved] Join Multi...
 
Notifications
Clear all

[Solved] Join Multiple Columns on Laravel Query Builder

0 Posts
1 Users
0 Likes
3 Views
0
Topic starter
Pieter Stephenson Asks: Join Multiple Columns on Laravel Query Builder
I have no idea how to write it in Laravel Query Builder. Here's the SQL query:

Code:
select l.id, l.title, is1.similarity
FROM l
left join is1 on (l.id = is1.listing_id1 and is1.listing_id2 = 225678) or (l.id = is1.listing_id2 and is1.listing_id1 = 225678)

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Unreplied Posts

[Solved] Audio not playing through Java on Raspberry Pi

kviLL Asks: Audio not playing through Java on Raspberry Pi

The issue​


I’m trying to play sound on a Raspberry Pi 3 B+ through Java, but it doesn’t work. I have

  1. Written code (shown below) in IntelliJ, and confirmed that it works on Windows 10.
  2. Connected speakers to my Raspberry Pi through aux and
    • Used sudo raspi-config to set audio to “headphones” (the only option).
    • Confirmed they work with aplay my-file.wav.
  3. Attempted to run my code (through Gradle) with gradle run in the project directory. It displays the text “Playing audio” as expected, but no audio plays.
  4. Tried the advice in this answer and this one and this forum (hence my audio testing above), all to no avail.

My entire code​


Code:
import javax.sound.sampled.*;
import java.io.File;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws UnsupportedAudioFileException, IOException, LineUnavailableException, InterruptedException {
        File file = new File("my-file.wav");
        AudioInputStream audioStream = AudioSystem.getAudioInputStream(file.getAbsoluteFile());
        Clip clip = AudioSystem.getClip();
        clip.open(audioStream);
        System.out.println("Playing audio");
        clip.start();
        Thread.sleep(10000);
    }
}

Other info​


I’m connecting to my Pi over SSH from Windows. My java --version is

Code:
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-post-Raspbian-2deb10u1)
OpenJDK Server VM (build 11.0.12+7-post-Raspbian-2deb10u1, mixed mode)

My gradle --version is Gradle 6.8.3. I’m using Gradle because the real project I’m working on requires it (this one is obviously just a demo).

I’m interested in any solution whatsoever to use Java to play sound. Is there a way to simply have Java call another bit of code that does work?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.
 
 
 

[Solved] DFRobot GPS init error [Arduino Uno, SIM808]

Dave M Asks: DFRobot GPS init error [Arduino Uno, SIM808]
i have problem with initialization DFRobot SIM808 actually when i try to recieve gps data by SoftwareSerial only it does works (i mean examples based on sending and reading command to and from serial’s), and recieve data but very long string of data and i need only Latitude and Longitude and i think using DFRobot will be the easiest way to extract the data i need. So the simple test program like this one is not working:

Code:
    /*
### Get GPS data
1. This example is used to test SIM808 GPS/GPRS/GSM Shield's reading GPS data.
2. Open the SIM808_GetGPS example or copy these code to your project
3. Download and dial the function switch to Arduino
4. open serial helper
4. Place it outside, waiting for a few minutes and then it will send GPS data to serial

create on 2016/09/23, version: 1.0
by jason

*/
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX    7
#define PIN_RX    8
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,



void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);

  //******** Initialize sim808 module *************
  while(!sim808.init()) { 
      delay(1000);
      Serial.print("Sim808 init errorrn");
  }

  //************* Turn on the GPS power************
  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else 
      Serial.println("Open the GPS power failure");

}

void loop() {
   //************** Get GPS data *******************
   if (sim808.getGPS()) {
    Serial.print(sim808.GPSdata.year);
    Serial.print("/");
    Serial.print(sim808.GPSdata.month);
    Serial.print("/");
    Serial.print(sim808.GPSdata.day);
    Serial.print(" ");
    Serial.print(sim808.GPSdata.hour);
    Serial.print(":");
    Serial.print(sim808.GPSdata.minute);
    Serial.print(":");
    Serial.print(sim808.GPSdata.second);
    Serial.print(":");
    Serial.println(sim808.GPSdata.centisecond);
    Serial.print("latitude :");
    Serial.println(sim808.GPSdata.lat);
    Serial.print("longitude :");
    Serial.println(sim808.GPSdata.lon);
    Serial.print("speed_kph :");
    Serial.println(sim808.GPSdata.speed_kph);
    Serial.print("heading :");
    Serial.println(sim808.GPSdata.heading);
    Serial.println();

    //************* Turn off the GPS power ************
    sim808.detachGPS();
  }

}


error

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] I am working on a project and I’m getting a was not declared in this scope error see my code below please reply fast!

Drake Asks: I am working on a project and I’m getting a was not declared in this scope error see my code below please reply fast!
#include <Servo.h> #include <SPI.h> #include <RFID.h>

RFID rfid(10, 9);

byte kart[5] = {F7,55,AA,85}; Servo myservo; boolean card;

void setup() {

Serial.begin(9600); SPI.begin(); rfid.init(); myservo.attach(3); myservo.write(100);

}

void loop() {

if (rfid.isCard()) {

Code:
if (rfid.readCardSerial())
{
  Serial.print("Found ID: ");
  Serial.print(rfid.serNum[0]);
  Serial.print(",");
  Serial.print(rfid.serNum[1]);
  Serial.print(",");
  Serial.print(rfid.serNum[2]);
  Serial.print(",");
  Serial.print(rfid.serNum[3]);
  Serial.print(",");
  Serial.println(rfid.serNum[4]);

}
for (int i = 1; i < 5; i++)
{
  if (rfid.serNum[0] == kart[0] && rfid.serNum[1] == kart[1] && rfid.serNum[2] == kart[2] && rfid.serNum[3] == kart[3] && rfid.serNum[4] == kart[4])
  {
    card = true;
  }
  else {
    card = false;
  }
}
if (card == true)
{
  Serial.println("Correct Card");
  myservo.write(20);
  delay(15000);
  myservo.write(100);
}
else
{
  Serial.println("Wrong Card");

}
rfid.halt();

} }

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] add custom LWC to lightning record page causing error (Only happens when the org has a namespace )

red Asks: add custom LWC to lightning record page causing error (Only happens when the org has a namespace )
it was working earlier this week, but starting from June 18th I believe after SF pushing upgrade or something, it stopped working.

add custom LWC to lightning record page for standard object still works, however, if it’s for custom object it will not work.

to re-produce, create a simple test LWC and add it to a custom object lightning record page:

Code:
test.html 
<template> Test LWC </template> 

test.js
import { LightningElement } from 'lwc';

export default class Test extends LightningElement {}

test.js-meta.xml 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="test">
    <apiVersion>45.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>

Tested in scratch org, it always says something like this below:

Looks like there’s a problem.

Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details.

Anyone experienced the same issue? Any ideas how to solve this? Thanks in advance

per call with Partner Support (6/25), they are saying they will be rolling new patches to fix a variety of LWC issues (including the one I have within the managed package). So hopefully it will be fixed soon

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Add test method to your test class error getting, please help how to resolve

user105753 Asks: Add test method to your test class error getting, please help how to resolve

Code:
public with sharing class CreateQuotePDFController {
    public list<QuoteLineItem> quoteLineItemsList{get;set;}
    public Id getid{get;set;} 
    public Double grandTotalTax{get;set;}
    public Double finalPO{get;set;}
    public Date expirationDate{get;set;}
    public CreateQuotePDFController(ApexPages.StandardController controller) {
        getid=ApexPages.currentPage().getParameters().get('id');
        Quote quote = [SELECT Account.Name, Account.BillingCountry,Account.BillingPostalCode,Account.BillingState,Account.BillingCity,Account.BillingStreet, Contact.Name, GrandTotal, ExpirationDate FROM quote where id=:getid ];
        quoteLineItemsList = [select id,product2id,Discount_Percentage__c, PricebookEntry.Product2.Name , UnitPrice, Quantity, Subtotal from quotelineitem where QuoteId=: getid];        
        System.debug('grand total is : ' +quote.GrandTotal);
        grandTotalTax = (quote.GrandTotal * 0.18).setScale(2);
        finalPO = (quote.GrandTotal+grandTotalTax).setScale(2);
        expirationDate = quote.ExpirationDate;
    }
}

Test Class :-

Code:
@isTest
public class CreateQuotePDFController_Test {
@testsetup static void data_setup(){
Account acc1 = new Account();
        acc1.Name = 'test account';
        insert acc1;
        system.debug('insert acc1 is success');

        Opportunity Opp1 = new Opportunity();
        Opp1.Name = 'testOpp';
        Opp1.AccountId = acc1.Id;
        Opp1.StageName = 'Closed Won';
        Opp1.CloseDate = system.Today();
        insert Opp1;        
        system.debug('insert opp1 success');

        Product2 Pro1 = new Product2();
        Pro1.Name = 'SLA: Bronze';
        pro1.isActive = True;
        Insert pro1;
        system.debug('insert pro1 is success');        

        Pricebook2 pb = new pricebook2();
        pb.Name = 'Standard Price Book 2009';
        pb.description = 'Price Book 2009 Products';
        pb.isActive = True;
        insert pb;
        system.debug('pb value is'+ pb.Id);
        system.debug('insert pricebook2 is success');

        Id pricebookId = Test.getStandardPricebookId();        

        PricebookEntry StandardPriceBookEntry = new PricebookEntry();
        StandardPriceBookEntry.Pricebook2Id = pricebookId;
        StandardPriceBookEntry.Product2Id = pro1.Id;
        StandardPriceBookEntry.UnitPrice = 10000;
        StandardPriceBookEntry.IsActive =True;        
        insert StandardPriceBookEntry;
        system.debug('insert StandardPriceBookEntry');

        PricebookEntry pbe = new PricebookEntry(pricebook2id=pb.id, product2id=pro1.id, unitprice=10000, isActive = True);
        insert pbe;
        system.debug('insert pbe is success');

        Quote Quo1 = new Quote(); 
        Quo1.OpportunityId = Opp1.Id;
        Quo1.Pricebook2Id = pb.Id;
        Quo1.Name = 'test Quo1';      
        insert Quo1;       
        system.debug('insert Quo1 success');

        QuoteLineItem QLI  = new QuoteLineItem();
        QLI.Product2Id = pro1.Id;
        QLI.QuoteId = Quo1.Id;
        QLI.PricebookEntryId = Pbe.Id;
        QLI.Quantity = 2;
        QLI.UnitPrice = 150000.0; 
        insert QLI;    
        system.debug('insert QLI is success');
     
    PageReference pageRef = Page.CreateQuotePDF;
    Test.setCurrentPage(pageRef);
    pageRef.getParameters().put('id', String.valueOf(Quo1.Id));
     ApexPages.StandardController sc = new ApexPages.StandardController(Quo1);
        
     CreateQuotePDFController qpc = new CreateQuotePDFController(sc);
     
       
   } 
     
    
}

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Error importing product csv

EricH Asks: Error importing product csv
I exported product csv, then added prices and tried to re-import them. This is giving me an error. Per someone’s suggestion I deleted the products in admin and now I can’t add them back.

Here is error message: Following Error(s) has been occurred during importing process: Only the first 100 errors are shown. Download full report 1. Invalid option value for attribute “design” in row(s): 654, 656 2. Attribute with code “000” is not super in row(s): 654, 656 3. Please make sure attribute “name” is not empty. in row(s): 655 4. This name is already being used for custom option. Please enter a different name. in row(s): 654, 655

Also, trying to import unaltered export file shows the same errors.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Is it possible to allocate memory dynamically to the global variable or static variable?

funckingcoding Asks: Is it possible to allocate memory dynamically to the global variable or static variable?

Code:
#include <stdio.h>
int* arr = new int[10];
int main()
{
    for (int i = 0; i < 5; i++) {
        arr[i] = i;
        printf("%d", arr[i]);
    }
    return 0;
}

I thought global variable cannot be allocated dynamically, because global(and static) variable is initialized before running program and the dynamic allocation occurs in running time. But the code works well!! I cannot understand why the code works..

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] I have two strings with the same character’s that are not returning true when compared in Java [duplicate]

Jackson Brummell Asks: I have two strings with the same character’s that are not returning true when compared in Java [duplicate]
I have two strings that are exactly equal in terms of characters and look identical when printed but don’t ever fulfil the == operator in an if statement. Even if I use .trim() on both

One of the strings is a user input string from Scanner and one is a string parsed from a JSON object and made into a String, however, they are still identical and I can’t workout how to make them equal for this comparison.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Fatal Exception: java.lang.IllegalArgumentException: fromIndex(10) > toIndex(0)

Nidhi Asks: Fatal Exception: java.lang.IllegalArgumentException: fromIndex(10) > toIndex(0)
I am new in android. I have made pagination in my list and on click, its change recyclerview list. My code is like below

Code:
private void setAdapter(int From, int To) {

        textPageCount.setText(CURRENT_PAGE +"/" +TOTAL_PAGE);
        butPrev.setVisibility((CURRENT_PAGE ==1) ? View.INVISIBLE : View.VISIBLE);
        butNext.setVisibility((CURRENT_PAGE == TOTAL_PAGE) ? View.INVISIBLE : View.VISIBLE);

        progressBar.setVisibility(View.GONE);
        ArrayList<ItemCategory> arraylistsub = new ArrayList<>(Constant.arrayListCategories.subList(From, To));
        adapterCat = new AdapterCat(arraylistsub);
        adapterCat.notifyDataSetChanged();
        recyclerView.setAdapter(adapterCat);
        setEmpty();
    }

butNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CURRENT_PAGE = CURRENT_PAGE+1;
                FROM = (CURRENT_PAGE-1)* Constant.ITEM_PER_PAGE;
                TO = FROM + Constant.ITEM_PER_PAGE;
                if(TO>TOTAL){
                    TO = TOTAL;
                }
                setAdapter(FROM,TO);
            }
        });
        butPrev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CURRENT_PAGE = CURRENT_PAGE-1;

                FROM = (CURRENT_PAGE-1) * Constant.ITEM_PER_PAGE;
                TO = FROM + Constant.ITEM_PER_PAGE;
                if(TO>TOTAL){
                    TO = TOTAL;
                }
                setAdapter(FROM,TO);
            }
        });

I am hiding button if there no next or previous pages. Still sometime if user speedy click the buttons, I am getting below fatal error.

Code:
Fatal Exception: java.lang.IllegalArgumentException: fromIndex(10) > toIndex(0)
       at java.util.ArrayList.subListRangeCheck(ArrayList.java:1018)
       at java.util.ArrayList.subList(ArrayList.java:1008)
       at com.karopass.fragment.FragmentCat.setAdapter(FragmentCat.java:192)
       at com.karopass.fragment.FragmentCat.access$200(FragmentCat.java:35)
       at com.karopass.fragment.FragmentCat$2.onClick(FragmentCat.java:95)
       at android.view.View.performClick(View.java:7394)
       at android.view.View.performClickInternal(View.java:7348)
       at android.view.View.access$3900(View.java:827)
       at android.view.View$PerformClick.run(View.java:28293)
       at android.os.Handler.handleCallback(Handler.java:899)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:238)
       at android.app.ActivityThread.main(ActivityThread.java:7864)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:998)

On line this

Code:
ArrayList<ItemCategory> arraylistsub = new ArrayList<>(Constant.arrayListCategories.subList(From, To));

Full Fragment code

Code:
public class FragmentCat extends Fragment {

    private Methods methods;
    private RecyclerView recyclerView;
    private AdapterCat adapterCat;
    private ProgressBar progressBar;

    private TextView textView_empty,textPageCount;
    private LinearLayout ll_empty;
    private String errr_msg;
    private AppCompatButton button_try;
    private int CURRENT_PAGE =1;
    private int TOTAL_PAGE= 0;
    private RelativeLayout butNext, butPrev;
    private int FROM  = 0, TO =0, TOTAL =0;

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_category, container, false);


        methods = new Methods(getActivity());


        ll_empty = rootView.findViewById(R.id.ll_empty);
        textView_empty = rootView.findViewById(R.id.tv_empty_msg);
        button_try = rootView.findViewById(R.id.button_empty_try);
        butNext = rootView.findViewById(R.id.butNext);
        butPrev = rootView.findViewById(R.id.butPrev);
        textPageCount = rootView.findViewById(R.id.textPageCount);

        LinearLayout ll_adView = rootView.findViewById(R.id.ll_adView);
        methods.showBannerAd(ll_adView);



        TOTAL = Constant.arrayListCategories.size();
        TOTAL_PAGE = TOTAL/Constant.ITEM_PER_PAGE+((TOTAL%Constant.ITEM_PER_PAGE)>0?1:0);
        FROM = (CURRENT_PAGE-1) * Constant.ITEM_PER_PAGE;
        TO = FROM + Constant.ITEM_PER_PAGE;
        if(TO>TOTAL){
            TO = TOTAL;
        }

        button_try.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setAdapter(FROM,TO);
            }
        });

        butNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CURRENT_PAGE = CURRENT_PAGE+1;
                FROM = (CURRENT_PAGE-1)* Constant.ITEM_PER_PAGE;
                TO = FROM + Constant.ITEM_PER_PAGE;
                if(TO>TOTAL){
                    TO = TOTAL;
                }
                setAdapter(FROM,TO);
            }
        });
        butPrev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CURRENT_PAGE = CURRENT_PAGE-1;

                FROM = (CURRENT_PAGE-1) * Constant.ITEM_PER_PAGE;
                TO = FROM + Constant.ITEM_PER_PAGE;
                if(TO>TOTAL){
                    TO = TOTAL;
                }
                setAdapter(FROM,TO);
            }
        });


        progressBar = rootView.findViewById(R.id.my_progressBar);

        recyclerView = rootView.findViewById(R.id.rv_author);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 1);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(gridLayoutManager);

        recyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {

                int FinalPosition = position;
                if(CURRENT_PAGE>1){
                    FinalPosition = ((CURRENT_PAGE-1)*Constant.ITEM_PER_PAGE)+position;
                }

                String id = Constant.arrayListCategories.get(FinalPosition).getId();
                Intent intent = new Intent(getActivity(), QuotesByCatActivity.class);
                intent.putExtra("id", id);
                intent.putExtra("name", Constant.arrayListCategories.get(FinalPosition).getName());
                intent.putExtra("TOTAL", Constant.arrayListCategories.get(FinalPosition).getTotal());
                intent.putExtra("Push", false);
                startActivity(intent);
            }
        }));



        setAdapter(FROM,TO);
        setHasOptionsMenu(true);
        return rootView;
    }

    @Override
    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
        inflater.inflate(R.menu.menu_main, menu);

        final MenuItem searchItem = menu.findItem(R.id.menu_search);
        searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW | MenuItem.SHOW_AS_ACTION_IF_ROOM);
        final SearchView searchView = (SearchView) searchItem.getActionView();
        searchView.setOnQueryTextListener((new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                return false;
            }

            @SuppressLint("NotifyDataSetChanged")
            @Override
            public boolean onQueryTextChange(String newText) {
                if (!searchView.isIconified()) {
                    adapterCat.getFilter().filter(newText);
                    adapterCat.notifyDataSetChanged();
                }
                return true;
            }
        }));
        super.onCreateOptionsMenu(menu, inflater);
    }

    private int getPos(String id) {
        int count = 0;
        int rid = Integer.parseInt(id);
        for (int i = 0; i < Constant.arrayListCategories.size(); i++) {
            if (rid == Integer.parseInt(Constant.arrayListCategories.get(i).getId())) {
                count = i;
                break;
            }
        }
        return count;
    }


    private void setAdapter(int From, int To) {

        textPageCount.setText(CURRENT_PAGE +"/" +TOTAL_PAGE);
        butPrev.setVisibility((CURRENT_PAGE ==1) ? View.INVISIBLE : View.VISIBLE);
        butNext.setVisibility((CURRENT_PAGE == TOTAL_PAGE) ? View.INVISIBLE : View.VISIBLE);

        progressBar.setVisibility(View.GONE);
        ArrayList<ItemCategory> arraylistsub = new ArrayList<>(Constant.arrayListCategories.subList(From, To));
        adapterCat = new AdapterCat(arraylistsub);
        adapterCat.notifyDataSetChanged();
        recyclerView.setAdapter(adapterCat);
        setEmpty();
    }

    private void setEmpty() {
        if (Constant.arrayListCategories.size() > 0) {
            recyclerView.setVisibility(View.VISIBLE);
            ll_empty.setVisibility(View.GONE);
        } else {
            textView_empty.setText(errr_msg);
            recyclerView.setVisibility(View.GONE);
            ll_empty.setVisibility(View.VISIBLE);
        }
    }
}

I am not getting idea how I can handle this situation. Let me know if anyone here can help me for solve the issue. Thanks!

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Trying to send an email in Python and always error happened

hamza DC Asks: Trying to send an email in Python and always error happened

Code:
from smtplib import SMTP
sendMsg = SMTP("smtp.gmail.com", 587)
sendMsg.StartTLS()
sendMsg.login("my-email", "mypassword")
sendMsg.sendmail("sender" , "reciever", "message ehich i sent")
sendMsg.quit()

. this is error

File “D:sendMsg.py”, line 3, in sendMsg.StartTLS() AttributeError: ‘SMTP’ object has no attribute ‘StartTLS’

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Share: