List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:com.google.android.apps.santatracker.rocketsleigh.RocketSleighActivity.java
private void addFactoryObstacles(int screens) { int totalSlots = screens * SLOTS_PER_SCREEN; for (int i = 0; i < totalSlots;) { // Any given "slot" has a 1 in 3 chance of having an obstacle if (mRandom.nextInt(2) == 0) { View view = mInflater.inflate(R.layout.obstacle_layout, null); ImageView top = (ImageView) view.findViewById(R.id.top_view); ImageView bottom = (ImageView) view.findViewById(R.id.bottom_view); ImageView back = (ImageView) view.findViewById(R.id.back_view); // Which obstacle? int width = 0; // int obstacle = mRandom.nextInt((FACTORY_OBSTACLES.length/2)); if ((mFactoryObstacleIndex % 20) == 0) { ObstacleLoadTask task = new ObstacleLoadTask(getResources(), FACTORY_OBSTACLES, mFactoryObstacles, mFactoryObstacleList, mFactoryObstacleIndex + 20, 2, mScaleX, mScaleY);/*from w w w. jav a2s .c o m*/ task.execute(); } int obstacle = mFactoryObstacleList.get(mFactoryObstacleIndex++); if (mFactoryObstacleIndex >= mFactoryObstacleList.size()) { mFactoryObstacleIndex = 0; } int topIndex = obstacle * 2; int bottomIndex = topIndex + 1; back.setVisibility(View.GONE); int currentObstacle = 0; // Same values as mLastObstacle if (FACTORY_OBSTACLES[topIndex] != -1) { currentObstacle |= 1; Bitmap bmp = null; synchronized (mFactoryObstacles) { bmp = mFactoryObstacles.get(FACTORY_OBSTACLES[topIndex]); } while (bmp == null) { synchronized (mFactoryObstacles) { bmp = mFactoryObstacles.get(FACTORY_OBSTACLES[topIndex]); if (bmp == null) { try { mFactoryObstacles.wait(); } catch (InterruptedException e) { } } } } width = bmp.getWidth(); top.setImageBitmap(bmp); } else { top.setVisibility(View.GONE); } if (FACTORY_OBSTACLES[bottomIndex] != -1) { currentObstacle |= 2; Bitmap bmp = null; synchronized (mFactoryObstacles) { bmp = mFactoryObstacles.get(FACTORY_OBSTACLES[bottomIndex]); } while (bmp == null) { synchronized (mFactoryObstacles) { bmp = mFactoryObstacles.get(FACTORY_OBSTACLES[bottomIndex]); if (bmp == null) { try { mFactoryObstacles.wait(); } catch (InterruptedException e) { } } } } if (bmp.getWidth() > width) { width = bmp.getWidth(); } bottom.setImageBitmap(bmp); } else { bottom.setVisibility(View.GONE); } int slots = (width / mSlotWidth); if ((width % mSlotWidth) != 0) { slots++; } // If last obstacle had a top and this is a bottom or vice versa, insert a space if ((mLastObstacle & 0x1) > 0) { if ((currentObstacle & 0x2) > 0) { addSpaceOrPresent(mSlotWidth); i++; } } else if ((mLastObstacle & 0x2) > 0) { if ((currentObstacle & 0x1) > 0) { addSpaceOrPresent(mSlotWidth); i++; } } // If the new obstacle is too wide for the remaining space, skip it and fill spacer instead if ((i + slots) > totalSlots) { addSpaceOrPresent(mSlotWidth * (totalSlots - i)); i = totalSlots; } else { mLastObstacle = currentObstacle; LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(slots * mSlotWidth, LinearLayout.LayoutParams.WRAP_CONTENT); view.setLayoutParams(lp); mObstacleLayout.addView(view); i += slots; } } else { addSpaceOrPresent(mSlotWidth); i++; } } // Account for rounding errors in mSlotWidth int extra = ((screens * mScreenWidth) - (totalSlots * mSlotWidth)); if (extra > 0) { // Add filler to ensure sync with background/foreground scrolls! LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(extra, LinearLayout.LayoutParams.MATCH_PARENT); View view = new View(this); view.setLayerType(View.LAYER_TYPE_HARDWARE, null); mObstacleLayout.addView(view, lp); } }
From source file:ua.mkh.settings.full.MainActivity.java
@SuppressLint("NewApi") @Override/*from ww w. j a va 2 s.c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //try { String roman = "fonts/Regular.otf"; String medium = "fonts/Medium.otf"; String bold = "fonts/Bold.otf"; String thin = "fonts/Thin.otf"; typefaceRoman = Typeface.createFromAsset(getAssets(), roman); typefaceMedium = Typeface.createFromAsset(getAssets(), medium); typefaceBold = Typeface.createFromAsset(getAssets(), bold); typefaceThin = Typeface.createFromAsset(getAssets(), thin); mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE); ll1 = (LinearLayout) findViewById(R.id.ll1); ll1.requestFocus(); searchView = (SearchView) findViewById(R.id.search); searchView.setIconifiedByDefault(false); searchView.setOnQueryTextListener(this); searchView.setOnCloseListener(this); mListView = (ListView) findViewById(R.id.list); b1 = (Button) findViewById(R.id.button1); b2 = (Button) findViewById(R.id.button2); b11 = (Button) findViewById(R.id.button11); b21 = (Button) findViewById(R.id.button21); ed1 = (EditText) findViewById(R.id.EditText01); ed11 = (EditText) findViewById(R.id.EditText011); b21.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { b11.setVisibility(View.GONE); b21.setVisibility(View.GONE); ed11.clearFocus(); ed1.clearFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(ed1.getWindowToken(), 0); ed11.setText(""); ed1.setText(""); LinearLayout list_res_top = (LinearLayout) findViewById(R.id.list_res_top); list_res_top.setVisibility(View.GONE); LinearLayout list_res = (LinearLayout) findViewById(R.id.list_res); list_res.setVisibility(View.GONE); ll1.setVisibility(View.VISIBLE); sear = false; } }); ed1.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { b11.setVisibility(View.VISIBLE); b21.setVisibility(View.VISIBLE); LinearLayout list_res_top = (LinearLayout) findViewById(R.id.list_res_top); list_res_top.setVisibility(View.VISIBLE); LinearLayout list_res = (LinearLayout) findViewById(R.id.list_res); list_res.setVisibility(View.VISIBLE); sear = true; //ll1.setVisibility(View.INVISIBLE); ed11.requestFocus(); ed1.clearFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(ed11, InputMethodManager.SHOW_IMPLICIT); //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); //lp.setMargins(0, 0, 0, 0); //ll1.setLayoutParams(lp); } else { ll1.setVisibility(View.GONE); b11.setVisibility(View.VISIBLE); LinearLayout list_res = (LinearLayout) findViewById(R.id.list_res); list_res.setVisibility(View.VISIBLE); //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); //lp.setMargins(0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 39, getResources().getDisplayMetrics()), 0, 0); //ll1.setLayoutParams(lp); } } }); ed11.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text searchView.setQuery(cs, false); mListView.setVisibility(View.VISIBLE); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void afterTextChanged(Editable arg0) { } }); mDbHelper = new CustomersDbAdapter(this); mDbHelper.open(); /* //Clean all Customers mDbHelper.deleteAllCustomers(); */ ////////////////////// LinearLayoutWiFi = (LinearLayout) findViewById(R.id.LinearLayoutWiFi); LinearLayoutBluetooth = (LinearLayout) findViewById(R.id.LinearLayoutBluetooth); LinearLayoutSotSvyaz = (LinearLayout) findViewById(R.id.LinearLayoutSotSvyaz); LinearLayoutOperator = (LinearLayout) findViewById(R.id.LinearLayoutOperator); LinearLayoutGeo = (LinearLayout) findViewById(R.id.LinearLayoutGeo); LinearLayoutNotif = (LinearLayout) findViewById(R.id.LinearLayoutNotif); LinearLayoutControl = (LinearLayout) findViewById(R.id.LinearLayoutControl); LinearLayoutMail = (LinearLayout) findViewById(R.id.LinearLayoutMail); LinearLayoutNotes = (LinearLayout) findViewById(R.id.LinearLayoutNotes); LinearLayoutMessages = (LinearLayout) findViewById(R.id.LinearLayoutMessages); LinearLayoutPhone = (LinearLayout) findViewById(R.id.LinearLayoutPhone); LinearLayoutSafari = (LinearLayout) findViewById(R.id.LinearLayoutSafari); LinearLayoutMusic = (LinearLayout) findViewById(R.id.LinearLayoutMusic); LinearLayoutCompass = (LinearLayout) findViewById(R.id.LinearLayoutCompass); LinearLayoutWeather = (LinearLayout) findViewById(R.id.LinearLayoutWeather); LinearLayoutGameCenter = (LinearLayout) findViewById(R.id.LinearLayoutGameCenter); LinearLayoutPasscode = (LinearLayout) findViewById(R.id.LinearLayoutPasscode); LinearLayoutPrivacy = (LinearLayout) findViewById(R.id.LinearLayoutPrivacy); LinearLayoutApn = (LinearLayout) findViewById(R.id.LinearLayoutApn); LinearLayoutCloud = (LinearLayout) findViewById(R.id.LinearLayoutCloud); LinearLayoutTunes = (LinearLayout) findViewById(R.id.LinearLayoutTunes); LinearLayoutMaps = (LinearLayout) findViewById(R.id.LinearLayoutMaps); LinearLayoutVk = (LinearLayout) findViewById(R.id.LinearLayoutVk); LinearLayoutViber = (LinearLayout) findViewById(R.id.LinearLayoutViber); LinearLayoutOk = (LinearLayout) findViewById(R.id.LinearLayoutOK); LinearLayoutSkype = (LinearLayout) findViewById(R.id.LinearLayoutSkype); LinearLayoutWhatsapp = (LinearLayout) findViewById(R.id.LinearLayoutWhatsApp); LinearLayoutTwitter = (LinearLayout) findViewById(R.id.LinearLayoutTwitter); LinearLayoutFacebook = (LinearLayout) findViewById(R.id.LinearLayoutFacebook); LinearLayoutInstagram = (LinearLayout) findViewById(R.id.LinearLayoutInstagram); LinearLayoutNew1 = (LinearLayout) findViewById(R.id.LinearLayoutApp1); LinearLayoutNew2 = (LinearLayout) findViewById(R.id.LinearLayoutApp2); LinearLayoutNew3 = (LinearLayout) findViewById(R.id.LinearLayoutApp3); LinearLayoutNew4 = (LinearLayout) findViewById(R.id.LinearLayoutApp4); LinearLayoutNew1.setVisibility(View.GONE); LinearLayoutNew2.setVisibility(View.GONE); LinearLayoutNew3.setVisibility(View.GONE); LinearLayoutNew4.setVisibility(View.GONE); LinearLayoutGeo.setVisibility(View.GONE); LinearLayoutMail.setVisibility(View.GONE); LinearLayoutNotes.setVisibility(View.GONE); LinearLayoutMessages.setVisibility(View.GONE); LinearLayoutPhone.setVisibility(View.GONE); LinearLayoutSafari.setVisibility(View.GONE); LinearLayoutMusic.setVisibility(View.GONE); LinearLayoutCompass.setVisibility(View.GONE); LinearLayoutWeather.setVisibility(View.GONE); LinearLayoutGameCenter.setVisibility(View.GONE); LinearLayoutNotif.setVisibility(View.GONE); LinearLayoutControl.setVisibility(View.GONE); LinearLayoutTunes.setVisibility(View.GONE); LinearLayoutMaps.setVisibility(View.GONE); LinearLayoutVk.setVisibility(View.GONE); LinearLayoutViber.setVisibility(View.GONE); LinearLayoutOk.setVisibility(View.GONE); LinearLayoutSkype.setVisibility(View.GONE); LinearLayoutWhatsapp.setVisibility(View.GONE); LinearLayoutTwitter.setVisibility(View.GONE); LinearLayoutFacebook.setVisibility(View.GONE); LinearLayoutInstagram.setVisibility(View.GONE); textwifi = (TextView) findViewById(R.id.textwifi); textbt = (TextView) findViewById(R.id.textbt); TextOper = (TextView) findViewById(R.id.TextOper); textVPN = (TextView) findViewById(R.id.TextView01); wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); btn_avia = (Button) findViewById(R.id.Button01); tb_am = (ToggleButton) findViewById(R.id.ToggleButton01); tb_am.setOnClickListener(this); btn_wifi = (Button) findViewById(R.id.ButtonWifi); btn_wifi.setOnClickListener(this); btn_bluetooth = (Button) findViewById(R.id.ButtonBluetooth); btn_bluetooth.setOnClickListener(this); btn_sota = (Button) findViewById(R.id.ButtonSota); btn_sota.setOnClickListener(this); startService(new Intent(this, NotificationService.class)); btn_operator = (Button) findViewById(R.id.ButtonOperator); btn_operator.setOnClickListener(this); btn_osnova = (Button) findViewById(R.id.ButtonOsnova); btn_osnova.setOnClickListener(this); btn_zvuki = (Button) findViewById(R.id.ButtonZvuki); btn_zvuki.setOnClickListener(this); btn_oboi = (Button) findViewById(R.id.ButtonOboi); btn_oboi.setOnClickListener(this); btn_gps = (Button) findViewById(R.id.ButtonGeo); btn_gps.setOnClickListener(this); btn_passcode = (Button) findViewById(R.id.ButtonPasscode); btn_passcode.setOnClickListener(this); btn_battery = (Button) findViewById(R.id.ButtonBattery); btn_battery.setOnClickListener(this); btn_privacy = (Button) findViewById(R.id.ButtonPrivacy); btn_privacy.setOnClickListener(this); btn_notification = (Button) findViewById(R.id.ButtonNotification); btn_notification.setOnClickListener(this); btn_control = (Button) findViewById(R.id.ButtonControl); btn_control.setOnClickListener(this); btn_disturb = (Button) findViewById(R.id.ButtonDisturb); btn_disturb.setOnClickListener(this); btn_mail = (Button) findViewById(R.id.ButtonMail); btn_mail.setOnClickListener(this); btn_notes = (Button) findViewById(R.id.ButtonNotes); btn_notes.setOnClickListener(this); btn_messages = (Button) findViewById(R.id.ButtonMessages); btn_messages.setOnClickListener(this); btn_phone = (Button) findViewById(R.id.ButtonPhone); btn_phone.setOnClickListener(this); btn_safari = (Button) findViewById(R.id.ButtonSafari); btn_safari.setOnClickListener(this); btn_music = (Button) findViewById(R.id.ButtonMusic); btn_music.setOnClickListener(this); btn_compass = (Button) findViewById(R.id.ButtonCompass); btn_compass.setOnClickListener(this); btn_weather = (Button) findViewById(R.id.ButtonWeather); btn_weather.setOnClickListener(this); btn_games = (Button) findViewById(R.id.ButtonGameCenter); btn_games.setOnClickListener(this); btn_maps = (Button) findViewById(R.id.ButtonMaps); btn_maps.setOnClickListener(this); btn_vk = (Button) findViewById(R.id.ButtonVk); btn_vk.setOnClickListener(this); btn_viber = (Button) findViewById(R.id.ButtonViber); btn_viber.setOnClickListener(this); btn_ok = (Button) findViewById(R.id.ButtonOk); btn_ok.setOnClickListener(this); btn_skype = (Button) findViewById(R.id.ButtonSkype); btn_skype.setOnClickListener(this); btn_whatsapp = (Button) findViewById(R.id.ButtonWhatsapp); btn_whatsapp.setOnClickListener(this); btn_twitter = (Button) findViewById(R.id.ButtonTwitter); btn_twitter.setOnClickListener(this); btn_facebook = (Button) findViewById(R.id.ButtonFacebook); btn_facebook.setOnClickListener(this); btn_instagram = (Button) findViewById(R.id.ButtonInstagram); btn_instagram.setOnClickListener(this); btn_new1 = (Button) findViewById(R.id.Button02); btn_new1.setOnClickListener(this); btn_new2 = (Button) findViewById(R.id.Button03); btn_new2.setOnClickListener(this); btn_new3 = (Button) findViewById(R.id.Button04); btn_new3.setOnClickListener(this); btn_new4 = (Button) findViewById(R.id.Button05); btn_new4.setOnClickListener(this); btn_vpn = (Button) findViewById(R.id.Button06); btn_vpn.setOnClickListener(this); btn_display = (Button) findViewById(R.id.ButtonDisplay); btn_display.setOnClickListener(this); btn_iCloud = (Button) findViewById(R.id.ButtonCloud); btn_iCloud.setOnClickListener(this); btn_iTunes = (Button) findViewById(R.id.ButtonTunes); btn_iTunes.setOnClickListener(this); buttonBack = (Button) findViewById(R.id.buttonBack); btn_menu_settings = (Button) findViewById(R.id.ButtonMenuSettings); btn_menu_cancel = (Button) findViewById(R.id.ButtonMenuCancel); textView1 = (TextView) findViewById(R.id.textView1); textView2 = (TextView) findViewById(R.id.textView2); textView3 = (TextView) findViewById(R.id.textView3); text_app_main = (TextView) findViewById(R.id.text_app_main); text_app_main.setText(R.string.text_app_name); ImageView imageView2 = (ImageView) findViewById(R.id.imageView2); imageView2.setVisibility(View.GONE); text_app_main.setTypeface(typefaceBold); btn_avia.setTypeface(typefaceRoman); //textView1.setTypeface(typefaceRoman); textView3.setTypeface(typefaceRoman); btn_wifi.setTypeface(typefaceRoman); btn_bluetooth.setTypeface(typefaceRoman); btn_sota.setTypeface(typefaceRoman); btn_operator.setTypeface(typefaceRoman); btn_osnova.setTypeface(typefaceRoman); btn_passcode.setTypeface(typefaceRoman); btn_battery.setTypeface(typefaceRoman); btn_privacy.setTypeface(typefaceRoman); btn_zvuki.setTypeface(typefaceRoman); btn_oboi.setTypeface(typefaceRoman); btn_notification.setTypeface(typefaceRoman); btn_control.setTypeface(typefaceRoman); btn_disturb.setTypeface(typefaceRoman); btn_gps.setTypeface(typefaceRoman); btn_mail.setTypeface(typefaceRoman); btn_notes.setTypeface(typefaceRoman); btn_messages.setTypeface(typefaceRoman); btn_phone.setTypeface(typefaceRoman); btn_safari.setTypeface(typefaceRoman); btn_music.setTypeface(typefaceRoman); btn_compass.setTypeface(typefaceRoman); btn_weather.setTypeface(typefaceRoman); btn_games.setTypeface(typefaceRoman); btn_new1.setTypeface(typefaceRoman); btn_new2.setTypeface(typefaceRoman); btn_new3.setTypeface(typefaceRoman); btn_new4.setTypeface(typefaceRoman); btn_vpn.setTypeface(typefaceRoman); btn_display.setTypeface(typefaceRoman); btn_maps.setTypeface(typefaceRoman); btn_vk.setTypeface(typefaceRoman); btn_viber.setTypeface(typefaceRoman); btn_ok.setTypeface(typefaceRoman); btn_skype.setTypeface(typefaceRoman); btn_whatsapp.setTypeface(typefaceRoman); btn_twitter.setTypeface(typefaceRoman); btn_facebook.setTypeface(typefaceRoman); btn_instagram.setTypeface(typefaceRoman); btn_iCloud.setTypeface(typefaceRoman); btn_iTunes.setTypeface(typefaceRoman); textwifi.setTypeface(typefaceRoman); textbt.setTypeface(typefaceRoman); TextOper.setTypeface(typefaceRoman); textVPN.setTypeface(typefaceRoman); //LinearLayoutPrivacy.setVisibility(View.GONE); //LinearLayoutApn.setVisibility(View.GONE); //LinearLayoutPasscode.setVisibility(View.GONE); //layoutTunes.setVisibility(View.GONE); //////////////////START/////////////////// ///////////////////APP////////////// pm = this.getPackageManager(); //Notification notif_inoty = pm.getLaunchIntentForPackage("net.suckga.inoty"); notif_espier = pm.getLaunchIntentForPackage("mobi.espier.launcher.plugin.notifications7pro"); //Control Center control_hi = pm.getLaunchIntentForPackage("com.hi.apps.studio.control.center"); control_espier = pm.getLaunchIntentForPackage("mobi.espier.launcher.plugin.controller7pro"); //Mail mail_stok = pm.getLaunchIntentForPackage("com.android.email"); //Phone phone_stok = pm.getLaunchIntentForPackage("com.android.dialer"); //Messages messages_stok = pm.getLaunchIntentForPackage("com.android.mms"); //Safari safari_stok = pm.getLaunchIntentForPackage("com.android.browser"); //Music; music_stok = pm.getLaunchIntentForPackage("com.android.music"); //VK vk_stok = pm.getLaunchIntentForPackage("com.vkontakte.android"); //Viber viber_stok = pm.getLaunchIntentForPackage("com.viber.voip"); //Ok ok_stok = pm.getLaunchIntentForPackage("ru.ok.android"); //Skype skype_stok = pm.getLaunchIntentForPackage("com.skype.raider"); //WhatsApp!!!! whatsapp_stok = pm.getLaunchIntentForPackage("com.whatsapp"); //Twitter twitter_stok = pm.getLaunchIntentForPackage("com.twitter.android"); //Facebook facebook_stok = pm.getLaunchIntentForPackage("com.facebook.katana"); //Instagram instagram_stok = pm.getLaunchIntentForPackage("com.instagram.android"); //Maps maps_stok = pm.getLaunchIntentForPackage("com.google.android.apps.maps"); bt = BluetoothAdapter.getDefaultAdapter(); //Check Availability of bluetooth if (bt == null) { LinearLayoutBluetooth.setVisibility(View.GONE); } }
From source file:de.baumann.hhsmoodle.data_bookmarks.Bookmarks_Fragment.java
public void setBookmarksList() { //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "bookmarks_title", "bookmarks_content", "bookmarks_creation" }; final Cursor row = db.fetchAllData(getActivity()); adapter = new SimpleCursorAdapter(getActivity(), layoutstyle, row, column, xml_id, 0) { @Override/* w w w . j a v a 2 s. co m*/ public View getView(final int position, View convertView, ViewGroup parent) { Cursor row = (Cursor) lv.getItemAtPosition(position); final String _id = row.getString(row.getColumnIndexOrThrow("_id")); final String bookmarks_title = row.getString(row.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row.getString(row.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row.getString(row.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row .getString(row.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row.getString(row.getColumnIndexOrThrow("bookmarks_creation")); View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); final ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (bookmarks_icon) { case "01": iv_icon.setImageResource(R.drawable.circle_red); break; case "02": iv_icon.setImageResource(R.drawable.circle_yellow); break; case "03": iv_icon.setImageResource(R.drawable.circle_green); break; case "04": iv_icon.setImageResource(R.drawable.ic_school_grey600_48dp); break; case "05": iv_icon.setImageResource(R.drawable.ic_view_dashboard_grey600_48dp); break; case "06": iv_icon.setImageResource(R.drawable.ic_face_profile_grey600_48dp); break; case "07": iv_icon.setImageResource(R.drawable.ic_calendar_grey600_48dp); break; case "08": iv_icon.setImageResource(R.drawable.ic_chart_areaspline_grey600_48dp); break; case "09": iv_icon.setImageResource(R.drawable.ic_bell_grey600_48dp); break; case "10": iv_icon.setImageResource(R.drawable.ic_settings_grey600_48dp); break; case "11": iv_icon.setImageResource(R.drawable.ic_web_grey600_48dp); break; case "12": iv_icon.setImageResource(R.drawable.ic_magnify_grey600_48dp); break; case "13": iv_icon.setImageResource(R.drawable.ic_pencil_grey600_48dp); break; case "14": iv_icon.setImageResource(R.drawable.ic_check_grey600_48dp); break; case "15": iv_icon.setImageResource(R.drawable.ic_clock_grey600_48dp); break; case "16": iv_icon.setImageResource(R.drawable.ic_bookmark_grey600_48dp); break; } switch (bookmarks_attachment) { case "": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_outline); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_grey); break; } iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (bookmarks_attachment.equals("")) { if (db.isExistFav("true")) { Snackbar.make(lv, R.string.bookmark_setFav_not, Snackbar.LENGTH_LONG).show(); } else { iv_attachment.setImageResource(R.drawable.star_grey); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "true", bookmarks_creation); setBookmarksList(); sharedPref.edit().putString("favoriteURL", bookmarks_content) .putString("favoriteTitle", bookmarks_title).apply(); Snackbar.make(lv, R.string.bookmark_setFav, Snackbar.LENGTH_LONG).show(); } } else { iv_attachment.setImageResource(R.drawable.star_outline); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "", bookmarks_creation); setBookmarksList(); } } }); iv_icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final helper_main.Item[] items = { new helper_main.Item(getString(R.string.note_priority_2), R.drawable.circle_red), new helper_main.Item(getString(R.string.note_priority_1), R.drawable.circle_yellow), new helper_main.Item(getString(R.string.note_priority_0), R.drawable.circle_green), new helper_main.Item(getString(R.string.text_tit_11), R.drawable.ic_school_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_1), R.drawable.ic_view_dashboard_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_2), R.drawable.ic_face_profile_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_8), R.drawable.ic_calendar_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_3), R.drawable.ic_chart_areaspline_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_4), R.drawable.ic_bell_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_5), R.drawable.ic_settings_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_6), R.drawable.ic_web_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_7), R.drawable.ic_magnify_grey600_48dp), new helper_main.Item(getString(R.string.title_notes), R.drawable.ic_pencil_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_9), R.drawable.ic_check_grey600_48dp), new helper_main.Item(getString(R.string.text_tit_10), R.drawable.ic_clock_grey600_48dp), new helper_main.Item(getString(R.string.title_bookmarks), R.drawable.ic_bookmark_grey600_48dp), }; ListAdapter adapter = new ArrayAdapter<helper_main.Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "01", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 1) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "02", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 2) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "03", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 3) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "04", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 4) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "05", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 5) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "06", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 6) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "07", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 7) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "08", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 8) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "09", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 9) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "10", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 10) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "11", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 11) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "12", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 12) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "13", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 13) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "14", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 14) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "15", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } else if (item == 15) { db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, "16", bookmarks_attachment, bookmarks_creation); setBookmarksList(); } } }).show(); } }); return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_bookmarksBY", "bookmarks_title"); sharedPref.edit().putString("filter_bookmarksBY", "bookmarks_title").apply(); filter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return db.fetchDataByFilter(constraint.toString(), note_search); } }); lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); sharedPref.edit().putString("load_next", "true").apply(); sharedPref.edit().putString("loadURL", bookmarks_content).apply(); ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.viewpager); viewPager.setCurrentItem(0); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row2 .getString(row2.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation")); final CharSequence[] options = { getString(R.string.number_edit_entry), getString(R.string.bookmark_remove_bookmark), getString(R.string.todo_menu), getString(R.string.bookmark_createNote), getString(R.string.count_create), getString(R.string.bookmark_createShortcut), getString(R.string.bookmark_createEvent) }; new AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @SuppressWarnings("ConstantConditions") @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.number_edit_entry))) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_title, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setHint(R.string.bookmark_edit_title); edit_title.setText(bookmarks_title); builder.setView(dialogView); builder.setTitle(R.string.bookmark_edit_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); db.update(Integer.parseInt(_id), inputTag, bookmarks_content, bookmarks_icon, bookmarks_attachment, bookmarks_creation); setBookmarksList(); Snackbar.make(lv, R.string.bookmark_added, Snackbar.LENGTH_SHORT).show(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(getActivity(), edit_title); } if (options[item].equals(getString(R.string.todo_menu))) { Todo_helper.newTodo(getActivity(), bookmarks_title, "", ""); } if (options[item].equals(getString(R.string.count_create))) { Count_helper.newCount(getActivity(), bookmarks_title, bookmarks_content, getActivity().getString(R.string.note_content), false); } if (options[item].equals(getString(R.string.bookmark_createEvent))) { helper_main.createCalendarEvent(getActivity(), bookmarks_title, bookmarks_content); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setBookmarksList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.bookmark_createNote))) { Notes_helper.newNote(getActivity(), bookmarks_title, bookmarks_content, "", "", "", ""); } if (options[item].equals(getString(R.string.bookmark_createShortcut))) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.setData(Uri.parse(bookmarks_content)); Intent shortcut = new Intent(); shortcut.putExtra("android.intent.extra.shortcut.INTENT", i); shortcut.putExtra("android.intent.extra.shortcut.NAME", "THE NAME OF SHORTCUT TO BE SHOWN"); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, bookmarks_title); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext( getActivity().getApplicationContext(), R.mipmap.ic_launcher)); shortcut.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getActivity().sendBroadcast(shortcut); Snackbar.make(lv, R.string.toast_shortcut, Snackbar.LENGTH_LONG).show(); } } }).show(); return true; } }); }
From source file:org.getlantern.firetweet.fragment.support.AccountsDashboardFragment.java
private void onAccountSelected(AccountProfileImageViewHolder holder, final ParcelableAccount account) { if (mSwitchAccountAnimationPlaying) return;/* w ww. j av a 2 s . c o m*/ final ImageView snapshotView = mFloatingProfileImageSnapshotView; final ShapedImageView profileImageView = mAccountProfileImageView; final ShapedImageView clickedImageView = holder.getIconView(); // Reset snapshot view position snapshotView.setPivotX(0); snapshotView.setPivotY(0); snapshotView.setTranslationX(0); snapshotView.setTranslationY(0); final Matrix matrix = new Matrix(); final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF(); getLocationOnScreen(clickedImageView, sourceBounds); getLocationOnScreen(profileImageView, destBounds); getLocationOnScreen(snapshotView, snapshotBounds); final float finalScale = destBounds.width() / sourceBounds.width(); final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix, new RectF(0, 0, sourceBounds.width(), sourceBounds.height())); final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams(); lp.width = clickedImageView.getWidth(); lp.height = clickedImageView.getHeight(); snapshotView.setLayoutParams(lp); // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/ AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left, destBounds.left - snapshotBounds.left)) .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y, sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale)) .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1)); final long animationTransition = 400; set.setDuration(animationTransition); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListener() { private Drawable clickedDrawable; private int[] clickedColors; @Override public void onAnimationStart(Animator animation) { snapshotView.setVisibility(View.VISIBLE); snapshotView.setImageBitmap(snapshotBitmap); final Drawable profileDrawable = profileImageView.getDrawable(); clickedDrawable = clickedImageView.getDrawable(); clickedColors = clickedImageView.getBorderColors(); final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount(); mImageLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount.profile_image_url, profileDrawable); // mImageLoader.displayDashboardProfileImage(profileImageView, // account.profile_image_url, clickedDrawable); clickedImageView.setBorderColors(profileImageView.getBorderColors()); mSwitchAccountAnimationPlaying = true; } @Override public void onAnimationEnd(Animator animation) { finishAnimation(); } private void finishAnimation() { final Editor editor = mPreferences.edit(); editor.putLong(KEY_DEFAULT_ACCOUNT_ID, account.account_id); editor.apply(); mAccountsAdapter.setSelectedAccountId(account.account_id); mAccountOptionsAdapter.setSelectedAccount(account); updateAccountOptionsSeparatorLabel(clickedDrawable); snapshotView.setVisibility(View.INVISIBLE); snapshotView.setImageDrawable(null); profileImageView.setImageDrawable(clickedDrawable); profileImageView.setBorderColors(clickedColors); profileImageView.setAlpha(1f); clickedImageView.setScaleX(1); clickedImageView.setScaleY(1); clickedImageView.setAlpha(1f); mSwitchAccountAnimationPlaying = false; } @Override public void onAnimationCancel(Animator animation) { finishAnimation(); } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); }
From source file:com.yaniv.online.MainActivity.java
public void updateParticipantUI(String pid) { Log.d(TAG, "updateParticipantUI()"); int i;/* w w w .jav a2s. com*/ int arr[]; Log.d(TAG, "updateParticipantUI() - mParticipantPlayerPosition - " + mParticipantPlayerPosition); Log.d(TAG, "updateParticipantUI() - pid - " + pid); if (mParticipantPlayerPosition.get("top").equals(pid)) { LinearLayout layout = (LinearLayout) findViewById(R.id.player_top); ViewGroup.LayoutParams params = layout.getLayoutParams(); params.width = mParticipantCards.get(pid).size() * topCardWidthParam; layout.setLayoutParams(params); arr = cardsTopID; } else if (mParticipantPlayerPosition.get("left").equals(pid)) { arr = cardsLeftID; } else { arr = cardsRightID; } ImageView myCard; Log.d(TAG, "updateParticipantUI() - mParticipantCards.get(pid) - " + mParticipantCards.get(pid)); for (i = 0; i < mParticipantCards.get(pid).size() && i < 5; i++) { int drawable; if (yaniv) { drawable = cardsDrawable.get("" + mParticipantCards.get(pid).get(i).getKey()); } else { drawable = R.drawable.pile_1; } myCard = (ImageView) findViewById(arr[i]); myCard.setImageResource(drawable); myCard.setVisibility(View.VISIBLE); } for (; i < 5; i++) { myCard = (ImageView) findViewById(arr[i]); myCard.setVisibility(View.GONE); } }
From source file:org.mariotaku.twidere.fragment.support.AccountsDashboardFragment.java
private void onAccountSelected(AccountProfileImageViewHolder holder, final ParcelableAccount account) { if (mSwitchAccountAnimationPlaying) return;/*from ww w . j ava2 s. c om*/ final ImageView snapshotView = mFloatingProfileImageSnapshotView; final ShapedImageView profileImageView = mAccountProfileImageView; final ShapedImageView clickedImageView = holder.getIconView(); // Reset snapshot view position snapshotView.setPivotX(0); snapshotView.setPivotY(0); snapshotView.setTranslationX(0); snapshotView.setTranslationY(0); final Matrix matrix = new Matrix(); final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF(); getLocationOnScreen(clickedImageView, sourceBounds); getLocationOnScreen(profileImageView, destBounds); getLocationOnScreen(snapshotView, snapshotBounds); final float finalScale = destBounds.width() / sourceBounds.width(); final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix, new RectF(0, 0, sourceBounds.width(), sourceBounds.height())); final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams(); lp.width = clickedImageView.getWidth(); lp.height = clickedImageView.getHeight(); snapshotView.setLayoutParams(lp); // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/ AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left, destBounds.left - snapshotBounds.left)) .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y, sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale)) .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1)); final long animationTransition = 400; set.setDuration(animationTransition); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListener() { private Drawable clickedDrawable; private int[] clickedColors; @Override public void onAnimationStart(Animator animation) { snapshotView.setVisibility(View.VISIBLE); snapshotView.setImageBitmap(snapshotBitmap); final Drawable profileDrawable = profileImageView.getDrawable(); clickedDrawable = clickedImageView.getDrawable(); clickedColors = clickedImageView.getBorderColors(); final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount(); mImageLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount.profile_image_url, profileDrawable); // mImageLoader.displayDashboardProfileImage(profileImageView, // account.profile_image_url, clickedDrawable); clickedImageView.setBorderColors(profileImageView.getBorderColors()); mSwitchAccountAnimationPlaying = true; } @Override public void onAnimationEnd(Animator animation) { finishAnimation(); } @Override public void onAnimationCancel(Animator animation) { finishAnimation(); } @Override public void onAnimationRepeat(Animator animation) { } private void finishAnimation() { final Editor editor = mPreferences.edit(); editor.putLong(KEY_DEFAULT_ACCOUNT_ID, account.account_id); editor.apply(); mAccountsAdapter.setSelectedAccountId(account.account_id); mAccountOptionsAdapter.setSelectedAccount(account); updateAccountOptionsSeparatorLabel(clickedDrawable); snapshotView.setVisibility(View.INVISIBLE); snapshotView.setImageDrawable(null); profileImageView.setImageDrawable(clickedDrawable); profileImageView.setBorderColors(clickedColors); profileImageView.setAlpha(1f); clickedImageView.setScaleX(1); clickedImageView.setScaleY(1); clickedImageView.setAlpha(1f); mSwitchAccountAnimationPlaying = false; } }); set.start(); }
From source file:org.thoughtland.xlocation.ActivityApp.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final int userId = Util.getUserId(Process.myUid()); // Check privacy service client if (!PrivacyService.checkClient()) return;// w ww .ja v a2s.c om // Set layout setContentView(R.layout.restrictionlist); // Get arguments Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } int uid = extras.getInt(cUid); String restrictionName = (extras.containsKey(cRestrictionName) ? extras.getString(cRestrictionName) : null); String methodName = (extras.containsKey(cMethodName) ? extras.getString(cMethodName) : null); // Get app info mAppInfo = new ApplicationInfoEx(this, uid); if (mAppInfo.getPackageName().size() == 0) { finish(); return; } // Set sub title getActionBar().setSubtitle(TextUtils.join(", ", mAppInfo.getApplicationName())); // Handle info click ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo); imgInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Packages can be selected on the web site Util.viewUri(ActivityApp.this, Uri.parse(String.format(ActivityShare.getBaseURL() + "?package_name=%s", mAppInfo.getPackageName().get(0)))); } }); // Display app name TextView tvAppName = (TextView) findViewById(R.id.tvApp); tvAppName.setText(mAppInfo.toString()); // Background color if (mAppInfo.isSystem()) { LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo); llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous))); } // Display app icon final ImageView imgIcon = (ImageView) findViewById(R.id.imgIcon); imgIcon.setImageDrawable(mAppInfo.getIcon(this)); // Handle icon click imgIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openContextMenu(imgIcon); } }); // Display on-demand state final ImageView imgCbOnDemand = (ImageView) findViewById(R.id.imgCbOnDemand); boolean isApp = PrivacyManager.isApplication(mAppInfo.getUid()); boolean odSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemandSystem, false); boolean gondemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true); if ((isApp || odSystem) && gondemand) { boolean ondemand = PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); imgCbOnDemand.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean ondemand = !PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, Boolean.toString(ondemand)); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); } }); } else imgCbOnDemand.setVisibility(View.GONE); // Display restriction state swEnabled = (Switch) findViewById(R.id.swEnable); swEnabled.setChecked( PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true)); swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, Boolean.toString(isChecked)); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); imgCbOnDemand.setEnabled(isChecked); } }); imgCbOnDemand.setEnabled(swEnabled.isChecked()); // Add context menu to icon registerForContextMenu(imgIcon); // Check if internet access if (!mAppInfo.hasInternet(this)) { ImageView imgInternet = (ImageView) findViewById(R.id.imgInternet); imgInternet.setVisibility(View.INVISIBLE); } // Check if frozen if (!mAppInfo.isFrozen(this)) { ImageView imgFrozen = (ImageView) findViewById(R.id.imgFrozen); imgFrozen.setVisibility(View.INVISIBLE); } // Display version TextView tvVersion = (TextView) findViewById(R.id.tvVersion); tvVersion.setText(TextUtils.join(", ", mAppInfo.getPackageVersionName(this))); // Display package name TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName); tvPackageName.setText(TextUtils.join(", ", mAppInfo.getPackageName())); // Fill privacy expandable list view adapter final ExpandableListView elvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction); elvRestriction.setGroupIndicator(null); mPrivacyListAdapter = new RestrictionAdapter(this, R.layout.restrictionentry, mAppInfo, restrictionName, methodName); elvRestriction.setAdapter(mPrivacyListAdapter); // Listen for group expand elvRestriction.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(final int groupPosition) { if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingMethodExpert, false)) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityApp.this); alertDialogBuilder.setTitle(R.string.app_name); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); alertDialogBuilder.setMessage(R.string.msg_method_expert); alertDialogBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PrivacyManager.setSetting(userId, PrivacyManager.cSettingMethodExpert, Boolean.toString(true)); } }); alertDialogBuilder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { elvRestriction.collapseGroup(groupPosition); } }); alertDialogBuilder.setCancelable(false); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } } }); // Go to method if (restrictionName != null) { int groupPosition = new ArrayList<String>(PrivacyManager.getRestrictions(this).values()) .indexOf(restrictionName); elvRestriction.setSelectedGroup(groupPosition); elvRestriction.expandGroup(groupPosition); if (methodName != null) { Version version = new Version(Util.getSelfVersionName(this)); int childPosition = PrivacyManager.getHooks(restrictionName, version) .indexOf(new Hook(restrictionName, methodName)); elvRestriction.setSelectedChild(groupPosition, childPosition, true); } } // Listen for package add/remove IntentFilter iff = new IntentFilter(); iff.addAction(Intent.ACTION_PACKAGE_REMOVED); iff.addDataScheme("package"); registerReceiver(mPackageChangeReceiver, iff); mPackageChangeReceiverRegistered = true; // Up navigation getActionBar().setDisplayHomeAsUpEnabled(true); // Tutorial if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialDetails, false)) { ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE); ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE); } View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { ViewParent parent = view.getParent(); while (!parent.getClass().equals(ScrollView.class)) parent = parent.getParent(); ((View) parent).setVisibility(View.GONE); PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialDetails, Boolean.TRUE.toString()); } }; ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener); ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener); // Process actions if (extras.containsKey(cAction)) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(mAppInfo.getUid()); if (extras.getInt(cAction) == cActionClear) optionClear(); else if (extras.getInt(cAction) == cActionSettings) optionSettings(); } }
From source file:org.mariotaku.twidere.fragment.AccountsDashboardFragment.java
private void onAccountSelected(AccountProfileImageViewHolder holder, @NonNull final ParcelableAccount account) { if (mSwitchAccountAnimationPlaying) return;//from ww w . j a v a2s. c o m final ImageView snapshotView = mFloatingProfileImageSnapshotView; final ShapedImageView profileImageView = mAccountProfileImageView; final ShapedImageView clickedImageView = holder.getIconView(); // Reset snapshot view position snapshotView.setPivotX(0); snapshotView.setPivotY(0); snapshotView.setTranslationX(0); snapshotView.setTranslationY(0); final Matrix matrix = new Matrix(); final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF(); getLocationOnScreen(clickedImageView, sourceBounds); getLocationOnScreen(profileImageView, destBounds); getLocationOnScreen(snapshotView, snapshotBounds); final float finalScale = destBounds.width() / sourceBounds.width(); final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix, new RectF(0, 0, sourceBounds.width(), sourceBounds.height())); final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams(); lp.width = clickedImageView.getWidth(); lp.height = clickedImageView.getHeight(); snapshotView.setLayoutParams(lp); // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/ AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left, destBounds.left - snapshotBounds.left)) .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y, sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale)) .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale)) .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1)) .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1)); final long animationTransition = 400; set.setDuration(animationTransition); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListener() { private Drawable clickedDrawable; private int[] clickedColors; @Override public void onAnimationStart(Animator animation) { snapshotView.setVisibility(View.VISIBLE); snapshotView.setImageBitmap(snapshotBitmap); final Drawable profileDrawable = profileImageView.getDrawable(); clickedDrawable = clickedImageView.getDrawable(); clickedColors = clickedImageView.getBorderColors(); final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount(); if (oldSelectedAccount == null) return; mMediaLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount, profileDrawable); clickedImageView.setBorderColors(profileImageView.getBorderColors()); displayAccountBanner(account); mSwitchAccountAnimationPlaying = true; } @Override public void onAnimationEnd(Animator animation) { finishAnimation(); } @Override public void onAnimationCancel(Animator animation) { finishAnimation(); } @Override public void onAnimationRepeat(Animator animation) { } private void finishAnimation() { final Editor editor = mPreferences.edit(); editor.putString(KEY_DEFAULT_ACCOUNT_KEY, account.account_key.toString()); editor.apply(); mAccountsAdapter.setSelectedAccount(account); updateAccountActions(); displayCurrentAccount(clickedDrawable); snapshotView.setVisibility(View.INVISIBLE); snapshotView.setImageDrawable(null); profileImageView.setImageDrawable(clickedDrawable); profileImageView.setBorderColors(clickedColors); profileImageView.setAlpha(1f); clickedImageView.setScaleX(1); clickedImageView.setScaleY(1); clickedImageView.setAlpha(1f); mSwitchAccountAnimationPlaying = false; } }); set.start(); }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override protected void onResume() { super.onResume(); final Resources rr = NullCheck.notNull(this.getResources()); final TableLayout in_table_with_code = NullCheck.notNull(this.table_with_code); final TableLayout in_table_signup = NullCheck.notNull(this.table_signup); final TextView in_account_name_text = NullCheck.notNull(this.account_name_text); final TextView in_account_subtitle_text = NullCheck.notNull(this.account_subtitle_text); final ImageView in_account_icon = NullCheck.notNull(this.account_icon); final TextView in_barcode_text = NullCheck.notNull(this.barcode_text); final TextView in_pin_text = NullCheck.notNull(this.pin_text); final ImageView in_barcode_image = NullCheck.notNull(this.barcode_image); final TextView in_barcode_image_toggle = NullCheck.notNull(this.barcode_image_toggle); final Button in_login = NullCheck.notNull(this.login); final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox)); in_account_name_text.setText(this.account.getName()); in_account_subtitle_text.setText(this.account.getSubtitle()); try {//from w ww. j a v a 2 s . c om in_account_icon.setImageBitmap(this.account.getLogoBitmap()); } catch (IllegalArgumentException e) { in_account_icon.setImageResource(R.drawable.librarylogomagic); } final BooksType userAccount; if (this.account == null) { userAccount = Simplified.getCatalogAppServices().getBooks(); } else { userAccount = Simplified.getBooks(this.account, this, Simplified.getCatalogAppServices().getAdobeDRMExecutor()); } final AccountsDatabaseType accounts_database = Simplified.getAccountsDatabase(this.account, this); if (!accounts_database.accountGetCredentials().isSome()) { this.sync_table_row.setVisibility(View.GONE); LOG.debug("No user currently signed in, bypassing UI update and Sync Status Initiation."); return; } final AccountCredentials creds = ((Some<AccountCredentials>) accounts_database.accountGetCredentials()) .get(); if (syncButtonShouldBeVisible()) { if (this.annotationsManager == null) { this.annotationsManager = new AnnotationsManager(this.account, creds, this); checkServerSyncPermission(userAccount); } this.sync_table_row.setVisibility(View.VISIBLE); this.advanced_table_row.setVisibility(View.VISIBLE); } else { this.sync_table_row.setVisibility(View.GONE); this.advanced_table_row.setVisibility(View.GONE); } if (account.supportsBarcodeDisplay()) { Bitmap barcodeBitmap = generateBarcodeImage(creds.getBarcode().toString()); if (barcodeBitmap != null) { in_barcode_image.setImageBitmap(barcodeBitmap); in_barcode_image_toggle.setVisibility(View.VISIBLE); in_barcode_image_toggle.setOnClickListener(view -> { if (in_barcode_image_toggle.getText() == getText(R.string.settings_toggle_barcode_show)) { in_barcode_image.setVisibility(View.VISIBLE); in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_hide); } else { in_barcode_image.setVisibility(View.GONE); in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_show); } }); } } in_table_with_code.setVisibility(View.VISIBLE); in_table_signup.setVisibility(View.GONE); in_barcode_text.setText(creds.getBarcode().toString()); in_barcode_text.setContentDescription(creds.getBarcode().toString().replaceAll(".(?=.)", "$0,")); in_pin_text.setText(creds.getPin().toString()); in_pin_text.setContentDescription(creds.getPin().toString().replaceAll(".(?=.)", "$0,")); in_eula_checkbox.setEnabled(false); in_login.setText(rr.getString(R.string.settings_log_out)); in_login.setOnClickListener(view -> { final LogoutDialog dialog = LogoutDialog.newDialog(); dialog.setOnConfirmListener(() -> { //Delete cache if logging out of current active library account userAccount.accountLogout(creds, this, this, this); if (this.account == Simplified.getCurrentAccount()) { userAccount.destroyBookStatusCache(); } }); final FragmentManager fm = this.getFragmentManager(); dialog.show(fm, "logout-confirm"); }); }
From source file:com.yaniv.online.MainActivity.java
public void drawMyCards() { if (myCards == null) { Log.d(TAG, "Call on null object - myCards"); return;//from ww w. j a va 2s .c om } int i; ImageView myCard; // Gets linearlayout LinearLayout layout = (LinearLayout) findViewById(R.id.myCardsLayout); // Gets the layout params that will allow you to resize the layout ViewGroup.LayoutParams params = layout.getLayoutParams(); // Changes the height and width to the specified *pixels* params.width = myCards.size() * myCardWidthParam; layout.setLayoutParams(params); for (i = 0; i < myCards.size(); i++) { int drawable = cardsDrawable.get("" + myCards.get(i).getKey()); myCard = (ImageView) findViewById(cardsID[i]); myCard.setImageResource(drawable); myCard.setVisibility(View.VISIBLE); } for (; i < 5; i++) { myCard = (ImageView) findViewById(cardsID[i]); myCard.setVisibility(View.GONE); } }