Friday, August 24, 2018

Compiling error of VLC for Android

When I'm compiling VLC for Android according to this page, at the step of:

sh compile.sh

I get this error:

For an ARMv6 device without FPU:
$ export NO_FPU=1
For an ARMv5 device:
$ export NO_ARMV6=1

    If you plan to use a release build, run 'compile.sh release'
    VLC source found
    Building tools
    ./bootstrap: line 63: [: 6b: integer expression expected
    You are ready to build VLC and its contribs
    Building the contribs
    Generating EGL pkg-config file
    Generating GLESv2 pkg-config file
    Guessing build system... x86_64-redhat-linux
    Creating configuration file... config.mak
    Bootstrap completed.

    Run "make" to start compilation.

    Other targets:
     * make install      same as "make"
     * make prebuilt     fetch and install prebuilt binaries
     * make list         list packages
     * make fetch        fetch required source tarballs
     * make fetch-all    fetch all source tarballs
     * make distclean    clean everything and undo bootstrap
     * make mostlyclean  clean everything except source tarballs
     * make clean        clean everything
     * make package      prepare prebuilt packages
    make: Nothing to be done for `fetch'.
    mkdir -p -- /home/heda/adt-bundle/android/vlc/contrib/arm-linux-androideabi/share/aclocal && cd a52dec && autoreconf -fiv -I/home/heda/adt-bundle/android/vlc/contrib/arm-linux-androideabi/share/aclocal
    autoreconf: Entering directory `.'
    autoreconf: configure.in: not using Gettext
    autoreconf: running: aclocal -I /home/heda/adt-bundle/android/vlc/contrib/arm-linux-androideabi/share/aclocal --force 
    aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
    autoreconf: configure.in: tracing
    autoreconf: configure.in: not using Libtool
    autoreconf: running: /home/heda/adt-bundle/android/vlc/extras/tools/build/bin/autoconf --include=/home/heda/adt-bundle/android/vlc/contrib/arm-linux-androideabi/share/aclocal --force
    configure.in:74: error: possibly undefined macro: AC_DISABLE_SHARED
          If this token and others are legitimate, please use m4_pattern_allow.
          See the Autoconf documentation.
    configure.in:75: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
    configure.in:76: error: possibly undefined macro: AC_PROG_LIBTOOL
    autoreconf: /home/heda/adt-bundle/android/vlc/extras/tools/build/bin/autoconf failed with exit status: 1
    make: *** [.a52] Error 1

Solved

A similar thing happened to me when installing a different package. The fix was to install libtool with:

$ sudo apt-get install libtool

then run:

$ ./auto_gen.sh

then proceed as normal.


I was using Ubuntu 13.04 and after recompiling it in Ubuntu 14.04, the error is gone. I guess it's because the autotools can not updated to the latest version by using apt-get update in 13.04.


Monday, August 20, 2018

How to get Unauthenticated identity using Swift

I have initialized the credentials provider per this AWS Developer Guide. I'm not sure if it worked, and how to check. I can't seem to find any documentation on how to use Cognito with Swift. I'm running it as a unit test, and the test passes and the line print("identityId", identityId) outputs:

identityId

However, during debug the property identityProvider.identityId is nil.

Here are my files:

// MyAuth.swift

import Foundation
import AWSCognito

class MyAuth {

    func getUnauthCognitoId()->Bool {
        let identityProvider = MyIdentityProvider()
        let credentialsProvider = AWSCognitoCredentialsProvider(regionType: AWSRegionType.USEast1, identityProvider: identityProvider, unauthRoleArn: Constants.ARNUnauth.value, authRoleArn: Constants.ARNAuth.value)
        let defaultServiceConfiguration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialsProvider)
        AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration

        if let identityId = identityProvider.getIdentityId() {
            print("identityId", identityId)
            return true
        } else {
            return false
        }

    }

}

And

//  MyIdentityProvider.swift

import Foundation
import AWSCognito

class MyIdentityProvider: AWSAbstractCognitoIdentityProvider {
    var _token: String!
    var _logins: [ NSObject : AnyObject ]!

    // Header stuff you may not need but I use for auth with my server
    /*let acceptHeader = "application/vnd.exampleapp-api+json;version=1;"
    let authHeader = "Token token="
    let userDefaults = NSUserDefaults.standardUserDefaults()
    let authToken = self.userDefaults.valueForKey("authentication_token") as String*/

    // End point that my server gives amazon identityId and tokens to authorized users
    let url = "https://api.myapp.com/api/amazon_id/"

    func authenticatedWithProvider()->Bool {
        if let logins = _logins {
            return logins["ProviderName"] == nil
        }
        else {
            return false
        }
    }

    override var token: String {
        get {
            return _token
        }
    }

    override var logins: [ NSObject : AnyObject ]! {
        get {
            return _logins
        }
        set {
            _logins = newValue
        }
    }

    override func getIdentityId() -> AWSTask! {
        if self.identityId != nil {
            return AWSTask(result: self.identityId)
        }
        else if(!self.authenticatedWithProvider()) {
            return super.getIdentityId()
        }
        else{
            return AWSTask(result: nil).continueWithBlock({ (task) -> AnyObject! in
                if self.identityId == nil {
                    return self.refresh()
                }
                return AWSTask(result: self.identityId)
            })
        }
    }

    override func refresh() -> AWSTask! {
        let task = AWSTaskCompletionSource()
        if(!self.authenticatedWithProvider()) {
            return super.getIdentityId()
        }
        else {
            // TODO: Authenticate with developer
            return task.task
        }
        /*let request = AFHTTPRequestOperationManager()
        request.requestSerializer.setValue(self.acceptHeader, forHTTPHeaderField: "ACCEPT")
        request.requestSerializer.setValue(self.authHeader+authToken, forHTTPHeaderField: "AUTHORIZATION")
        request.GET(self.url, parameters: nil, success: { (request: AFHTTPRequestOperation!, response: AnyObject!) -> Void in
            // The following 3 lines are required as referenced here: http://stackoverflow.com/a/26741208/535363
            var tmp = NSMutableDictionary()
            tmp.setObject("temp", forKey: "ExampleApp")
            self.logins = tmp

            // Get the properties from my server response
            let properties: NSDictionary = response.objectForKey("properties") as NSDictionary
            let amazonId = properties.objectForKey("amazon_identity") as String
            let amazonToken = properties.objectForKey("token") as String

            // Set the identityId and token for the ExampleAppIdentityProvider
            self.identityId = amazonId
            self._token = amazonToken

            task.setResult(response)
            }, failure: { (request: AFHTTPRequestOperation!, error: NSError!) -> Void in
                task.setError(error)
        })*/
        return task.task
    }
}

And

import XCTest
@testable import My

class MyTests: XCTestCase {

    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }

    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }

    func testExample() {
        // This is an example of a functional test case.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
    }

    func testPerformanceExample() {
        // This is an example of a performance test case.
        self.measureBlock {
            // Put the code you want to measure the time of here.
        }
    }

    func testGetUnauthCognitoId() {
        let myAuth = MyAuth()
        XCTAssertTrue(myAuth.getUnauthCognitoId())
    }

}

Solved

getIdentityId returns an AWSTask. Since AWSTask is essentially BFTask with a different name, you can get the identityId using the continueWithBlock syntax shown on the BFTask page. Something like:

credentialProvider.getIdentityId().continueWithBlock {
    (task: AWSTask!) -> AWSTask in
    if task.error() {
        // failed to retrieve identityId.
    } else {
        print("identityId", task.result())
    }

It turns out that if you create a default service configuration within the application:didFinishLaunchingWithOptions: application delegate method in your app delegate file as described here:

let credentialsProvider = AWSCognitoCredentialsProvider(
        regionType: AWSRegionType.USEast1, identityPoolId: cognitoIdentityPoolId)

let defaultServiceConfiguration = AWSServiceConfiguration(
        region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)

AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration

The SDK will use an unauthenticated identity whenever you try to use any of the AWS services, and you don't necessarily need to create a cognitoIdentity object.


Sunday, August 19, 2018

How to send an array of parameter through GET with Restangular

I have to send an array of filters through get parameters in an API like this :

/myList?filters[nickname]=test&filters[status]=foo

Now if I send an object directly like this :

Restangular.one('myList').get({filters: {
    nickname: 'test',
    status: 'foo'
}});

The query really sent is

?filters={"nickname":"test","status":"foo"}

How to send a real array ? Should I thinks about an alternative ?

Solved

I found a way to do it, I have to iterate over the filter object to create a new object with the [] in the name :

var query = {};
for (var i in filters) {
    query['filters['+i+']'] = filters[i];
}

Restangular.one('myList').get(query);

Produce:

&filters%5Bnickname%5D=test

Someone have better solution ?


Try this:

Restangular.all('myList').getList({filters: {
    nickname: 'test',
    status: 'foo'
}});

if you have very few and controlled parameters, you can use this way.

Assuming that you have few filters:

    var api = Restangular.all('yourEntityName');
    var params = {  commonWay          : 'value1',
                   'filter[property1]' : filterVariable1,
                   'filter[property2]' : filterVariable2
                 };

    api.getList(params).then(function (data) {
        alert(data);
    });

I hope this help you.


stringify the content using JSON

{
  "startkey": JSON.stringify(["Forum-03fa10f4-cefc-427a-9d57-f53bae4a0f7e"]),
  "endkey": JSON.stringify(["Forum-03fa10f4-cefc-427a-9d57-f53bae4a0f7e", {}]),
}

translates to

?endkey=%5B"Forum-03fa10f4-cefc-427a-9d57-f53bae4a0f7e",+%7B%7D%5D&startkey=%5B"Forum-03fa10f4-cefc-427a-9d57-f53bae4a0f7e"%5D

i.e.

?endkey=["Forum-03fa10f4-cefc-427a-9d57-f53bae4a0f7e",{}]&startkey=["Forum-03fa10f4-cefc-427a-9d57-f53bae4a0f7e"]

Saturday, August 18, 2018

how to find date in arraylist and display messgae from database

im getting dates from database see database:

image

im loding dates in array list i want tocheck if current date exist in arraylistthen print title of that day how i will do that?

                static ArrayList Vacation_ID = new ArrayList();
static ArrayList Vacation_name = new ArrayList();
static ArrayList Vacation_Date = new ArrayList();


            Cursor mCursor3 =  db.selectQuery("SELECT * FROM uss_vacation WHERE calendar_id = 
                '"+Calendar_id+"' ");


    if (mCursor3.moveToFirst()) {
        do {



    Vacation_ID.add(mCursor3.getString(mCursor3.getColumnIndex("id")));

           Vacation_name.add(mCursor3.getString(mCursor3.getColumnIndex("title")));

            Vacation_Date.add(mCursor3.getString(mCursor3.getColumnIndex("date")));


        } while (mCursor3.moveToNext());
    }


    mCursor3.close();


            now i want to check if current date exist in araylist   Vacation_Date show title  
    of   that date like  
            if (Vacation_Date.contains("2013-11-11")) {
                 string datetitle;
                    datetitle="Veterans Day" from database

Solved

You are storing the date in an array list so, you will need to check every element of array list if the string containing matches the date specified by you.

Compare the ArrayList values as follows:-

String datetitle = "";
for (int index = 0; index< Vacation_Date.size();index++)
{
     String date = Vacation_Date.get(index);
     if(date.contains("2013-11-11"));
     //datetitle = "your value";
}

use below code

Date dt = new Date();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String check = dateFormat.format(dt);
Cursor mCursor3 =  db.selectQuery("SELECT * FROM uss_vacation WHERE calendar_id = 
            '"+check+"' ");

i think it is work please check this link for database operation this