Example usage for android.widget ImageView setOnClickListener

List of usage examples for android.widget ImageView setOnClickListener

Introduction

In this page you can find the example usage for android.widget ImageView setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.fullteem.yueba.app.adapter.MessageAdapter.java

/**
 * /*  w  w w. j a  v  a2s .  c  o m*/
 * 
 * @param localThumb
 *            
 * @param iv
 * @param thumbnailUrl
 *            
 * @param message
 */
private void showVideoThumbView(String localThumb, ImageView iv, String thumbnailUrl, final EMMessage message) {
    // first check if the thumbnail image already loaded into cache
    Bitmap bitmap = ImageCache.getInstance().get(localThumb);
    if (bitmap != null) {
        // thumbnail image is already loaded, reuse the drawable
        iv.setImageBitmap(bitmap);
        iv.setClickable(true);
        iv.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // VideoMessageBody videoBody = (VideoMessageBody)
                // message.getBody();
                // System.err.println("video view is on click");
                // Intent intent = new Intent(activity,
                // ShowVideoActivity.class);
                // intent.putExtra("localpath", videoBody.getLocalUrl());
                // intent.putExtra("secret", videoBody.getSecret());
                // intent.putExtra("remotepath", videoBody.getRemoteUrl());
                // if (message != null && message.direct ==
                // EMMessage.Direct.RECEIVE && !message.isAcked
                // && message.getChatType() != ChatType.GroupChat) {
                // message.isAcked = true;
                // try {
                // EMChatManager.getInstance().ackMessageRead(message.getFrom(),
                // message.getMsgId());
                // } catch (Exception e) {
                // e.printStackTrace();
                // }
                // }
                // activity.startActivity(intent);

            }
        });

    } else {
        // new LoadVideoImageTask().execute(localThumb, thumbnailUrl, iv,
        // activity, message, this);
    }

}

From source file:cn.ucai.superwechat.adapter.MessageAdapter.java

/**
 * ?//w  ww  .  j  a v a  2 s.c om
 * @param message
 * @param imageView
 */
private void setUserAvatar(final EMMessage message, ImageView imageView) {
    if (message.direct == Direct.SEND) {
        //?
        UserUtils.setCurrentUserAvatar(context, imageView);
    } else {
        UserUtils.setAppUserAvatar(context, message.getFrom(), imageView);
    }
    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(context, UserProfileActivity.class);
            intent.putExtra("username", message.getFrom());
            intent.putExtra("groupId", username);
            context.startActivity(intent);
        }
    });
}

From source file:com.mobicage.rogerthat.plugins.friends.ActionScreenActivity.java

@SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface", "NewApi" })
@Override/*from w  w  w  .  j  av  a2s  .  c o  m*/
public void onCreate(Bundle savedInstanceState) {
    if (CloudConstants.isContentBrandingApp()) {
        super.setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.action_screen);
    mBranding = (WebView) findViewById(R.id.branding);
    WebSettings brandingSettings = mBranding.getSettings();
    brandingSettings.setJavaScriptEnabled(true);
    brandingSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        brandingSettings.setAllowFileAccessFromFileURLs(true);
    }
    mBrandingHttp = (WebView) findViewById(R.id.branding_http);
    mBrandingHttp.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    WebSettings brandingSettingsHttp = mBrandingHttp.getSettings();
    brandingSettingsHttp.setJavaScriptEnabled(true);
    brandingSettingsHttp.setCacheMode(WebSettings.LOAD_DEFAULT);

    if (CloudConstants.isContentBrandingApp()) {
        mSoundThread = new HandlerThread("rogerthat_actionscreenactivity_sound");
        mSoundThread.start();
        Looper looper = mSoundThread.getLooper();
        mSoundHandler = new Handler(looper);

        int cameraPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
        if (cameraPermission == PackageManager.PERMISSION_GRANTED) {
            mQRCodeScanner = QRCodeScanner.getInstance(this);
            final LinearLayout previewHolder = (LinearLayout) findViewById(R.id.preview_view);
            previewHolder.addView(mQRCodeScanner.view);
        }
        mBranding.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                initFullScreenForContentBranding();
            }
        });

        mBrandingHttp.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                initFullScreenForContentBranding();
            }
        });
    }

    final View brandingHeader = findViewById(R.id.branding_header_container);

    final ImageView brandingHeaderClose = (ImageView) findViewById(R.id.branding_header_close);
    final TextView brandingHeaderText = (TextView) findViewById(R.id.branding_header_text);
    brandingHeaderClose
            .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text)));

    brandingHeaderClose.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mQRCodeScanner != null) {
                mQRCodeScanner.onResume();
            }
            brandingHeader.setVisibility(View.GONE);
            mBrandingHttp.setVisibility(View.GONE);
            mBranding.setVisibility(View.VISIBLE);
            mBrandingHttp.loadUrl("about:blank");
        }
    });

    final View brandingFooter = findViewById(R.id.branding_footer_container);

    if (CloudConstants.isContentBrandingApp()) {
        brandingHeaderClose.setVisibility(View.GONE);
        final ImageView brandingFooterClose = (ImageView) findViewById(R.id.branding_footer_close);
        final TextView brandingFooterText = (TextView) findViewById(R.id.branding_footer_text);
        brandingFooterText.setText(getString(R.string.back));
        brandingFooterClose
                .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text)));

        brandingFooter.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mQRCodeScanner != null) {
                    mQRCodeScanner.onResume();
                }
                brandingHeader.setVisibility(View.GONE);
                brandingFooter.setVisibility(View.GONE);
                mBrandingHttp.setVisibility(View.GONE);
                mBranding.setVisibility(View.VISIBLE);
                mBrandingHttp.loadUrl("about:blank");
            }
        });
    }

    final RelativeLayout openPreview = (RelativeLayout) findViewById(R.id.preview_holder);

    openPreview.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mQRCodeScanner != null) {
                mQRCodeScanner.previewHolderClicked();
            }
        }
    });

    mBranding.addJavascriptInterface(new JSInterface(this), "__rogerthat__");
    mBranding.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onConsoleMessage(String message, int lineNumber, String sourceID) {
            if (sourceID != null) {
                try {
                    sourceID = new File(sourceID).getName();
                } catch (Exception e) {
                    L.d("Could not get fileName of sourceID: " + sourceID, e);
                }
            }
            if (mIsHtmlContent) {
                L.i("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message);
            } else {
                L.d("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message);
            }
        }
    });
    mBranding.setWebViewClient(new WebViewClient() {
        private boolean isExternalUrl(String url) {
            for (String regularExpression : mBrandingResult.externalUrlPatterns) {
                if (url.matches(regularExpression)) {
                    return true;
                }
            }
            return false;
        }

        @SuppressLint("DefaultLocale")
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            L.i("Branding is loading url: " + url);
            Uri uri = Uri.parse(url);
            String lowerCaseUrl = url.toLowerCase();
            if (lowerCaseUrl.startsWith("tel:") || lowerCaseUrl.startsWith("mailto:") || isExternalUrl(url)) {
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);
                return true;
            } else if (lowerCaseUrl.startsWith(POKE)) {
                String tag = url.substring(POKE.length());
                poke(tag);
                return true;
            } else if (lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://")) {
                if (mQRCodeScanner != null) {
                    mQRCodeScanner.onPause();
                }
                brandingHeaderText.setText(getString(R.string.loading));
                brandingHeader.setVisibility(View.VISIBLE);
                if (CloudConstants.isContentBrandingApp()) {
                    brandingFooter.setVisibility(View.VISIBLE);
                }
                mBranding.setVisibility(View.GONE);
                mBrandingHttp.setVisibility(View.VISIBLE);
                mBrandingHttp.loadUrl(url);
                return true;
            } else {
                brandingHeader.setVisibility(View.GONE);
                brandingFooter.setVisibility(View.GONE);
                mBrandingHttp.setVisibility(View.GONE);
                mBranding.setVisibility(View.VISIBLE);
            }
            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            L.i("onPageFinished " + url);
            if (!mInfoSet && mService != null && mIsHtmlContent) {
                Map<String, Object> info = mFriendsPlugin.getRogerthatUserAndServiceInfo(mServiceEmail,
                        mServiceFriend);

                executeJS(true, "if (typeof rogerthat !== 'undefined') rogerthat._setInfo(%s)",
                        JSONValue.toJSONString(info));
                mInfoSet = true;
            }
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
            L.i("Checking access to: '" + url + "'");
            final URL parsedUrl;
            try {
                parsedUrl = new URL(url);
            } catch (MalformedURLException e) {
                L.d("Webview tried to load malformed URL");
                return new WebResourceResponse("text/plain", "UTF-8", null);
            }
            if (!parsedUrl.getProtocol().equals("file")) {
                return null;
            }
            File urlPath = new File(parsedUrl.getPath());
            if (urlPath.getAbsolutePath().startsWith(mBrandingResult.dir.getAbsolutePath())) {
                return null;
            }
            L.d("404: Webview tries to load outside its sandbox.");
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }
    });

    mBrandingHttp.setWebViewClient(new WebViewClient() {
        @SuppressLint("DefaultLocale")
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            L.i("BrandingHttp is loading url: " + url);
            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            brandingHeaderText.setText(view.getTitle());
            L.i("onPageFinished " + url);
        }
    });

    Intent intent = getIntent();
    mBrandingKey = intent.getStringExtra(BRANDING_KEY);
    mServiceEmail = intent.getStringExtra(SERVICE_EMAIL);
    mItemTagHash = intent.getStringExtra(ITEM_TAG_HASH);
    mItemLabel = intent.getStringExtra(ITEM_LABEL);
    mItemCoords = intent.getLongArrayExtra(ITEM_COORDS);
    mRunInBackground = intent.getBooleanExtra(RUN_IN_BACKGROUND, true);
}

From source file:com.fa.mastodon.activity.ComposeActivity.java

private void addMediaToQueue(QueuedMedia.Type type, Bitmap preview, Uri uri, long mediaSize) {
    final QueuedMedia item = new QueuedMedia(type, uri, new ImageView(this), mediaSize);
    ImageView view = item.preview;
    Resources resources = getResources();
    int side = resources.getDimensionPixelSize(R.dimen.compose_media_preview_side);
    int margin = resources.getDimensionPixelSize(R.dimen.compose_media_preview_margin);
    int marginBottom = resources.getDimensionPixelSize(R.dimen.compose_media_preview_margin_bottom);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(side, side);
    layoutParams.setMargins(margin, 0, margin, marginBottom);
    view.setLayoutParams(layoutParams);/*w w w . j av  a 2s. c om*/
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    view.setImageBitmap(preview);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            removeMediaFromQueue(item);
        }
    });
    mediaPreviewBar.addView(view);
    mediaQueued.add(item);
    int queuedCount = mediaQueued.size();
    if (queuedCount == 1) {
        /* The media preview bar is actually not inset in the EditText, it just overlays it and
         * is aligned to the bottom. But, so that text doesn't get hidden under it, extra
         * padding is added at the bottom of the EditText. */
        int totalHeight = side + margin + marginBottom;
        textEditor.setPadding(textEditor.getPaddingLeft(), textEditor.getPaddingTop(),
                textEditor.getPaddingRight(), totalHeight);
        // If there's one video in the queue it is full, so disable the button to queue more.
        if (item.type == QueuedMedia.Type.VIDEO) {
            disableMediaButtons();
        }
    } else if (queuedCount >= Status.MAX_MEDIA_ATTACHMENTS) {
        // Limit the total media attachments, also.
        disableMediaButtons();
    }
    if (queuedCount >= 1) {
        showMarkSensitive(true);
    }
    waitForMediaLatch.countUp();
    if (mediaSize > STATUS_MEDIA_SIZE_LIMIT && type == QueuedMedia.Type.IMAGE) {
        downsizeMedia(item);
    } else {
        uploadMedia(item);
    }
}

From source file:com.wewow.MainActivity.java

private void showCover() {

    toolbar.setBackgroundColor(getResources().getColor(R.color.cover));
    if (isAppBarFolded) {
        imageViewLine.setBackgroundColor(getResources().getColor(R.color.cover));
        mTabLayout.setBackgroundColor(getResources().getColor(R.color.cover));
        layoutCoverTab.setVisibility(View.VISIBLE);
        layoutCoverTab.setOnClickListener(new View.OnClickListener() {
            @Override/*from  ww  w . ja  va  2  s  .com*/
            public void onClick(View v) {
                removeCover(true);
            }
        });
    }
    RelativeLayout layoutCover = (RelativeLayout) findViewById(R.id.layoutCover);
    layoutCover.setVisibility(View.VISIBLE);
    layoutCover.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //                searchView.setVisibility(View.INVISIBLE);
            //                if(isAppBarFolded)
            //                {
            //                    textTitle.setVisibility(View.VISIBLE);
            //                }
            removeCover(true);

            new Handler().postDelayed(new Runnable() {

                public void run() {
                    //execute the task
                    searchView.setVisibility(View.INVISIBLE);
                    imageViewUnderLine.setVisibility(View.INVISIBLE);
                    RemoveUnderLine();
                    searchView.setText("");
                    resetDropdownOffset = true;
                    imageViewHome.setImageResource(R.drawable.menu);
                    isSearchViewShown = false;
                    if (isAppBarFolded) {
                        textTitle.setVisibility(View.VISIBLE);
                        imageViewHome.setImageResource(R.drawable.menu_b);
                    }
                }
            }, 200);
        }
    });
    ImageView imageViewBack = (ImageView) findViewById(R.id.layoutMenuCover);
    imageViewBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (!isSearchViewShown) {
                drawerLayout.openDrawer(GravityCompat.START);

            } else {
                removeCover(true);

                new Handler().postDelayed(new Runnable() {

                    public void run() {
                        //execute the task

                        if (isAppBarFolded) {
                            textTitle.setVisibility(View.VISIBLE);
                            imageViewHome.setImageResource(R.drawable.menu_b);

                            imageViewUnderLine.setVisibility(View.INVISIBLE);
                        }
                        searchView.setVisibility(View.INVISIBLE);
                        imageViewUnderLine.setVisibility(View.INVISIBLE);
                        RemoveUnderLine();
                        searchView.setText("");
                        resetDropdownOffset = true;
                        imageViewHome.setImageResource(R.drawable.menu);
                        isSearchViewShown = false;
                    }
                }, 200);
            }

        }
    });

    ImageView imageViewSearchBottom = (ImageView) findViewById(R.id.layoutSearchCover);
    imageViewSearchBottom.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String queryText = searchView.getText().toString().trim();
            if (!isSearchViewShown) {
                if (isAppBarFolded) {
                    imageViewHome.setImageResource(R.drawable.back_b);
                } else {
                    imageViewHome.setImageResource(R.drawable.back);
                }

                ListSearchAdapter adapter = new ListSearchAdapter(hotWords, MainActivity.this);
                //
                //                    ArrayAdapter<String> adapter = new ArrayAdapter<>(MainActivity.this, R.layout.list_item_search, R.id.text, hotWords);

                searchView.setAdapter(adapter);
                searchView.setHint(getResources().getString(R.string.search_hint));

                searchView.setThreshold(0);
                if (resetDropdownOffset) {
                    //                        searchView.setDropDownVerticalOffset(40);
                    //                        resetDropdownOffset = false;
                }
                showUnderLine();

                showCover();
                new Handler().postDelayed(new Runnable() {

                    public void run() {
                        //execute the task
                        searchView.setVisibility(View.VISIBLE);
                        textTitle.setVisibility(View.GONE);
                        searchView.requestFocus();
                        InputMethodManager inputManager = (InputMethodManager) searchView.getContext()
                                .getSystemService(Context.INPUT_METHOD_SERVICE);
                        inputManager.showSoftInput(searchView, 0);
                    }
                }, 100);

                new Handler().postDelayed(new Runnable() {

                    public void run() {
                        //execute the task
                        searchView.showDropDown();
                    }
                }, 200);

                searchView.addTextChangedListener(MainActivity.this);
                searchView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        if (position != 0) {
                            searchView.setText(hotWords.get(position), true);
                            removeCover(true);
                            layoutSearch.performClick();
                        } else {
                            searchView.setText("");
                        }
                        //

                    }
                });
                searchView.setThreshold(0);

                isSearchViewShown = true;
            } else {

                if (!queryText.equals("")) {
                    searchView.setText("");
                    searchView.setVisibility(View.INVISIBLE);
                    imageViewUnderLine.setVisibility(View.INVISIBLE);
                    Intent intentSearch = new Intent(MainActivity.this, SearchResultActivity.class);
                    intentSearch.putExtra("key_word", queryText);
                    startActivity(intentSearch);
                    if (isAppBarFolded) {
                        imageViewHome.setImageResource(R.drawable.menu_b);
                    } else {
                        imageViewHome.setImageResource(R.drawable.menu);
                    }

                    isSearchViewShown = false;
                    if (isAppBarFolded) {
                        textTitle.setVisibility(View.VISIBLE);
                    }
                } else {

                    if (isAppBarFolded) {
                        imageViewHome.setImageResource(R.drawable.back_b);
                    } else {
                        imageViewHome.setImageResource(R.drawable.back);
                    }
                    searchView.setHint(getResources().getString(R.string.search_hint));

                    final String[] testStrings = getResources().getStringArray(R.array.test_array);
                    //                        ArrayAdapter<String> adapter = new ArrayAdapter<>(MainActivity.this, R.layout.list_item_search, R.id.text, hotWords);
                    ListSearchAdapter adapter = new ListSearchAdapter(hotWords, MainActivity.this);
                    searchView.setAdapter(adapter);
                    searchView.requestFocus();

                    if (resetDropdownOffset) {
                        //                            resetDropdownOffset = false;
                        //                            searchView.setDropDownVerticalOffset(-40);
                    }
                    //                        searchView.setDropDownVerticalOffset(-40);
                    showUnderLine();

                    showCover();
                    new Handler().postDelayed(new Runnable() {

                        public void run() {
                            //execute the task
                            searchView.setVisibility(View.VISIBLE);
                            textTitle.setVisibility(View.GONE);
                            searchView.requestFocus();
                            InputMethodManager inputManager = (InputMethodManager) searchView.getContext()
                                    .getSystemService(Context.INPUT_METHOD_SERVICE);
                            inputManager.showSoftInput(searchView, 0);
                        }
                    }, 100);

                    new Handler().postDelayed(new Runnable() {

                        public void run() {
                            //execute the task
                            searchView.showDropDown();
                        }
                    }, 200);
                    searchView.addTextChangedListener(MainActivity.this);
                    searchView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                            if (position != 0) {
                                searchView.setText(hotWords.get(position), true);
                                removeCover(true);
                                imageViewSearch.performClick();
                            }
                            //

                        }
                    });
                    searchView.setThreshold(0);

                    isSearchViewShown = true;
                }

            }
        }
    });
}

From source file:de.blinkt.openvpn.ActivityServerList.java

private void makeFavoriteServer() {
    linearFavorites.removeAllViews();//from w ww.  j ava2  s.  c o m

    for (int i = 0; i < mServerList.size(); i++) {
        final String server = mServerList.get(i);

        if (spGlobal.getBoolean(server, false)) {
            final View viewItem = LayoutInflater.from(this).inflate(R.layout.itemserver, linearSelectedServer,
                    false);
            ImageView imgViewFlag = (ImageView) viewItem.findViewById(R.id.imgViewFlag);
            TextView txtCountry = (TextView) viewItem.findViewById(R.id.txtViewCountryName);
            ImageView imgFavorite = (ImageView) viewItem.findViewById(R.id.imgFavorite);

            imgFavorite.setImageResource(
                    getResources().getIdentifier("drawable/icon_favorite", null, getPackageName()));
            imgViewFlag.setVisibility(View.GONE);
            for (int j = 0; j < countryList.length; j++) {
                String country = countryList[j];
                if (server.toLowerCase().contains(country.toLowerCase())) {
                    String resourceName = country.toLowerCase().replace(" ", "_");

                    int checkExistence = getResources().getIdentifier(resourceName, "drawable",
                            getPackageName());
                    if (checkExistence != 0) { // the resouce exists...
                        imgViewFlag.setVisibility(View.VISIBLE);
                        imgViewFlag.setImageResource(getResources().getIdentifier("drawable/" + resourceName,
                                null, getPackageName()));
                    }
                    break;
                }
            }
            txtCountry.setText(server);

            imgFavorite.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    edGlobal.putBoolean(server, false);
                    edGlobal.commit();
                    linearFavorites.removeView(viewItem);
                    makeAvaiableServer();
                }
            });

            txtCountry.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connected)
                            || (ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) {
                        if (ActivityDashboard.lolstring.equals(server)) {

                        } else {
                            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    switch (which) {
                                    case DialogInterface.BUTTON_POSITIVE:
                                        dialog.dismiss();
                                        ActivityDashboard.lolstring = server;

                                        if (VpnStatus.isVPNActive()) {

                                            if (ActivityDashboard.mService != null) {
                                                try {
                                                    ActivityDashboard.mService.stopVPN(false);
                                                } catch (RemoteException e) {
                                                    VpnStatus.logException(e);
                                                }
                                            }
                                        }
                                        ActivityDashboard.DISCONNECT_VPN_SERVERLIST = 1;
                                        finish();
                                        break;

                                    case DialogInterface.BUTTON_NEGATIVE:
                                        dialog.dismiss();
                                        break;
                                    }
                                }
                            };

                            AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this);
                            if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) {
                                builder.setMessage(
                                        "Currently connecting to another VPN server. Are you sure you want to change the server?")
                                        .setPositiveButton("Yes", dialogClickListener)
                                        .setNegativeButton("No", dialogClickListener).show();
                            } else {
                                builder.setMessage(
                                        "Currently connected to another VPN server. Are you sure you want to change the server?")
                                        .setPositiveButton("Yes", dialogClickListener)
                                        .setNegativeButton("No", dialogClickListener).show();
                            }
                        }
                    } else {
                        ActivityDashboard.lolstring = server;
                        finish();
                    }
                    /* if(VpnStatus.isVPNActive() && ActivityDashboard.m_status.equals(Status.Connected) ) {
                    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            switch (which){
                                case DialogInterface.BUTTON_POSITIVE:
                                    dialog.dismiss();
                                    ActivityDashboard.lolstring = server;
                                    finish();
                                    break;
                            
                                case DialogInterface.BUTTON_NEGATIVE:
                                    dialog.dismiss();
                                    break;
                            }
                        }
                    };
                            
                    AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this);
                    builder.setMessage("Currently connected to another VPN server. Are you sure you want to change the server?").setPositiveButton("Yes", dialogClickListener)
                            .setNegativeButton("No", dialogClickListener).show();
                     }else{
                    ActivityDashboard.lolstring = server;
                    finish();
                     }*/
                }
            });
            linearFavorites.addView(viewItem);
        }
    }
}

From source file:com.google.samples.apps.iosched.ui.SessionDetailActivity.java

private void onSpeakersQueryComplete(Cursor cursor) {
    mSpeakersCursor = true;//from   w  ww .  j  a v  a  2  s  . co  m
    final ViewGroup speakersGroup = (ViewGroup) findViewById(R.id.session_speakers_block);

    // Remove all existing speakers (everything but first child, which is the header)
    for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) {
        speakersGroup.removeViewAt(i);
    }

    final LayoutInflater inflater = getLayoutInflater();

    boolean hasSpeakers = false;

    cursor.moveToPosition(-1); // move to just before first record
    while (cursor.moveToNext()) {
        final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME);
        if (TextUtils.isEmpty(speakerName)) {
            continue;
        }

        final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL);
        final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY);
        final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL);
        final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT);

        String speakerHeader = speakerName;
        if (!TextUtils.isEmpty(speakerCompany)) {
            speakerHeader += ", " + speakerCompany;
        }

        final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false);
        final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header);
        final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image);
        final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract);

        if (!TextUtils.isEmpty(speakerImageUrl) && mSpeakersImageLoader != null) {
            mSpeakersImageLoader.loadImage(speakerImageUrl, speakerImageView);
        }

        speakerHeaderView.setText(speakerHeader);
        speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader));
        UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract);

        if (!TextUtils.isEmpty(speakerUrl)) {
            speakerImageView.setEnabled(true);
            speakerImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl));
                    speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    UIUtils.preferPackageForIntent(SessionDetailActivity.this, speakerProfileIntent,
                            UIUtils.GOOGLE_PLUS_PACKAGE_NAME);
                    startActivity(speakerProfileIntent);
                }
            });
        } else {
            speakerImageView.setEnabled(false);
            speakerImageView.setOnClickListener(null);
        }

        speakersGroup.addView(speakerView);
        hasSpeakers = true;
        mHasSummaryContent = true;
    }

    speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE);
    updateEmptyView();
}

From source file:com.ncode.android.apps.schedo.ui.EventDetailActivity.java

private void onSpeakersQueryComplete(Cursor cursor) {
    mSpeakersCursor = true;//from w ww.j a v a2  s .c  o m
    final ViewGroup speakersGroup = (ViewGroup) findViewById(R.id.session_speakers_block);

    // Remove all existing speakers (everything but first child, which is the header)
    for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) {
        speakersGroup.removeViewAt(i);
    }

    final LayoutInflater inflater = getLayoutInflater();

    boolean hasSpeakers = false;

    cursor.moveToPosition(-1); // move to just before first record
    while (cursor.moveToNext()) {
        final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME);
        if (TextUtils.isEmpty(speakerName)) {
            continue;
        }

        final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL);
        final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY);
        final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL);
        final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT);

        String speakerHeader = speakerName;
        if (!TextUtils.isEmpty(speakerCompany)) {
            speakerHeader += ", " + speakerCompany;
        }

        final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false);
        final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header);
        final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image);
        final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract);

        if (!TextUtils.isEmpty(speakerImageUrl) && mSpeakersImageLoader != null) {
            mSpeakersImageLoader.loadImage(speakerImageUrl, speakerImageView);
        }

        speakerHeaderView.setText(speakerHeader);
        speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader));
        UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract);

        if (!TextUtils.isEmpty(speakerUrl)) {
            speakerImageView.setEnabled(true);
            speakerImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl));
                    speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    UIUtils.preferPackageForIntent(EventDetailActivity.this, speakerProfileIntent,
                            UIUtils.GOOGLE_PLUS_PACKAGE_NAME);
                    startActivity(speakerProfileIntent);
                }
            });
        } else {
            speakerImageView.setEnabled(false);
            speakerImageView.setOnClickListener(null);
        }

        speakersGroup.addView(speakerView);
        hasSpeakers = true;
        mHasSummaryContent = true;
    }

    speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE);
    updateEmptyView();
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

public void reminderDialog() {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    View dialogView = this.getLayoutInflater().inflate(R.layout.alert_label_editor, null);
    dialogBuilder.setView(dialogView);/* ww  w  .  ja  v a 2 s . c  o m*/
    final AlertDialog alertDialog = dialogBuilder.create();

    ImageView rate_app_dialog_button = (ImageView) dialogView.findViewById(R.id.rate_app_dialog_button);
    ImageView no_thanks_dialog_button = (ImageView) dialogView.findViewById(R.id.no_thanks_dialog_button);
    ImageView edidremind_dialog_button = (ImageView) dialogView.findViewById(R.id.remind_dialog_button);

    rate_app_dialog_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            openUri(PLAY_STORE_URL);
        }
    });
    no_thanks_dialog_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.dismiss();
        }
    });
    edidremind_dialog_button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();
}

From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java

private void setupButtonEvents(View header) {
    ImageView shareButton = (ImageView) header.findViewById(R.id.select_album_share);
    if (share != null || podcastId != null
            || !Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_SHARED, true)
            || Util.isOffline(context) || !UserUtil.canShare() || artistInfo != null) {
        shareButton.setVisibility(View.GONE);
    } else {//from  ww  w.j a  v a2s. c o  m
        shareButton.setVisibility(View.GONE);
        shareButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                createShare(SelectDirectoryFragment.this.entries);
            }
        });
    }

    final ImageButton starButton = (ImageButton) header.findViewById(R.id.select_album_star);
    if (directory != null && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)
            && artistInfo == null) {
        if (directory.isStarred()) {
            starButton.setImageDrawable(DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star));
        } else {
            starButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.star_outline));
        }
        starButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UpdateHelper.toggleStarred(context, directory, new UpdateHelper.OnStarChange() {
                    @Override
                    public void starChange(boolean starred) {
                        if (directory.isStarred()) {
                            starButton.setImageResource(
                                    DrawableTint.getDrawableRes(context, R.attr.star_outline));
                            starButton.setImageDrawable(
                                    DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star));
                        } else {
                            starButton.setImageResource(
                                    DrawableTint.getDrawableRes(context, R.attr.star_outline));
                        }
                    }

                    @Override
                    public void starCommited(boolean starred) {

                    }
                });
            }
        });
        starButton.setVisibility(View.GONE);
    } else {
        starButton.setVisibility(View.GONE);
    }

    View ratingBarWrapper = header.findViewById(R.id.select_album_rate_wrapper);
    final RatingBar ratingBar = (RatingBar) header.findViewById(R.id.select_album_rate);
    if (directory != null
            && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_RATING, true)
            && !Util.isOffline(context) && artistInfo == null) {
        ratingBar.setRating(directory.getRating());
        ratingBarWrapper.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UpdateHelper.setRating(context, directory, new UpdateHelper.OnRatingChange() {
                    @Override
                    public void ratingChange(int rating) {
                        ratingBar.setRating(directory.getRating());
                    }
                });
            }
        });
        ratingBar.setVisibility(View.GONE);
    } else {
        ratingBar.setVisibility(View.GONE);
    }
}