Example usage for android.util Log wtf

List of usage examples for android.util Log wtf

Introduction

In this page you can find the example usage for android.util Log wtf.

Prototype

public static int wtf(String tag, Throwable tr) 

Source Link

Document

What a Terrible Failure: Report an exception that should never happen.

Usage

From source file:im.ene.lab.design.widget.coverflow.FeatureCoverFlow.java

@Override
protected void fillFirstTime(final int lastItemPos, final int firstItemPos) {
    final int leftScreenEdge = 0;
    final int rightScreenEdge = leftScreenEdge + getWidth();

    int right;/*  w  ww. ja  v a 2  s  .  c  om*/
    int left;
    View child;

    boolean isRepeatingNow = false;

    //scrolling is enabled until we find out we don't have enough items
    isSrollingDisabled = false;

    mLastItemPosition = lastItemPos;
    mFirstItemPosition = firstItemPos;
    mLeftChildEdge = (int) (-mCoverWidth * mSpacing);
    right = 0;
    left = mLeftChildEdge;

    while (right < rightScreenEdge) {
        mLastItemPosition++;

        if (isRepeatingNow && mLastItemPosition >= firstItemPos)
            return;

        if (mLastItemPosition >= mAdapter.getCount()) {
            if (firstItemPos == 0 && shouldRepeat)
                mLastItemPosition = 0;
            else {
                if (firstItemPos > 0) {
                    mLastItemPosition = 0;
                    isRepeatingNow = true;
                } else if (!shouldRepeat) {
                    mLastItemPosition--;
                    isSrollingDisabled = true;
                    final int w = right - mLeftChildEdge;
                    final int dx = (getWidth() - w) / 2;
                    scrollTo(-dx, 0);
                    return;
                }

            }
        }

        if (mLastItemPosition >= mAdapter.getCount()) {
            Log.wtf("EndlessLoop", "mLastItemPosition > mAdapter.getCount()");
            return;
        }

        child = mAdapter.getView(mLastItemPosition, getCachedView(), this);
        Validate.notNull(child, "Your adapter has returned null from getView.");
        child = addAndMeasureChildHorizontal(child, LAYOUT_MODE_AFTER);
        left = layoutChildHorizontal(child, left, (LayoutParams) child.getLayoutParams());
        right = child.getRight();

        //if selected view is going to screen, set selected state on him
        if (mLastItemPosition == mSelectedPosition) {
            child.setSelected(true);
        }

    }

    if (mScrollPositionIfEndless > 0) {
        final int p = mScrollPositionIfEndless;
        mScrollPositionIfEndless = -1;
        removeAllViewsInLayout();
        refillOnChange(p);
    }
}

From source file:com.android.dialer.DialtactsFragment.java

@Override
public void onClick(View view) {
    int i = view.getId();
    if (i == R.id.floating_action_button) {//                if (mListsFragment.getCurrentTabIndex()
        //                        == ListsFragment.TAB_INDEX_ALL_CONTACTS && !mInRegularSearch) {
        //                    DialerUtils.startActivityWithErrorToast(
        //                            this,
        //                            IntentUtil.getNewContactIntent(),
        //                            R.string.add_contact_not_available);
        //                } else if (!mIsDialpadShown) {
        //                    mInCallDialpadUp = false;
        //                    showDialpadFragment(true);
        //                }
        Log.d(TAG, " onClic mIsDialpadShown " + mIsDialpadShown);
        if (!mIsDialpadShown) {
            mInCallDialpadUp = false;/* w  ww .java 2  s.com*/
            showDialpadFragment(true);
        }

    } else if (i == R.id.voice_search_button) {
        try {
            startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),
                    ACTIVITY_REQUEST_CODE_VOICE_SEARCH);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(DialtactsFragment.this.getContext(), R.string.voice_search_not_available,
                    Toast.LENGTH_SHORT).show();
        }

    } else if (i == R.id.dialtacts_options_menu_button) {
        mOverflowMenu.show();

    } else if (i == R.id.dialtacts_bottom_menu_button_call) {
        if (!mIsDialpadShown) {
            mInCallDialpadUp = false;
            showDialpadFragment(true);
        } else {
            if (TextUtils.isEmpty(mSearchQuery)
                    || (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()
                            && mSmartDialSearchFragment.getAdapter().getCount() == 0)) {
                exitSearchUi();
            }
            hideDialpadFragment(true, true);
        }

    } else if (i == R.id.actionbar_menu) {
        initCallLogSelectPopupWindow();
        Log.e(TAG, " onClick actionbar_menu");

    } else if (i == R.id.actionbar_name) {
        initCallLogSelectPopupWindow();
        Log.e(TAG, " ---- onClick actionbarName ----");

    } else if (i == R.id.actionbar_call_dialtacts_action_editer) {
        StringBuilder sb = new StringBuilder("");
        if (mDialtactsActionBarController.getEditerText()
                .equals(getResources().getString(R.string.call_detail_editer))) {
            showMultipleEditer();
            mDialtactsActionBarController.setEditerTxt(getString(R.string.call_delete_select_all));
        } else if (mDialtactsActionBarController.getEditerText()
                .equals(getResources().getString(R.string.call_delete_select_all))) {
            mCalllogList.allSelectLog(true);
            mDialtactsActionBarController.setEditerTxt(getString(R.string.call_delete_cansel_all));
            sb.append(mCalllogList.getSelectLogCount()).append("?");
            mDialtactsActionBarController.setActionName(new String(sb));
        } else if (mDialtactsActionBarController.getEditerText()
                .equals(getResources().getString(R.string.call_delete_cansel_all))) {
            mCalllogList.allSelectLog(false);
            mDialtactsActionBarController.setEditerTxt(getString(R.string.call_delete_select_all));
            mDialtactsActionBarController.setActionName(getString(R.string.select_call_log));
        }
        mFloatingActionButtonController.setVisible(false);
        mCalllogList.setmSelectCallLogImpl(mSeletectCallLogImpl);

    } else if (i == R.id.actionbar_call_dialtacts_action_cancel) {
        hideMultipleEditer();

    } else if (i == R.id.dialtacts_bottom_menu_button_delete) {
        processDeleteBtn();
    } else {
        Log.wtf(TAG, "Unexpected onClick event from " + view);
    }
}

From source file:com.example.android.recyclingbanks.MainActivity.java

@Override
public void onMapReady(GoogleMap googleMap) {
    mapReady = true;/*  w w w.  ja v  a  2  s.  c  o m*/
    m_map = googleMap;

    //        if (!usesGPS) {
    //            getDataLoaderGoing();
    //        }

    Log.i("!!!!!!onMapReady: ", "should have location permission");
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    m_map.setMyLocationEnabled(true);

    //check if using user defined home location, or gps
    if (!usesGPS) {
        Log.i("onMapReady",
                "user lat: " + String.valueOf(mUserLatitude) + ", user lon:" + String.valueOf(mUserLatitude));
        LatLng manualHomeLatLng = new LatLng(mUserLatitude, mUserLongitude);
        makeHomeMarker(manualHomeLatLng);
        // now move the camera
        cameraPosition = new CameraPosition.Builder().target(manualHomeLatLng).zoom(14).bearing(0).tilt(0)
                .build();
        m_map.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    } else if (cameraPosition != null) {
        // in this instance we're waiting for GPS, so just resume the last cameraPos
        m_map.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        Log.wtf("onMapReady", "moving camera to old Pos");
        Toast.makeText(this, "resuming from last location", Toast.LENGTH_SHORT);
        //cameraPosition = null;
    }
    Log.wtf("onMapReady", "cameraPos: " + String.valueOf(cameraPosition));
    //setupMap();

    // center on present location zoomed in
    //Location userLocation = getMyLocation();
    //LatLng userCoords = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());

    //        LatLng edinburgh = new LatLng(55.948611, -3.199935);
    //        CameraPosition target = CameraPosition.builder().target(edinburgh).zoom(14).build();
    //        m_map.moveCamera(CameraUpdateFactory.newCameraPosition(target));
}

From source file:com.example.android.recyclingbanks.MainActivity.java

/**
 * Runs when a GoogleApiClient object successfully connects.  (for obtaining user gps
 *///from   w ww  .  j a  va 2 s .  c  om
@Override
public void onConnected(@Nullable Bundle bundle) {
    Log.i("onConnected", "connected to apiClient");
    // TODO fix asking for permissions here.
    // Provides a simple way of getting a device's location and is well suited for
    // applications that do not require a fine-grained location and that do not need location
    // updates. Gets the best and most recent location currently available, which may be null
    // in rare cases when a location is not available.

    //TODO need to check if I activate usesGPS in settings, that when returning it will use GPS,
    // TODO or whether this isn't called on Activity resume.
    Boolean usesGPS = mSharedPrefs.getBoolean("usesGPS", false);
    Log.wtf("onConnected", "contain usesGPS key? " + String.valueOf(mSharedPrefs.contains("usesGPS")));
    Log.wtf("onConnected", "all prefs: " + String.valueOf(mSharedPrefs.getAll()));
    //check if using user defined home location, or gps
    if (usesGPS == false) {
        Log.wtf("onConnected", "using gps? " + String.valueOf(usesGPS));
        // TODO need to make sure this happens!  Doesn't just goto EDINBURGH
        return;
    }
    Log.i("onConnected", "using GPS, seeking address");
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            && ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);

    if (mLastLocation != null) {
        mUserLatitude = mLastLocation.getLatitude();
        mUserLongitude = mLastLocation.getLongitude();
        mUserLatLng = new LatLng(mUserLatitude, mUserLongitude);
        Log.i("onConnected", "got gps, now fetching String of street");

        // Determine whether a Geocoder is available to get the address from mLastLocation.
        if (Geocoder.isPresent()) {
            fetchAddress();
        } else {
            Toast.makeText(this, R.string.no_geocoder_available, Toast.LENGTH_SHORT).show();
        }
    } else {
        Log.wtf("onConnected", "lastLocation = null, huh?");
        // no gps, skip to address screen for user to enter their address
        Toast.makeText(this, "no location detected\nenter mannually", Toast.LENGTH_SHORT).show();
        // gps unavailable, change setting to not try for it
        preferences.edit().putBoolean("usesGPS", false);
        Intent settingsIntent = new Intent(this, SettingsActivity.class);
        // pass the geocoded home address through, for display as summary
        settingsIntent.putExtra("userAddress", mAddressOutput);
        startActivity(settingsIntent);
        //mUserLatLng = EDINBURGH; // co-ords of Edinburgh city center
    }
    // need to get data for the map
    Log.i("onConnected", "got gps, now getting markers with loader");
    getDataLoaderGoing();
    // TODO is this needed here?  Is it being repeated elsewhere?
    mUserLatLng = new LatLng(mUserLatitude, mUserLongitude);
    cameraPosition = new CameraPosition.Builder().target(mUserLatLng).zoom(14).bearing(0).tilt(0).build();
    Log.wtf("onConnected", "cameraPos: " + String.valueOf(cameraPosition));
    m_map.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    makeHomeMarker(mUserLatLng);
}

From source file:com.example.android.recyclingbanks.MainActivity.java

@Override
public void onInfoWindowClick(Marker marker) {
    Log.wtf("onInfoWindowClick", marker.getSnippet() + " clicked!");
    Toast.makeText(this, marker.getSnippet() + " clicked!", Toast.LENGTH_SHORT);
    Intent intent = new Intent(this, StreetViewFragment.class);

    // to transfer over LatLng of bank we need this:
    Bundle args = new Bundle();
    args.putParcelable("bankLatLng", marker.getPosition());
    intent.putExtra("bundle", args);

    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);//from   ww  w  .j a va 2  s  . c  om
    }
}

From source file:com.example.android.recyclingbanks.MainActivity.java

private View prepareInfoView(final Marker marker) {
    // TODO change this to xml?
    //prepare InfoView programmatically
    final LinearLayout infoView = new LinearLayout(MainActivity.this);
    LinearLayout.LayoutParams infoViewParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    infoView.setOrientation(LinearLayout.VERTICAL);
    // attach the above layout to the infoView
    infoView.setLayoutParams(infoViewParams);

    String markerLongitude = Double.toString(marker.getPosition().longitude);
    String markerLatitude = Double.toString(marker.getPosition().latitude);

    final String imageURL = "https://maps.googleapis.com/maps/api/streetview?size=" + "500x300&location="
            + markerLatitude + "," + markerLongitude + "&fov=120&heading=0&pitch=0";

    //create street view preview @ top
    ImageView streetViewPreviewIV = new ImageView(MainActivity.this);

    Log.wtf("comparing TAG", String.valueOf(marker.getTag()));

    if (marker.getTag() == null) {
        Log.i("prepareInfoView", "fetching image");
        Picasso.with(this).load(imageURL).fetch(new MarkerCallback(marker));
    } else {/* w ww . j  a  va 2s. c  o m*/
        Log.wtf("prepareInfoView", "building info window");

        // this scales the image to match parents WIDTH?, but retain image's height??
        LinearLayout.LayoutParams streetViewImageViewParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        streetViewPreviewIV.setLayoutParams(streetViewImageViewParams);
        // TODO upon conversion to xml, the imageView needs these to scale image to box
        // android:scaleType="fitStart"
        // android:adjustViewBounds="true"
        Picasso.with(MainActivity.this).load(imageURL).into(streetViewPreviewIV);
        infoView.addView(streetViewPreviewIV);
        //Log.wtf("prepareInfoView, marker tag set?", String.valueOf(marker.getTag()));
        //Picasso.with(this).setLoggingEnabled(true);
    }

    // create text boxes
    LinearLayout subInfoView = new LinearLayout(MainActivity.this);
    LinearLayout.LayoutParams subInfoViewParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    subInfoView.setOrientation(LinearLayout.VERTICAL);
    subInfoView.setLayoutParams(subInfoViewParams);

    TextView titleTextView = new TextView(MainActivity.this);
    titleTextView.setText(marker.getTitle());
    TextView snippetTextView = new TextView(MainActivity.this);
    snippetTextView.setText(marker.getSnippet());
    subInfoView.addView(titleTextView);
    subInfoView.addView(snippetTextView);
    infoView.addView(subInfoView);

    // add the image on the right
    ImageView streetViewIcon = new ImageView(MainActivity.this);
    // this scales the image to match parents height.
    LinearLayout.LayoutParams imageViewParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    streetViewIcon.setLayoutParams(imageViewParams);
    Drawable drawable = ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_streetview);
    streetViewIcon.setImageDrawable(drawable);
    infoView.addView(streetViewIcon);
    //Picasso.with(this).load(imageURL).into(streetViewPreviewIV, new MarkerCallback(marker));

    return infoView;
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

public void response(final ChatResponse response) {
    if (speechPlayer != null || tts != null) {
        try {//  w  ww .  j  a v a2 s  .  c  o m
            tts.stop();
            speechPlayer.pause();
        } catch (Exception ignore) {
            Log.e("RESPONSE", "Error: " + ignore.getMessage());
        }
    }
    //needs when calling "sleep" or the its not going to let the mic off
    //also to stop the mic until the bot finish the sentence
    try {
        stopListening();
        this.response = response;

        String status = "";
        if (response.emote != null && !response.emote.equals("NONE")) {
            status = status + response.emote.toLowerCase();
        }
        if (response.action != null) {
            if (!status.isEmpty()) {
                status = status + " ";
            }
            status = status + response.action;
        }
        if (response.pose != null) {
            if (!status.isEmpty()) {
                status = status + " ";
            }
            status = status + response.pose;
        }

        if (response.command != null) {
            JSONObject jsonObject = response.getCommand();
            Command command = new Command(this, jsonObject);
        }

        TextView statusView = (TextView) findViewById(R.id.statusText);
        statusView.setText(status);

        final String text = response.message;
        final ListView list = (ListView) findViewById(R.id.chatList);
        if (text == null) {
            list.post(new Runnable() {
                @Override
                public void run() {
                    ChatResponse ready = new ChatResponse();
                    ready.message = "ready";
                    messages.add(ready);
                    ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged();
                    list.invalidateViews();
                    if (list.getCount() > 2) {
                        list.setSelection(list.getCount() - 2);
                    }
                    beginListening();
                }
            });
            return;
        }
        list.post(new Runnable() {
            @Override
            public void run() {
                messages.add(response);
                ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged();
                list.invalidateViews();
                if (list.getCount() > 2) {
                    list.setSelection(list.getCount() - 2);
                }
            }
        });

        WebView responseView = (WebView) findViewById(R.id.responseText);
        String html = Utils.linkHTML(text);
        if (html.contains("<") && html.contains(">")) {
            html = linkPostbacks(html);
        }
        responseView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);

        boolean talk = (text.trim().length() > 0) && (MainActivity.deviceVoice
                || (this.response.speech != null && this.response.speech.length() > 0));
        if (MainActivity.sound && talk) {
            if (!MainActivity.disableVideo && !videoError && this.response.isVideo()
                    && this.response.isVideoTalk()) {

                videoView.setOnPreparedListener(new OnPreparedListener() {
                    @Override
                    public void onPrepared(MediaPlayer mp) {
                        try {
                            mp.setLooping(true);
                            if (!MainActivity.deviceVoice) {
                                // Voice audio
                                speechPlayer = playAudio(response.speech, false, false, false);
                                speechPlayer.setOnCompletionListener(new OnCompletionListener() {
                                    @Override
                                    public void onCompletion(MediaPlayer mp) {
                                        mp.release();
                                        videoView.post(new Runnable() {
                                            public void run() {
                                                cycleVideo(response);
                                            }
                                        });
                                        runOnUiThread(new Runnable() {
                                            public void run() {
                                                if (!music) {
                                                    beginListening();
                                                }
                                            }
                                        });
                                    }
                                });

                                speechPlayer.start();
                            } else {
                                HashMap<String, String> params = new HashMap<String, String>();
                                params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "id");

                                tts.speak(Utils.stripTags(text), TextToSpeech.QUEUE_FLUSH, params);
                            }
                        } catch (Exception exception) {
                            Log.wtf(exception.getMessage(), exception);
                        }
                    }
                });
                playVideo(this.response.avatarTalk, false);
            } else if (talk) {
                if (!MainActivity.deviceVoice) {
                    // Voice audio
                    playAudio(this.response.speech, false, false, true);
                } else {
                    HashMap<String, String> params = new HashMap<String, String>();
                    params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "id");

                    this.tts.speak(Utils.stripTags(text), TextToSpeech.QUEUE_FLUSH, params);
                }
            }
        } else if (talk && (!MainActivity.disableVideo && !videoError && this.response.isVideo()
                && this.response.avatarTalk != null)) {
            videoView.setOnPreparedListener(new OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    mp.setLooping(false);
                }
            });
            videoView.setOnCompletionListener(new OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mp) {
                    videoView.setOnCompletionListener(null);
                    cycleVideo(response);
                }
            });
            playVideo(this.response.avatarTalk, false);
            runOnUiThread(new Runnable() {
                public void run() {
                    beginListening();
                }
            });
        } else {
            runOnUiThread(new Runnable() {
                public void run() {
                    beginListening();
                }
            });
        }
    } catch (Exception exception) {
        Log.wtf(exception.getMessage(), exception);
    }
    if (micLastStat) {
        MainActivity.listenInBackground = true;
    }
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

public void playVideo(String video, boolean loop) {
    if (loop) {//from   ww  w  .j  av  a2  s .c o m
        videoView.setOnPreparedListener(new OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mp.setLooping(true);
            }
        });
    }
    try {
        Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
        if (videoUri == null) {
            videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
        }
        videoView.setVideoURI(videoUri);
        videoView.start();
    } catch (Exception exception) {
        Log.wtf(exception.toString(), exception);
    }
}

From source file:com.android.contacts.activities.PeopleActivity.java

@Override
public void onClick(View view) {
    switch (view.getId()) {
    case R.id.floating_action_button:
        Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            intent.putExtras(extras);/*from  w w  w  .  j ava2  s  .  c  o  m*/
        }
        try {
            ImplicitIntentsUtil.startActivityInApp(PeopleActivity.this, intent);
        } catch (ActivityNotFoundException ex) {
            Toast.makeText(PeopleActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show();
        }
        break;
    default:
        Log.wtf(TAG, "Unexpected onClick event from " + view);
    }
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

public void cycleVideo(final ChatResponse response) {
    if ((response.avatar2 == null || response.avatar3 == null || response.avatar4 == null
            || response.avatar5 == null)
            || (response.avatar2.isEmpty() || response.avatar3.isEmpty() || response.avatar4.isEmpty()
                    || response.avatar5.isEmpty())
            || (response.avatar.equals(response.avatar2) && response.avatar2.equals(response.avatar3)
                    && response.avatar3.equals(response.avatar4)
                    && response.avatar4.equals(response.avatar5))) {
        playVideo(response.avatar, true);
        return;//w  w w. j  ava 2 s . c  o m
    }
    videoView.setOnPreparedListener(new OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(false);
        }
    });
    videoView.setOnCompletionListener(new OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            cycleVideo(response);
        }
    });
    int value = random.nextInt(5);
    String avatar = response.avatar;
    switch (value) {
    case 1:
        avatar = response.avatar2;
        break;
    case 2:
        avatar = response.avatar3;
        break;
    case 3:
        avatar = response.avatar5;
        break;
    case 14:
        avatar = response.avatar4;
        break;
    }

    try {
        Uri videoUri = HttpGetVideoAction.fetchVideo(this, avatar);
        if (videoUri == null) {
            videoUri = Uri.parse(MainActivity.connection.fetchImage(avatar).toURI().toString());
        }
        videoView.setVideoURI(videoUri);
        videoView.start();
    } catch (Exception exception) {
        Log.wtf(exception.toString(), exception);
    }
}