All posts by stackoverflow

Two seperate API call values in one array


I have two API calls, one to get all the devices and one to get all the groups. What I would like to accomplish is to have one call that would fetch the groups with its devices.

This is the function to get the devices

public function getAll($environment, $options)
    // Get group ids from database, used for pairing groups with environments
    $groups = Device::where('source_id', $options['deviceSourceId'])->get();
    $groupIds = [];
    foreach ($groups as $group) {
        $groupIds[] = $group['group_id'];

    // Parameters
    $apiparams = [
        'headers' => $this->getHeaders($environment)

    $devices = [];

    foreach($groupIds as $groupId)
        $responseAPI = $this->getClient()->request('GET', 'devices?groupid=' . $groupId, $apiparams);
        $responseAPI = json_decode($responseAPI->getBody()->getContents(), true);
        $devices[] = $responseAPI['devices'];

    return $devices;

read more

Swift 3 Button in UICollectionViewCell not respond to touch

I have an UICollectionViewCell and two buttons inside that, but the buttons not respond to touch, i create button programmatically and add that to cell by addSubView it works, but when i added by holder.addSubView not working!

UserInteractionEnabeld of holder is true!

help please

class FavoriteProductCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var holder: UIView!

    override func awakeFromNib() {

        let btnFindBestPrice = UIButton(frame: CGRect(x: 0, y: 0, width: 151, height: 20))

        btnFindBestPrice.setTitle("Find best price", for: .normal)
        btnFindBestPrice.backgroundColor = UIColor.ButtonBackGreen

        btnFindBestPrice.isUserInteractionEnabled = true

        btnFindBestPrice.addTarget(self, action: #selector(findBestPrice), for: .touchUpInside)

        // AddTarget not working

        // AddTarget works fine

read more

Icon Color in Android Slide Menu

I am looking for a way to define the color of different icons in the Slide Out menu of Android . I have searched a lot on this site but could not find any answer to my specific question .
So I have three items in my slide out menu . Each item has a text and an icon . I want to give a different color to each of these icons at design time. I have been able to give a single color to all these icons using the following code

 //Some more code here
 app:itemIconTint="@android:color/holo_blue_bright" />

This gives a single uniform color to all the icons but this is not what I want . I want each of the menu icons to have their own color .

1) I have tried the following –

<item android:id="@+id/nav_camera"

2) I have also tried to change the color in the vector definition of ic_camera . This approach also does not work .

The icon color always remains gray and does not respond to any of the above code changes .

Can someone please help me with this .

compileSdkVersion 26
    defaultConfig {
        applicationId "..."
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""

read more

App goes stuck when click on firebase push notification in Killed state

I was handling push notification data and then after call API based in push notification custom data. This will work fine when app is in Active and background state.

But when app is not running and then click on notification, I was able to get custom data from custom date But, API is not called and app getting stuck.

I checked in iOS 10 and 11, but not working

Handling push is like this.


func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                         fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

            redirectToScreen(notificaiton: userInfo)


//Notify through Notification center
    func redirectToScreen(notificaiton: [AnyHashable: Any]) {
  let dictPayload = notificaiton as NSDictionary


        if let type = dictPayload.value(forKey: "type") as? String {

            var dict = ["type" : type]
 NSNotification.Name.init(rawValue: "handlePush"), object: dict)


read more

How can i compare my 2 SQL tables?

I have 2 tables, with a bunch of supplier ports in them, some more fields than in the 2 screenshots but the important fields are the 3 here, supplier no, port code and port active.

I would like to compare there 2 tables in 3 different ways:

  1. What does table 1 have, that table 2 does not have?
  2. What does table 2 have, that table 1 does not have?
  3. What do both tables have, but they are different, eg: port active = Y or table 1 and N in the same port in table 2.

read more