List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:org.catnut.fragment.TweetFragment.java
/** * ??// w w w.j ava 2 s .co m * * @param thumb url * @param originalUrl url */ private void loadThumbs(String thumb, final String originalUrl, final ImageView thumbs, final JSONArray jsonArray, View overflow) { if (!TextUtils.isEmpty(thumb)) { if (mStayInLatest) { int screenWidth = CatnutUtils.getScreenWidth(getActivity()); Picasso.with(getActivity()).load(thumb).into(thumbs); thumbs.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return CatnutUtils.imageOverlay(v, event); } }); thumbs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { thumbs.getDrawable().clearColorFilter(); mText.invalidate(); Intent intent = SingleFragmentActivity.getIntent(getActivity(), SingleFragmentActivity.PHOTO_VIEWER); intent.putExtra(Constants.PIC, originalUrl); startActivity(intent); } }); } else { thumbs.setImageResource(R.drawable.error); } thumbs.setVisibility(View.VISIBLE); } else { thumbs.setVisibility(View.GONE); overflow.setVisibility(View.GONE); } if (jsonArray != null && jsonArray.length() > 1) { overflow.setVisibility(View.VISIBLE); overflow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View view = LayoutInflater.from(getActivity()).inflate(R.layout.tweet_pics, null); LinePageIndicator indicator = (LinePageIndicator) view.findViewById(R.id.indicator); final ViewPager pager = (ViewPager) view.findViewById(R.id.pager); pager.setPageTransformer(true, new PageTransformer.DepthPageTransformer()); pager.setAdapter(new PagerAdapter() { @Override public int getCount() { return jsonArray.length(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } @Override public Object instantiateItem(ViewGroup container, int position) { View v = LayoutInflater.from(getActivity()).inflate(R.layout.photo, null); TouchImageView iv = (TouchImageView) v.findViewById(R.id.image); String url = jsonArray.optJSONObject(position).optString(Status.thumbnail_pic); String replace = url.replace(Constants.THUMBNAIL, Status.MEDIUM_THUMBNAIL); Picasso.with(getActivity()).load(replace).into(iv); container.addView(v); return v; } }); indicator.setViewPager(pager); new AlertDialog.Builder( new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Dialog)).setView(view) .setPositiveButton(getString(R.string.original_pics), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ArrayList<Uri> urls = new ArrayList<Uri>(jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { String s = jsonArray.optJSONObject(i) .optString(Status.thumbnail_pic) .replace(Constants.THUMBNAIL, Status.LARGE_THUMBNAIL); urls.add(Uri.parse(s)); } Intent intent = SingleFragmentActivity.getIntent(getActivity(), SingleFragmentActivity.GALLERY); intent.putExtra(GalleryPagerFragment.CUR_INDEX, pager.getCurrentItem()); intent.putExtra(GalleryPagerFragment.URLS, urls); intent.putExtra(GalleryPagerFragment.TITLE, getString(R.string.tweet_pics)); startActivity(intent); } }) .setNegativeButton(getString(R.string.close), null).show(); } }); } else { overflow.setVisibility(View.GONE); } }
From source file:im.vector.adapters.VectorRoomSummaryAdapter.java
/** * Compute the View that should be used to render the child, * given its position and its groups position *///from ww w. ja v a2s .co m @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { // sanity check if (null == mSummaryListByGroupPosition) { return null; } if (convertView == null) { convertView = mLayoutInflater.inflate(mChildLayoutResourceId, parent, false); } if (!mMxSession.isAlive()) { return convertView; } int roomNameBlack = ThemeUtils.getColor(mContext, R.attr.riot_primary_text_color); int fushiaColor = ContextCompat.getColor(mContext, R.color.vector_fuchsia_color); int vectorDefaultTimeStampColor = ThemeUtils.getColor(mContext, R.attr.default_text_light_color); int vectorGreenColor = ContextCompat.getColor(mContext, R.color.vector_green_color); int vectorSilverColor = ContextCompat.getColor(mContext, R.color.vector_silver_color); // retrieve the UI items ImageView avatarImageView = convertView.findViewById(R.id.room_avatar); TextView roomNameTxtView = convertView.findViewById(R.id.roomSummaryAdapter_roomName); TextView roomMsgTxtView = convertView.findViewById(R.id.roomSummaryAdapter_roomMessage); View bingUnreadMsgView = convertView.findViewById(R.id.bing_indicator_unread_message); TextView timestampTxtView = convertView.findViewById(R.id.roomSummaryAdapter_ts); View separatorView = convertView.findViewById(R.id.recents_separator); View separatorGroupView = convertView.findViewById(R.id.recents_groups_separator_line); final View actionView = convertView.findViewById(R.id.roomSummaryAdapter_action); final ImageView actionImageView = convertView.findViewById(R.id.roomSummaryAdapter_action_image); TextView unreadCountTxtView = convertView.findViewById(R.id.roomSummaryAdapter_unread_count); View directChatIcon = convertView.findViewById(R.id.room_avatar_direct_chat_icon); View encryptedIcon = convertView.findViewById(R.id.room_avatar_encrypted_icon); View invitationView = convertView.findViewById(R.id.recents_groups_invitation_group); Button preViewButton = convertView.findViewById(R.id.recents_invite_preview_button); Button rejectButton = convertView.findViewById(R.id.recents_invite_reject_button); View showMoreView = convertView.findViewById(R.id.roomSummaryAdapter_show_more_layout); View actionClickArea = convertView.findViewById(R.id.roomSummaryAdapter_action_click_area); // directory management if ((mDirectoryGroupPosition == groupPosition) || (mRoomByAliasGroupPosition == groupPosition)) { // some items are show bingUnreadMsgView.setVisibility(View.INVISIBLE); timestampTxtView.setVisibility(View.GONE); actionImageView.setVisibility(View.GONE); invitationView.setVisibility(View.GONE); separatorView.setVisibility(View.GONE); separatorGroupView.setVisibility(View.VISIBLE); showMoreView.setVisibility(View.VISIBLE); actionClickArea.setVisibility(View.GONE); unreadCountTxtView.setVisibility(View.GONE); directChatIcon.setVisibility(View.GONE); encryptedIcon.setVisibility(View.GONE); if (mDirectoryGroupPosition == groupPosition) { roomNameTxtView.setText(mContext.getResources().getString(R.string.directory_search_results_title)); if (!TextUtils.isEmpty(mSearchedPattern)) { if (null == mMatchedPublicRoomsCount) { roomMsgTxtView .setText(mContext.getResources().getString(R.string.directory_searching_title)); } else { String value = mMatchedPublicRoomsCount.toString(); if (mMatchedPublicRoomsCount >= PublicRoomsManager.PUBLIC_ROOMS_LIMIT) { value = "> " + PublicRoomsManager.PUBLIC_ROOMS_LIMIT; } roomMsgTxtView.setText( mContext.getResources().getQuantityString(R.plurals.directory_search_rooms_for, mMatchedPublicRoomsCount, value, mSearchedPattern)); } } else { if (null == mPublicRoomsCount) { roomMsgTxtView.setText(null); } else { roomMsgTxtView.setText(mContext.getResources().getQuantityString( R.plurals.directory_search_rooms, mPublicRoomsCount, mPublicRoomsCount)); } } avatarImageView.setImageBitmap(VectorUtils.getAvatar(avatarImageView.getContext(), VectorUtils.getAvatarColor(null), null, true)); } else { roomNameTxtView.setText(mSearchedPattern); roomMsgTxtView.setText(""); avatarImageView.setImageBitmap(VectorUtils.getAvatar(avatarImageView.getContext(), VectorUtils.getAvatarColor(null), "@", true)); } return convertView; } showMoreView.setVisibility(View.GONE); RoomSummary childRoomSummary = mSummaryListByGroupPosition.get(groupPosition).get(childPosition); final Room childRoom = mMxSession.getDataHandler().getStore().getRoom(childRoomSummary.getRoomId()); int unreadMsgCount = childRoomSummary.getUnreadEventsCount(); int highlightCount = 0; int notificationCount = 0; if (null != childRoom) { highlightCount = childRoom.getHighlightCount(); notificationCount = childRoom.getNotificationCount(); if (mMxSession.getDataHandler().getBingRulesManager().isRoomMentionOnly(childRoom.getRoomId())) { notificationCount = highlightCount; } } // get last message to be displayed CharSequence lastMsgToDisplay = getChildMessageToDisplay(childRoomSummary); // display the room avatar final String roomName = VectorUtils.getRoomDisplayName(mContext, mMxSession, childRoom); VectorUtils.loadRoomAvatar(mContext, mMxSession, avatarImageView, childRoom); // display the room name roomNameTxtView.setText(roomName); roomNameTxtView.setTextColor(roomNameBlack); roomNameTxtView.setTypeface(null, (0 != unreadMsgCount) ? Typeface.BOLD : Typeface.NORMAL); // display the last message roomMsgTxtView.setText(lastMsgToDisplay); // set the timestamp timestampTxtView.setText(getFormattedTimestamp(childRoomSummary.getLatestReceivedEvent())); timestampTxtView.setTextColor(vectorDefaultTimeStampColor); timestampTxtView.setTypeface(null, Typeface.NORMAL); // set bing view background colour int bingUnreadColor; if (0 != highlightCount) { bingUnreadColor = fushiaColor; } else if (0 != notificationCount) { bingUnreadColor = vectorGreenColor; } else if (0 != unreadMsgCount) { bingUnreadColor = vectorSilverColor; } else { bingUnreadColor = Color.TRANSPARENT; } bingUnreadMsgView.setBackgroundColor(bingUnreadColor); // display the unread badge counter if ((0 != notificationCount)) { unreadCountTxtView.setVisibility(View.VISIBLE); unreadCountTxtView.setText(String.valueOf(notificationCount)); unreadCountTxtView.setTypeface(null, Typeface.BOLD); setUnreadBackground(unreadCountTxtView, bingUnreadColor); } else { unreadCountTxtView.setVisibility(View.GONE); } // some items are shown boolean isInvited = false; if (null != childRoom) { isInvited = childRoom.isInvited(); } if (null != childRoom) { directChatIcon.setVisibility( RoomUtils.isDirectChat(mMxSession, childRoom.getRoomId()) ? View.VISIBLE : View.GONE); encryptedIcon.setVisibility(childRoom.isEncrypted() ? View.VISIBLE : View.GONE); } else { directChatIcon.setVisibility(View.GONE); encryptedIcon.setVisibility(View.GONE); } bingUnreadMsgView.setVisibility(isInvited ? View.INVISIBLE : View.VISIBLE); invitationView.setVisibility(isInvited ? View.VISIBLE : View.GONE); final String fRoomId = childRoomSummary.getRoomId(); if (isInvited) { actionClickArea.setVisibility(View.GONE); preViewButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mListener) { mListener.onPreviewRoom(mMxSession, fRoomId); } } }); rejectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mListener) { mListener.onRejectInvitation(mMxSession, fRoomId); } } }); // display an exclamation mark like the webclient unreadCountTxtView.setVisibility(View.VISIBLE); unreadCountTxtView.setText("!"); unreadCountTxtView.setTypeface(null, Typeface.BOLD); setUnreadBackground(unreadCountTxtView, fushiaColor); timestampTxtView.setVisibility(View.GONE); actionImageView.setVisibility(View.GONE); } else { final boolean isFavorite = groupPosition == mFavouritesGroupPosition; final boolean isLowPrior = groupPosition == mLowPriorGroupPosition; actionClickArea.setVisibility(View.VISIBLE); actionClickArea.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { RoomUtils.displayPopupMenu(mContext, mMxSession, childRoom, actionView, isFavorite, isLowPrior, mMoreActionListener); } }); timestampTxtView.setVisibility(mIsSearchMode ? View.INVISIBLE : View.VISIBLE); actionImageView.setVisibility(mIsSearchMode ? View.INVISIBLE : View.VISIBLE); } separatorView.setVisibility(isLastChild ? View.GONE : View.VISIBLE); separatorGroupView .setVisibility((isLastChild && ((groupPosition + 1) < getGroupCount())) ? View.VISIBLE : View.GONE); return convertView; }
From source file:org.alfresco.mobile.android.application.fragments.node.details.NodeDetailsFragment.java
protected void displayToolsBar() { // BUTTONS/*w w w.j a v a 2 s . c om*/ ImageView b = (ImageView) viewById(R.id.action_openin); if (b == null) { return; } if ((node instanceof Document && ((Document) node).getContentStreamLength() > 0 && !isRestrictable) || (node instanceof NodeSyncPlaceHolder && !isRestrictable)) { // Tablet : Header thumbnail must be clickable if (viewById(R.id.icon) != null) { viewById(R.id.icon).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openin(); } }); } b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openin(); } }); } else { b.setVisibility(View.GONE); } hideActionIfNecessary(b, ConfigurableActionHelper.ACTION_NODE_OPEN); b = (ImageView) viewById(R.id.action_like); if (node instanceof NodeSyncPlaceHolder) { b.setVisibility(View.GONE); viewById(R.id.like_progress).setVisibility(View.GONE); } if (getSession() != null && getSession().getRepositoryInfo() != null && getSession().getRepositoryInfo().getCapabilities() != null && getSession().getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) { isLiked(b); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { like(v); } }); } else { b.setVisibility(View.GONE); if (viewById(R.id.like_progress) != null) { viewById(R.id.like_progress).setVisibility(View.GONE); } } hideActionIfNecessary(b, ConfigurableActionHelper.ACTION_NODE_LIKE); // BUTTONS b = (ImageView) viewById(R.id.action_favorite); if (node instanceof NodeSyncPlaceHolder) { b.setVisibility(View.GONE); viewById(R.id.favorite_progress).setVisibility(View.GONE); } else if (!isRestrictable) { isFavorite(b); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { favorite(v); } }); } else { b.setVisibility(View.GONE); viewById(R.id.favorite_progress).setVisibility(View.GONE); } hideActionIfNecessary(b, ConfigurableActionHelper.ACTION_NODE_FAVORITE); // SYNC b = (ImageView) viewById(R.id.action_sync); if (node instanceof NodeSyncPlaceHolder) { b.setVisibility(View.VISIBLE); b.setImageResource(R.drawable.ic_synced_dark); } else if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount())) { isSynced = (node.isFolder()) ? SyncContentManager.getInstance(getActivity()).isRootSynced(getAccount(), node) : SyncContentManager.getInstance(getActivity()).isSynced(getAccount(), node); if (isSynced && !isRootSynced(b)) { b.setVisibility(View.GONE); } else if (node instanceof NodeSyncPlaceHolder) { b.setVisibility(View.VISIBLE); b.setImageResource(R.drawable.ic_synced_dark); } else if (!isRestrictable) { b.setImageResource(isSynced ? R.drawable.ic_synced_dark : R.drawable.ic_sync_light); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { isSynced = (node.isFolder()) ? SyncContentManager.getInstance(getActivity()).isRootSynced(getAccount(), node) : SyncContentManager.getInstance(getActivity()).isSynced(getAccount(), node); sync(v); } }); } else { b.setVisibility(View.GONE); } } else { b.setVisibility(View.GONE); } hideActionIfNecessary(b, ConfigurableActionHelper.ACTION_NODE_SYNC); b = (ImageView) viewById(R.id.action_share); if (node.isDocument() && !isRestrictable) { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { share(); } }); } else { b.setVisibility(View.GONE); } hideActionIfNecessary(b, ConfigurableActionHelper.ACTION_NODE_SHARE); b = (ImageView) viewById(R.id.action_open_in_alfresco_editor); if (node.isDocument()) { String mimetype = node.getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE); if (!TextUtils.isEmpty(mimetype) && mimetype.startsWith(MimeType.TYPE_TEXT)) { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openin(true); } }); } else { b.setVisibility(View.GONE); } } else { b.setVisibility(View.GONE); } hideActionIfNecessary(b, ConfigurableActionHelper.ACTION_NODE_EDIT_WITH_ALFRESCO); }
From source file:io.github.trulyfree.easyaspi.MainActivity.java
/** * *///w w w.j a v a2 s . c o m private void resetConfigReturned() { final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned); LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config); EditText moduleName = (EditText) findViewById(R.id.module_returned_configname); EditText moduleVersion = (EditText) findViewById(R.id.module_returned_configversion); EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl); EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl); LinearLayout moduleDependencies = (LinearLayout) findViewById(R.id.module_returned_dependencies); Button validate = (Button) findViewById(R.id.module_returned_validate); Button cancel = (Button) findViewById(R.id.module_returned_cancel); moduleName.setText(R.string.module_returned_configname); moduleVersion.setText(R.string.module_returned_configversion); moduleConfigUrl.setText(R.string.module_returned_configurl); moduleJarUrl.setText(R.string.module_returned_jarurl); moduleDependencies.removeAllViewsInLayout(); validate.setOnClickListener(null); cancel.setOnClickListener(null); final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorClear); final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(ANIMATION_DURATION); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); layout.setClickable(false); configResponseBlock.setVisibility(View.VISIBLE); colorAnimation.start(); }
From source file:de.blinkt.openvpn.ActivityServerList.java
private void makeAvaiableServer() { linearAvailableServers.removeAllViews(); for (int i = 0; i < mServerList.size(); i++) { final String server = mServerList.get(i); View viewItem = LayoutInflater.from(this).inflate(R.layout.itemserver, linearSelectedServer, false); ImageView imgViewFlag = (ImageView) viewItem.findViewById(R.id.imgViewFlag); TextView txtCountry = (TextView) viewItem.findViewById(R.id.txtViewCountryName); final ImageView imgFavorite = (ImageView) viewItem.findViewById(R.id.imgFavorite); if (!spGlobal.getBoolean(server, false)) { imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_unfavorite", null, getPackageName())); imgFavorite.setOnClickListener(new View.OnClickListener() { @Override/*w w w. j a v a 2 s .com*/ public void onClick(View v) { edGlobal.putBoolean(server, true); edGlobal.commit(); imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_favorite", null, getPackageName())); makeFavoriteServer(); } }); } else { imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_favorite", null, getPackageName())); imgFavorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { edGlobal.putBoolean(server, false); edGlobal.commit(); imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_unfavorite", null, getPackageName())); makeFavoriteServer(); } }); } imgViewFlag.setVisibility(View.GONE); for (int j = 0; j < countryList.length; j++) { String country = countryList[j]; if (server.toLowerCase().contains(country.toLowerCase())) { String resourceName = country.toLowerCase().replace(" ", "_"); int checkExistence = getResources().getIdentifier(resourceName, "drawable", getPackageName()); if (checkExistence != 0) { // the resouce exists... imgViewFlag.setVisibility(View.VISIBLE); imgViewFlag.setImageResource( getResources().getIdentifier("drawable/" + resourceName, null, getPackageName())); } break; } } txtCountry.setText(server); txtCountry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connected) || (ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) { if (ActivityDashboard.lolstring.equals(server)) { } else { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: dialog.dismiss(); ActivityDashboard.lolstring = server; if (VpnStatus.isVPNActive()) { if (ActivityDashboard.mService != null) { try { ActivityDashboard.mService.stopVPN(false); } catch (RemoteException e) { VpnStatus.logException(e); } } } ActivityDashboard.DISCONNECT_VPN_SERVERLIST = 1; finish(); break; case DialogInterface.BUTTON_NEGATIVE: dialog.dismiss(); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this); if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) { builder.setMessage( "Currently connecting to another VPN server. Are you sure you want to change the server?") .setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } else { builder.setMessage( "Currently connected to another VPN server. Are you sure you want to change the server?") .setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } } } else { ActivityDashboard.lolstring = server; finish(); } /*if(VpnStatus.isVPNActive() && ActivityDashboard.m_status.equals(Status.Connected) ) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which){ case DialogInterface.BUTTON_POSITIVE: dialog.dismiss(); ActivityDashboard.lolstring = server; finish(); break; case DialogInterface.BUTTON_NEGATIVE: dialog.dismiss(); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this); builder.setMessage("Currently connected to another VPN server. Are you sure you want to change the server?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); }else{ ActivityDashboard.lolstring = server; finish(); }*/ } }); linearAvailableServers.addView(viewItem); } }
From source file:jahirfiquitiva.iconshowcase.activities.ShowcaseActivity.java
public static void setupToolbarHeader(Context context, ImageView toolbarHeader) { if (themeMode) { wallpaperDrawable = ContextCompat.getDrawable(context, R.drawable.heroimage); toolbarHeader.setImageDrawable(wallpaperDrawable); toolbarHeaderImage = Utils.drawableToBitmap(wallpaperDrawable); } else if (ENABLE_USER_WALLPAPER_IN_TOOLBAR && mPrefs.getWallpaperAsToolbarHeaderEnabled()) { WallpaperManager wm = WallpaperManager.getInstance(context); if (wm != null) { Drawable currentWallpaper = wm.getFastDrawable(); if (currentWallpaper != null) { toolbarHeader.setAlpha(0.9f); toolbarHeader.setImageDrawable(currentWallpaper); wallpaperDrawable = currentWallpaper; toolbarHeaderImage = Utils.drawableToBitmap(currentWallpaper); }//from ww w . j ava 2 s. co m } } else { String[] wallpapers = context.getResources().getStringArray(R.array.wallpapers); if (wallpapers.length > 0) { int res; ArrayList<Integer> wallpapersArray = new ArrayList<>(); for (String wallpaper : wallpapers) { res = context.getResources().getIdentifier(wallpaper, "drawable", context.getPackageName()); if (res != 0) { final int thumbRes = context.getResources().getIdentifier(wallpaper, "drawable", context.getPackageName()); if (thumbRes != 0) { wallpapersArray.add(thumbRes); } } } Random random = new Random(); if (wallpaper == -1) { wallpaper = random.nextInt(wallpapersArray.size()); } wallpaperDrawable = ContextCompat.getDrawable(context, wallpapersArray.get(wallpaper)); toolbarHeader.setImageDrawable(wallpaperDrawable); toolbarHeaderImage = Utils .drawableToBitmap(ContextCompat.getDrawable(context, wallpapersArray.get(wallpaper))); } } toolbarHeader.setVisibility(View.VISIBLE); }
From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java
/** * Shows a test question on screen/* w ww. ja v a 2 s. c om*/ * * @param pos Question's position in questions's list of the test */ private void showQuestion(int pos) { TestQuestion question = test.getQuestions().get(pos); List<TestAnswer> answers = question.getAnswers(); TestAnswer a; ScrollView scrollContent = (ScrollView) findViewById(R.id.testMakeScroll); LinearLayout testMakeList = (LinearLayout) findViewById(R.id.testMakeList); TextView stem = (TextView) findViewById(R.id.testMakeQuestionStem); TextView questionFeedback = (TextView) findViewById(R.id.testMakeQuestionFeedback); TextView answerFeedback = (TextView) findViewById(R.id.testMakeAnswerFeedback); TextView score = (TextView) findViewById(R.id.testMakeQuestionScore); TextView textCorrectAnswer = (TextView) findViewById(R.id.testMakeCorrectAnswer); EditText textAnswer = (EditText) findViewById(R.id.testMakeEditText); ImageView img = (ImageView) findViewById(R.id.testMakeCorrectAnswerImage); MenuItem actionScoreItem = menu.findItem(R.id.action_score); CheckedAnswersArrayAdapter checkedAnswersAdapter; String answerType = question.getAnswerType(); String feedback = test.getFeedback(); String questionFeedbackText = question.getFeedback(); String correctAnswer = ""; int numAnswers = answers.size(); Float questionScore; DecimalFormat df = new DecimalFormat("0.00"); int feedbackLevel; int mediumFeedbackLevel = Test.FEEDBACK_VALUES.indexOf(Test.FEEDBACK_MEDIUM); int maxFeedbackLevel = Test.FEEDBACK_VALUES.indexOf(Test.FEEDBACK_MAX); scrollContent.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { findViewById(R.id.testMakeList).getParent().requestDisallowInterceptTouchEvent(false); return false; } }); testMakeList.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { // Disallow the touch request for parent scroll on touch of child view v.getParent().requestDisallowInterceptTouchEvent(true); return false; } }); questionFeedback.setVisibility(View.GONE); answerFeedback.setVisibility(View.GONE); textAnswer.setVisibility(View.GONE); textCorrectAnswer.setVisibility(View.GONE); testMakeList.setVisibility(View.GONE); img.setVisibility(View.GONE); testMakeList.removeAllViews(); stem.setText(Html.fromHtml(question.getStem())); if ((questionFeedbackText != null) && (!questionFeedbackText.equals(Constants.NULL_VALUE))) { questionFeedback.setText(Html.fromHtml(questionFeedbackText)); } feedbackLevel = Test.FEEDBACK_VALUES.indexOf(feedback); if (test.isEvaluated() && (feedbackLevel == maxFeedbackLevel) && !question.getFeedback().equals(Constants.NULL_VALUE)) { questionFeedback.setVisibility(View.VISIBLE); } else { questionFeedback.setVisibility(View.GONE); } if (answerType.equals(TestAnswer.TYPE_TEXT) || answerType.equals(TestAnswer.TYPE_INT) || answerType.equals(TestAnswer.TYPE_FLOAT)) { if (answerType.equals(TestAnswer.TYPE_INT)) { textAnswer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); } else if (answerType.equals(TestAnswer.TYPE_FLOAT)) { textAnswer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); } else { textAnswer.setInputType(InputType.TYPE_CLASS_TEXT); } a = answers.get(0); textAnswer.setText(a.getUserAnswer()); textAnswer.setVisibility(View.VISIBLE); answerFeedback.setText(Html.fromHtml(a.getFeedback())); if (test.isEvaluated() && (feedbackLevel > mediumFeedbackLevel)) { if (answerType.equals(TestAnswer.TYPE_FLOAT)) { correctAnswer = "[" + a.getAnswer() + ";" + answers.get(1).getAnswer() + "]"; if ((feedbackLevel == maxFeedbackLevel) && !a.getFeedback().equals(Constants.NULL_VALUE)) { answerFeedback.setVisibility(View.VISIBLE); } else { answerFeedback.setVisibility(View.GONE); } } else { for (int i = 0; i < numAnswers; i++) { a = answers.get(i); if ((feedbackLevel == maxFeedbackLevel) && !a.getFeedback().equals(Constants.NULL_VALUE)) { correctAnswer += "<strong>" + a.getAnswer() + "</strong><br/>"; correctAnswer += "<i>" + a.getFeedback() + "</i><br/><br/>"; } else { correctAnswer += a.getAnswer() + "<br/>"; } } } textCorrectAnswer.setText(Html.fromHtml(correctAnswer)); textCorrectAnswer.setVisibility(View.VISIBLE); } } else if (answerType.equals(TestAnswer.TYPE_MULTIPLE_CHOICE)) { checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_multiple_choice, answers, test.isEvaluated(), test.getFeedback(), answerType); for (int i = 0; i < numAnswers; i++) { a = answers.get(i); CheckableLinearLayout item = (CheckableLinearLayout) checkedAnswersAdapter.getView(i, null, null); item.setChecked(Utils.parseStringBool(a.getUserAnswer())); testMakeList.addView(item); } testMakeList.setVisibility(View.VISIBLE); } else { if (answerType.equals(TestAnswer.TYPE_TRUE_FALSE) && (numAnswers < 2)) { if (answers.get(0).getAnswer().equals(TestAnswer.VALUE_TRUE)) { answers.add(1, new TestAnswer(0, 1, 0, false, TestAnswer.VALUE_FALSE, answers.get(0).getFeedback())); } else { answers.add(0, new TestAnswer(0, 0, 0, false, TestAnswer.VALUE_TRUE, answers.get(0).getFeedback())); } numAnswers = 2; } checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_single_choice, answers, test.isEvaluated(), test.getFeedback(), answerType); for (int i = 0; i < numAnswers; i++) { a = answers.get(i); CheckableLinearLayout item = (CheckableLinearLayout) checkedAnswersAdapter.getView(i, null, null); item.setChecked(a.getAnswer().equals(answers.get(0).getUserAnswer())); testMakeList.addView(item); } testMakeList.setVisibility(View.VISIBLE); } if (test.isEvaluated() && (feedbackLevel > mediumFeedbackLevel)) { textAnswer.setEnabled(false); textAnswer.setOnClickListener(null); if (feedback.equals(Test.FEEDBACK_HIGH)) { img.setImageResource(R.drawable.btn_check_buttonless_on); if (!answerType.equals(TestAnswer.TYPE_TRUE_FALSE) && !answerType.equals(TestAnswer.TYPE_MULTIPLE_CHOICE) && !answerType.equals(TestAnswer.TYPE_UNIQUE_CHOICE)) { if (!answers.get(0).isCorrectAnswered()) { img.setImageResource(android.R.drawable.ic_delete); } img.setVisibility(View.VISIBLE); } } questionScore = test.getQuestionScore(pos); if (questionScore > 0) { score.setTextColor(getResources().getColor(R.color.green)); } else if (questionScore < 0) { score.setTextColor(getResources().getColor(R.color.red)); } else { score.setTextColor(Color.BLACK); } score.setText(df.format(questionScore)); MenuItemCompat.setActionView(actionScoreItem, score); actionScoreItem.setVisible(true); } }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override public void onAccountIsLoggedIn(final AccountCredentials creds) { LOG.debug("account is logged in: {}", creds); final SimplifiedCatalogAppServicesType app = Simplified.getCatalogAppServices(); final BooksType books = app.getBooks(); 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); UIThread.runOnUIThread(() -> {/* w ww. ja v a 2s . c o m*/ in_table_with_code.setVisibility(View.VISIBLE); in_table_signup.setVisibility(View.GONE); in_account_name_text.setText(this.account.getName()); in_account_subtitle_text.setText(this.account.getSubtitle()); try { in_account_icon.setImageBitmap(this.account.getLogoBitmap()); } catch (IllegalArgumentException e) { in_account_icon.setImageResource(R.drawable.librarylogomagic); } 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,")); 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(v -> { 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_login.setText(rr.getString(R.string.settings_log_out)); in_login.setOnClickListener(v -> { final LogoutDialog d = LogoutDialog.newDialog(); d.setOnConfirmListener(() -> books.accountLogout(creds, this, this, this)); final FragmentManager fm = this.getFragmentManager(); d.show(fm, "logout-confirm"); }); }); }
From source file:com.mobicage.rogerthat.plugins.friends.ActionScreenActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface", "NewApi" }) @Override/*from w ww . j a va 2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { if (CloudConstants.isContentBrandingApp()) { super.setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen); } super.onCreate(savedInstanceState); setContentView(R.layout.action_screen); mBranding = (WebView) findViewById(R.id.branding); WebSettings brandingSettings = mBranding.getSettings(); brandingSettings.setJavaScriptEnabled(true); brandingSettings.setCacheMode(WebSettings.LOAD_DEFAULT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { brandingSettings.setAllowFileAccessFromFileURLs(true); } mBrandingHttp = (WebView) findViewById(R.id.branding_http); mBrandingHttp.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); WebSettings brandingSettingsHttp = mBrandingHttp.getSettings(); brandingSettingsHttp.setJavaScriptEnabled(true); brandingSettingsHttp.setCacheMode(WebSettings.LOAD_DEFAULT); if (CloudConstants.isContentBrandingApp()) { mSoundThread = new HandlerThread("rogerthat_actionscreenactivity_sound"); mSoundThread.start(); Looper looper = mSoundThread.getLooper(); mSoundHandler = new Handler(looper); int cameraPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (cameraPermission == PackageManager.PERMISSION_GRANTED) { mQRCodeScanner = QRCodeScanner.getInstance(this); final LinearLayout previewHolder = (LinearLayout) findViewById(R.id.preview_view); previewHolder.addView(mQRCodeScanner.view); } mBranding.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { initFullScreenForContentBranding(); } }); mBrandingHttp.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { initFullScreenForContentBranding(); } }); } final View brandingHeader = findViewById(R.id.branding_header_container); final ImageView brandingHeaderClose = (ImageView) findViewById(R.id.branding_header_close); final TextView brandingHeaderText = (TextView) findViewById(R.id.branding_header_text); brandingHeaderClose .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text))); brandingHeaderClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.onResume(); } brandingHeader.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl("about:blank"); } }); final View brandingFooter = findViewById(R.id.branding_footer_container); if (CloudConstants.isContentBrandingApp()) { brandingHeaderClose.setVisibility(View.GONE); final ImageView brandingFooterClose = (ImageView) findViewById(R.id.branding_footer_close); final TextView brandingFooterText = (TextView) findViewById(R.id.branding_footer_text); brandingFooterText.setText(getString(R.string.back)); brandingFooterClose .setColorFilter(UIUtils.imageColorFilter(getResources().getColor(R.color.mc_homescreen_text))); brandingFooter.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.onResume(); } brandingHeader.setVisibility(View.GONE); brandingFooter.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl("about:blank"); } }); } final RelativeLayout openPreview = (RelativeLayout) findViewById(R.id.preview_holder); openPreview.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mQRCodeScanner != null) { mQRCodeScanner.previewHolderClicked(); } } }); mBranding.addJavascriptInterface(new JSInterface(this), "__rogerthat__"); mBranding.setWebChromeClient(new WebChromeClient() { @Override public void onConsoleMessage(String message, int lineNumber, String sourceID) { if (sourceID != null) { try { sourceID = new File(sourceID).getName(); } catch (Exception e) { L.d("Could not get fileName of sourceID: " + sourceID, e); } } if (mIsHtmlContent) { L.i("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message); } else { L.d("[BRANDING] " + sourceID + ":" + lineNumber + " | " + message); } } }); mBranding.setWebViewClient(new WebViewClient() { private boolean isExternalUrl(String url) { for (String regularExpression : mBrandingResult.externalUrlPatterns) { if (url.matches(regularExpression)) { return true; } } return false; } @SuppressLint("DefaultLocale") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.i("Branding is loading url: " + url); Uri uri = Uri.parse(url); String lowerCaseUrl = url.toLowerCase(); if (lowerCaseUrl.startsWith("tel:") || lowerCaseUrl.startsWith("mailto:") || isExternalUrl(url)) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); return true; } else if (lowerCaseUrl.startsWith(POKE)) { String tag = url.substring(POKE.length()); poke(tag); return true; } else if (lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://")) { if (mQRCodeScanner != null) { mQRCodeScanner.onPause(); } brandingHeaderText.setText(getString(R.string.loading)); brandingHeader.setVisibility(View.VISIBLE); if (CloudConstants.isContentBrandingApp()) { brandingFooter.setVisibility(View.VISIBLE); } mBranding.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.VISIBLE); mBrandingHttp.loadUrl(url); return true; } else { brandingHeader.setVisibility(View.GONE); brandingFooter.setVisibility(View.GONE); mBrandingHttp.setVisibility(View.GONE); mBranding.setVisibility(View.VISIBLE); } return false; } @Override public void onPageFinished(WebView view, String url) { L.i("onPageFinished " + url); if (!mInfoSet && mService != null && mIsHtmlContent) { Map<String, Object> info = mFriendsPlugin.getRogerthatUserAndServiceInfo(mServiceEmail, mServiceFriend); executeJS(true, "if (typeof rogerthat !== 'undefined') rogerthat._setInfo(%s)", JSONValue.toJSONString(info)); mInfoSet = true; } } @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { L.i("Checking access to: '" + url + "'"); final URL parsedUrl; try { parsedUrl = new URL(url); } catch (MalformedURLException e) { L.d("Webview tried to load malformed URL"); return new WebResourceResponse("text/plain", "UTF-8", null); } if (!parsedUrl.getProtocol().equals("file")) { return null; } File urlPath = new File(parsedUrl.getPath()); if (urlPath.getAbsolutePath().startsWith(mBrandingResult.dir.getAbsolutePath())) { return null; } L.d("404: Webview tries to load outside its sandbox."); return new WebResourceResponse("text/plain", "UTF-8", null); } }); mBrandingHttp.setWebViewClient(new WebViewClient() { @SuppressLint("DefaultLocale") @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { L.i("BrandingHttp is loading url: " + url); return false; } @Override public void onPageFinished(WebView view, String url) { brandingHeaderText.setText(view.getTitle()); L.i("onPageFinished " + url); } }); Intent intent = getIntent(); mBrandingKey = intent.getStringExtra(BRANDING_KEY); mServiceEmail = intent.getStringExtra(SERVICE_EMAIL); mItemTagHash = intent.getStringExtra(ITEM_TAG_HASH); mItemLabel = intent.getStringExtra(ITEM_LABEL); mItemCoords = intent.getLongArrayExtra(ITEM_COORDS); mRunInBackground = intent.getBooleanExtra(RUN_IN_BACKGROUND, true); }
From source file:org.sirimangalo.meditationplus.AdapterMed.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;/* w w w.j a va2s. c o m*/ if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.list_item_med, parent, false); } else { rowView = convertView; } JSONObject p = values.get(position); TextView walk = (TextView) rowView.findViewById(R.id.one_walking); TextView sit = (TextView) rowView.findViewById(R.id.one_sitting); ImageView status = (ImageView) rowView.findViewById(R.id.one_status); TextView name = (TextView) rowView.findViewById(R.id.one_med); ImageView flag = (ImageView) rowView.findViewById(R.id.one_flag); View anuView = rowView.findViewById(R.id.anumodana_shell); TextView anuText = (TextView) rowView.findViewById(R.id.anumodana); try { String wo = p.getString("walking"); String so = p.getString("sitting"); int wi = Integer.parseInt(wo); int si = Integer.parseInt(so); int ti = Integer.parseInt(p.getString("start")); int ei = Integer.parseInt(p.getString("end")); long nowL = System.currentTimeMillis() / 1000; int now = (int) nowL; boolean finished = false; String ws = "0"; String ss = "0"; if (ei > now) { float secs = now - ti; if (secs > wi * 60 || wi == 0) { //walking done float ssecs = (int) (secs - (wi * 60)); if (ssecs < si * 60) // still sitting ss = Integer.toString((int) Math.floor(si - ssecs / 60)); status.setImageResource(R.drawable.sitting_icon); } else { // still walking ws = Integer.toString((int) Math.floor(wi - secs / 60)); ss = so; status.setImageResource(R.drawable.walking_icon); } ws += "/" + wo; ss += "/" + so; } else { ws = wo; ss = so; double age = 1 - (now - ei) / MAX_AGE; String ageColor = Integer.toHexString((int) (255 * age)); if (ageColor.length() == 1) ageColor = "0" + ageColor; int alpha = Color.parseColor("#" + ageColor + "000000"); walk.setTextColor(alpha); sit.setTextColor(alpha); name.setTextColor(alpha); status.setAlpha((float) age); flag.setAlpha((float) age); } walk.setText(ws); sit.setText(ss); if (p.has("country")) { int id = context.getResources().getIdentifier("flag_" + p.getString("country").toLowerCase(), "drawable", context.getPackageName()); flag.setImageResource(id); flag.setVisibility(View.VISIBLE); } final String username = p.getString("username"); final String edit = p.getString("can_edit"); name.setText(username); name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.showProfile(username); } }); String type = p.getString("type"); if ("love".equals(type)) status.setImageResource(R.drawable.love_icon); String anu = p.getString("anumodana"); if (!anu.equals("0")) anuText.setText(anu); if (p.getString("anu_me").equals("1")) { anuText.setTextColor(0xFF00BB00); anuText.setTypeface(null, Typeface.BOLD); } final String sid = p.getString("sid"); anuView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "anu clicked"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String loggedUsername = prefs.getString("username", ""); String loginToken = prefs.getString("login_token", ""); ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("form_id", "anumed_" + sid)); nvp.add(new BasicNameValuePair("login_token", loginToken)); nvp.add(new BasicNameValuePair("submit", "Refresh")); nvp.add(new BasicNameValuePair("username", loggedUsername)); nvp.add(new BasicNameValuePair("source", "android")); PostTaskRunner postTask = new PostTaskRunner(postHandler, context); postTask.doPostTask(nvp); } }); } catch (Exception e) { e.printStackTrace(); } return rowView; }