I have an application using SpriteKit. I made a simple transition using a SKEffectNode which has a CIFilter, which I apply a setValue to change the filter's parameters on every update according to some function.

This worked perfectly fine on iOS 9 and before I upgraded to Swift 3, although I don't think the Swift version has anything to do with it.

Now, I get a frame with the first parameter value, which persists until the final parameter value. What has changed from iOS 9 to iOS 10 here?

I am developing iBeacon-based ios Apps, I want to let didExitRegion got fired in the background when iBeacon is out the region. But I found that it takes about 20-40s seconds to fire didExitRegion method, but I want this method fired immediately. I also noticed didEnterRegion takes only a few seconds to fire. What is controlling the delay of firing these two methods, can I adjust this delay?

I have a tableview of data to be shown in the app. For that, I should hit an API first, which will give me the list of data. Then, I have to hit another api for each individual cell to get another piece of data i need to display it in the tableview for each cell. I have used Alamofire and am done with getting the data from the first API. But, am stuck with how to get the data for each individual cell record from the second API. 1. Should I do the second request synchronously. 2. Also, there are 1000 of cell data from the first API. So, before rendering the UI how will I do 1000 of requests to get data from the Second API.

Please help.

I am trying to find a way to do the following for a given View (call it X, think of it as a button with activated/unactivated states) that is represented in two separate activities:

Starting in a fragment( with RecyclerView) that is hosted in Activity A:

  1. Open Activity B
  2. Change the activation state of X
  3. Return to Activity A
  4. Reflect the changes made (i.e. update the appearance of X) without reloading the entire fragment/recyclerview or losing the scroll position.

Is this possible?

I tried updating the recyclerview's data set and calling notifyItemChanged but this did not update the appearance/state of the recyclerview element. I had to reset the entire adapter for changes to be reflected.

Here's the onBindViewHolder (excess code cut out)

 @Override
    public void onBindViewHolder(CardViewHolder holder, int position){

        String likes = recipez[position].getLikes();

        holder.bindCard(likes);
    }

and here's where its view would be updated (excess code cut out)

public void bindCard(String likes) {

    if(likes.equals("1")){
        mLikeButtonThumb.setImageResource(R.drawable.thumb_up);
    }

    }

Thank you kindly for your time.

My android project works on my personal laptop but not on office laptop as it has restrictions to download any dependencies from studio, how can copy the dependencies form my personal laptop to office to make it run without my office laptop being connected to internet

I'm messing around with a new 5Ghz WiFi AP here and I'm having some trouble settling on an appropriate channel to use

The issue is that my Android tablet and my Windows PC each support their own selection of 5Ghz channels... in other words, a channel that works on one device, isn't supported by the other

Without clicking through each channel on the AP and checking if my devices support it - are there any known methods for displaying the list of supported channels on a Windows or Android device?


Some H/W details:

  • PC: Acer Travelmate P253, running W10 64-bit with an Atheros AR5BWB222 WiFi card
  • Tablet: Samsung Note 10.1 running Android KitKat 4.4.2


Thanks

Here is the LoginPage.java

package com.example.stormy.greenfrogcafe;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.firebase.ui.auth.AuthUI;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.appindexing.Thing;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.api.client.googleapis.util.Utils;
import com.google.firebase.auth.AuthResult;
import com.firebase.ui.auth.AuthUI;
import com.google.firebase.auth.FirebaseAuth;

import static android.R.string.ok;
import static com.example.stormy.greenfrogcafe.R.id.password;
import static com.example.stormy.greenfrogcafe.R.id.saveLoginCheckBox;

public abstract class LoginPage extends AppCompatActivity implements OnClickListener {


    private EditText etEmailUser;
    private EditText etPassword;
    private Button bLogin;
    private TextView tvRegisterHere;
    private CheckBox btRememberME;
    private Button bForgotpassword;
    private FirebaseAuth mAuth;
    private  FirebaseAuth.AuthStateListener mAuthListener;
    private static final int RC_SIGN_IN = 0;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;
    private SharedPreferences loginPreferences;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        FirebaseAuth auth = FirebaseAuth.getInstance();
        if (auth.getCurrentUser() != null) {
            //user already logged in

        } else {

            startActivityForResult(AuthUI.getInstance()
                    .createSignInIntentBuilder()
                    .setProviders(
                            AuthUI.FACEBOOK_PROVIDER)
                    .build(), RC_SIGN_IN);


            mAuth = FirebaseAuth.getInstance();

            EditText etEmail = (EditText) findViewById(R.id.etEmailUser);
            EditText etPassword = (EditText) findViewById(R.id.etPassword);
            CheckBox saveLoginCheckBox;
            final TextView registerLink = (TextView) findViewById(R.id.tvRegisterHere);

            registerLink.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent registerIntent = new Intent(LoginPage.this, register.class);
                    LoginPage.this.startActivity(registerIntent);
                }
            });


            Button bLogin = (Button) findViewById(R.id.bLogin);

            mAuthListener = new FirebaseAuth.AuthStateListener() {
                @Override
                public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {

                    if (firebaseAuth.getCurrentUser() != null) {

                        startActivity(new Intent(LoginPage.this, HybridActivity.class));
                    }

                }

            };

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

                    startSignIn();


                }
            });

            // ATTENTION: This was auto-generated to implement the App Indexing API.
            // See https://g.co/AppIndexing/AndroidStudio for more information.
            client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
        }
    }

    public void startSignIn() {

        String email = etEmailUser.getText().toString();
        String password = etPassword.getText().toString();

        if (TextUtils.isEmpty(email) || TextUtils.isEmpty(password)) {


        } else {
            mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        Toast.makeText(LoginPage.this, "Sign in problem", Toast.LENGTH_LONG).show();
                    }
                }
            });

        }

    }
    public Action getIndexApiAction() {
        Thing object = new Thing.Builder()
                .setName("LoginPage Page") // TODO: Define a title for the content shown.
                // TODO: Make sure this auto-generated URL is correct.
                .setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
                .build();
        return new Action.Builder(Action.TYPE_VIEW)
                .setObject(object)
                .setActionStatus(Action.STATUS_TYPE_COMPLETED)
                .build();
    }

    @Override
    public void onStart() {
        super.onStart();

        mAuth.addAuthStateListener(mAuthListener);

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        AppIndex.AppIndexApi.start(client, getIndexApiAction());
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        AppIndex.AppIndexApi.end(client, getIndexApiAction());
        client.disconnect();
    }
}

Here is the XML file. I cannot seem to find any tutorial on this website https://www.firebase.com/docs/web/api/firebase/resetpassword.html to make the checkbox, forgot password button and sign in with Facebook button work after my Spashscreen class is loaded. Is there something wrong with my coding?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.stormy.greenfrogcafe.LoginPage">


    <Button
        android:text="Forgot Password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/bForgotpassword"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srcCompat="@drawable/frog"
        android:layout_centerHorizontal="true"
        android:id="@+id/imageView3"
        android:layout_above="@+id/etEmailUser"
        android:layout_alignParentTop="true" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress"
        android:ems="10"
        android:id="@+id/etEmailUser"
        android:hint="email "
        android:layout_above="@+id/login_button"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="144dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <com.facebook.login.widget.LoginButton
        android:id="@+id/login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="27dp"
        android:layout_above="@+id/bForgotpassword"
        android:layout_centerHorizontal="true" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:ems="10"
        android:id="@+id/etPassword"
        android:hint="password"
        android:layout_below="@+id/imageView3"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="46dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <Button
        android:text="Login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/bLogin"
        android:layout_below="@+id/etPassword"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:text="Register Here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tvRegisterHere"
        android:layout_below="@+id/bLogin"
        android:layout_toRightOf="@+id/btRememberMe"
        android:layout_toEndOf="@+id/btRememberMe"
        android:layout_marginLeft="28dp"
        android:layout_marginStart="28dp" />

    <CheckBox
        android:text="Remember Me"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btRememberMe"
        android:textSize="10sp"
        android:checked="true"
        android:layout_below="@+id/bLogin"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

I try use this code but it works when i click on item of list view. I want to change all text size in different class. Here is the code that i used:

Setting.class

 

Text_Size.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            int txtSize=0;
            switch (checkedId)
            {
                case R.id.small:
                    txtSize=15;
                    break;
                case R.id.medium:
                    txtSize=20;
                    break;
                case R.id.big:
                    txtSize=30;
                    break;
                default:
                    break;
            }
                Setting.this.getSharedPreferences("MY_SHARED",0).edit().putInt("FONT_SIZE",txtSize).commit();
        }
});

fragment.class


@Override
public void onResume() {
    super.onResume();
    title.setTextSize(getActivity().getSharedPreferences("MY_SHARED",0).getInt("FONT_SIZE",20));
    ADAPTER_OF_YOUR_LISTVIEW.notifyAll();
}

I want to accommodate for older Android versions (say 17 to 20) with specific style specs. So I made these:

  • values/styles.xml (what I think should be the default)
  • values-v17/styles.xml
  • values-v18/styles.xml
  • values-v19/styles.xml
  • values-v20/styles.xml

In my values/styles.xml file I keep the default for versions 21+. However, the style that's actually applied in both the preview and the virtual device is that of v20, for display versions 21 and up. If I erase values-v20/styles.xml then it's the next one down the line, v19, that takes over. Why isn't the default style taking over?

Simple example:

values-v20/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Button.AccentButton" parent="Theme.AppCompat">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:background">@color/red</item>
    </style>
</resources>

values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Button.AccentButton" parent="Theme.AppCompat">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:background">@color/green</item>
    </style>
</resources>

Final result: v21+ button shows red, should be green.

Right now this is how I am assigning / using callback listeners:

public class SomeDialogFragment extends DialogFragment {

    private static final String ARGUMENT_TOY = "argument_toy";
    private Toy toy;
    private ToyClicker toyClickListener;

    public interface ToyClicker {
        void doSomething(Toy toy);
    }

    public static SomeDialogFragment newInstance(Toy toy) {
        Bundle args = new Bundle();
        SomeDialogFragment fragment = new SomeDialogFragment();
        args.putParcelable(ARGUMENT_TOY, toy);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Fragment parentFragment = getParentFragment();
        if (parentFragment != null) {
            toyClickListener = (ToyClicker) parentFragment;
        }
        else {
            toyClickListener = (ToyClicker) context;
        }
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        toy = getArguments().getParcelable(ARGUMENT_TOY);
        //random stuff
        //somewhere, a call to toyClickListener.doSomething(toy);
    }
}

So in this case, if we're in an Activity we can instantiate SomeDialogFragment and it will assign the listener to the Activity's context, so we implement void doSomething(Toy toy) in that Activity.

But if we're instead in a Fragment and we instantiate SomeDialogFragment from there directly, then it will assign the listener to the Fragment instead of the base Activity's context, so we implement void doSomething(Toy toy) in the Fragment.

But is there a way to better control this? Because I imagine a scenario where we have a deep chain of nested Fragments. For example:

MainActivity -> FragmentA -> FragmentB -> FragmentC -> SomeDialogFragment

How would I do the following:

  1. Let's say I want to implement void doSomething(Toy toy) in MainActivity. How would I be able to pass this context (which would be in the form of ToyClicker) all the way through the chain of Fragments so that I can trigger the callback in SomeDialogFragment? (I am guessing that it would just be the context in onAttach() no matter how deep we go?)

  2. Let's say I want to implement void doSomething(Toy toy) in FragmentA instead. How can I pass that specific Fragment (which would be in the form of ToyClicker, again) all the way through to SomeFragment? (no idea)

  3. How about implementing it in FragmentB? (no idea)

  4. FragmentC? (I think this would be targeted by using getParentFragment())

It doesn't seem possible for me to be able to pass these thing as arguments to newInstance() because I have no way to store them in the Bundle of args.

So how can I pass these listeners through and target the correct areas?

I am creating an app where bubbles bounce around the screen and you get points for popping them and then they re-spawn.

Each bubble is exactly identical except for the speed and direction integers used to control their motion around the screen.

As of now I have a single imageview called bubble. Then I run the method randoms() which i created.

Code for randoms()

    public void randoms(){

        ySpeedRand = new Random();
        xSpeedRand = new Random();
        yPolarityRand = new Random();
        xPolarityRand = new Random();

        ySpeed = ySpeedRand.nextInt(5) + 4;
        xSpeed = xSpeedRand.nextInt(5) + 4;
        yPolarity = yPolarityRand.nextInt(3) + 1;
        xPolarity = xPolarityRand.nextInt(3) + 1;

        if (xPolarity == 1){
            xSpeed*=-1;
        }
        if (yPolarity == 2){
            ySpeed*=-1;
        }

    }

Then i have a listener to check when the bubble is tapped and then i make it invisible, rerun the randoms() block and then make it visible.

This is the handler that controls the position of the bubbles.

final Handler handler = new Handler();
    Runnable run = new Runnable() {
        @Override
        public void run() {

            bubble.setX(bubble.getX()+xSpeed);
            bubble.setY(bubble.getY()+ySpeed);
            handler.postDelayed(this, 5);

        }
    };handler.post(run);

And i use this code to check if the bubble is still on the screen.

        final Handler checkHandler = new Handler();
        Runnable check = new Runnable() {
            @Override
            public void run() {

                if (bubble.getX()>SCREEN_WIDTH-bubble.getWidth()/2){xSpeed*=-1;}
                if (bubble.getX()<0){xSpeed*=-1;}
                if (bubble.getY()>SCREEN_HEIGHT-bubble.getHeight()){ySpeed*=-1;}
                if (bubble.getY()<bubble.getHeight()/2+barHeight+actionBorder.getHeight()){ySpeed*=-1;}

                handler.postDelayed(this, 50);

            }
        };checkHandler.post(check);

Is there an easy way to simply expand this system so I can call a method createbubble() and then have the new bubbles assume the exact propertes as the old ones, but with newly generated randoms?

I am 100% stuck and I cant find anything. Any help is extremely appreciated!

-Kelton

MainActivity Class:

/* all necessary imports */

public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    /* Other variable initialized here... */
    FragOne fo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        fo.setTextViewText("This is added from Activity");

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

        viewPager = (ViewPager) findViewById(R.id.viewpager);
        setupViewPager(viewPager);

        tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(viewPager);
    }


    private void setupViewPager(ViewPager viewPager) {
        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
        adapter.addFragment(new FragOne(), "My Tracker");
        adapter.addFragment(new FragTwo(), "Team Tracker");
        viewPager.setAdapter(adapter);
    }

    class ViewPagerAdapter extends FragmentPagerAdapter {
        private final List<Fragment> mFragmentList = new ArrayList<>();
        private final List<String> mFragmentTitleList = new ArrayList<>();

        public ViewPagerAdapter(FragmentManager manager) {
            super(manager);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }

        public void addFragment(Fragment fragment, String title) {
            mFragmentList.add(fragment);
            mFragmentTitleList.add(title);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mFragmentTitleList.get(position);
        }
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();

        if (id == R.id.nav_manage) {

        } else if (id == R.id.nav_share) {

        } else if (id == R.id.nav_send) {

        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
}

Fragment Class:

/* all necessary imports */
public class FragOne extends Fragment {

    TextView tvCName;

    public FragOne() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_frag_one, container, false);

        return view;
        //return inflater.inflate(R.layout.fragment_frag_one, container, false);
    }

    @Override
    public void onViewCreated(View view , Bundle savedInstanceState) {
        tvCName = (TextView) view.findViewById(R.id.tvctq);
    }

    public void setTextViewText(String value){
        tvCName.setText(value);
    }

}

Fragment XML Layout:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.mytip.FragOne">

        <TextView
            android:text="TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/tvctq" />
</FrameLayout>

I am trying to access the TextView inside the Fragment from MainActivity like this:

FragOne fo;
fo.setTextViewText("This is added from Activity");

I keep getting a NullPointerExceptionError. I looked at all the articles to see how to access, however none of them helped me.

Can someone please let me know what am I doing wrong and how to fix it?

I also plan on adding other Views inside my Fragment that I would need to access in the future.

I have HomeActivity contain recyclerView show data load from Firebase, but when click items and back HomeActivity then app reload data from Firebase. I want holder data when back HomeActivity (list data put into CustomAdapter).

I want to use its various methods like setRequestMethod, setRequestProperty

Here is the piece of code which I need to implement it using glide library instead of async task

Thanks in advance.

public class ImageLoadingAsyncTask extends AsyncTask { Bitmap bmp;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pb_imageProgressBar.setVisibility(VISIBLE);
    }

    @Override
    protected Void doInBackground(Integer... integers) {

        String url = PrefManager.getInstanceUrl()
                + "clients/"
                + integers[0]
                + "/images?maxHeight=120&maxWidth=120";
        Log.d("ashu",url);
        try {
            HttpURLConnection httpURLConnection = (HttpURLConnection) (new URL(url))
                    .openConnection();
            httpURLConnection.setRequestMethod("GET");
            httpURLConnection.setRequestProperty(MifosInterceptor.HEADER_TENANT,
                    "default");
            httpURLConnection.setRequestProperty(MifosInterceptor.HEADER_AUTH,
                    PrefManager.getToken());
            httpURLConnection.setRequestProperty("Accept", "application/octet-stream");
            httpURLConnection.setDoInput(true);
            httpURLConnection.connect();
            InputStream inputStream = httpURLConnection.getInputStream();
            bmp = BitmapFactory.decodeStream(inputStream);
            httpURLConnection.disconnect();
        } catch (MalformedURLException e) {
        } catch (IOException ioe) {
        }
        return null;
    }


    @Override
    protected void onPostExecute(Void aVoid) {
        if (bmp != null) {
            iv_clientImage.setImageBitmap(bmp);
        } else {
            iv_clientImage.setImageDrawable(
                    ContextCompat.getDrawable(getActivity(), R.drawable.ic_launcher));
            pb_imageProgressBar.setVisibility(GONE);
        }

    }
}

After upgrading to Android gradle plugin 2.2.0 (and Android Studio 2.2) I've been having trouble reading from a zip file which is located at app/src/main/assets/magic_info.zip It used to work fine with plugin versions 2.1.3 and prior but now it throws the following exception

java.io.FileNotFoundException: magic_info.zip
 at android.content.res.AssetManager.openAsset(Native Method)
 at android.content.res.AssetManager.open(AssetManager.java:334)
 at android.content.res.AssetManager.open(AssetManager.java:308)

for some reason it can't find the file from assets which is otherwise there.

Here is my code that used to work in the past.

   public static ZipInputStream getZipInputStream(Context context)
{
    try
    {
        return new ZipInputStream(context.getAssets().open("magic_info.zip"));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    return null;
}

Any idea what's wrong with this? Am I missing something?

I'm writing my code using Xamarin. I'm developing my IOS app which allows me to read the BLE devices, Services , characteristic value and activation of the notification.

My BLE beacon have one custom Services that contain two custom characteristics and both have the notification implemented using CCCD.

My ble devices work correctly I test it with BLE scanner app and it working well without any problem. I can read value and I can active the notification for both characteristic. above a picture:

enter image description here

The app that I wrote using xamarin work correctly (reading services, characteristic value....) the only problem that didn't work is the activation of the notification. Here's a portion of the code :

    public UUID Charac_UUID0 = UUID.FromString("0000beef-1212-efde-1523-785fef13d123");
        public UUID Charac_UUID = UUID.FromString("0000b1e0-1212-efde-1523-785fef13d123") ;
        public UUID Descr_UUID =  UUID.FromString("00002902-1212-efde-1523-785fef13d123");
        protected BluetoothGattCharacteristic _charac ;
…....
…....

        this._charac = App.Current.State.SelectedService.GetCharacteristic(Charac_UUID0);
 BluetoothLEManager.Current.ConnectedDevices[App.Current.State.SelectedDevice].SetCharacteristicNotification(_charac, true);

            BluetoothGattDescriptor descriptor = _charac.GetDescriptor(Descr_UUID0);

            descriptor.SetValue(BluetoothGattDescriptor.EnableNotificationValue.ToArray());
            BluetoothLEManager.Current.ConnectedDevices[App.Current.State.SelectedDevice].WriteDescriptor(descriptor);

the code always give me an error at descriptor.SetValue and it indicate me that the descriptor is NULL meaning that _charac.GetDescriptor didn't return any value.

I suspect the Descriptor UUID value (Descr_UUID) is not correct. I don't know excatly how can I determine the Descr_UUID but I saw many example in the internet of people replacing the custom Uuid of the caracteristic by 2902 which give me in my case a 128 descriptor Uuid equal to 00002902-1212-efde-1523-785fef13d123.

But there is a problem here. The descriptor Uuid for both characteristic will be the same because the base Uuid is the same for both characteristic ?

Any solution ?

I managed to disable bouncing effect when user scrolls to the top. I would like to reverse it somehow so that the bouncing effect is disabled on the bottom. Could you help me with modifying my code for that purpose?

var lastY: CGFloat = 0.0

func scrollViewDidScroll(scrollView: UIScrollView) {
    let currentY = scrollView.contentOffset.y
    let currentBottomY = scrollView.frame.size.height + currentY
    if currentY > lastY {
        //"scrolling down"
        tableView.bounces = true
    } else {
        //"scrolling up"
        // Check that we are not in bottom bounce
        if currentBottomY < scrollView.contentSize.height + scrollView.contentInset.bottom {
            tableView.bounces = false
        }
    }
    lastY = scrollView.contentOffset.y
}

The Microsoft Azure Management portal has been very slow for me and a lot of my colleges. In order to cut costs I turn off (delocated) my development VMs when not in use. I also do use automation for my productions servers, but the development machines are not always used during business hours.

Would it be possible to write an asp.net core or even a 4.5 mvc web application to start and stop the Azure virtual machines? I use powershell, but that does not work for everyone and if someone runs a bad command it could really create a problem for us. Preferably I would like to run this on an Azure App Service to isolate it from my network.

I want to do an application that test a java code sent by users. I explain:

The application would ask the user to programm a method who receive some arguments and return something. My program have to test this java source code and find if it he return what is expected. I think something like:

  • The program have to compile the code (how?)
  • The code has to pass some unit test that I will programm for this method or class.
  • I have to catch the response of the unit test.

Is there possible? Have you some another idea to do this task?

Thanks for your help

From Kelvin Murphy's review on Algorithms (4th Edition) by Sedgewick and Wayne

For data structures, it is obviously natural to use classes, but they also adopt this approach for many algorithms, esp. graph processing ones. This allows the algo to do pre-processing and to store internal state, and then to provide a service to the caller. This is more general than the standard stateless functional view of algorithms.

  • What does the "stateless functional view of algorithms" mean?

  • The views I have read from some algorithm books are based on states of objects. So I think that the standard view of algorithms are based on states, correct?

Thanks.

This is for a CCU programming class that I am in:

What drew you to programming? How long have you been programming? What types of software development projects have you worked on? What are the greatest rewards of programming? What are the greatest challenges of programming? What advice would you give to an upcoming programmer?