List of usage examples for android.view View setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.aikidonord.Intervenant.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intervenant); View rlLoading = findViewById(R.id.loadingPanel); View listView = findViewById(R.id.list); ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(getResources().getString(R.string.actionbar_titre_intervenant)); if (VerifConnexion.isOnline(this)) { rlLoading.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); new QueryForAnimateurTask().execute(this, this.getApplicationContext()); } else {//from w w w.j a va 2 s . com AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getResources().getString(R.string.app_name)); alertDialog.setMessage(getResources().getString(R.string.no_network)); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setCancelable(false); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity Intervenant.this.finish(); } }); alertDialog.show(); } }
From source file:com.afayear.android.client.activity.DualPaneActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); super.onCreate(savedInstanceState); final Resources res = getResources(); final int orientation = res.getConfiguration().orientation; final int layout; final boolean is_large_screen = res.getBoolean(R.bool.is_large_screen); mDualPaneInPortrait = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_PORTRAIT, is_large_screen); mDualPaneInLandscape = mPreferences.getBoolean(PREFERENCE_KEY_DUAL_PANE_IN_LANDSCAPE, is_large_screen); switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: layout = mDualPaneInLandscape || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes() : getNormalLayoutRes();/*from w w w . j av a 2 s.co m*/ break; case Configuration.ORIENTATION_PORTRAIT: layout = mDualPaneInPortrait || shouldForceEnableDualPaneMode() ? getDualPaneLayoutRes() : getNormalLayoutRes(); break; default: layout = getNormalLayoutRes(); break; } setContentView(layout); if (mSlidingPane != null) { mSlidingPane.setRightPaneBackground(getPaneBackground()); } final FragmentManager fm = getSupportFragmentManager(); fm.addOnBackStackChangedListener(this); if (savedInstanceState != null) { final Fragment left_pane_fragment = fm.findFragmentById(PANE_LEFT); final View main_view = findViewById(R.id.main); final boolean left_pane_used = left_pane_fragment != null && left_pane_fragment.isAdded(); if (main_view != null) { final int visibility = left_pane_used ? View.GONE : View.VISIBLE; main_view.setVisibility(visibility); } } }
From source file:tf.nox.wifisetup.WifiSetup.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.logon);// w ww .ja v a 2s. com flipper = (ViewFlipper) findViewById(R.id.viewflipper); username = (EditText) findViewById(R.id.username); password = (EditText) findViewById(R.id.password); check5g = (CheckBox) findViewById(R.id.check5g); check5g.setChecked(true); /* TextView label5g = (TextView) findViewById(R.id.label5g); if (android.os.Build.VERSION.SDK_INT >= 21) { check5g.setChecked(get5G()); label5g.setText("(autodetected value)"); } else { check5g.setChecked(true); label5g.setText("(Android 5.0 is needed to autodetect this)"); } */ ImageView img = (ImageView) findViewById(R.id.logo); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { logoclicks++; if (logoclicks == 4) { toastText("You're cute!"); } if (logoclicks == 6) { toastText("Stop that!"); } if (logoclicks == 7) { View logindata = findViewById(R.id.logindata); logindata.setVisibility(View.VISIBLE); } } }); btn = (Button) findViewById(R.id.button1); if (btn == null) throw new RuntimeException("button1 not found. Odd"); btn.setOnClickListener(new Button.OnClickListener() { public void onClick(View _v) { if (busy) { return; } busy = true; _v.setClickable(false); // Most of this stuff runs in the background Thread t = new Thread() { @Override public void run() { try { if (android.os.Build.VERSION.SDK_INT >= 18) { saveWifiConfig(); resultStatus(true, "You should now have a wifi connection entry with correct security settings and certificate verification.\n\nMake sure to actually use it!"); // Clear the password field in the UI thread /* mHandler.post(new Runnable() { @Override public void run() { password.setText(""); }; }); */ } else { throw new RuntimeException("What version is this?! API Mismatch"); } } catch (RuntimeException e) { resultStatus(false, "Something went wrong: " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } busy = false; mHandler.post(new Runnable() { @Override public void run() { btn.setClickable(true); }; }); } }; t.start(); } }); }
From source file:net.openid.appauthdemo.TokenActivity.java
@MainThread private void displayAuthorized() { findViewById(R.id.authorized).setVisibility(View.VISIBLE); findViewById(R.id.not_authorized).setVisibility(View.GONE); findViewById(R.id.loading_container).setVisibility(View.GONE); AuthState state = mStateManager.getCurrent(); TextView refreshTokenInfoView = (TextView) findViewById(R.id.refresh_token_info); refreshTokenInfoView.setText((state.getRefreshToken() == null) ? R.string.no_refresh_token_returned : R.string.refresh_token_returned); TextView idTokenInfoView = (TextView) findViewById(R.id.id_token_info); idTokenInfoView//from w w w . ja v a 2s . c o m .setText((state.getIdToken()) == null ? R.string.no_id_token_returned : R.string.id_token_returned); TextView accessTokenInfoView = (TextView) findViewById(R.id.access_token_info); if (state.getAccessToken() == null) { accessTokenInfoView.setText(R.string.no_access_token_returned); } else { Long expiresAt = state.getAccessTokenExpirationTime(); if (expiresAt == null) { accessTokenInfoView.setText(R.string.no_access_token_expiry); } else if (expiresAt < System.currentTimeMillis()) { accessTokenInfoView.setText(R.string.access_token_expired); } else { String template = getResources().getString(R.string.access_token_expires_at); accessTokenInfoView.setText(String.format(template, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss ZZ").print(expiresAt))); } } Button refreshTokenButton = (Button) findViewById(R.id.refresh_token); refreshTokenButton.setVisibility(state.getRefreshToken() != null ? View.VISIBLE : View.GONE); refreshTokenButton.setOnClickListener((View view) -> refreshAccessToken()); Button viewProfileButton = (Button) findViewById(R.id.view_profile); AuthorizationServiceDiscovery discoveryDoc = state.getAuthorizationServiceConfiguration().discoveryDoc; if (discoveryDoc == null || discoveryDoc.getUserinfoEndpoint() == null) { viewProfileButton.setVisibility(View.GONE); } else { viewProfileButton.setVisibility(View.VISIBLE); viewProfileButton.setOnClickListener((View view) -> fetchUserInfo()); } ((Button) findViewById(R.id.sign_out)).setOnClickListener((View view) -> signOut()); View userInfoCard = findViewById(R.id.userinfo_card); JSONObject userInfo = mUserInfoJson.get(); if (userInfo == null) { userInfoCard.setVisibility(View.INVISIBLE); } else { try { String name = "???"; if (userInfo.has("name")) { name = userInfo.getString("name"); } ((TextView) findViewById(R.id.userinfo_name)).setText(name); if (userInfo.has("picture")) { Glide.with(TokenActivity.this).load(Uri.parse(userInfo.getString("picture"))).fitCenter() .into((ImageView) findViewById(R.id.userinfo_profile)); } ((TextView) findViewById(R.id.userinfo_json)).setText(mUserInfoJson.toString()); userInfoCard.setVisibility(View.VISIBLE); } catch (JSONException ex) { Log.e(TAG, "Failed to read userinfo JSON", ex); } } }
From source file:id.zelory.tanipedia.activity.TanyaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tanya); toolbar = (Toolbar) findViewById(R.id.anim_toolbar); setSupportActionBar(toolbar);//from w w w . j a va2 s . co m getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle("Tanya Tani"); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin); drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer); setUpNavDrawer(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.getMenu().getItem(2).setChecked(true); TextView nama = (TextView) navigationView.findViewById(R.id.nama); nama.setText(PrefUtils.ambilString(this, "nama")); TextView email = (TextView) navigationView.findViewById(R.id.email); email.setText(PrefUtils.ambilString(this, "email")); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawers(); Intent intent; switch (menuItem.getItemId()) { case R.id.cuaca: intent = new Intent(TanyaActivity.this, CuacaActivity.class); break; case R.id.berita: intent = new Intent(TanyaActivity.this, BeritaActivity.class); break; case R.id.tanya: return true; case R.id.harga: intent = new Intent(TanyaActivity.this, KomoditasActivity.class); break; case R.id.logout: PrefUtils.simpanString(TanyaActivity.this, "nama", null); intent = new Intent(TanyaActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); return true; case R.id.tentang: intent = new Intent(TanyaActivity.this, TentangActivity.class); startActivity(intent); return true; default: return true; } startActivity(intent); finish(); return true; } }); recyclerView = (RecyclerView) findViewById(R.id.scrollableview); recyclerView.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.addOnScrollListener(new MyRecyclerScroll() { @Override public void show() { fab.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } @Override public void hide() { fab.animate().translationY(fab.getHeight() + fabMargin) .setInterpolator(new AccelerateInterpolator(2)).start(); } }); tanyaGambar = (ImageView) findViewById(R.id.tanya_gambar); tanyaGambar.setVisibility(View.GONE); fab = (FrameLayout) findViewById(R.id.myfab_main); fab.setVisibility(View.GONE); fabBtn = (ImageButton) findViewById(R.id.myfab_main_btn); View fabShadow = findViewById(R.id.myfab_shadow); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { fabShadow.setVisibility(View.GONE); fabBtn.setBackground(getDrawable(R.drawable.ripple_accent)); } fabBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new MaterialDialog.Builder(TanyaActivity.this).title("TaniPedia").content("Kirim Pertanyaan") .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT) .input("Ketik pertanyaan anda disini!", null, false, new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { try { pertanyaan = URLEncoder.encode(input.toString(), "UTF-8"); new KirimSoal().execute(); } catch (UnsupportedEncodingException e) { Snackbar.make(fabBtn, "Terjadi kesalahan, silahkan coba lagi!", Snackbar.LENGTH_LONG).show(); e.printStackTrace(); } } }).positiveColorRes(R.color.primary_dark).positiveText("Kirim") .cancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { } }).negativeColorRes(R.color.primary_dark).negativeText("Batal").show(); } }); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.showProgress(true); new DownloadData().execute(); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fabButton.showProgress(true); new DownloadData().execute(); } }); }
From source file:ca.marklauman.dominionpicker.CardAdapter.java
/** Binds the contents of the Cursor to View elements * provided by this adapter. When a value is bound * by this method, it returns {@code true}, so * that no other binding is performed. If it * returns false, the value is bound by the default * SimpleCursorAdapter methods.//from ww w .j a va 2 s. c o m * @param view the view to bind the data to. * @param cursor the cursor to get the data from * (it has been moved to the appropriate position * for this row). * @param columnIndex the index of the column * that is being bound right now. * @return {@code true} if that column was bound to * the view, {@code false} otherwise. */ @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (col_cost == columnIndex || col_gold == columnIndex || col_vict == columnIndex) { if ("0".equals(cursor.getString(columnIndex))) view.setVisibility(View.GONE); else view.setVisibility(View.VISIBLE); return false; } else if (col_potion == columnIndex) { if (1 > cursor.getInt(columnIndex)) view.setVisibility(View.GONE); else view.setVisibility(View.VISIBLE); return true; } else if (col_expansion == columnIndex) { String val = cursor.getString(col_expansion); ImageView v = (ImageView) view; v.setContentDescription(val); Integer icon_id = exp_icons.get(val); if (icon_id == null) icon_id = R.drawable.ic_set_unknown; v.setImageResource(icon_id); return true; } else if (col_buy == columnIndex) { String res = ""; String val = cursor.getString(col_buy); if (!"0".equals(val)) res += ", +" + val + " buy"; val = cursor.getString(col_draw); if (!"0".equals(val)) res += ", +" + val + " card"; val = cursor.getString(col_act); if (!"0".equals(val)) res += ", +" + val + " action"; if (0 != col_gold && 0 != col_vict && res.length() > 2) res = res.substring(2); if ("".equals(res)) view.setVisibility(View.GONE); else { view.setVisibility(View.VISIBLE); TextView v = (TextView) view; v.setText(res); } return true; } else if (col_desc == columnIndex) { String desc = cursor.getString(columnIndex); if ("".equals(desc)) { view.setVisibility(View.GONE); return true; } view.setVisibility(View.VISIBLE); return false; } else if (col_id == columnIndex) { TextView v = (TextView) view; if (yw_bane != cursor.getLong(col_id)) v.setVisibility(View.GONE); else v.setVisibility(View.VISIBLE); return true; } return false; }
From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflator.inflate(R.layout.create_account_generic_row, parent, false); }/*from ww w. java 2 s . co m*/ LinearLayout formLayout = (LinearLayout) convertView.findViewById(R.id.create_account_form); // Next button should be invisible in last form. View nextButton = convertView.findViewById(R.id.create_account_next); if (position == FORMS_QTY - 1) { nextButton.setVisibility(View.GONE); } else { nextButton.setVisibility(View.VISIBLE); } if (mDelegate != null) { nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mDelegate.scroll(CreateAccountDelegate.FORWARD); } }); } // Handle create account button Button createButton = (Button) convertView.findViewById(R.id.create_account_create); if (position == FORMS_QTY - 1) { createButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processForm(); } }); createButton.setVisibility(View.VISIBLE); } else { createButton.setVisibility(View.GONE); } switch (position) { case 0: populateFirstForm(formLayout); break; case 1: populateSecondForm(formLayout); break; case 2: populateThirdForm(formLayout); break; case 3: populateFourthForm(formLayout); break; default: break; } return convertView; }
From source file:br.com.devfestsul.planetas.utils.ScrollAwareFABBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; }// w w w. j av a2 s . co m public void onAnimationCancel(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:br.com.bioscada.apps.biotracks.fragments.MarkerDetailFragment.java
/** * Updates the UI./*from www. j a va 2 s. c o m*/ */ @SuppressWarnings("deprecation") private void updateUi() { View waypointView = getView().findViewById(R.id.marker_detail_waypoint); View statisticsView = getView().findViewById(R.id.marker_detail_statistics); boolean isWaypoint = waypoint.getType() == Waypoint.WaypointType.WAYPOINT; waypointView.setVisibility(isWaypoint ? View.VISIBLE : View.GONE); statisticsView.setVisibility(isWaypoint ? View.GONE : View.VISIBLE); if (isWaypoint) { String photoUrl = waypoint.getPhotoUrl(); boolean hasPhoto = photoUrl != null && !photoUrl.equals(""); photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE); textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE); waypointInfo.setVisibility(View.VISIBLE); if (hasPhoto) { handler.removeCallbacks(hideText); Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay(); PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), defaultDisplay.getHeight(), true); handler.postDelayed(hideText, HIDE_TEXT_DELAY); } setName(R.id.marker_detail_waypoint_name, hasPhoto); TextView category = (TextView) getView().findViewById(R.id.marker_detail_waypoint_category); ListItemUtils.setTextView(getActivity(), category, StringUtils.getCategory(waypoint.getCategory()), hasPhoto); TextView description = (TextView) getView().findViewById(R.id.marker_detail_waypoint_description); ListItemUtils.setTextView(getActivity(), description, waypoint.getDescription(), hasPhoto); setLocation(R.id.marker_detail_waypoint_location, hasPhoto); } else { setName(R.id.marker_detail_statistics_name, false); setLocation(R.id.marker_detail_statistics_location, false); Track track = myTracksProviderUtils.getTrack(waypoint.getTrackId()); ActivityType activityType = track != null ? CalorieUtils.getActivityType(getActivity(), track.getCategory()) : ActivityType.INVALID; StatsUtils.setTripStatisticsValues(getActivity(), null, getView(), waypoint.getTripStatistics(), activityType, null); StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false); } }
From source file:cn.lingox.android.share.view.ScrollAwareFABBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; }/* w w w . j av a2s .co m*/ public void onAnimationCancel(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.design_fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }