I occured this issue when running ionic run android cmd enter image description here

Any help ?

I'm doing the Android Udacity tutorial on learning how to make an android app.

The video tutorial tells me to use some sort of view with a fragment - but then the text acknowledges that this doesn't exist anymore as a starting option, and instead of editing the tutorial they just ask I read up about fragments.

So I did, and fragments are confusing? There seem to be two imports I can user for fragments - android.app and android.support.v4.app? Which am I meant to use (not for making the same code as the tutorial, but for making quality code today)?

And then, for this exercise - just a view with a list - would I even use a fragment or would I kick it off with an activity directly?

I guess I'm asking what is best practice for my MainActivity class to make a screen that has a (i know it won't scroll bc there are so few items!) scrollable list with the entries

bob
jane
marko
helena

I am struggling with changing the TEXT color of AppCompat DialogFragments.

My App uses a DARK theme (Theme.AppCompat.NoActionBar), but for dialogs I want a LIGHT theme. I am using Build Tools, Support Library and compileSdkVersion to 25, shall it matters.

I am able to change everything else on the dialog (title, background, window background) but not the primary and accented text colors, that keep on using the (white) settings for the dark theme, resulting in white text over white background.

I've tried dozens of solutions in similar questions here in SO, like:

1) The easy one: On the styles.xml:

 <!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
    <item name="android:alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
</style>

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <!-- ignored !!!! -->
    <item name="colorPrimary">#ff0000</item>
    <!-- ignored !!!! -->
    <item name="colorPrimaryDark">#ff0000</item>
    <!-- ignored !!!! -->
    <item name="colorAccent">#ff0000</item>
    <!-- ignored !!!! -->
    <item name="android:textColorPrimary">#F040FF</item>
    <!-- ignored !!!! -->
    <item name="android:textColor">#F040FF</item>

</style>

With this solution, the background and buttons style from AppCompat.Light.Dialog.Alert IS APPLIED, but not the text colors as you can see in the screenshot:

enter image description here

2) Manually specifying the style on the AlertDialog Creation:

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View hostView = mHostView = inflater.inflate(layoutId, null);

Same problem. Light background, Light text.

3) Using a ContextWrapper:

    ContextThemeWrapper ctw = new ContextThemeWrapper(getActivity(),  R.style.AppCompatAlertDialogStyle);
    AlertDialog.Builder builder = new AlertDialog.Builder(ctw);

Nothing :( Same thing happens

4) Manually specifying other exotic constants I came across the many posts here in SO, like

Theme_DeviceDefault_Light_Dialog_Alert
THEME_DEVICE_DEFAULT_LIGHT

This was just a desperate attempt, but anyways the text is not changed

5) Specifying the style in the fragment rather than on the dialog

    Dialog_Meta newFragment = new Dialog_Meta();
    newFragment.setStyle(DialogFragment.STYLE_NORMAL, R.style.AppCompatAlertDialogStyle);
    newFragment.show(fragmentManager, TAG);

I used this solution time ago in a very old API version, can't remember what was the problem, but anyways, doesn't solve the present issue :(

Can anybody tell me what's going on?

i wonder about this technique which i can Display my sites posts in my application and Facebook posts wall together

like an application i saw displays a sites wll posts as a Cardview and also the facebook page posts

Here is a Screenshot of the app that i told display Site's Posts

here is another screenshot dispaly FB page wall posts

i want to know how to do this technique or what is thae name of the func and obj

I try to create project with library Apache POI to read .xlsx, but, during compiling - take an error (multidex is enabled):

:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2421Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:prepareIoReactivexRxandroid121Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileRetrolambdaDebug UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug
Error:trouble processing "javax/xml/XMLConstants.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

It's my build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"

    defaultConfig {
        applicationId "com.rostislav.dugin.reminderofwork"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'com.android.support:multidex:1.0.1'
    compile 'org.apache.poi:poi:3.15'
    compile 'org.apache.poi:poi-ooxml:3.15'
}

In gradle.properties I setted this param:

org.gradle.jvmargs=-Xmx2048m

Why I take this error and how it fix?

Following is my code. According to my APp, I can enter From DAte and ToDAte by clicking respective buttons. But after selecting dates from datepicker dialog, i have to find the diffrence between days. And then calculate the total cost. But there's something wrong with my code, due to which my FromDate and ToDate takes the same date and therefore shows the total cost as zero only. I am new to the Android. Please help me to solve this problem.

public class MainActivity extends AppCompatActivity {

TextView tv_rentcarheading, tv_costresult;
Button btndateFrom, btndateTo, btncalculate;
int CurrentYear1, CurrentMonth1, CurrentDay1, CurrentYear2, CurrentMonth2, CurrentDay2;
final int rent = 150;
static final int dialog_id1 = 0, dialog_id2 = 0;
long n, totalcost;


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

    tv_rentcarheading = (TextView) findViewById(R.id.tv_rentcar);
    tv_costresult = (TextView) findViewById(R.id.tv_result);
    btndateFrom = (Button) findViewById(R.id.btn_fromdate);
    btndateTo = (Button) findViewById(R.id.btn_todate);
    btncalculate = (Button) findViewById(R.id.btn_result);

    tv_costresult.setVisibility(View.INVISIBLE);

    Calendar calendar1 = Calendar.getInstance();

    CurrentYear1 = calendar1.get(Calendar.YEAR);
    CurrentMonth1 = calendar1.get(Calendar.MONTH);
    CurrentDay1 = calendar1.get(Calendar.DAY_OF_MONTH);

    Calendar calendar2 = Calendar.getInstance();
    CurrentYear2 = calendar2.get(Calendar.YEAR);
    CurrentMonth2 = calendar2.get(Calendar.MONTH);
    CurrentDay2 = calendar2.get(Calendar.DAY_OF_MONTH);


    showDialogOnButtonClick();

    calendar1.set(CurrentYear1, CurrentMonth1, CurrentDay1);
    calendar2.set(CurrentYear2, CurrentMonth2, CurrentDay2);

    n = (calendar2.getTimeInMillis() - calendar1.getTimeInMillis() );
    totalcost = n * rent;

    btncalculate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            totalcost = n * rent;
            tv_costresult.setText("The Cost of car from " +CurrentMonth1+"/"+CurrentDay1+"/"+CurrentYear1+" to "+CurrentMonth1+"/"+CurrentDay1+"/"+CurrentYear1+" is "+totalcost);
            tv_costresult.setVisibility(View.VISIBLE);
        }
    });
}


public void showDialogOnButtonClick()
{
    btndateFrom.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(dialog_id1);
        }
    });

    btndateTo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog(dialog_id2);
        }
    });
}


@Override
protected Dialog onCreateDialog(int id)
{
    if(id == dialog_id1)
        return new DatePickerDialog(MainActivity.this, setDateListener1, CurrentYear1, CurrentMonth1, CurrentDay1);


    if(id == dialog_id2)
        return new DatePickerDialog(MainActivity.this, setDateListener2, CurrentYear2, CurrentMonth2, CurrentDay2);


    else
        return null;
}


private DatePickerDialog.OnDateSetListener setDateListener1 = new DatePickerDialog.OnDateSetListener()
{
    @Override
    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth)
    {
        CurrentYear1 = year;
        CurrentMonth1 = month + 1;
        CurrentDay1 = dayOfMonth;
        Toast.makeText(MainActivity.this, "From Date is " + CurrentMonth1 +"/" + CurrentDay1+ "/" + CurrentYear1, Toast.LENGTH_LONG ).show();
    }
};


private DatePickerDialog.OnDateSetListener setDateListener2 = new DatePickerDialog.OnDateSetListener()
{
    @Override
    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth)
    {
        CurrentYear2 = year;
        CurrentMonth2 = month +1;
        CurrentDay2 = dayOfMonth;
        Toast.makeText(MainActivity.this, "From Date is " + CurrentMonth2 +"/" + CurrentDay2+ "/" + CurrentYear2, Toast.LENGTH_LONG ).show();
    }
};

}

I m writing this code to retrieve statistics from the app usage and cal.add doesn't work and I don't know why

context context =null;
UsageStatsManager usm = (UsageStatsManager) context.getSystemService("usagestats");
int interval = UsageStatsManager.INTERVAL_YEARLY;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, 1);
List<UsageStats> queryUsageStats = usm
        .queryUsageStats(UsageStatsManager.INTERVAL_DAILY, cal.getTimeInMillis(),
                System.currentTimeMillis());

What is best solution for viewcontroller and views like in facebook app. Example, in news feed are posts, images, videos, that are all diffenrent views(design), so what is best solution?

I have one idea, to use tableview with different cell design based on post type. Any other?

Since a few weeks I can find the mapping.txt from proguard after I generate a APK. I'm sure the buildtype is release. It used to be in MYAPP\app\build\outputs\mapping\release. Now I can only see dump.txt, seeds.txt and usage.txt

Minify is enabled:

buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' zipAlignEnabled true } debug{ minifyEnabled false } }

I think it happend after updating my gradle to the latest version. Where the mapping.txtgo?

How to delete pictures from camera roll? I've nokia lumia 625, windows 8.0 and the pictures are saved in my hotmail account and i am unable to delete 'em from mu cell phone's memory as i dont remember my hotmail account's password. I don't want to flash the phone memory or reset it as I don't want my other stuff to be deleted. Help!

I would like to develop an ARM (Dragonboard etc.) and x86 compatible application for Windows.

However I would like to target also the maximum of desktop OS (Windows XP, Vista, 7)

What guidelines should I follow to keep compatible my application on both ARM and x86 ?

  • For example ; I've heard that on Windows 10 IOT they are only consoles running, can/should I rely on window messages then ? (I don't think the answer is yes but this is just an example I would like guidelines with a bigger scope)

I'm making a Clue(do) board game in Java to improve my programming skills. I've done a lot of work so far, but now I'm stuck at finding an algorithm to make sure if a player can make a certain move.

Quick draw of how it's organised:

  • Superclass GameTile
  • Subclasses for each roomtype (RoomTile, DefaultTile, StartTile & OutsideTile)

The goal is to show the players all the possible moves a player can do when he throws the dice. I have found a way to look "around" the player to see which tiles it can reach, but the problem to see if a player can enter the room through a door (or if the player can reach that default tile), remains.

All squares you can see are presenting one of the classes previously mentioned:

  • Black: outside
  • white/pink: default
  • lightblue: rooms (doors are inside the roomclass flagged with boolean, no visual representation yet)
  • colored: start tiles

Visual example of what I'm meaning

Anyone have an idea to solve this? Thanks in advance!

PS. I'm new to this side of stackexchange (I'm used to stackoverflow) so if any more information is needed or if somethings wrong with a question like this, please let me know.

Given a list of integers l

e.g. [1,7,3,21,13,19]

and a list of 2-tuples containing elements of l.

e.g [(1,21),(1,13),(1,19),(7,3),(7,13),(7,19),(3,19),(21,13),(21,19)]

Find the maximum amount of 2-tuples that don't reuse an element of l

e.g. [(1,13),(7,3),(21,19)]

I'm having a difficulty to figure out relating an item to classes properly.

For example, I have a business directory website that shows profiles of different companies according to the products/services they offer. "LG" company, for instance, produces smartphones, TVs, blenders, etc.

And I want the company to show up on each category accordingly and each parent category to show number of companies that it holds [i.e. Electronics(243) there are 243 companies that produce electronics]. Here's the question: if

  1. Electronics (243)
    • Computers (14)
    • Smartphones (8)
    • TVs (10)
  2. Kitchen tools (120)
    • Blenders (4)
    • etc.

Wouldn't there be any duplicates?

User uploads images from the device gallery and they are displayed in the user photos (attached files section). List is not showing all of the uploaded images. TotalCount of uploaded images is 42. But the list is limited to show only 20 of them.
I think i should change the logic here. Thank for Your time and response.

- (void)showPatientImagesList {
    __weak BaseChartingController *weakSelf = self;
    [weakSelf showLoading:YES];
    [[RestClient sharedClient] callMethodByPath:METHOD_GET_PATIENT_FILES withHTTPMethodType:HTTP_GET withParameters:@{@"patientKey" : weakSelf.patientKey} callback:^(NSDictionary *responseDic, NSError *error) {
        [weakSelf showLoading:NO];
        if (SUCCEED_RESPONSE(responseDic, error)) {
            NSArray *images = [PatientAttachment arrayOfModelsFromDictionaries:[[responseDic objectForKey:@"data"] objectForKey:@"list"]];
            if (images.count) {
//                DLog(@"%@", responseDic);
                weakSelf.patientPhotos = [NSMutableArray arrayWithCapacity:0];
                for (PatientAttachment *patientAttachment in images) {
                    MWPhoto *photo = [MWPhoto photoWithURL:patientAttachment.photo.url];
                    photo.objectId = patientAttachment.photo.objectId;
                    photo.caption = patientAttachment.descrip;
//                    photo.caption = [NSString stringWithFormat:@"%@                %@: %@", patientAttachment.descrip, TRANSLATE(@"Upload date"),
//                                                               [[DateUtils sharedUtils] stringFromServerLongDate:patientAttachment.createdDate withFormat:SHORT_DATE_FORMAT]];
                    [weakSelf.patientPhotos addObject:photo];
                }
                MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:weakSelf];
                browser.displayActionButton = NO;
                browser.displayDeleteBtn = [self.permissions containsObject:REMOVE_PATIENT_CHART_IMAGE_ATTACHMENT];
                browser.displayNavArrows = YES;
                browser.alwaysShowControls = NO;
                browser.zoomPhotosToFill = YES;
                browser.displaySelectionButtons = YES;

#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
                browser.wantsFullScreenLayout = YES;
#endif
                browser.enableGrid = YES;
                browser.startOnGrid = YES;
                browser.enableSwipeToDismiss = YES;
                [browser setCurrentPhotoIndex:0];
                //                browser.thumbPhotos = photos;
                [weakSelf.selectedImages removeAllObjects];
                [weakSelf.navigationController pushViewController:browser animated:YES];
                weakSelf.searchParameters.start = @(weakSelf.patientPhotos.count);
            } else {
                ALERT(TRANSLATE(@"Patient has not images"));
            }

        } else {
            [[RestClient sharedClient] showErrorMessage:responseDic];
        }
    }];




}

This code build fine in Debug mode (Xcode8.0):

private func rebuildMyClass3sForMyClassCache() {
    emojiWorker.fetchClass1Categories { (categories: [MyClass2]) in
        self.representedMyClass3sForMyClass1 = categories
            .flatMap { $0.class1s.sorted(by: { (a: MyClass1, b: MyClass1) -> Bool in
                return (a.priorityWithinCategoryCategory ?? 0) < (b.priorityWithinCategoryCategory ?? 0)
            })
    }
            // we want to show MyClass1 sections only for MyClass1s that actually contain MyClass3s
    .filter { $0.belongingMyClass3s.count > 0 }
}

but gives linker errors when in building Release:

Showing Recent Issues   "Swift.UnsafeMutableBufferPointer.(subscript.materializeForSet : (Swift.Int) -> A).(closure #1)", referenced from:

function signature specialization <Arg[2] = Exploded> of generic specialization
<Swift.UnsafeMutableBufferPointer<MessagesExtension.MyClass1> with
Swift.UnsafeMutableBufferPointer<MessagesExtension.MyClass1> :
Swift.MutableCollection in Swift and
Swift.UnsafeMutableBufferPointer<MessagesExtension.MyClass1> :
Swift.RandomAccessCollection in Swift> of Swift._siftDown <A where A:
Swift.MutableCollection, A: Swift.RandomAccessCollection> (inout A, index : A.Index, subRange : Swift.Range<A.Index>, by : inout (A.Iterator.Element, A.Iterator.Element) -> Swift.Bool) -> () in ManageMyClass3sInteractor.o

this Question suggests to disable compiler optimizations, which is not an option for Release in my opinion.

Update:

The issue shows up in Xcode 8.0, but is updating to Xcode 8.1 cured it.

One feature of my app is NSCalendar based, and when i download the app from my computer to my iPhone directly everything works as expected (even after disconnected from the computer)

However, when anyone downloads it from the App Store including me on the same device as the one used for testing with my computer, the NSCalendar based feature doesn't work at all.

Basically, a new object should be added to a TableView connected array every calendar day. This works flawlessly when downloaded from Xcode but doesn't work at all when downloaded from the App Store.

Any ideas how I would be able to fix this, what the problem is, etc?

Thanks!

EDIT: The class extends UITableViewController and UITabBarDelegate

func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
    if item.tag == 1 {
        viewDidLoad()
    }
}

override func viewDidLoad() {
    super.viewDidLoad()

    if let savedHW = loadHW() {
        assignments += savedHW
    }

    navBar.rightBarButtonItem = editButtonItem

    let currentDate = Date()
    let dateFormatter = DateFormatter()

    let dayOfTheWeek = Calendar(identifier: Calendar.Identifier.gregorian).component(.weekday, from: Date())
    print(dayOfTheWeek)

    dateFormatter.dateFormat = "M/dd/YY"
    let convertedCurrentDate = dateFormatter.string(from: currentDate)
    print(convertedCurrentDate)

    //Adds an assignment based on date comparisons
    if let dates = NSKeyedUnarchiver.unarchiveObject(withFile: SettingsViewController.datesURL.path) as? [Date] {
        if currentDate >= dates[0] && currentDate <= dates[1] {
            if let weekendHW = NSKeyedUnarchiver.unarchiveObject(withFile: SettingsViewController.weekendURL.path) as? Bool {
                if(weekendHW || (!weekendHW && dayOfTheWeek != 1 && dayOfTheWeek != 7)){
                    if assignments.count > 0 && assignments[0].date != convertedCurrentDate {
                        assignments.insert(Assignment(hw: assignments[0].hw, date: convertedCurrentDate)!, at: 0)
                    }
                    saveHW()
                }
            }
        }
}

    //adds assignment on first launch of app
    if assignments.count == 0 {
        assignments.append(Assignment(hw: "", date: convertedCurrentDate)!)
        saveHW()
    }

    tableView.reloadData()
}

A new Assignment is created and appears in the table correctly when the app is downloaded from my computer to my phone directly, but doesn't create or doesn't reload data to show the new Assignment daily when the app is downloaded from Xcode.

I set my UI elements with offsets 0(left), 0(right). However, there are extra spacing on this sides. Please take a look at screen:

enter image description here

How to fix that?

As I currently understand it one way to do it is to use JSON. But it would seem better and easier to just send the swift object to the server making sure the server has the same class available. This way I can just keep using swift every step of the way.

Is this possible and how would I go about doing this?

Current setup:

  1. Swift playground to send data.
  2. Kitura server to receive data.

Playground code:

import UIKit
import PlaygroundSupport

PlaygroundPage.current.needsIndefiniteExecution = true

struct TestObject {
    let foo = "just some text"
    let number = 125
    let array = ["foo", "bar"]

    func printSomeInfo() {
        print(foo + "\(number+25)")
    }
}

func send() {
    let request = NSMutableURLRequest(url: URL(string: "http://192.168.178.80:8090/test")!)
    request.httpMethod = "POST"

    let testObject = TestObject()

    let bodyData = "\(testObject)"
    request.httpBody = bodyData.data(using: String.Encoding.utf8)

    let task =  URLSession.shared.dataTask(with: request as URLRequest,
                                           completionHandler: {
                                            (data, response, error) -> Void in

    })

    task.resume()
}

send()

Kitura main.swift code:

import Kitura
import Foundation

let router = Router()

class TestObject {
    let text = "just a string"
    let number = 125
    let array = ["bar", "foo"]
}

router.post("/test") {request, response, next in
    response.headers["Content-Type"] = "text/plain; charset=utf-8"

    if let post = try request.readString() {
        // would like to cast to TestObject but that doesn't work
        // let postObject = post as TestObject
        print(post)
    }
}


Kitura.addHTTPServer(onPort: 8090, with: router)
Kitura.run()

with my code I would save multiple data with a loop in my Firebase Database. I have used a while loop to save some strings in my Database but my app saves only the last book and I don't know how to fix this problem. Any ideas?

let refUsers = FIRDatabase.database().reference().child("Users").child("User" + tag_login).child(user_key).child("Books").child("Others")
        let key = refUsers.childByAutoId().key
        let multipleBooksValues = ["multipleBooks": "Yes", "read": "Yes"] as NSDictionary
        refUsers.child(key).setValue(multipleBooksValues)

        let refBooks = FIRDatabase.database().reference().child("Books").child("User's books").child(book_key)

        var bookNumber = 0

        let numberOfBooks = bookList.count

        while bookNumber < numberOfBooks {

            let book = bookList[bookNumber]

            let values = ["book_key\(bookNumber)" : book.book_key!] as NSDictionary
            refUsers.child(key).child("multipleBooksNumber").setValue(values)
            refBooks.updateChildValues(["onGoingNegotiations" : "Yes", "other_user_key" : self.user_key, "other_tag_login": self.tag_login])

            refUsers.child(key).child("multipleBooksNumber").observe(.value, with: { (snapshot) in
                let numberChildren = Int(snapshot.childrenCount - 1)
                if numberChildren == bookNumber{
                    bookNumber += 1
                }
            })

        }

Thank you in advance.

I'm looking to create a social media app and I need to find a solid PHP framework that provides an API for my app to call and that I can build on top of. The main point that I am looking for is something that is stable, scalable, fast, good community provides JSON responses and has authentication built in.

I would also like if possible to have some social media functionality pre built so I can work on just the bespoke bits of functionality that I need.

I have taken a look at elgg but would like to know if anyone has any other recommendations.

Also please let me know if this is not the best place for this question and where it should be.