List of usage examples for android.view View setEnabled
@RemotableViewMethod public void setEnabled(boolean enabled)
From source file:com.google.samples.apps.iosched.ui.BaseActivity.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that * shows which account the user is logged in as, and lets them switch accounts. It also * shows the user's Google+ cover photo as background. *///from w w w.j a v a 2s .c om private void setupAccountBox() { mAccountListContainer = (LinearLayout) findViewById(R.id.account_list); if (mAccountListContainer == null) { //This activity does not have an account box return; } final View chosenAccountView = findViewById(R.id.chosen_account_view); Account chosenAccount = AccountUtils.getActiveAccount(this); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); mAccountListContainer.setVisibility(View.INVISIBLE); } AccountManager am = AccountManager.get(this); Account[] accountArray = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE); List<Account> accounts = new ArrayList<Account>(Arrays.asList(accountArray)); accounts.remove(chosenAccount); ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); TextView nameTextView = (TextView) chosenAccountView.findViewById(R.id.profile_name_text); TextView email = (TextView) chosenAccountView.findViewById(R.id.profile_email_text); mExpandAccountBoxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator); String name = AccountUtils.getPlusName(this); if (name == null) { nameTextView.setVisibility(View.GONE); } else { nameTextView.setVisibility(View.VISIBLE); nameTextView.setText(name); } String imageUrl = AccountUtils.getPlusImageUrl(this); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(this); if (coverImageUrl != null) { findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.GONE); coverImageView.setVisibility(View.VISIBLE); coverImageView.setContentDescription( getResources().getString(R.string.navview_header_user_image_content_description)); mImageLoader.loadImage(coverImageUrl, coverImageView); coverImageView.setColorFilter(getResources().getColor(R.color.light_content_scrim)); } email.setText(chosenAccount.name); if (accounts.isEmpty()) { // There's only one account on the device, so no need for a switcher. mExpandAccountBoxIndicator.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); chosenAccountView.setEnabled(false); return; } chosenAccountView.setEnabled(true); mExpandAccountBoxIndicator.setVisibility(View.VISIBLE); chosenAccountView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAccountBoxExpanded = !mAccountBoxExpanded; setupAccountBoxToggle(); } }); setupAccountBoxToggle(); populateAccountList(accounts); }
From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java
/** * Show a dialog for sorting options and resort file list after user * selected an option./*from w w w . j a va 2 s . c om*/ */ private void resortViewFiles() { final Dialog dialog = new Dialog(getActivity(), Ui.resolveAttribute(getActivity(), R.attr.afc_theme_dialog)); dialog.setCanceledOnTouchOutside(true); // get the index of button of current sort type int btnCurrentSortTypeIdx = 0; switch (DisplayPrefs.getSortType(getActivity())) { case BaseFile.SORT_BY_NAME: btnCurrentSortTypeIdx = 0; break; case BaseFile.SORT_BY_SIZE: btnCurrentSortTypeIdx = 2; break; case BaseFile.SORT_BY_MODIFICATION_TIME: btnCurrentSortTypeIdx = 4; break; } if (!DisplayPrefs.isSortAscending(getActivity())) btnCurrentSortTypeIdx++; View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (v.getId() == R.id.afc_button_sort_by_name_asc) { DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_NAME); DisplayPrefs.setSortAscending(getActivity(), true); } else if (v.getId() == R.id.afc_button_sort_by_name_desc) { DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_NAME); DisplayPrefs.setSortAscending(getActivity(), false); } else if (v.getId() == R.id.afc_button_sort_by_size_asc) { DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_SIZE); DisplayPrefs.setSortAscending(getActivity(), true); } else if (v.getId() == R.id.afc_button_sort_by_size_desc) { DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_SIZE); DisplayPrefs.setSortAscending(getActivity(), false); } else if (v.getId() == R.id.afc_button_sort_by_date_asc) { DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME); DisplayPrefs.setSortAscending(getActivity(), true); } else if (v.getId() == R.id.afc_button_sort_by_date_desc) { DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME); DisplayPrefs.setSortAscending(getActivity(), false); } /* * Reload current location. */ goTo(getCurrentLocation()); getActivity().supportInvalidateOptionsMenu(); }// onClick() };// listener View view = getLayoutInflater(null).inflate(R.layout.afc_settings_sort_view, null); for (int i = 0; i < BUTTON_SORT_IDS.length; i++) { View v = view.findViewById(BUTTON_SORT_IDS[i]); v.setOnClickListener(listener); if (i == btnCurrentSortTypeIdx) { v.setEnabled(false); if (v instanceof Button) ((Button) v).setText(R.string.afc_bullet); } } dialog.setTitle(R.string.afc_title_sort_by); dialog.setContentView(view); dialog.show(); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * Show a dialog for sorting options and resort file list after user * selected an option./*from ww w .j a va 2 s . c o m*/ */ private void resortViewFiles() { final Dialog dialog = new Dialog(getActivity(), UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog)); dialog.setCanceledOnTouchOutside(true); // get the index of button of current sort type int btnCurrentSortTypeIdx = 0; switch (Display.getSortType(getActivity())) { case BaseFile.SORT_BY_NAME: btnCurrentSortTypeIdx = 0; break; case BaseFile.SORT_BY_SIZE: btnCurrentSortTypeIdx = 2; break; case BaseFile.SORT_BY_MODIFICATION_TIME: btnCurrentSortTypeIdx = 4; break; } if (!Display.isSortAscending(getActivity())) btnCurrentSortTypeIdx++; View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_name_asc) { Display.setSortType(getActivity(), BaseFile.SORT_BY_NAME); Display.setSortAscending(getActivity(), true); } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_name_desc) { Display.setSortType(getActivity(), BaseFile.SORT_BY_NAME); Display.setSortAscending(getActivity(), false); } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_size_asc) { Display.setSortType(getActivity(), BaseFile.SORT_BY_SIZE); Display.setSortAscending(getActivity(), true); } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_size_desc) { Display.setSortType(getActivity(), BaseFile.SORT_BY_SIZE); Display.setSortAscending(getActivity(), false); } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_date_asc) { Display.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME); Display.setSortAscending(getActivity(), true); } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_date_desc) { Display.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME); Display.setSortAscending(getActivity(), false); } /* * Reload current location. */ goTo(getCurrentLocation()); getActivity().supportInvalidateOptionsMenu(); }// onClick() };// listener View view = getLayoutInflater(null).inflate(R.layout.anhuu_f5be488d_settings_sort_view, null); for (int i = 0; i < BUTTON_SORT_IDS.length; i++) { View v = view.findViewById(BUTTON_SORT_IDS[i]); v.setOnClickListener(listener); if (i == btnCurrentSortTypeIdx) { v.setEnabled(false); if (v instanceof Button) ((Button) v).setText(R.string.anhuu_f5be488d_bullet); } } dialog.setTitle(R.string.anhuu_f5be488d_title_sort_by); dialog.setContentView(view); dialog.show(); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void updateSendButtonState() { boolean enable = false; if (isPreparedForSending()) { // When the type of attachment is slideshow, we should // also hide the 'Send' button since the slideshow view // already has a 'Send' button embedded. if (!mWorkingMessage.hasSlideshow()) { enable = true;/*from w ww. j a v a 2 s . c o m*/ } else { mAttachmentEditor.setCanSend(true); } } else if (null != mAttachmentEditor) { mAttachmentEditor.setCanSend(false); } boolean requiresMms = mWorkingMessage.requiresMms(); View sendButton = showSmsOrMmsSendButton(requiresMms); sendButton.setEnabled(enable); sendButton.setFocusable(enable); }
From source file:com.android.launcher2.Launcher.java
/** * Sets the app market icon//from w w w . j ava2s.c o m */ private void updateAppMarketIcon() { final View marketButton = findViewById(R.id.market_button); Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET); // Find the app market activity by resolving an intent. // (If multiple app markets are installed, it will return the ResolverActivity.) ComponentName activityName = intent.resolveActivity(getPackageManager()); if (activityName != null) { int coi = getCurrentOrientationIndexForGlobalIcons(); mAppMarketIntent = intent; sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(R.id.market_button, activityName, R.drawable.ic_launcher_market_holo, TOOLBAR_ICON_METADATA_NAME); marketButton.setVisibility(View.VISIBLE); } else { // We should hide and disable the view so that we don't try and restore the visibility // of it when we swap between drag & normal states from IconDropTarget subclasses. marketButton.setVisibility(View.GONE); marketButton.setEnabled(false); } }
From source file:de.da_sense.moses.client.DetailFragment.java
/** * Initializes the button logic/*from w w w .jav a2 s . co m*/ */ private void initializeButtons() { ActionBar ab = mActivity.getActionBar(); if (mBelongsTo == AVAILABLE) { ab.setTitle(getString(R.string.userStudy_available)); // get start button Button button = (Button) mDetailFragmentView.findViewById(R.id.startapp); // change the text of it to install button.setText(getString(R.string.install)); // make an action listener for it button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ExternalApplication app = AvailableFragment.getInstance().getExternalApps().get(mIndex);// getShownIndex()); Log.d(LOG_TAG, "installing app ( " + app.getName() + " ) with apkid = " + app.getID()); AvailableFragment.getInstance().handleInstallApp(app); } }); // get update button button = (Button) mDetailFragmentView.findViewById(R.id.update); button.setVisibility(View.GONE); // there is no update // for // this new app // get questionnaire button button = (Button) mDetailFragmentView.findViewById(R.id.btn_questionnaire); button.setVisibility(View.GONE); // there is no // questionnaire for // this new app } else if (mBelongsTo == RUNNING) { ab.setTitle(getString(R.string.userStudy_running)); // get start button Button button = (Button) mDetailFragmentView.findViewById(R.id.startapp); Button updateButton = (Button) mDetailFragmentView.findViewById(R.id.update); updateButton.setVisibility( RunningFragment.getInstance().getInstalledApps().get(getShownIndex()).getUpdateAvailable() ? View.VISIBLE : View.GONE); // change the text of it to install button.setText(getString(R.string.open)); // make an action listener for it button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { InstalledExternalApplication app = RunningFragment.getInstance().getInstalledApps().get(mIndex);// getShownIndex()); Log.d(LOG_TAG, "open app ( " + app.getName() + " ) with apkid = " + app.getID()); RunningFragment.getInstance().handleStartApp(app); } }); // get questionnaire button, if the questionnaire is not // yet // sent button = (Button) mDetailFragmentView.findViewById(R.id.btn_questionnaire); // check if it has Questionnaire and if it's sent if (InstalledExternalApplicationsManager.getInstance() == null) InstalledExternalApplicationsManager.init(MosesService.getInstance()); InstalledExternalApplication app = InstalledExternalApplicationsManager.getInstance() .getAppForId(mAPKID); Log.d(LOG_TAG, "app = " + app); if (app != null) { final boolean hasSurveyLocal = app.hasSurveyLocally(); boolean isQuestionnaireSent = hasSurveyLocal ? app.getSurvey().hasBeenSent() : false; Log.d(LOG_TAG, "hasQuestLocal" + hasSurveyLocal + "isQuestSent" + isQuestionnaireSent); // set button according to the booleans if (isQuestionnaireSent) { button.setText(getString(R.string.details_running_questionnairesent)); button.setClickable(false); button.setEnabled(false); } else { if (hasSurveyLocal) { button.setText(getString(R.string.btn_survey)); button.setClickable(true); button.setEnabled(true); } else { button.setText(getString(R.string.download_survey)); if (AsyncGetSurvey.isRunning()) { // disable the button, the async task is // still waiting for the survey button.setEnabled(false); } else { if (!app.getEndDateReached()) { // the button should be disabled because the end date has still not been reached button.setEnabled(false); } } } button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (hasSurveyLocal) { startSurveyActivity(mAPKID); } else { Log.d(LOG_TAG, "Getting Questionnaire from Server"); v.setEnabled(false); // disable the // button Toaster.showToast(mActivity, getString(R.string.notification_downloading_survey)); AsyncGetSurvey getSurveyAsyncTask = new AsyncGetSurvey(); InstalledExternalApplicationsManager.getInstance().getAppForId(mAPKID) .getQuestionnaireFromServer(); getSurveyAsyncTask.execute(mAPKID); } } }); } // get update button boolean updateAvailable = InstalledExternalApplicationsManager.getInstance().getAppForId(mAPKID) .isUpdateAvailable(); button = (Button) mDetailFragmentView.findViewById(R.id.update); if (updateAvailable) { button.setVisibility(View.VISIBLE); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AvailableFragment.getInstance().handleInstallApp( InstalledExternalApplicationsManager.getInstance().getAppForId(mAPKID)); } }); // make the label of survey button shorter Button surveyButton = (Button) mDetailFragmentView.findViewById(R.id.btn_questionnaire); surveyButton.setText(getString(R.string.btn_survey_short)); } else { button.setVisibility(View.GONE); } } } else if (mBelongsTo == HISTORY) { ab.setTitle(getString(R.string.userStudy_past)); // get start button Button button = (Button) mDetailFragmentView.findViewById(R.id.startapp); button.setVisibility(View.GONE); // hide open / install // button // get update button button = (Button) mDetailFragmentView.findViewById(R.id.update); button.setVisibility(View.GONE); // there is no update // for // this old app // get questionnaire button, if the questionnaire is not // yet // sent button = (Button) mDetailFragmentView.findViewById(R.id.btn_questionnaire); button.setVisibility(View.GONE); // check if it has Questionnaire and if it's sent if (HistoryExternalApplicationsManager.getInstance() == null) HistoryExternalApplicationsManager.init(MosesService.getInstance()); boolean hasQuestionnaire = HistoryExternalApplicationsManager.getInstance().getAppForId(mAPKID) .hasSurveyLocally(); // boolean isQuestionnaireSent = hasQuestionnaire ? HistoryExternalApplicationsManager // .getInstance().getAppForId(mAPKID).getSurvey() // .hasBeenSent() // : true; // set button according to the booleans if (!hasQuestionnaire) { button.setText(getString(R.string.details_running_noquestionnaire)); button.setClickable(false); button.setEnabled(false); } // else if (isQuestionnaireSent) { // button.setText(getString(R.string.details_running_questionnairesent)); // button.setClickable(false); // button.setEnabled(false); // } else { // we have Survey button.setVisibility(View.VISIBLE); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(mActivity, SurveyActivity.class); intent.putExtra(ExternalApplication.KEY_APK_ID, mAPKID); intent.putExtra(WelcomeActivity.KEY_BELONGS_TO, HISTORY); startActivity(intent); } }); } } }
From source file:email.schaal.ocreader.ListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*www .j a v a 2 s. c om*/ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setColorSchemeResources(R.color.primary); swipeRefreshLayout.setOnRefreshListener(this); profileDrawerItem = new ProfileDrawerItem() .withName(preferences.getString(Preferences.USERNAME.getKey(), getString(R.string.app_name))) .withEmail(Preferences.URL.getString(preferences)); updateUserProfile(); IProfile profileSettingsItem = new ProfileSettingDrawerItem().withName(getString(R.string.account_settings)) .withIconTinted(true).withIcon(R.drawable.ic_settings).withTag(new Runnable() { @Override public void run() { Intent loginIntent = new Intent(ListActivity.this, LoginActivity.class); startActivityForResult(loginIntent, LoginActivity.REQUEST_CODE); } }); accountHeader = new AccountHeaderBuilder().withActivity(this) .withHeaderBackground(R.drawable.header_background) .addProfiles(profileDrawerItem, profileSettingsItem).withCurrentProfileHiddenInList(true) .withProfileImagesClickable(false).withSavedInstance(savedInstanceState) .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { @Override public boolean onProfileChanged(View view, IProfile profile, boolean current) { if (profile instanceof Tagable) { Tagable tagable = (Tagable) profile; if (tagable.getTag() instanceof Runnable) { ((Runnable) tagable.getTag()).run(); return false; } } return true; } }).build(); refreshDrawerItem = new PrimaryDrawerItem().withName(getString(R.string.action_sync)).withSelectable(false) .withIconTintingEnabled(true).withIcon(R.drawable.ic_refresh).withIdentifier(REFRESH_DRAWER_ITEM_ID) .withTag(new Runnable() { @Override public void run() { SyncService.startSync(ListActivity.this); } }); DrawerBuilder startDrawerBuilder = new DrawerBuilder().withActivity(this).withAccountHeader(accountHeader) .addStickyDrawerItems(refreshDrawerItem).withOnDrawerListener(new Drawer.OnDrawerListener() { @Override public void onDrawerOpened(View drawerView) { drawerManager.getStartAdapter().updateUnreadCount(getRealm(), isShowOnlyUnread()); } @Override public void onDrawerClosed(View drawerView) { } @Override public void onDrawerSlide(View drawerView, float slideOffset) { } }).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem.getTag() instanceof TreeItem) { TreeItem item = (TreeItem) drawerItem.getTag(); onStartDrawerItemClicked(item); return false; } else if (drawerItem.getTag() instanceof Runnable) { ((Runnable) drawerItem.getTag()).run(); } return true; } }).withSavedInstance(savedInstanceState); DrawerBuilder endDrawerBuilder = new DrawerBuilder().withActivity(this).withDrawerGravity(Gravity.END) .withSavedInstance(savedInstanceState).withShowDrawerOnFirstLaunch(true) .withOnDrawerListener(new Drawer.OnDrawerListener() { @Override public void onDrawerOpened(View drawerView) { drawerManager.getEndAdapter().updateUnreadCount(getRealm(), isShowOnlyUnread()); } @Override public void onDrawerClosed(View drawerView) { } @Override public void onDrawerSlide(View drawerView, float slideOffset) { } }).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem.getTag() instanceof Feed) { Feed feed = (Feed) drawerItem.getTag(); onEndDrawerItemClicked(feed); return false; } return true; } }); startDrawerBuilder.withToolbar(toolbar); startDrawer = startDrawerBuilder.build(); drawerManager = new DrawerManager(this, startDrawer, endDrawerBuilder.append(startDrawer), isShowOnlyUnread(), this); RecyclerView itemsRecyclerView = (RecyclerView) findViewById(R.id.items_recyclerview); layoutManager = new LinearLayoutManager(this); adapter = new SelectableItemsAdapter(getRealm(), drawerManager.getState(), this, Preferences.ORDER.getOrder(preferences), Preferences.SORT_FIELD.getString(preferences), this); fab_mark_all_read = (FloatingActionButton) findViewById(R.id.fab_mark_all_as_read); fab_mark_all_read.setOnClickListener(new View.OnClickListener() { private void onCompletion(View view) { adapter.updateItems(false); view.setEnabled(true); } @Override public void onClick(final View v) { Queries.markTemporaryFeedAsRead(getRealm(), new Realm.Transaction.OnSuccess() { @Override public void onSuccess() { onCompletion(v); } }, new Realm.Transaction.OnError() { @Override public void onError(Throwable error) { error.printStackTrace(); onCompletion(v); } }); } }); fab_mark_all_read.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(ListActivity.this, R.string.mark_all_as_read, Toast.LENGTH_SHORT).show(); return true; } }); itemsRecyclerView.setAdapter(adapter); itemsRecyclerView.setLayoutManager(layoutManager); if (savedInstanceState != null) layoutManager.onRestoreInstanceState(savedInstanceState.getParcelable(LAYOUT_MANAGER_STATE)); itemsRecyclerView.addItemDecoration(new DividerItemDecoration(this, 40)); itemsRecyclerView.setItemAnimator(new DefaultItemAnimator()); drawerManager.getState().restoreInstanceState(getRealm(), PreferenceManager.getDefaultSharedPreferences(this)); adapter.updateItems(false); drawerManager.reloadAdapters(getRealm(), isShowOnlyUnread()); //noinspection ConstantConditions getSupportActionBar().setTitle(drawerManager.getState().getTreeItem().getName()); }
From source file:github.nisrulz.sampleoptimushttp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Setup Data/* w w w. j av a 2s .co m*/ data = new ArrayList<>(); data.add("POST Request"); data.add("GET Request"); data.add("PUT Request"); data.add("DELETE Request"); data.add("Cancel All Request"); progressDialog = new ProgressDialog(this); progressDialog.setMessage("Connecting"); textView_res = (TextView) findViewById(R.id.txt_res); //ListView lv = (ListView) findViewById(R.id.listView); adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, data); lv.setAdapter(adapter); // Initialize the OptimusHTTP Client client = new OptimusHTTP(this); // Enable Logs client.enableDebugging(); // Store the references of all the requests made in an arraylist for the purpose of cancelling them later on refHttpReqList = new ArrayList<>(); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { switch (position) { case 0: { // POST // Create a param key value map to post in body of req ArrayMap<String, String> params = new ArrayMap<>(); params.put("email", "abc@abc.com"); params.put("mobileno", "000000000"); params.put("Key1", "value1"); params.put("key2", "value2"); // Set method client.setMethod(OptimusHTTP.METHOD_POST); // Set Mode client.setMode(OptimusHTTP.MODE_PARALLEL); // Set Connect Timeout client.setConnectTimeout(10 * 1000); //ms // Set Read Timeout client.setReadTimeout(10 * 1000); //ms // Set Content Type client.setContentType(OptimusHTTP.CONTENT_TYPE_JSON); // Create a map of header key value pair and set headers to the client ArrayMap<String, String> headerMap = new ArrayMap<>(); headerMap.put("Accept-Encoding", "gzip, deflate"); headerMap.put("Accept-Language", "en-US"); headerMap.put("Content-Language", "en-US"); client.setHeaderMap(headerMap); try { // makeRequest() returns the reference of the request made // which can be used later to call the cancelReq() if required // if no request is made the makeRequest() returns null progressDialog.show(); req = client.makeRequest(SERVER, params, new OptimusHTTP.ResponseListener() { @Override public void onSuccess(String msg) { progressDialog.dismiss(); getInfoFromJson(msg); } @Override public void onFailure(String msg) { progressDialog.dismiss(); loadInfo(msg); } }); if (req != null) { refHttpReqList.add(req); } } catch (Exception e) { e.printStackTrace(); } } break; case 1: { // GET ArrayMap<String, String> params = new ArrayMap<>(); params.put("email", "abc@abc.com"); params.put("mobileno", "000000000"); client.setMethod(OptimusHTTP.METHOD_GET); client.setMode(OptimusHTTP.MODE_SEQ); try { progressDialog.show(); req = client.makeRequest(SERVER, params, responseListener); if (req != null) { refHttpReqList.add(req); } } catch (Exception e) { e.printStackTrace(); } } break; case 2: { //PUT ArrayMap<String, String> params = new ArrayMap<>(); params.put("email", "abc@abc.com"); params.put("mobileno", "000000000"); params.put("Key1", "value3"); params.put("key2", "value2"); client.setMethod(OptimusHTTP.METHOD_PUT); client.setMode(OptimusHTTP.MODE_SEQ); try { progressDialog.show(); req = client.makeRequest(SERVER, params, responseListener); if (req != null) { refHttpReqList.add(req); } } catch (Exception e) { e.printStackTrace(); } } break; case 3: { // DELETE ArrayMap<String, String> params = new ArrayMap<>(); client.setMethod(OptimusHTTP.METHOD_DELETE); client.setMode(OptimusHTTP.MODE_SEQ); try { progressDialog.show(); req = client.makeRequest(SERVER, params, responseListener); if (req != null) { refHttpReqList.add(req); } } catch (Exception e) { e.printStackTrace(); } } break; case 4: { // Cancel All if (refHttpReqList.size() > 0) { view.setEnabled(false); for (int i = 0; i < refHttpReqList.size(); i++) client.cancelReq(refHttpReqList.get(i)); refHttpReqList.clear(); view.setEnabled(true); } } break; } } }); }
From source file:com.android.soma.Launcher.java
/** * Sets the app market icon// w w w . ja v a 2 s. c o m */ private void updateAppMarketIcon() { if (!DISABLE_MARKET_BUTTON) { final View marketButton = findViewById(R.id.market_button); Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET); // Find the app market activity by resolving an intent. // (If multiple app markets are installed, it will return the ResolverActivity.) ComponentName activityName = intent.resolveActivity(getPackageManager()); if (activityName != null) { int coi = getCurrentOrientationIndexForGlobalIcons(); mAppMarketIntent = intent; sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(R.id.market_button, activityName, R.drawable.ic_launcher_market_holo, TOOLBAR_ICON_METADATA_NAME); marketButton.setVisibility(View.VISIBLE); } else { // We should hide and disable the view so that we don't try and restore the visibility // of it when we swap between drag & normal states from IconDropTarget subclasses. marketButton.setVisibility(View.GONE); marketButton.setEnabled(false); } } }
From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java
public void contextXposedPatch() { runWithWait(new Runnable() { public void run() { try { listAppsFragment.this.runToMain(new Runnable() { public void run() { localArrayList = new ArrayList(); Object localObject = null; try { JSONObject localJSONObject = Utils.readXposedParamBoolean(); localObject = localJSONObject; } catch (JSONException localJSONException) { for (;;) { localJSONException.printStackTrace(); localArrayList.add(new CoreItem(Utils.getText(2131165300), true)); localArrayList.add(new CoreItem(Utils.getText(2131165302), true)); localArrayList.add(new CoreItem(Utils.getText(2131165304), true)); localArrayList.add(new CoreItem(Utils.getText(2131165307), true)); localArrayList.add(new CoreItem(Utils.getText(2131165273), false)); }// w w w .j a v a 2 s.com } if (localObject != null) { localArrayList.clear(); localArrayList.add(new CoreItem(Utils.getText(2131165300), ((JSONObject) localObject).optBoolean("patch1", true))); localArrayList.add(new CoreItem(Utils.getText(2131165302), ((JSONObject) localObject).optBoolean("patch2", true))); localArrayList.add(new CoreItem(Utils.getText(2131165304), ((JSONObject) localObject).optBoolean("patch3", true))); localArrayList.add(new CoreItem(Utils.getText(2131165307), ((JSONObject) localObject).optBoolean("patch4", true))); localArrayList.add(new CoreItem(Utils.getText(2131165273), ((JSONObject) localObject).optBoolean("hide", false))); } if ((listAppsFragment.all_d != null) && (listAppsFragment.all_d.adapter != null)) { listAppsFragment.all_d.adapter.notifyDataSetChanged(); } listAppsFragment.removeDialogAll(39); listAppsFragment.showDialogAll(39, new ArrayAdapter(listAppsFragment.this.getContext(), 2130968605, localArrayList) { TextView txtStatus; TextView txtTitle; public View getView(int paramAnonymous3Int, View paramAnonymous3View, ViewGroup paramAnonymous3ViewGroup) { CoreItem localCoreItem = (CoreItem) getItem(paramAnonymous3Int); View localView = ((LayoutInflater) listAppsFragment.getInstance() .getSystemService("layout_inflater")).inflate(2130968642, paramAnonymous3ViewGroup, false); this.txtTitle = ((TextView) localView.findViewById(2131558483)); this.txtStatus = ((TextView) localView.findViewById(2131558484)); this.txtTitle.setTextAppearance(getContext(), listAppsFragment.getSizeText()); this.txtStatus.setTextAppearance(getContext(), listAppsFragment.getSizeText()); paramAnonymous3View = (CheckBox) localView.findViewById(2131558535); paramAnonymous3View.setChecked(localCoreItem.Status); if (!Utils.isXposedEnabled()) { paramAnonymous3View.setEnabled(false); paramAnonymous3View.setClickable(false); this.txtStatus.setTextAppearance(getContext(), 16973894); this.txtStatus.setTextColor(-7829368); this.txtTitle.setTextColor(-1); this.txtTitle.setText(((CoreItem) getItem(paramAnonymous3Int)).Name); this.txtTitle.setTypeface(null, 1); paramAnonymous3View = ((CoreItem) getItem(paramAnonymous3Int)).Name; this.txtTitle.setText( Utils.getColoredText(paramAnonymous3View, "#ff00ff00", "bold")); if (paramAnonymous3Int == 0) { paramAnonymous3View = Utils.getText(2131165301); } if (paramAnonymous3Int == 1) { paramAnonymous3View = Utils.getText(2131165303); } if (paramAnonymous3Int == 2) { paramAnonymous3View = Utils.getText(2131165305) + "\n" + Utils.getText(2131165306); } if (paramAnonymous3Int == 3) { paramAnonymous3View = Utils.getText(2131165309); } if (paramAnonymous3Int == 4) { paramAnonymous3View = Utils.getText(2131165274); } paramAnonymous3ViewGroup = paramAnonymous3View; if (Utils.isXposedEnabled()) { paramAnonymous3ViewGroup = paramAnonymous3View; if (localCoreItem.Status) { if (paramAnonymous3Int == 0) { if ((!Utils.checkCoreJarPatch11()) || (!Utils.checkCoreJarPatch12())) { break label595; } this.txtTitle .append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165814), "#ff008800", "")); } label370: if (paramAnonymous3Int == 1) { if (!Utils.checkCoreJarPatch20()) { break label648; } this.txtTitle .append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165814), "#ff008800", "")); } label431: if (paramAnonymous3Int == 2) { if (!Utils.checkCoreJarPatch30(listAppsFragment.getPkgMng())) { break label701; } this.txtTitle .append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165814), "#ff008800", "")); } label495: if (paramAnonymous3Int == 3) { if (!Utils.checkCoreJarPatch40()) { break label754; } this.txtTitle .append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165814), "#ff008800", "")); } } } } for (;;) { paramAnonymous3ViewGroup = paramAnonymous3View; if (paramAnonymous3Int == 4) { paramAnonymous3ViewGroup = Utils.getText(2131165274); } this.txtStatus.append(Utils.getColoredText(paramAnonymous3ViewGroup, "#ff888888", "italic")); return localView; paramAnonymous3View.setEnabled(true); break; label595: this.txtTitle.append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165806), "#ff880000", "")); break label370; label648: this.txtTitle.append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165806), "#ff880000", "")); break label431; label701: this.txtTitle.append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165806), "#ff880000", "")); break label495; label754: this.txtTitle.append(Utils.getColoredText( "\n" + Utils.getText(2131165815) + ": " + Utils.getText(2131165806), "#ff880000", "")); } } }); listAppsFragment.removeDialogLP(11); } }); return; } catch (Exception localException) { System.out.println("LuckyPatcher: handler Null."); } } }); System.out.println("LuckyPatcher: Start core.jar test!"); }