Java Code Examples for android.widget.ProgressBar#setVisibility()
The following examples show how to use
android.widget.ProgressBar#setVisibility() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PLManager.java From panoramagl with Apache License 2.0 | 6 votes |
/** * This event is fired when GLSurfaceView is created * * @param glSurfaceView current GLSurfaceView */ @SuppressWarnings("deprecation") protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView) { for (int i = 0; i < kMaxTouches; i++) mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f))); mContentLayout = new RelativeLayout(context); mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); mProgressBar = new ProgressBar(context); mProgressBar.setIndeterminate(true); mProgressBar.setVisibility(View.GONE); mContentLayout.addView(mProgressBar, progressBarLayoutParams); return this.onContentViewCreated(mContentLayout); }
Example 2
Source File: ConnectingProcessWorkerTask.java From particle-android with Apache License 2.0 | 6 votes |
private void updateProgress(StepProgress progress, View progressStepContainer) { ProgressBar progBar = Ui.findView(progressStepContainer, R.id.spinner); ImageView checkmark = Ui.findView(progressStepContainer, R.id.checkbox); // don't show the spinner again if we've already shown the checkmark, // regardless of the underlying state that might hide if (checkmark.getVisibility() == View.VISIBLE) { return; } progressStepContainer.setVisibility(View.VISIBLE); if (progress.status == StepProgress.STARTING) { checkmark.setVisibility(View.GONE); progBar.setProgressDrawable(tintedSpinner); progBar.setVisibility(View.VISIBLE); } else { progBar.setVisibility(View.GONE); checkmark.setImageDrawable(tintedCheckmark); checkmark.setVisibility(View.VISIBLE); } }
Example 3
Source File: DefaultMessageProcessor.java From imsdk-android with MIT License | 6 votes |
@Override public void processErrorSendingView(ProgressBar progressBar, ImageView errImgView, IMessageItem item) { if(progressBar!=null && errImgView !=null){ if(MessageStatus.isExistStatus (item.getMessage().getMessageState(),MessageStatus.LOCAL_STATUS_SUCCESS )){ progressBar.setVisibility(View.GONE); errImgView.setVisibility(View.GONE); }else if(MessageStatus.isExistStatus (item.getMessage().getMessageState(),MessageStatus.LOCAL_STATUS_PROCESSION )){ progressBar.setVisibility(View.VISIBLE); errImgView.setVisibility(View.GONE); }else { progressBar.setVisibility(View.GONE); errImgView.setVisibility(View.VISIBLE); } } }
Example 4
Source File: HeatmapsPlacesDemoActivity.java From android-maps-utils with Apache License 2.0 | 6 votes |
/** * Takes the input from the user and generates the required heatmap. * Called when a search query is submitted */ public void submit(View view) { if ("YOUR_KEY_HERE".equals(API_KEY)) { Toast.makeText(this, "Please sign up for a Places API key and add it to HeatmapsPlacesDemoActivity.API_KEY", Toast.LENGTH_LONG).show(); return; } EditText editText = findViewById(R.id.input_text); String keyword = editText.getText().toString(); if (mOverlays.contains(keyword)) { Toast.makeText(this, "This keyword has already been inputted :(", Toast.LENGTH_SHORT).show(); } else if (mOverlaysRendered == MAX_CHECKBOXES) { Toast.makeText(this, "You can only input " + MAX_CHECKBOXES + " keywords. :(", Toast.LENGTH_SHORT).show(); } else if (keyword.length() != 0) { mOverlaysInput++; ProgressBar progressBar = findViewById(R.id.progress_bar); progressBar.setVisibility(View.VISIBLE); new MakeOverlayTask().execute(keyword); editText.setText(""); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); } }
Example 5
Source File: ActivityMain.java From XPrivacy with GNU General Public License v3.0 | 5 votes |
private void applyFilter() { if (mAppAdapter != null) { ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter); TextView tvStats = (TextView) findViewById(R.id.tvStats); TextView tvState = (TextView) findViewById(R.id.tvState); // Get settings int userId = Util.getUserId(Process.myUid()); boolean fUsed = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUsed, false); boolean fInternet = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFInternet, false); boolean fRestriction = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestriction, false); boolean fRestrictionNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFRestrictionNot, false); boolean fPermission = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFPermission, true); boolean fOnDemand = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemand, false); boolean fOnDemandNot = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFOnDemandNot, false); boolean fUser = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFUser, true); boolean fSystem = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFSystem, false); String filter = String.format("%s\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b\n%b", searchQuery, fUsed, fInternet, fRestriction, fRestrictionNot, fPermission, fOnDemand, fOnDemandNot, fUser, fSystem); pbFilter.setVisibility(ProgressBar.VISIBLE); tvStats.setVisibility(TextView.GONE); // Adjust progress state width RelativeLayout.LayoutParams tvStateLayout = (RelativeLayout.LayoutParams) tvState.getLayoutParams(); tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.pbFilter); mAppAdapter.getFilter().filter(filter); } }
Example 6
Source File: PRTHeader.java From Mobike with Apache License 2.0 | 5 votes |
public PRTHeader(Context context) { super(context); int[] size = R.getScreenSize(context); float screenWidth = size[0] < size[1] ? size[0] : size[1]; float ratio = screenWidth / DESIGN_SCREEN_WIDTH; setOrientation(VERTICAL); LinearLayout llInner = new LinearLayout(context); LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_HORIZONTAL; addView(llInner, lp); ivArrow = new RotateImageView(context); int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr"); if (resId > 0) { ivArrow.setImageResource(resId); } int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH); lp = new LayoutParams(avatarWidth, avatarWidth); lp.gravity = Gravity.CENTER_VERTICAL; int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING); lp.topMargin = lp.bottomMargin = avataPadding; llInner.addView(ivArrow, lp); pbRefreshing = new ProgressBar(context); resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar"); Drawable pbdrawable = context.getResources().getDrawable(resId); pbRefreshing.setIndeterminateDrawable(pbdrawable); llInner.addView(pbRefreshing, lp); pbRefreshing.setVisibility(View.GONE); tvHeader = new TextView(getContext()); tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvHeader.setPadding(avataPadding, 0, avataPadding, 0); tvHeader.setTextColor(0xff09bb07); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; llInner.addView(tvHeader, lp); }
Example 7
Source File: PRTHeader.java From Social with Apache License 2.0 | 5 votes |
public PRTHeader(Context context) { super(context); int[] size = R.getScreenSize(context); float screenWidth = size[0] < size[1] ? size[0] : size[1]; float ratio = screenWidth / DESIGN_SCREEN_WIDTH; setOrientation(VERTICAL); LinearLayout llInner = new LinearLayout(context); LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_HORIZONTAL; addView(llInner, lp); ivArrow = new RotateImageView(context); int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr"); if (resId > 0) { ivArrow.setImageResource(resId); } int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH); lp = new LayoutParams(avatarWidth, avatarWidth); lp.gravity = Gravity.CENTER_VERTICAL; int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING); lp.topMargin = lp.bottomMargin = avataPadding; llInner.addView(ivArrow, lp); pbRefreshing = new ProgressBar(context); resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar"); Drawable pbdrawable = context.getResources().getDrawable(resId); pbRefreshing.setIndeterminateDrawable(pbdrawable); llInner.addView(pbRefreshing, lp); pbRefreshing.setVisibility(View.GONE); tvHeader = new TextView(getContext()); tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvHeader.setPadding(avataPadding, 0, avataPadding, 0); tvHeader.setTextColor(0xff09bb07); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; llInner.addView(tvHeader, lp); }
Example 8
Source File: CatalogNetworkFragment.java From Ouroboros with GNU General Public License v3.0 | 5 votes |
@Override protected void onPostExecute(Void aVoid) { catalogAdapter.changeCursor(infiniteDbHelper.getCatalogCursor(SettingsHelper.getSortByMethod(getContext()))); swipeRefreshLayout = (SwipeRefreshLayout) activity.findViewById(R.id.catalog_swipe_container); ProgressBar progressBar = (ProgressBar) activity.findViewById(R.id.progress_bar); if(swipeRefreshLayout != null) { swipeRefreshLayout.setRefreshing(false); } if (progressBar != null){ progressBar.setVisibility(View.INVISIBLE); } }
Example 9
Source File: PRTHeader.java From LQRWeChat with MIT License | 5 votes |
public PRTHeader(Context context) { super(context); int[] size = ResHelper.getScreenSize(context); float screenWidth = size[0] < size[1] ? size[0] : size[1]; float ratio = screenWidth / DESIGN_SCREEN_WIDTH; setOrientation(VERTICAL); LinearLayout llInner = new LinearLayout(context); LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_HORIZONTAL; addView(llInner, lp); ivArrow = new RotateImageView(context); int resId = ResHelper.getBitmapRes(context, "ssdk_oks_ptr_ptr"); if (resId > 0) { ivArrow.setImageResource(resId); } int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH); lp = new LayoutParams(avatarWidth, avatarWidth); lp.gravity = Gravity.CENTER_VERTICAL; int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING); lp.topMargin = lp.bottomMargin = avataPadding; llInner.addView(ivArrow, lp); pbRefreshing = new ProgressBar(context); resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_progressbar"); Drawable pbdrawable = context.getResources().getDrawable(resId); pbRefreshing.setIndeterminateDrawable(pbdrawable); llInner.addView(pbRefreshing, lp); pbRefreshing.setVisibility(View.GONE); tvHeader = new TextView(getContext()); tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvHeader.setPadding(avataPadding, 0, avataPadding, 0); tvHeader.setTextColor(0xff09bb07); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; llInner.addView(tvHeader, lp); }
Example 10
Source File: CacheFragment.java From Aurora with Apache License 2.0 | 5 votes |
private void showDownload(int position) { VideoDownLoadInfo item = data.get(position); item.setDownLoading(true); adapter.setDownPosition(position); ProgressBar seekBar = (ProgressBar) adapter.getViewByPosition(position, R.id.sb_progress); TextView size = (TextView) adapter.getViewByPosition(position, R.id.tv_pause); size.setText(StringUtils.getPrintSize(item.getCurrentBytes() == null ? 0 : item.getCurrentBytes(), false) + "/" + StringUtils.getPrintSize(item.getContentLength() == null ? 0 : item.getContentLength(), true)); seekBar.setVisibility(View.VISIBLE); seekBar.setIndeterminate(false); seekBar.setProgress(data.get(position).getPercent()); }
Example 11
Source File: ActorBrowserTvFragment.java From Mizuu with Apache License 2.0 | 5 votes |
public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); mProgressBar = (ProgressBar) v.findViewById(R.id.progress); if (mActors.size() > 0) mProgressBar.setVisibility(View.GONE); // Hack to remove the ProgressBar on orientation change mAdapter = new ImageAdapter(getActivity()); mGridView = (GridView) v.findViewById(R.id.gridView); mGridView.setAdapter(mAdapter); // Calculate the total column width to set item heights by factor 1.5 mGridView.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { final int numColumns = (int) Math.floor( mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { mGridView.setNumColumns(numColumns); } } }); mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), arg1.findViewById(R.id.cover), "cover"); ActivityCompat.startActivity(getActivity(), IntentUtils.getActorIntent(getActivity(), mActors.get(arg2)), options.toBundle()); } }); TextView title = (TextView) v.findViewById(R.id.empty_library_title); title.setText(R.string.no_actors); TextView description = (TextView) v.findViewById(R.id.empty_library_description); description.setText(R.string.no_actors_description); mGridView.setEmptyView(v.findViewById(R.id.empty_library_layout)); }
Example 12
Source File: FunRegistActivity.java From RePlugin-GameSdk with Apache License 2.0 | 5 votes |
@Override protected void onPreExecute() { super.onPreExecute(); registProgressBar = new ProgressBar(FunRegistActivity.this, null, android.R.attr.progressBarStyle); registProgressBar.setVisibility(View.VISIBLE); LayoutParams progressBarParams = new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarParams.addRule(RelativeLayout.CENTER_IN_PARENT); registRelativeLayout.addView(registProgressBar, progressBarParams); }
Example 13
Source File: PublicServerListFragment.java From Plumble with GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_public_server_list, container, false); mServerGrid = (GridView) view.findViewById(R.id.server_list_grid); mServerGrid.setOnItemClickListener(this); if(mServerAdapter != null) mServerGrid.setAdapter(mServerAdapter); mServerProgress = (ProgressBar) view.findViewById(R.id.serverProgress); mServerProgress.setVisibility(mServerAdapter == null ? View.VISIBLE : View.GONE); return view; }
Example 14
Source File: PRTHeader.java From YiZhi with Apache License 2.0 | 5 votes |
public PRTHeader(Context context) { super(context); int[] size = ResHelper.getScreenSize(context); float screenWidth = size[0] < size[1] ? size[0] : size[1]; float ratio = screenWidth / DESIGN_SCREEN_WIDTH; setOrientation(VERTICAL); LinearLayout llInner = new LinearLayout(context); LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_HORIZONTAL; addView(llInner, lp); ivArrow = new RotateImageView(context); int resId = ResHelper.getBitmapRes(context, "ssdk_oks_ptr_ptr"); if (resId > 0) { ivArrow.setImageResource(resId); } int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH); lp = new LayoutParams(avatarWidth, avatarWidth); lp.gravity = Gravity.CENTER_VERTICAL; int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING); lp.topMargin = lp.bottomMargin = avataPadding; llInner.addView(ivArrow, lp); pbRefreshing = new ProgressBar(context); resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_progressbar"); Drawable pbdrawable = context.getResources().getDrawable(resId); pbRefreshing.setIndeterminateDrawable(pbdrawable); llInner.addView(pbRefreshing, lp); pbRefreshing.setVisibility(View.GONE); tvHeader = new TextView(getContext()); tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvHeader.setPadding(avataPadding, 0, avataPadding, 0); tvHeader.setTextColor(0xff09bb07); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; llInner.addView(tvHeader, lp); }
Example 15
Source File: MainActivity.java From your-local-weather with GNU General Public License v3.0 | 5 votes |
private void setUpdateButtonState(boolean isUpdate) { if (mToolbarMenu != null) { MenuItem updateItem = mToolbarMenu.findItem(R.id.main_menu_refresh); ProgressBar progressUpdate = (ProgressBar) findViewById(R.id.toolbar_progress_bar); if (isUpdate) { updateItem.setVisible(false); progressUpdate.setVisibility(View.VISIBLE); } else { progressUpdate.setVisibility(View.GONE); updateItem.setVisible(true); } } }
Example 16
Source File: ActivityMain.java From XPrivacy with GNU General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("unchecked") protected void publishResults(CharSequence constraint, FilterResults results) { if (results != null) { clear(); TextView tvStats = (TextView) findViewById(R.id.tvStats); TextView tvState = (TextView) findViewById(R.id.tvState); ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter); pbFilter.setVisibility(ProgressBar.GONE); tvStats.setVisibility(TextView.VISIBLE); runOnUiThread(new Runnable() { @Override public void run() { setProgress(getString(R.string.title_restrict), 0, 1); } }); // Adjust progress state width RelativeLayout.LayoutParams tvStateLayout = (RelativeLayout.LayoutParams) tvState.getLayoutParams(); tvStateLayout.addRule(RelativeLayout.LEFT_OF, R.id.tvStats); if (results.values == null) notifyDataSetInvalidated(); else { addAll((ArrayList<ApplicationInfoEx>) results.values); notifyDataSetChanged(); } AppListAdapter.this.showStats(); } }
Example 17
Source File: PRTHeader.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
public PRTHeader(Context context) { super(context); int[] size = R.getScreenSize(context); float screenWidth = size[0] < size[1] ? size[0] : size[1]; float ratio = screenWidth / DESIGN_SCREEN_WIDTH; setOrientation(VERTICAL); LinearLayout llInner = new LinearLayout(context); LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_HORIZONTAL; addView(llInner, lp); ivArrow = new RotateImageView(context); int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr"); if (resId > 0) { ivArrow.setImageResource(resId); } int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH); lp = new LayoutParams(avatarWidth, avatarWidth); lp.gravity = Gravity.CENTER_VERTICAL; int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING); lp.topMargin = lp.bottomMargin = avataPadding; llInner.addView(ivArrow, lp); pbRefreshing = new ProgressBar(context); resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar"); Drawable pbdrawable = context.getResources().getDrawable(resId); pbRefreshing.setIndeterminateDrawable(pbdrawable); llInner.addView(pbRefreshing, lp); pbRefreshing.setVisibility(View.GONE); tvHeader = new TextView(getContext()); tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); tvHeader.setPadding(avataPadding, 0, avataPadding, 0); tvHeader.setTextColor(0xff09bb07); lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; llInner.addView(tvHeader, lp); }
Example 18
Source File: VideocastActivity.java From AnotherRSS with The Unlicense | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_videoweb); VideoView videoView = (VideoView) findViewById(R.id.videoView); WebView webView = (WebView) findViewById(R.id.webView); progressBar = (ProgressBar) findViewById(R.id.progressBar); Intent intent = getIntent(); Uri uri = intent.getData(); if (uri != null) { String url = uri.toString(); if (url.endsWith(".mp4")) { webView.setVisibility(View.GONE); progressBar.setVisibility(View.GONE); videoView.setVisibility(View.VISIBLE); videoView.setMediaController(AnotherRSS.mediaController); videoView.setVideoURI(uri); videoView.requestFocus(); videoView.start(); } else { webView.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE); videoView.setVisibility(View.GONE); webView.setWebViewClient(new MyWebClient()); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.loadUrl(url); } } }
Example 19
Source File: IndividualProductSeller.java From NITKart with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_individual_product_seller); progressBar = (ProgressBar) findViewById(R.id.individualProductPageProgressBarSeller); progressBar.setVisibility(View.VISIBLE); item = (ShoppingItem) getIntent().getSerializableExtra("product"); quantity = item.getQuantity(); removeProduct = (Button) findViewById(R.id.deleteProductSeller); myRef = database.getReference("sellers/" + FirebaseAuth.getInstance().getCurrentUser().getUid()); removeProduct.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { myRef.addListenerForSingleValueEvent(new ValueEventListener() { ArrayList<ShoppingItem> productList = new ArrayList<>(); @Override public void onDataChange(DataSnapshot dataSnapshot) { // for getting the list of products. shuold probably make this a new class tbh. for (DataSnapshot snap : dataSnapshot.child("products").getChildren()) { int itemPrice = -1; try { itemPrice = Integer.valueOf(NumberFormat.getCurrencyInstance() .parse(String.valueOf(snap.child("price").getValue())) .toString()); } catch (ParseException e) { e.printStackTrace(); } String productID = snap.child("productID").getValue().toString(); productList.add(new ShoppingItem( productID, snap.child("title").getValue().toString(), snap.child("type").getValue().toString(), snap.child("description").getValue().toString(), itemPrice, Integer.valueOf(snap.child("quantity").getValue().toString()) )); } for (ShoppingItem x : productList){ if(x.getProductID().equals(item.getProductID())){ productList.remove(x); break; } } if(productList.size() == 0){ myRef.child("isProdsEmpty").setValue(Boolean.TRUE.toString()); productList.add(new ShoppingItem("", "", "", "", -1, -1)); } Map<String, Object> seller_products = new HashMap<>(); seller_products.put("products", productList); myRef.updateChildren(seller_products); Toast.makeText(getApplicationContext(), "Removed!", Toast.LENGTH_SHORT).show(); finish(); } @Override public void onCancelled(DatabaseError databaseError) { } }); } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarSeller); toolbar.setTitle(""); // setSupportActionBar(toolbar); ip = getResources().getString(R.string.ip); name = (TextView) findViewById(R.id.productNameIndividualProductSeller); name.setText(item.getTitle()); description = (TextView) findViewById(R.id.productDescriptionIndividualProductSeller); description.setText(item.getDescription()); quantityView = (TextView) findViewById(R.id.quantityIndividualProductSeller); quantityView.setText(String.valueOf(quantity)); ((TextView) findViewById(R.id.productPriceIndividualProductSeller)) .setText(item.getPrice()); productImage = (ImageView) findViewById(R.id.productImageIndividualProductSeller); Picasso.with(getApplicationContext()) .load(ip + String.valueOf(item.getProductID()) + ".jpg") .fit() .into(productImage); progressBar.setVisibility(View.GONE); }
Example 20
Source File: AddToGroupDialogFragment.java From glimmr with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mLayout = (LinearLayout) inflater.inflate( R.layout.add_to_group_fragment, container, false); mTitleView = (TextView) mLayout.findViewById(R.id.titleText); mTextUtils.setFont(mTitleView, TextUtils.FONT_ROBOTOBOLD); mProgressBar = (ProgressBar) mLayout.findViewById(R.id.progressIndicator); mProgressBar.setVisibility(View.VISIBLE); /* Nested fragments have to be added this way, not from xml */ FragmentTransaction ft = getChildFragmentManager().beginTransaction(); final boolean retainInstance = false; final PhotoStreamGridFragment frag = PhotoStreamGridFragment.newInstance(mOAuth.getUser(), retainInstance, ListView.CHOICE_MODE_MULTIPLE); ft.replace(R.id.photoStreamFragment, frag); ft.commit(); /* When add button is clicked, get selected ids and add to queue */ mLayout.findViewById(R.id.buttonAddToGroup).setOnClickListener( new View.OnClickListener() { public void onClick(View v) { List<Photo> selectedPhotos = frag.getSelectedPhotos(); if (mRemaining < 0 || selectedPhotos.size() == 0) { Log.e(TAG, "None or too many items selected"); return; } for (Photo photo : selectedPhotos) { mQueue.add(new AddItemToGroupTask(mGroup.getId(), photo.getId(), mOAuth)); } mActivity.startService(new Intent(mActivity, AddToGroupTaskQueueService.class)); dismiss(); Crouton.makeText(mActivity, R.string.photos_will_be_added, Style.CONFIRM).show(); } }); return mLayout; }