问:
How to convert 2k,1m,1g etc to 2000, 1000000 etc
Hello I'm new to java can anyone help me?

This code convert
2000 to 2k and 1000000 1m etc

```<code> private static final NavigableMap<Long, String> suffixes = new TreeMap<>();
    static {
        suffixes.put(1_000L, "k");
        suffixes.put(1_000_000L, "M");
        suffixes.put(1_000_000_000L, "G");
        suffixes.put(1_000_000_000_000L, "T");
        suffixes.put(1_000_000_000_000_000L, "P");
        suffixes.put(1_000_000_000_000_000_000L, "E");
    }

    public String format(long value) {
        //Long.MIN_VALUE == -Long.MIN_VALUE so we need an adjustment here
        if (value == Long.MIN_VALUE) return format(Long.MIN_VALUE + 1);
        if (value < 0) return "-" + format(-value);
        if (value < 1000) return Long.toString(value); //deal with easy case

        Map.Entry<Long, String> e = suffixes.floorEntry(value);
        Long divideBy = e.getKey();
        String suffix = e.getValue();

        long truncated = value / (divideBy / 10); //the number part of the output times 10
        boolean hasDecimal = truncated < 100 && (truncated / 10d) != (truncated / 10);
        return hasDecimal ? (truncated / 10d) + suffix : (truncated / 10) + suffix;
    }
</code>```

I need a code which reverse the conversion for example
2k to 2000 and 1m to 1000000

答: I got the solution just by storing the values in an ArrayList before converting and it worked osum. Thanks for the help everyone :)</p>

Body:
Hello I'm new to java can anyone help me?

This code convert
2000 to 2k and 1000000 1m etc

 private static final NavigableMap<Long, String> suffixes = new TreeMap<>();
    static {
        suffixes.put(1_000L, "k");
        suffixes.put(1_000_000L, "M");
        suffixes.put(1_000_000_000L, "G");
        suffixes.put(1_000_000_000_000L, "T");
        suffixes.put(1_000_000_000_000_000L, "P");
        suffixes.put(1_000_000_000_000_000_000L, "E");
    }

    public String format(long value) {
        //Long.MIN_VALUE == -Long.MIN_VALUE so we need an adjustment here
        if (value == Long.MIN_VALUE) return format(Long.MIN_VALUE + 1);
        if (value < 0) return "-" + format(-value);
        if (value < 1000) return Long.toString(value); //deal with easy case

        Map.Entry<Long, String> e = suffixes.floorEntry(value);
        Long divideBy = e.getKey();
        String suffix = e.getValue();

        long truncated = value / (divideBy / 10); //the number part of the output times 10
        boolean hasDecimal = truncated < 100 && (truncated / 10d) != (truncated / 10);
        return hasDecimal ? (truncated / 10d) + suffix : (truncated / 10) + suffix;
    }

I need a code which reverse the conversion for example
2k to 2000 and 1m to 1000000


来源: stackexchange

问:
Extjs Locked Grid Mouse wheel scrolling issue
Can anyone help why mouse wheel scrolling very slow in both Firefox and Chrome.
In Internet Explorer its working fine

Sample Test Case

答: onLockedViewScroll : Ext.emptyFn add this grid config</p>

ContentLicense: CC BY-SA 3.0


问:
Nested Structure Initialization
```<code>#include<stdio.h>
#include<stdlib.h>
int main(){
     struct nodeout
     {
      int out;
      struct nodein{int in; };
     };

     struct nodeout* p;
     p=(struct nodeout*)malloc(sizeof(struct nodeout));
     p->out=10;

     printf("%d",p->out);
 }
</code>```

<p>..Here is my code..How can I initialize the variable 'in' which is inside the structure nodein?</p>

答:
You did define struct nodein but did not define the nodein member for struct nodeout.

Do as following:

```<code>#include<stdio.h>
#include<stdlib.h>

int main(){
    struct nodeout
    {
        int out;
        struct nodein {int in; } node_in;
    };

    struct nodeout* p;
    p = (struct nodeout*)malloc(sizeof(struct nodeout));
    p->out = 10;
    p->node_in.in = 5

    printf("%d %d”, p->out, p->node_in.in);
}
</code>```

Title: Nested Structure Initialization

Body:
#include<stdio.h>
#include<stdlib.h>
int main(){
     struct nodeout
     {
      int out;
      struct nodein{int in; };
     };

     struct nodeout* p;
     p=(struct nodeout*)malloc(sizeof(struct nodeout));
     p->out=10;

     printf("%d",p->out);
 }

..Here is my code..How can I initialize the variable 'in' which is inside the structure nodein?

Body:
You did define struct nodein but did not define the nodein member for struct nodeout.

Do as following:

#include<stdio.h>
#include<stdlib.h>

int main(){
    struct nodeout
    {
        int out;
        struct nodein {int in; } node_in;
    };

    struct nodeout* p;
    p = (struct nodeout*)malloc(sizeof(struct nodeout));
    p->out = 10;
    p->node_in.in = 5

    printf("%d %d”, p->out, p->node_in.in);
}


问:
access the element in list of dictionary in python
hi every one i have list of dictionary all of the dictionaries like this:

```<code> dict1 = {Label:----,Chapter:----,Section:----,Massage:----}
 dict2 = {Label:----,Chapter:----,Section:----,Massage:----}
 dict3 = {Label:----,Chapter:----,Section:----,Massage:----}
 List = [dict1 , dict2 , dict3]
</code>```

i want first the all  dictionaries of list if the my label is equal with label in dictionary print the massage of that dictionary.

i use this method but it get nothing.

```<code>def printMassage(List , mylabel):
    for dicts in List:
        if (Label.value == mylabel):
            print( Massage.value)
</code>```

please help me!!

答:
```<code>def printMassage(List , mylabel):
    for dicts in List:
        if dicts[Label] == mylabel:
            print(dicts[Massage])
</code>```

Body:
hi every one i have list of dictionary all of the dictionaries like this:

 dict1 = {Label:----,Chapter:----,Section:----,Massage:----}
 dict2 = {Label:----,Chapter:----,Section:----,Massage:----}
 dict3 = {Label:----,Chapter:----,Section:----,Massage:----}
 List = [dict1 , dict2 , dict3]

i want first the all  dictionaries of list if the my label is equal with label in dictionary print the massage of that dictionary.

i use this method but it get nothing.

def printMassage(List , mylabel):
    for dicts in List:
        if (Label.value == mylabel):
            print( Massage.value)

please help me!!


问:
Unable to change the value of a property of an Object - JavaScript
I have a module in my code and I'm unable to change the value of a property of an Object. I have a more detailed explanation in code, see below:

```<code>var network = (function(){ // Created a closure.
  var ajax = {
    response: 0, // I set the initial value of response to 0
    parse: function(x){
             var y = JSON.parse(x);
             ajax.response = y; // This is where things don't seem to work. Value of response is still 0.
           }
    // Some other code.

    } // End of ajax object.

    return { // I return an Object .
     invoke: function(x){ ajax.parse(x); },
     reply: ajax.response
     }

})();

network.invoke(valid_argument); // I invoke the function and pass a valid json string received from a server via ajax.
console.log(network.reply); // I get 0, which is the initial value. Why?
</code>```

As mentioned in the Code this issue feels weird, any help is appreciated.

答:
I get 0, which is the initial value. Why?

Because reply: ajax.response assigns to reply (a copy of) the value that ajax.response has at the moment the line is executed. Future changes to ajax.response don't affect reply, there is no intrinsic connection between these two properties.

Here is a simplified example of the same situation:

```<code>var x = 42;
var y = x;
x = 21;
console.log(y); // still 42
</code>```

JavaScript is pass-by-value, not pass-by-reference. That means that a copy of the value is assigned to reply, not a reference to the ajax.response property.

Body:
I have a module in my code and I'm unable to change the value of a property of an Object. I have a more detailed explanation in code, see below:

var network = (function(){ // Created a closure.
  var ajax = {
    response: 0, // I set the initial value of response to 0
    parse: function(x){
             var y = JSON.parse(x);
             ajax.response = y; // This is where things don't seem to work. Value of response is still 0.
           }
    // Some other code.

    } // End of ajax object.

    return { // I return an Object .
     invoke: function(x){ ajax.parse(x); },
     reply: ajax.response
     }

})();

network.invoke(valid_argument); // I invoke the function and pass a valid json string received from a server via ajax.
console.log(network.reply); // I get 0, which is the initial value. Why?

As mentioned in the Code this issue feels weird, any help is appreciated.

Body:
I get 0, which is the initial value. Why?

Because reply: ajax.response assigns to reply (a copy of) the value that ajax.response has at the moment the line is executed. Future changes to ajax.response don't affect reply, there is no intrinsic connection between these two properties.

Here is a simplified example of the same situation:

var x = 42;
var y = x;
x = 21;
console.log(y); // still 42

JavaScript is pass-by-value, not pass-by-reference. That means that a copy of the value is assigned to reply, not a reference to the ajax.response property.


问:
Android App still remains connected to Google Sign in even after Uninstalling and reinstalling it
I have this strange problem in my App. My app has a GSigninActivity which is shown after Splash screen to facilitate Single Sign On with Google and Firebase. The problem is that on First Install and Launch, the app directly goes MainActivity without asking for Sign In.I have to the log Out from there and then Sign In. How is it that some Sign in data is present. Please Help.

GSigninActivity Code

```<code>    package com.example.joelmathew.firebidtest;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.example.joelmathew.firebidtest.models.User;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.api.GoogleApiClient;

/**
 * Created by Joel Mathew on 01-Jul-17.
 */

public class GSignInActivity extends BaseActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener {

    private static final String TAG = "GoogleActivity";
    private static final int RC_SIGN_IN = 9001;

    // [START declare_auth]
    private FirebaseAuth mAuth;
    private DatabaseReference mDatabase;
    // [END declare_auth]

    protected GoogleApiClient mGoogleApiClient;
    private String signout="false";
    public String personName;
   // private TextView mStatusTextView;
   // private TextView mDetailTextView;

    @Override
    @TargetApi(21)
    protected void onCreate(Bundle savedInstanceState) {
        FirebaseApp.initializeApp(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gsignin_activity);

        getSupportActionBar().hide();
        Window w = getWindow();
        w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        w.setStatusBarColor(ContextCompat.getColor(this, R.color.statusSplash));

        // Views
      //  mStatusTextView = (TextView) findViewById(R.id.status);
      //  mDetailTextView = (TextView) findViewById(R.id.detail);

        // Button listeners
        findViewById(R.id.sign_in_button).setOnClickListener(this);
        //findViewById(R.id.sign_out_button).setOnClickListener(this);
      //  findViewById(R.id.disconnect_button).setOnClickListener(this);

        // [START config_signin]
        // Configure Google Sign In
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();
        // [END config_signin]

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();

        // [START initialize_auth]
        mDatabase = FirebaseDatabase.getInstance().getReference();
        mAuth = FirebaseAuth.getInstance();
        // [END initialize_auth]

         /*Bundle b = getIntent().getExtras();
        if(b!=null) {
            signout = b.getString("Signout");
            if (signout.equals("true")) {
                Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                        new ResultCallback<Status>() {
                            @Override
                            public void onResult(@NonNull Status status) {
                                updateUI(null);
                            }
                        });
            }
        }*/

    }

    // [START on_start_check_user]
    @Override
    public void onStart() {
        super.onStart();
        // Check if user is signed in (non-null) and update UI accordingly.
        FirebaseUser currentUser = mAuth.getCurrentUser();
        updateUI(currentUser);
    }
    // [END on_start_check_user]

    // [START onactivityresult]
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (result.isSuccess()) {
                // Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = result.getSignInAccount();
                personName = account.getDisplayName();
                Log.v("LOG_VAL","GSigninActivity,onActivityResult: Person Name : "+ personName);
                PostKeyHolder.setGlobalPersonName(personName);
                Log.v("LOG_VAL","GSigninActivity,onActivityResult: Returned from Person Name : "+ PostKeyHolder.getGlobalPersonName());

                //String Number = account.
                firebaseAuthWithGoogle(account);
            } else {
                // Google Sign In failed, update UI appropriately
                // [START_EXCLUDE]
                updateUI(null);
                // [END_EXCLUDE]
            }
        }
    }
    // [END onactivityresult]

    // [START auth_with_google]
    private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
        Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
        // [START_EXCLUDE silent]
        showProgressDialog();
        // [END_EXCLUDE]
       final GoogleSignInAccount temp = acct;

        AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            // Sign in success, update UI with the signed-in user's information
                            Log.d(TAG, "signInWithCredential:success");
                            FirebaseUser user = mAuth.getCurrentUser();
                            personName = temp.getDisplayName();
                            Log.v("LOG_VAL","GSigninActivity,firebaseAuthWithGoogle: Person Name : "+ personName);
                            PostKeyHolder.setGlobalPersonName(personName);
                            Log.v("LOG_VAL","GSigninActivity,firebaseAuthWithGoogle: REturned from setting Person Name : "+ PostKeyHolder.getGlobalPersonName());
                            updateUI(user);
                            onAuthSuccess(user);
                        } else {
                            // If sign in fails, display a message to the user.
                            Log.w(TAG, "signInWithCredential:failure", task.getException());
                            Toast.makeText(GSignInActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                            updateUI(null);
                        }

                        // [START_EXCLUDE]
                        hideProgressDialog();
                        // [END_EXCLUDE]
                    }
                });
    }
    // [END auth_with_google]

    // [START signin]
    private void signIn() {
        Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
        startActivityForResult(signInIntent, RC_SIGN_IN);
    }
    // [END signin]

    private void signOut() {
        // Firebase sign out
        mAuth.signOut();

        // Google sign out
        Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                new ResultCallback<Status>() {
                    @Override
                    public void onResult(@NonNull Status status) {
                        updateUI(null);
                    }
                });
    }

    private void onAuthSuccess(FirebaseUser user) {
        String username = usernameFromEmail(user.getEmail());
        personName = user.getDisplayName();

        Log.v("LOG_VAL","GSigninActivity,onAuthSuccess: Person Name : "+ personName);
        PostKeyHolder.setGlobalPersonName(personName);
        Log.v("LOG_VAL","GSigninActivity,onAuthSuccess: Returned from Person Name : "+ PostKeyHolder.getGlobalPersonName());

        // Write new user
        writeNewUser(user.getUid(), username, user.getEmail(),personName);

       // PostKeyHolder.setGlobalPersonName(personName); //Setting Global Person handler

        // Go to MainActivity

        //Intent apiClient = new Intent(GSignInActivity.this,MainActivity.class);
        //apiClient.putExtra("ApiClient",mGoogleApiClient);
        updateUI(user);
        //startActivity(new Intent(GSignInActivity.this, MainActivity.class));
        finish();
    }

    private String usernameFromEmail(String email) {
        if (email.contains("@")) {
            return email.split("@")[0];
        } else {
            return email;
        }
    }

    // [START basic_write]
    private void writeNewUser(String userId, String username, String email, String personName) {
        User user = new User(username, email, personName);
        Log.v("LOG_VAL","GSigninActivity,writeNewUser: Person Name : "+ personName);
        PostKeyHolder.setGlobalPersonName(personName);
        Log.v("LOG_VAL","GSigninActivity,onActivityResult: Returned Person Name : "+ PostKeyHolder.getGlobalPersonName());

        mDatabase.child("GoogleSignIn").child(userId).setValue(user);
        mDatabase.child("users").child("GoogleSignIn").child(userId).setValue(user);
    }
    // [END basic_write]

    private void revokeAccess() {
        // Firebase sign out
        mAuth.signOut();

        // Google revoke access
        Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
                new ResultCallback<Status>() {
                    @Override
                    public void onResult(@NonNull Status status) {
                        //updateUI(null);
                    }
                });
    }

    private void updateUI(FirebaseUser user) {
        hideProgressDialog();
        if (user != null) {

            personName = user.getDisplayName();
            Log.v("LOG_VAL","GSigninActivity,updateUI: Person Name : "+ personName);

            PostKeyHolder.setGlobalPersonName(personName);
            Log.v("LOG_VAL","GSigninActivity,updateUI: Returned Person Name : "+ PostKeyHolder.getGlobalPersonName());

            //  mStatusTextView.setText(getString(R.string.google_status_fmt, user.getEmail()));
           // mDetailTextView.setText(getString(R.string.firebase_status_fmt, user.getUid()));

           findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
           startActivity(new Intent(GSignInActivity.this, MainActivity.class));
            finish();
          //  findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
        } else {

          //  mStatusTextView.setText(R.string.signed_out);
//            mDetailTextView.setText(null);

            findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
         //   findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
        }
    }

    @Override
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
        // An unresolvable error has occurred and Google APIs (including Sign-In) will not
        // be available.
        Log.d(TAG, "onConnectionFailed:" + connectionResult);
        Toast.makeText(this, "Google Play Services error.", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.sign_in_button) {
            signIn();
        } //else if (i == R.id.sign_out_button)
       /* // {
            signOut();
        } //else if (i == R.id.disconnect_button)
        /* {
            //evokeAccess();
        }*/
    }

}
</code>```

Manifest.XML

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.joelmathew.firebidtest">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" />
        <activity android:name=".NewPostActivity"
            android:windowSoftInputMode="adjustPan"/>

        <activity android:name=".BuyNow"/>
        <activity android:name=".BidMainScreen3"
            android:windowSoftInputMode="adjustPan"/>

        <!--activity android:name=".SignInActivity"-->
            <!--intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter-->
        <!--/activity-->

        <activity android:name=".SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity android:name=".GSignInActivity"></activity>
        <activity android:name=".PostDetailActivity"></activity>
        <activity android:name=".TopBidsActivity"></activity>
        <activity android:name=".OrdersActivity"></activity>
    </application>

</manifest>
</code>```

答:
Looks like you have android:allowBackup="true" in your AndroidManifest.xml.

Since Android 6.0 (API 23), Android has offered the Auto Backup for Apps feature as a way for developers to quickly add backup functionality to their apps. Auto Backup preserves app data by uploading it to the user's Google Drive account, where it is protected by the user's Google account credentials. The amount of data is limited to 25MB per user of your app and there is no charge for storing backup data.

You may want to disable backups. Read here in detail https://developer.android.com/guide/topics/data/autobackup.html#Files

Body:
I have this strange problem in my App. My app has a GSigninActivity which is shown after Splash screen to facilitate Single Sign On with Google and Firebase. The problem is that on First Install and Launch, the app directly goes MainActivity without asking for Sign In.I have to the log Out from there and then Sign In. How is it that some Sign in data is present. Please Help.

GSigninActivity Code

    package com.example.joelmathew.firebidtest;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.example.joelmathew.firebidtest.models.User;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.api.GoogleApiClient;

/**
 * Created by Joel Mathew on 01-Jul-17.
 */

public class GSignInActivity extends BaseActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener {

    private static final String TAG = "GoogleActivity";
    private static final int RC_SIGN_IN = 9001;

    // [START declare_auth]
    private FirebaseAuth mAuth;
    private DatabaseReference mDatabase;
    // [END declare_auth]

    protected GoogleApiClient mGoogleApiClient;
    private String signout="false";
    public String personName;
   // private TextView mStatusTextView;
   // private TextView mDetailTextView;

    @Override
    @TargetApi(21)
    protected void onCreate(Bundle savedInstanceState) {
        FirebaseApp.initializeApp(this);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gsignin_activity);

        getSupportActionBar().hide();
        Window w = getWindow();
        w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        w.setStatusBarColor(ContextCompat.getColor(this, R.color.statusSplash));

        // Views
      //  mStatusTextView = (TextView) findViewById(R.id.status);
      //  mDetailTextView = (TextView) findViewById(R.id.detail);

        // Button listeners
        findViewById(R.id.sign_in_button).setOnClickListener(this);
        //findViewById(R.id.sign_out_button).setOnClickListener(this);
      //  findViewById(R.id.disconnect_button).setOnClickListener(this);

        // [START config_signin]
        // Configure Google Sign In
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();
        // [END config_signin]

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();

        // [START initialize_auth]
        mDatabase = FirebaseDatabase.getInstance().getReference();
        mAuth = FirebaseAuth.getInstance();
        // [END initialize_auth]

         /*Bundle b = getIntent().getExtras();
        if(b!=null) {
            signout = b.getString("Signout");
            if (signout.equals("true")) {
                Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                        new ResultCallback<Status>() {
                            @Override
                            public void onResult(@NonNull Status status) {
                                updateUI(null);
                            }
                        });
            }
        }*/

    }

    // [START on_start_check_user]
    @Override
    public void onStart() {
        super.onStart();
        // Check if user is signed in (non-null) and update UI accordingly.
        FirebaseUser currentUser = mAuth.getCurrentUser();
        updateUI(currentUser);
    }
    // [END on_start_check_user]

    // [START onactivityresult]
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (result.isSuccess()) {
                // Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = result.getSignInAccount();
                personName = account.getDisplayName();
                Log.v("LOG_VAL","GSigninActivity,onActivityResult: Person Name : "+ personName);
                PostKeyHolder.setGlobalPersonName(personName);
                Log.v("LOG_VAL","GSigninActivity,onActivityResult: Returned from Person Name : "+ PostKeyHolder.getGlobalPersonName());

                //String Number = account.
                firebaseAuthWithGoogle(account);
            } else {
                // Google Sign In failed, update UI appropriately
                // [START_EXCLUDE]
                updateUI(null);
                // [END_EXCLUDE]
            }
        }
    }
    // [END onactivityresult]

    // [START auth_with_google]
    private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
        Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
        // [START_EXCLUDE silent]
        showProgressDialog();
        // [END_EXCLUDE]
       final GoogleSignInAccount temp = acct;

        AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            // Sign in success, update UI with the signed-in user's information
                            Log.d(TAG, "signInWithCredential:success");
                            FirebaseUser user = mAuth.getCurrentUser();
                            personName = temp.getDisplayName();
                            Log.v("LOG_VAL","GSigninActivity,firebaseAuthWithGoogle: Person Name : "+ personName);
                            PostKeyHolder.setGlobalPersonName(personName);
                            Log.v("LOG_VAL","GSigninActivity,firebaseAuthWithGoogle: REturned from setting Person Name : "+ PostKeyHolder.getGlobalPersonName());
                            updateUI(user);
                            onAuthSuccess(user);
                        } else {
                            // If sign in fails, display a message to the user.
                            Log.w(TAG, "signInWithCredential:failure", task.getException());
                            Toast.makeText(GSignInActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                            updateUI(null);
                        }

                        // [START_EXCLUDE]
                        hideProgressDialog();
                        // [END_EXCLUDE]
                    }
                });
    }
    // [END auth_with_google]

    // [START signin]
    private void signIn() {
        Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
        startActivityForResult(signInIntent, RC_SIGN_IN);
    }
    // [END signin]

    private void signOut() {
        // Firebase sign out
        mAuth.signOut();

        // Google sign out
        Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                new ResultCallback<Status>() {
                    @Override
                    public void onResult(@NonNull Status status) {
                        updateUI(null);
                    }
                });
    }

    private void onAuthSuccess(FirebaseUser user) {
        String username = usernameFromEmail(user.getEmail());
        personName = user.getDisplayName();

        Log.v("LOG_VAL","GSigninActivity,onAuthSuccess: Person Name : "+ personName);
        PostKeyHolder.setGlobalPersonName(personName);
        Log.v("LOG_VAL","GSigninActivity,onAuthSuccess: Returned from Person Name : "+ PostKeyHolder.getGlobalPersonName());

        // Write new user
        writeNewUser(user.getUid(), username, user.getEmail(),personName);

       // PostKeyHolder.setGlobalPersonName(personName); //Setting Global Person handler

        // Go to MainActivity

        //Intent apiClient = new Intent(GSignInActivity.this,MainActivity.class);
        //apiClient.putExtra("ApiClient",mGoogleApiClient);
        updateUI(user);
        //startActivity(new Intent(GSignInActivity.this, MainActivity.class));
        finish();
    }

    private String usernameFromEmail(String email) {
        if (email.contains("@")) {
            return email.split("@")[0];
        } else {
            return email;
        }
    }

    // [START basic_write]
    private void writeNewUser(String userId, String username, String email, String personName) {
        User user = new User(username, email, personName);
        Log.v("LOG_VAL","GSigninActivity,writeNewUser: Person Name : "+ personName);
        PostKeyHolder.setGlobalPersonName(personName);
        Log.v("LOG_VAL","GSigninActivity,onActivityResult: Returned Person Name : "+ PostKeyHolder.getGlobalPersonName());

        mDatabase.child("GoogleSignIn").child(userId).setValue(user);
        mDatabase.child("users").child("GoogleSignIn").child(userId).setValue(user);
    }
    // [END basic_write]

    private void revokeAccess() {
        // Firebase sign out
        mAuth.signOut();

        // Google revoke access
        Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
                new ResultCallback<Status>() {
                    @Override
                    public void onResult(@NonNull Status status) {
                        //updateUI(null);
                    }
                });
    }

    private void updateUI(FirebaseUser user) {
        hideProgressDialog();
        if (user != null) {

            personName = user.getDisplayName();
            Log.v("LOG_VAL","GSigninActivity,updateUI: Person Name : "+ personName);

            PostKeyHolder.setGlobalPersonName(personName);
            Log.v("LOG_VAL","GSigninActivity,updateUI: Returned Person Name : "+ PostKeyHolder.getGlobalPersonName());

            //  mStatusTextView.setText(getString(R.string.google_status_fmt, user.getEmail()));
           // mDetailTextView.setText(getString(R.string.firebase_status_fmt, user.getUid()));

           findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
           startActivity(new Intent(GSignInActivity.this, MainActivity.class));
            finish();
          //  findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
        } else {

          //  mStatusTextView.setText(R.string.signed_out);
//            mDetailTextView.setText(null);

            findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
         //   findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
        }
    }

    @Override
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
        // An unresolvable error has occurred and Google APIs (including Sign-In) will not
        // be available.
        Log.d(TAG, "onConnectionFailed:" + connectionResult);
        Toast.makeText(this, "Google Play Services error.", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.sign_in_button) {
            signIn();
        } //else if (i == R.id.sign_out_button)
       /* // {
            signOut();
        } //else if (i == R.id.disconnect_button)
        /* {
            //evokeAccess();
        }*/
    }

}

Manifest.XML

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.joelmathew.firebidtest">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" />
        <activity android:name=".NewPostActivity"
            android:windowSoftInputMode="adjustPan"/>

        <activity android:name=".BuyNow"/>
        <activity android:name=".BidMainScreen3"
            android:windowSoftInputMode="adjustPan"/>

        <activity android:name=".SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity android:name=".GSignInActivity"></activity>
        <activity android:name=".PostDetailActivity"></activity>
        <activity android:name=".TopBidsActivity"></activity>
        <activity android:name=".OrdersActivity"></activity>
    </application>

</manifest>


问:
Masking BGR image using a 2D mask
I have a three-dimensional array (image) with shape (480, 640, 3). Here, the 3 refers to BGR color code. I would like to place a mask over this image using the data from the array of the Red image. Depending on its value, certain pixels need to be masked.

Creating the mask works fine. It behaves exactly as expected. In order to apply the mask to the original image, I first apply the mask to the Blue and Green image. All is still fine. Now I stack the three masked arrays, which returns an array with shape (480, 640, 3). However, plotting this array using imshow results in the original image. No sign of any mask.

Below I put my code. The code works for any image size/shape. All you need to do is change the name "Whatever_image_you_like.png" to the name of any image on your pc.

```<code>import numpy
import numpy.ma
import scipy.misc
import matplotlib.pyplot as plt

pixel_value = 130   #Value in range 0 to 255

image = scipy.misc.imread("Whatever_image_you_like.png")

#Extract Blue, Green, and Red image from original image
image_B = numpy.copy(image[:, :, 0])
image_G = numpy.copy(image[:, :, 1])
image_R = numpy.copy(image[:, :, 2])

#Define mask depending on pixel value in Red image
image_mask = numpy.empty([image.shape[0], image.shape[1]], dtype = bool)
image_mask[image_R < pixel_value] = False

#Apply mask to Blue, Green, and Red images
B_masked = numpy.ma.masked_array(image_B, mask = ~image_mask)
G_masked = numpy.ma.masked_array(image_G, mask = ~image_mask)
R_masked = numpy.ma.masked_array(image_R, mask = ~image_mask)

#Stack masked images together again
masked_image = numpy.ma.dstack((B_masked, G_masked, R_masked))

#Plot original image and masked version
fig = plt.figure()

ax1 = fig.add_subplot(2, 1, 1)
ax1.imshow(image)

ax2 = fig.add_subplot(2, 1, 2)
ax2.imshow(masked_image)

plt.show()
</code>```

What am I doing wrong? Is there a better way to approach this problem?

答:
Maybe this alternative approach would be easier in similar cases:</p>

```<code>image[image_mask,:] = np.nan
</code>```

Title: Masking BGR image using a 2D mask

Body:
I have a three-dimensional array (image) with shape (480, 640, 3). Here, the 3 refers to BGR color code. I would like to place a mask over this image using the data from the array of the Red image. Depending on its value, certain pixels need to be masked.

Creating the mask works fine. It behaves exactly as expected. In order to apply the mask to the original image, I first apply the mask to the Blue and Green image. All is still fine. Now I stack the three masked arrays, which returns an array with shape (480, 640, 3). However, plotting this array using imshow results in the original image. No sign of any mask.

Below I put my code. The code works for any image size/shape. All you need to do is change the name "Whatever_image_you_like.png" to the name of any image on your pc.

import numpy
import numpy.ma
import scipy.misc
import matplotlib.pyplot as plt

pixel_value = 130   #Value in range 0 to 255

image = scipy.misc.imread("Whatever_image_you_like.png")

#Extract Blue, Green, and Red image from original image
image_B = numpy.copy(image[:, :, 0])
image_G = numpy.copy(image[:, :, 1])
image_R = numpy.copy(image[:, :, 2])

#Define mask depending on pixel value in Red image
image_mask = numpy.empty([image.shape[0], image.shape[1]], dtype = bool)
image_mask[image_R < pixel_value] = False

#Apply mask to Blue, Green, and Red images
B_masked = numpy.ma.masked_array(image_B, mask = ~image_mask)
G_masked = numpy.ma.masked_array(image_G, mask = ~image_mask)
R_masked = numpy.ma.masked_array(image_R, mask = ~image_mask)

#Stack masked images together again
masked_image = numpy.ma.dstack((B_masked, G_masked, R_masked))

#Plot original image and masked version
fig = plt.figure()

ax1 = fig.add_subplot(2, 1, 1)
ax1.imshow(image)

ax2 = fig.add_subplot(2, 1, 2)
ax2.imshow(masked_image)

plt.show()

What am I doing wrong? Is there a better way to approach this problem?

Body:
Maybe this alternative approach would be easier in similar cases:

image[image_mask,:] = np.nan


问:
Javascript object's prototype property
I have a question about prototype object.

I learned that constructor function has prototype property (not [[prototype]] property) and it indicates prototype object.

ex) If function's name is Person, prototype object's name will be Person.prototype

So I typed this code below.

```<code>function Person(name) {
    this.name = name;
}

var foo = new Person('foo');

console.dir(Person);
</code>```

If my thought is right, Person function's prototype property has to point Person.prototype but actual result is different.

But my book says:

Why is Person.prototype's name 'Object' ??? I don't know why...
My mental is going to be broken...

Someone please answer.. :(

答:
Your Person() function has a prototype property. Person().prototype is called Object because it is indeed an object. In console, it is purely saying that the prototype property is an object.

Because of the constructor name, it displays Person, possibly because the author used a different JavaScript/Browser version, or another version entirely. The 'Object' that you get is normal, and your code should work normally. You can ignore the difference.

A function's prototype property is to  allow you to add properties to your code. Here is an example:

```<code>function Person(name, age, id) {
  this.name = name;
  this.age = age;
  this.id = id;
}

var me = new Person("Brian", 12, 0);
</code>```

Then later on in the code if you want to add a property to the person function, like my favorite programming languages:

```<code>Person.prototype.favLanguages = null;
</code>```

When you want to define my favorite languages you can do:

```<code>me.favLanguages = ['JavaScript', 'Java', 'HTML', 'CSS'];
</code>```

Title: Javascript object's prototype property

Body:
I have a question about prototype object.

I learned that constructor function has prototype property (not [[prototype]] property) and it indicates prototype object.

ex) If function's name is Person, prototype object's name will be Person.prototype

So I typed this code below.

function Person(name) {
    this.name = name;
}

var foo = new Person('foo');

console.dir(Person);

If my thought is right, Person function's prototype property has to point Person.prototype but actual result is different.

But my book says:

Why is Person.prototype's name 'Object' ??? I don't know why...
My mental is going to be broken...

Someone please answer.. :(

Body:
Your Person() function has a prototype property. Person().prototype is called Object because it is indeed an object. In console, it is purely saying that the prototype property is an object.

Because of the constructor name, it displays Person, possibly because the author used a different JavaScript/Browser version, or another version entirely. The 'Object' that you get is normal, and your code should work normally. You can ignore the difference.

A function's prototype property is to  allow you to add properties to your code. Here is an example:

function Person(name, age, id) {
  this.name = name;
  this.age = age;
  this.id = id;
}

var me = new Person("Brian", 12, 0);

Then later on in the code if you want to add a property to the person function, like my favorite programming languages:

Person.prototype.favLanguages = null;

When you want to define my favorite languages you can do:

me.favLanguages = ['JavaScript', 'Java', 'HTML', 'CSS'];


问:
OAuth2 authorization for project and custom project-specific user role
I'm new to OAuth2 and trying to figure out what is the best practice for the following scenario:

I'm implementing 'ToDo' web service (CRUD for 'tasks')

I'm using OAuth2 and Google as auth provider to get user details (email, name)

Now I need to implement project-specific roles for users ('admin', 'user')

Speaking in terms of OAuth2 - Google doesn't 'own' my service, so it cannot help me with storing/providing 'ToDo'-specific roles, is it correct?

What is the common/best approach to implement it, do I need to create my own authorization service where I'll need to store relations like userinfo -> project-specific role?

答:
It is easy for you to setup your own authorization and resource server rather than depending on google services. In your own authentication server you have more control over your roles and users you specify.
You can setup and authentications server using spring boot app and using dependencies like Spring-starter-security, spring-security-oauth2 and etc.</p>


问:
How to implement chart.js in Angular2
I'm using Angular2-rc4 with angular-cli webpack and would like to implement a chart.js library.

I've installed chart.js to my project using:

npm install chart.js --save

Then I've tried to import the chart.js in my component:

```<code>import {Component, OnInit, ViewChild} from '@angular/core';
import 'chart.js/src/chart.js';
declare let Chart;

@Component({
  selector: 'app-dashboard',
  templateUrl: 'dashboard.component.html',
  styleUrls: ['dashboard.component.scss']
})
export class DashboardComponent {

  chart: Chart;

}
</code>```

But I get an error in console log:

```<code>[default] /Applications/MAMP/htdocs/bridge/src/app/dashboard/dashboard.component.ts:12:9
Cannot find name 'Chart'.
</code>```

What am I doing wrong?

答:
In the template don't forget to enclose canvas in a div.
If canvas is a direct child of custom directive in dom, then chart might not load.

```<code><div><canvas id="myChart"></canvas></div>
</code>```

I have wasted lot of time in finding this issue.

Title: How to implement chart.js in Angular2

Body:
I'm using Angular2-rc4 with angular-cli webpack and would like to implement a chart.js library.

I've installed chart.js to my project using:

npm install chart.js --save

Then I've tried to import the chart.js in my component:

import {Component, OnInit, ViewChild} from '@angular/core';
import 'chart.js/src/chart.js';
declare let Chart;

@Component({
  selector: 'app-dashboard',
  templateUrl: 'dashboard.component.html',
  styleUrls: ['dashboard.component.scss']
})
export class DashboardComponent {

  chart: Chart;

}

But I get an error in console log:

[default] /Applications/MAMP/htdocs/bridge/src/app/dashboard/dashboard.component.ts:12:9
Cannot find name 'Chart'.

What am I doing wrong?

Body:
In the template don't forget to enclose canvas in a div.
If canvas is a direct child of custom directive in dom, then chart might not load.

<div><canvas id="myChart"></canvas></div>

I have wasted lot of time in finding this issue.


问:
Error Buidling APK in android studio 2.3.1
I am trying to build an apk for my project in android studio 2.3.1 but I receive the error below:
    Error:Execution failed for task ':Dr_Application:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
  Error while executing java process with main class com.android.dx.command.Main with arguments
  {--dex --num-threads=4 --multi-dex --main-dex-list C:\Users\Nisile\Desktop\Nguvu Kazi New\code\HandyMan\Dr_Application\build\intermediates\multi-dex\debug\maindexlist.txt --output C:\Users\Nisile\Desktop\Nguvu Kazi New\code\HandyMan\Dr_Application\build\intermediates\transforms\dex\debug\folders\1000\1f\main C:\Users\Nisile\Desktop\Nguvu Kazi New\code\HandyMan\Dr_Application\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}

my build.gradle is:

```<code> apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.bluehorntech.drapplication"
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "2g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-Android/master/" }
}
dependencies {
    compile 'com.mcxiaoke.volley:library:1.0.6@aar'
    compile files('libs/httpmime-4.1.3.jar')
    compile 'com.android.support:multidex:1.0.1'
    compile project(':datetimepicker-library')
    compile fileTree(include: ['*.jar'], dir: 'libs')

//    compile files('src/libs/org.apache.http.legacy.jar')
//    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile project(':library')
    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
//    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.google.android.gms:play-services:9.0.0'
    compile 'com.jakewharton:butterknife:5.1.1'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile 'com.google.android.gms:play-services-auth:9.0.0'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.sendbird.sdk:sendbird-android-sdk:3.0.10'
    /*ald*/
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.github.sd6352051.niftydialogeffects:niftydialogeffects:1.0.0@aar'
}
apply plugin: 'com.google.gms.google-services'
</code>```

I read and tried every possible solution from former threads but still cannot resolve my problem. Please help.

答: Use this build and clean project

Body:
I am trying to build an apk for my project in android studio 2.3.1 but I receive the error below:
    Error:Execution failed for task ':Dr_Application:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
  Error while executing java process with main class com.android.dx.command.Main with arguments
  {--dex --num-threads=4 --multi-dex --main-dex-list C:\Users\Nisile\Desktop\Nguvu Kazi New\code\HandyMan\Dr_Application\build\intermediates\multi-dex\debug\maindexlist.txt --output C:\Users\Nisile\Desktop\Nguvu Kazi New\code\HandyMan\Dr_Application\build\intermediates\transforms\dex\debug\folders\1000\1f\main C:\Users\Nisile\Desktop\Nguvu Kazi New\code\HandyMan\Dr_Application\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}

my build.gradle is:

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.bluehorntech.drapplication"
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "2g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-Android/master/" }
}
dependencies {
    compile 'com.mcxiaoke.volley:library:1.0.6@aar'
    compile files('libs/httpmime-4.1.3.jar')
    compile 'com.android.support:multidex:1.0.1'
    compile project(':datetimepicker-library')
    compile fileTree(include: ['*.jar'], dir: 'libs')

//    compile files('src/libs/org.apache.http.legacy.jar')
//    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile project(':library')
    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
//    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.google.android.gms:play-services:9.0.0'
    compile 'com.jakewharton:butterknife:5.1.1'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile 'com.google.android.gms:play-services-auth:9.0.0'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.sendbird.sdk:sendbird-android-sdk:3.0.10'
    /*ald*/
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.github.sd6352051.niftydialogeffects:niftydialogeffects:1.0.0@aar'
}
apply plugin: 'com.google.gms.google-services'

I read and tried every possible solution from former threads but still cannot resolve my problem. Please help.

Body: Use this build and clean project


问:
I am getting Error saying "TypeError: callback is not a function"
Here is my code, I am getting Error saying "callback is undefined" and I am so confused that even though I have sent function as parameter to Search function it is considering it as an undefined.

```<code>    class Tree{
    constructor(){
        this.data;
        this.left;
        this.right;
    }
    Insert(data)
    {
       if(this.data)
       {
         if(this.data<data)
         {
             if(this.right)
             {
               this.right.Insert(data)
             }
             else{
                 this.right=new Tree();
                 this.right.Insert(data)
             }
         }
         else{
              if(this.left)
             {
               this.left.Insert(data)
             }
             else{
                 this.left=new Tree();
                 this.left.Insert(data)
             }
         }
       }
       else{
           this.data=data;
       }
    }
    Display(){
        if(this.left)
        {

            this.left.Display();
        }
        console.log(this.data);
        if(this.right)
        {
            this.right.Display();
        }
    }
    Search(data,callback){

        if(data==this.data)
        {
            console.log("found")
            callback("found")
        }
        else if(data>this.data)
        {
            if(this.right)
            {
                this.right.Search(data);
            }
            else callback("not found")
        }
        else if(data<this.data){
            if(this.left)
            {
                this.left.Search(data);
            }
            else callback("not found")
        }
    }
}

var k =new Tree();
k.Insert(41);
k.Insert(34);
k.Insert(53);
k.Insert(384);
k.Search(34,function (res){
  console.log(res)
});
</code>```

Could you guys help me on this? Many thanks in advance

答:
In search function You call Serach without callback parameter

```<code>Search(data,callback){

    if(data==this.data)
    {
        console.log("found")
        callback("found")
    }
    else if(data>this.data)
    {
        if(this.right)
        {
            this.right.Search(data, callback);
        }
        else callback("not found")
    }
    else if(data<this.data){
        if(this.left)
        {
            this.left.Search(data, callback);
        }
        else callback("not found")
    }
}
</code>```

Body:
Here is my code, I am getting Error saying "callback is undefined" and I am so confused that even though I have sent function as parameter to Search function it is considering it as an undefined.

    class Tree{
    constructor(){
        this.data;
        this.left;
        this.right;
    }
    Insert(data)
    {
       if(this.data)
       {
         if(this.data<data)
         {
             if(this.right)
             {
               this.right.Insert(data)
             }
             else{
                 this.right=new Tree();
                 this.right.Insert(data)
             }
         }
         else{
              if(this.left)
             {
               this.left.Insert(data)
             }
             else{
                 this.left=new Tree();
                 this.left.Insert(data)
             }
         }
       }
       else{
           this.data=data;
       }
    }
    Display(){
        if(this.left)
        {

            this.left.Display();
        }
        console.log(this.data);
        if(this.right)
        {
            this.right.Display();
        }
    }
    Search(data,callback){

        if(data==this.data)
        {
            console.log("found")
            callback("found")
        }
        else if(data>this.data)
        {
            if(this.right)
            {
                this.right.Search(data);
            }
            else callback("not found")
        }
        else if(data<this.data){
            if(this.left)
            {
                this.left.Search(data);
            }
            else callback("not found")
        }
    }
}

var k =new Tree();
k.Insert(41);
k.Insert(34);
k.Insert(53);
k.Insert(384);
k.Search(34,function (res){
  console.log(res)
});

Could you guys help me on this? Many thanks in advance

Body:
In search function You call Serach without callback parameter

Search(data,callback){

    if(data==this.data)
    {
        console.log("found")
        callback("found")
    }
    else if(data>this.data)
    {
        if(this.right)
        {
            this.right.Search(data, callback);
        }
        else callback("not found")
    }
    else if(data<this.data){
        if(this.left)
        {
            this.left.Search(data, callback);
        }
        else callback("not found")
    }
}


问:
Unable to display mathematical equation using mathview in android
I am working on an android app in which I need to display mathematical equations in my app. I have decided to use kexanie mathview library as suggested on stackoverflow but I am not able to understand how to use it.
There was an example given on github and when I copy pasted the code given below. it displays "Webview" instead of the mathematical equation.</p>

```<code><io.github.kexanie.library.MathView
    android:id="@+id/formula_one"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    auto:text="When \\(a \\ne 0\\), there are two solutions to \\(ax^2 + bx + c = 0\\)
    and they are $$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$"
    auto:engine="MathJax"
    >
</io.github.kexanie.library.MathView>
</code>```

答:
You need to add dependencies to build.gradle file :

```<code>dependencies {
    compile 'io.github.kexanie.library:MathView:0.0.6'
}
</code>```

Read more here.

Body:
I am working on an android app in which I need to display mathematical equations in my app. I have decided to use kexanie mathview library as suggested on stackoverflow but I am not able to understand how to use it.
There was an example given on github and when I copy pasted the code given below. it displays "Webview" instead of the mathematical equation.

<io.github.kexanie.library.MathView
    android:id="@+id/formula_one"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    auto:text="When \\(a \\ne 0\\), there are two solutions to \\(ax^2 + bx + c = 0\\)
    and they are $$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$"
    auto:engine="MathJax"
    >
</io.github.kexanie.library.MathView>

Body:
You need to add dependencies to build.gradle file :

dependencies {
    compile 'io.github.kexanie.library:MathView:0.0.6'
}

Read more here.


问:
Concatenate number with string in Swift
I need to concatenate a String and Int as below:

```<code>let myVariable: Int = 8
return "first " + myVariable
</code>```

But it does not compile, with the error:

Binary operator '+' cannot be applied to operands of type 'String' and 'Int'

What is the proper way to concatenate a String + Int?

答:
Optional keyword would appear when you have marked variable as optional with ! during declaration.

To avoid Optional keyword in the print output, you have two options:

Mark the optional variable as non-optional. For this, you will have
to give default value.

Use force unwrap (!) symbol, next to variable

In your case, this would work just fine

return "first \(myVariable!)"

ContentLicense: CC BY-SA 4.0

Title: Concatenate number with string in Swift

Body:
I need to concatenate a String and Int as below:

let myVariable: Int = 8
return "first " + myVariable

But it does not compile, with the error:

Binary operator '+' cannot be applied to operands of type 'String' and 'Int'

What is the proper way to concatenate a String + Int?