Example usage for android.app ProgressDialog isShowing

List of usage examples for android.app ProgressDialog isShowing

Introduction

In this page you can find the example usage for android.app ProgressDialog isShowing.

Prototype

public boolean isShowing() 

Source Link

Usage

From source file:org.androidpn.demoapp.MessageListActivity.java

private void checkIfAnyNewData() {
    final ProgressDialog checkDialog = new ProgressDialog(this);
    checkDialog.setMessage(getString(R.string.check_new_data));
    checkDialog.show();//from  ww  w  . j a v a2 s .com
    getSupportLoaderManager().restartLoader(LOADER_ONLINE_ID, null,
            new LoaderManager.LoaderCallbacks<MessageListResponse>() {
                @Override
                public Loader<MessageListResponse> onCreateLoader(int id, Bundle args) {
                    String identity = MobilePushApp.getInstance().getUserIdentity();
                    String url = Constants.getMessageList(identity, "");
                    LoadContext<MessageListResponse> loadContext = new LoadContext<MessageListResponse>();
                    loadContext.setFlag(LoadContext.FLAG_HTTP_ONLY);
                    loadContext.setClazz(MessageListResponse.class);
                    loadContext.setParam(url);

                    return new JsonLoaderJeallyBean<MessageListResponse>(MessageListActivity.this, loadContext,
                            new Configuration.CREATOR().setExpiration(Constants.EXPIRATION_TIME)
                                    .setCacheDir(getCacheDir().toString()).create());
                }

                @Override
                public void onLoadFinished(Loader<MessageListResponse> loader, MessageListResponse data) {
                    if (data != null && data.getResultCode().equals("1") && data.getList().size() > 0) {
                        if (!((SingleMessage) mAdapter.getItem(0)).getId().equals(data.getList().get(0).getId())
                                || manualRefresh) {
                            getContentResolver().delete(ServerMessage.CONTENT_URI, null, null);
                            saveData(data.getList());
                            mAdapter = new MessageListAdapter(MessageListActivity.this, data.getList());
                            mListView.setAdapter(mAdapter);
                            mAdapter.notifyDataSetChanged();
                            latestId = ((SingleMessage) (mAdapter.getItem(mAdapter.getCount() - 1))).getId();
                        }
                    }
                    if (checkDialog.isShowing())
                        checkDialog.dismiss();
                    manualRefresh = false;
                    mListView.onRefreshComplete();
                }

                @Override
                public void onLoaderReset(Loader<MessageListResponse> loader) {

                }
            });
}

From source file:nf.frex.android.FrexActivity.java

private void setWallpaper() {
    final WallpaperManager wallpaperManager = WallpaperManager.getInstance(FrexActivity.this);
    final int desiredWidth = wallpaperManager.getDesiredMinimumWidth();
    final int desiredHeight = wallpaperManager.getDesiredMinimumHeight();

    final Image image = view.getImage();
    final int imageWidth = image.getWidth();
    final int imageHeight = image.getHeight();

    final boolean useDesiredSize = desiredWidth > imageWidth || desiredHeight > imageHeight;

    DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() {
        @Override/*from   w w w .j a v  a  2s.  co m*/
        public void onClick(DialogInterface dialog, int which) {
            // ok
        }
    };

    if (useDesiredSize) {
        showYesNoDialog(this, R.string.set_wallpaper,
                getString(R.string.wallpaper_compute_msg, desiredWidth, desiredHeight),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        final Image wallpaperImage;
                        try {
                            wallpaperImage = new Image(desiredWidth, desiredHeight);
                        } catch (OutOfMemoryError e) {
                            alert(getString(R.string.out_of_memory));
                            return;
                        }

                        final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this);

                        Generator.ProgressListener progressListener = new Generator.ProgressListener() {
                            int numLines;

                            @Override
                            public void onStarted(int numTasks) {
                            }

                            @Override
                            public void onSomeLinesComputed(int taskId, int line1, int line2) {
                                numLines += 1 + line2 - line1;
                                progressDialog.setProgress(numLines);
                            }

                            @Override
                            public void onStopped(boolean cancelled) {
                                progressDialog.dismiss();
                                if (!cancelled) {
                                    setWallpaper(wallpaperManager, wallpaperImage);
                                }
                            }
                        };
                        final Generator wallpaperGenerator = new Generator(view.getGeneratorConfig(),
                                SettingsActivity.NUM_CORES, progressListener);

                        DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                if (progressDialog.isShowing()) {
                                    progressDialog.dismiss();
                                }
                                wallpaperGenerator.cancel();
                            }
                        };
                        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                        progressDialog.setCancelable(true);
                        progressDialog.setMax(desiredHeight);
                        progressDialog.setOnCancelListener(cancelListener);
                        progressDialog.show();

                        Arrays.fill(wallpaperImage.getValues(), FractalView.MISSING_VALUE);
                        wallpaperGenerator.start(wallpaperImage, false);
                    }
                }, noListener, null);
    } else {
        showYesNoDialog(this, R.string.set_wallpaper, getString(R.string.wallpaper_replace_msg),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        setWallpaper(wallpaperManager, image);
                    }
                }, noListener, null);
    }
}

From source file:com.juick.android.MainActivity.java

public void updateNavigation() {
    navigationItems = new ArrayList<NavigationItem>();

    List<MicroBlog> blogs = new ArrayList<MicroBlog>(microBlogs.values());
    Collections.<MicroBlog>sort(blogs, new Comparator<MicroBlog>() {
        @Override/*from  w  w w  .j  a v a 2 s . c  om*/
        public int compare(MicroBlog microBlog, MicroBlog microBlog2) {
            return microBlog.getPiority() - microBlog2.getPiority();
        }
    });
    for (MicroBlog blog : blogs) {
        blog.addNavigationSources(navigationItems, this);
    }
    navigationItems.add(new NavigationItem(NAVITEM_UNREAD, R.string.navigationUnread,
            R.drawable.navicon_juickadvanced, "msrcUnread") {
        @Override
        public void action() {
            final NavigationItem thisNi = this;
            final ProgressDialog pd = new ProgressDialog(MainActivity.this);
            pd.setIndeterminate(true);
            pd.setTitle(R.string.navigationUnread);
            pd.setCancelable(true);
            pd.show();
            UnreadSegmentsView.loadPeriods(MainActivity.this,
                    new Utils.Function<Void, ArrayList<DatabaseService.Period>>() {
                        @Override
                        public Void apply(ArrayList<DatabaseService.Period> periods) {
                            if (pd.isShowing()) {
                                pd.cancel();
                                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                                final AlertDialog alerDialog;
                                if (periods.size() == 0) {
                                    alerDialog = builder.setTitle(getString(R.string.UnreadSegments))
                                            .setMessage(getString(R.string.YouHaveNotEnabledForUnreadSegments))
                                            .setCancelable(true)
                                            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialogInterface, int i) {
                                                    dialogInterface.dismiss();
                                                    restoreLastNavigationPosition();
                                                }
                                            }).create();
                                } else {
                                    UnreadSegmentsView unreadSegmentsView = new UnreadSegmentsView(
                                            MainActivity.this, periods);
                                    final int myIndex = navigationItems.indexOf(thisNi);
                                    alerDialog = builder.setTitle(getString(R.string.ChooseUnreadSegment))
                                            .setView(unreadSegmentsView).setCancelable(true)
                                            .setNegativeButton(android.R.string.cancel,
                                                    new DialogInterface.OnClickListener() {
                                                        @Override
                                                        public void onClick(DialogInterface dialogInterface,
                                                                int i) {
                                                            dialogInterface.dismiss();
                                                            restoreLastNavigationPosition();
                                                        }
                                                    })
                                            .create();
                                    unreadSegmentsView.setListener(new UnreadSegmentsView.PeriodListener() {
                                        @Override
                                        public void onPeriodClicked(DatabaseService.Period period) {
                                            alerDialog.dismiss();
                                            int beforeMid = period.beforeMid;
                                            Bundle args = new Bundle();
                                            args.putSerializable("messagesSource",
                                                    new UnreadSegmentMessagesSource(
                                                            getString(R.string.navigationUnread),
                                                            MainActivity.this, period));
                                            if (getSelectedNavigationIndex() != myIndex) {
                                                setSelectedNavigationItem(myIndex);
                                            }
                                            runDefaultFragmentWithBundle(args, thisNi);
                                        }
                                    });
                                }
                                alerDialog.show();
                                restyleChildrenOrWidget(alerDialog.getWindow().getDecorView());
                            }
                            return null;
                        }
                    });
            return;
        }
    });
    navigationItems.add(new NavigationItem(NAVITEM_SAVED, R.string.navigationSaved,
            R.drawable.navicon_juickadvanced, "msrcSaved") {
        @Override
        public void action() {
            final Bundle args = new Bundle();
            args.putSerializable("messagesSource", new SavedMessagesSource(MainActivity.this));
            runDefaultFragmentWithBundle(args, this);
        }
    });
    navigationItems.add(new NavigationItem(NAVITEM_RECENT_READ, R.string.navigationRecentlyOpened,
            R.drawable.navicon_juickadvanced, "msrcRecentOpen") {
        @Override
        public void action() {
            final Bundle args = new Bundle();
            args.putSerializable("messagesSource", new RecentlyOpenedMessagesSource(MainActivity.this));
            runDefaultFragmentWithBundle(args, this);
        }
    });
    navigationItems.add(new NavigationItem(NAVITEM_RECENT_WRITE, R.string.navigationRecentlyCommented,
            R.drawable.navicon_juickadvanced, "msrcRecentComment") {
        @Override
        public void action() {
            final Bundle args = new Bundle();
            args.putSerializable("messagesSource", new RecentlyCommentedMessagesSource(MainActivity.this));
            runDefaultFragmentWithBundle(args, this);
        }
    });
    navigationItems.add(new NavigationItem(NAVITEM_ALL_COMBINED, R.string.navigationAllCombined,
            R.drawable.navicon_juickadvanced, "msrcAllCombined") {
        @Override
        public void action() {
            final Bundle args = new Bundle();
            args.putSerializable("messagesSource",
                    new CombinedAllMessagesSource(MainActivity.this, "combined_all"));
            runDefaultFragmentWithBundle(args, this);
        }

        @Override
        public ArrayList<String> getMenuItems() {
            String s = getString(R.string.SelectSources);
            ArrayList<String> strings = new ArrayList<String>();
            strings.add(s);
            return strings;
        }

        @Override
        public void handleMenuAction(int which, String value) {
            switch (which) {
            case 0:
                selectSourcesForAllCombined();
                break;
            }
        }
    });
    navigationItems.add(new NavigationItem(NAVITEM_SUBS_COMBINED, R.string.navigationSubsCombined,
            R.drawable.navicon_juickadvanced, "msrcSubsCombined") {
        @Override
        public void action() {
            final NavigationItem thiz = this;
            new Thread("MessageSource Initializer") {
                @Override
                public void run() {
                    final Bundle args = new Bundle();
                    args.putSerializable("messagesSource",
                            new CombinedSubscriptionMessagesSource(MainActivity.this));
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            runDefaultFragmentWithBundle(args, thiz);
                        }

                    });
                }
            }.start();
            final Bundle args = new Bundle();
            runDefaultFragmentWithBundle(args, this);
        }

        @Override
        public ArrayList<String> getMenuItems() {
            String s = getString(R.string.SelectSources);
            ArrayList<String> strings = new ArrayList<String>();
            strings.add(s);
            return strings;
        }

        @Override
        public void handleMenuAction(int which, String value) {
            switch (which) {
            case 0:
                selectSourcesForAllSubs();
                break;
            }
        }
    });
    int index = 10000;
    final SharedPreferences sp_order = getSharedPreferences("messages_source_ordering", MODE_PRIVATE);
    for (NavigationItem navigationItem : navigationItems) {
        navigationItem.itemOrder = sp_order.getInt("order_" + navigationItem.id, -1);
        if (navigationItem.itemOrder == -1) {
            navigationItem.itemOrder = index;
            sp_order.edit().putInt("order_" + navigationItem.id, navigationItem.itemOrder).commit();
        }
        index++;
    }
    Collections.sort(navigationItems, new Comparator<NavigationItem>() {
        @Override
        public int compare(NavigationItem lhs, NavigationItem rhs) {
            return lhs.itemOrder - rhs.itemOrder; // increasing
        }
    });
    allNavigationItems = new ArrayList<NavigationItem>(navigationItems);
    final Iterator<NavigationItem> iterator = navigationItems.iterator();
    while (iterator.hasNext()) {
        NavigationItem next = iterator.next();
        if (next.sharedPrefsKey != null) {
            if (!sp.getBoolean(next.sharedPrefsKey, defaultValues(next.sharedPrefsKey))) {
                iterator.remove();
            }
        }
    }
    sp_order.edit().commit(); // save

    final boolean compressedMenu = sp.getBoolean("compressedMenu", false);
    float menuFontScale = 1;
    try {
        menuFontScale = Float.parseFloat(sp.getString("menuFontScale", "1.0"));
    } catch (Exception e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }
    final float finalMenuFontScale = menuFontScale;
    navigationList = (DragSortListView) findViewById(R.id.navigation_list);

    // adapter for old-style navigation
    final BaseAdapter navigationAdapter = new BaseAdapter() {
        @Override
        public int getCount() {
            return navigationItems.size();
        }

        @Override
        public Object getItem(int position) {
            return navigationItems.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (position == -1) {
                // NOOK is funny
                return convertView;
            }
            final int screenHeight = getWindow().getWindowManager().getDefaultDisplay().getHeight();
            final int layoutId = R.layout.simple_list_item_1_mine;
            final PressableLinearLayout retval = convertView != null ? (PressableLinearLayout) convertView
                    : (PressableLinearLayout) getLayoutInflater().inflate(layoutId, null);
            TextView tv = (TextView) retval.findViewById(android.R.id.text1);
            if (parent instanceof Spinner) {
                tv.setTextSize(18 * finalMenuFontScale);
                tv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            } else {
                tv.setTextSize(22 * finalMenuFontScale);
            }
            tv.setText(getString(navigationItems.get(position).labelId));
            if (compressedMenu) {
                int minHeight = (int) ((screenHeight * 0.7) / getCount());
                tv.setMinHeight(minHeight);
                tv.setMinimumHeight(minHeight);
            }
            retval.setPressedListener(new PressableLinearLayout.PressedListener() {
                @Override
                public void onPressStateChanged(boolean selected) {
                    MainActivity.restyleChildrenOrWidget(retval, false);
                }

                @Override
                public void onSelectStateChanged(boolean selected) {
                    MainActivity.restyleChildrenOrWidget(retval, false);
                }
            });
            MainActivity.restyleChildrenOrWidget(retval, false);
            return retval;
        }
    };
    // adapter for new-style navigation
    final BaseAdapter navigationListAdapter = new BaseAdapter() {
        @Override
        public int getCount() {
            return getItems().size();
        }

        private ArrayList<NavigationItem> getItems() {
            if (navigationList.isDragEnabled()) {
                return allNavigationItems;
            } else {
                return navigationItems;
            }
        }

        @Override
        public Object getItem(int position) {
            return getItems().get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        float textSize = -1;

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (position == -1) {
                // NOOK is funny
                return convertView;
            }
            if (textSize < 0) {
                View inflate = getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null);
                TextView text = (TextView) inflate.findViewById(android.R.id.text1);
                textSize = text.getTextSize();
            }
            final int layoutId = R.layout.navigation_list_item;
            final PressableLinearLayout retval = convertView != null ? (PressableLinearLayout) convertView
                    : (PressableLinearLayout) getLayoutInflater().inflate(layoutId, null);
            TextView tv = (TextView) retval.findViewById(android.R.id.text1);
            final ArrayList<NavigationItem> items = getItems();
            final NavigationItem theItem = items.get(position);
            tv.setText(getString(theItem.labelId));
            ImageButton menuButton = (ImageButton) retval.findViewById(R.id.menu_button);
            menuButton.setFocusable(false);
            ArrayList<String> menuItems = theItem.getMenuItems();
            menuButton.setVisibility(menuItems != null && menuItems.size() > 0 ? View.VISIBLE : View.GONE);
            menuButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    doNavigationItemMenu(theItem);
                }
            });
            ImageView iv = (ImageView) retval.findViewById(android.R.id.icon);
            iv.setImageResource(theItem.imageId);
            retval.findViewById(R.id.draggable)
                    .setVisibility(items != allNavigationItems ? View.GONE : View.VISIBLE);
            retval.findViewById(R.id.checkbox).setVisibility(
                    items != allNavigationItems || theItem.sharedPrefsKey == null ? View.GONE : View.VISIBLE);
            CheckBox cb = (CheckBox) retval.findViewById(R.id.checkbox);
            cb.setOnCheckedChangeListener(null);
            if (theItem.sharedPrefsKey != null) {
                cb.setChecked(sp.getBoolean(theItem.sharedPrefsKey, defaultValues(theItem.sharedPrefsKey)));
            }
            cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    sp.edit().putBoolean(theItem.sharedPrefsKey, isChecked).commit();
                }
            });
            int spacing = sp.getInt("navigation_spacing", 0);
            tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize + spacing);

            retval.setPadding(0, spacing, 0, spacing);
            return retval;
        }
    };
    ActionBar bar = getSupportActionBar();
    updateActionBarMode();
    navigationList.setDragEnabled(false);
    ((DragSortController) navigationList.getFloatViewManager()).setDragHandleId(R.id.draggable);
    navigationList.setAdapter(navigationListAdapter);
    navigationList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
            setSelectedNavigationItem(position);
            closeNavigationMenu(true, false);
        }
    });
    navigationList.setDropListener(new DragSortListView.DropListener() {
        @Override
        public void drop(int from, int to) {
            final NavigationItem item = allNavigationItems.remove(from);
            allNavigationItems.add(to, item);

            int index = 0;
            for (NavigationItem allNavigationItem : allNavigationItems) {
                if (allNavigationItem.itemOrder != index) {
                    allNavigationItem.itemOrder = index;
                    sp_order.edit().putInt("order_" + allNavigationItem.id, allNavigationItem.itemOrder)
                            .commit();
                }
                index++;
            }
            sp_order.edit().commit(); // save
            navigationListAdapter.notifyDataSetChanged();
            //To change body of implemented methods use File | Settings | File Templates.
        }
    });
    bar.setListNavigationCallbacks(navigationAdapter, this);
    final View navigationMenuButton = (View) findViewById(R.id.navigation_menu_button);
    navigationMenuButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(MainActivity.this)
                    .setItems(navigationList.isDragEnabled() ? R.array.navigation_menu_end
                            : R.array.navigation_menu_start, new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    int spacing = sp.getInt("navigation_spacing", 0);
                                    switch (which) {
                                    case 0:
                                        if (navigationList.isDragEnabled()) {
                                            navigationList.setDragEnabled(false);
                                            updateNavigation();
                                        } else {
                                            navigationList.setDragEnabled(true);
                                        }
                                        break;
                                    case 1:
                                        final Map<String, ?> all = sp_order.getAll();
                                        for (String s : all.keySet()) {
                                            sp_order.edit().remove(s).commit();
                                        }
                                        sp_order.edit().commit();
                                        updateNavigation();
                                        break;
                                    case 2: // wider
                                        sp.edit().putInt("navigation_spacing", spacing + 1).commit();
                                        ((BaseAdapter) navigationList.getAdapter()).notifyDataSetInvalidated();
                                        break;
                                    case 3: // narrower
                                        if (spacing > 0) {
                                            sp.edit().putInt("navigation_spacing", spacing - 1).commit();
                                            ((BaseAdapter) navigationList.getAdapter())
                                                    .notifyDataSetInvalidated();
                                        }
                                        break;
                                    case 4: // logout from..
                                        logoutFromSomeServices();
                                        break;

                                    }
                                    navigationListAdapter.notifyDataSetChanged();
                                }
                            })
                    .setCancelable(true).create().show();
        }
    });

    final SharedPreferences spn = getSharedPreferences("saved_last_navigation_type", MODE_PRIVATE);
    int restoredLastNavItem = spn.getInt("last_navigation", 0);
    if (restoredLastNavItem != 0) {
        NavigationItem allSources = null;
        for (int i = 0; i < navigationItems.size(); i++) {
            NavigationItem navigationItem = navigationItems.get(i);
            if (navigationItem.labelId == restoredLastNavItem) {
                lastNavigationItem = navigationItem;
            }
            if (navigationItem.labelId == R.string.navigationAll) {
                allSources = navigationItem;
            }
        }
        if (lastNavigationItem == null) {
            lastNavigationItem = allSources; // could be null if not configured
        }
        if (lastNavigationItem == null && navigationItems.size() > 0) {
            lastNavigationItem = navigationItems.get(0); // last default
        }
        if (lastNavigationItem != null) {
            restoreLastNavigationPosition();
            lastNavigationItem.action();
        }
    }

}

From source file:com.commonsware.android.EMusicDownloader.SingleAlbum.java

private void getInfoFromXML() {

    //Show a progress dialog while reading XML
    final ProgressDialog dialog = ProgressDialog.show(this, "", getString(R.string.loading), true, true);
    setProgressBarIndeterminateVisibility(true);

    Thread t3 = new Thread() {
        public void run() {

            waiting(200);//from  w  w w.  ja v a 2 s .  c  o m

            try {

                //Log.d("EMD - ","About to parse");

                URL url = new URL(urlAddress);
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                XMLReader xr = sp.getXMLReader();
                XMLHandlerSingleAlbum myXMLHandler = new XMLHandlerSingleAlbum();
                xr.setContentHandler(myXMLHandler);
                xr.parse(new InputSource(url.openStream()));

                //Log.d("EMD - ","Done Parsing");

                statuscode = myXMLHandler.statuscode;
                if (statuscode != 200 && statuscode != 206) {
                    throw new Exception();
                }

                genre = myXMLHandler.genre;
                genreId = myXMLHandler.genreId;
                labelId = myXMLHandler.labelId;
                label = myXMLHandler.label;
                date = myXMLHandler.releaseDate;
                rating = myXMLHandler.rating;
                imageURL = myXMLHandler.imageURL;
                artist = myXMLHandler.artist;
                artistId = myXMLHandler.artistId;

                //Log.d("EMD - ","Set genre etc..");

                numberOfTracks = myXMLHandler.nItems;
                trackNames = myXMLHandler.tracks;
                //sampleAddresses = myXMLHandler.sampleAddress;
                //sampleExists = myXMLHandler.sampleExists;
                //vSamplesExist = myXMLHandler.samplesExist;

                handlerSetContent.sendEmptyMessage(0);
                dialog.dismiss();
                updateImage();

            } catch (Exception e) {
                final Exception ef = e;
                nameTextView.post(new Runnable() {
                    public void run() {
                        nameTextView.setText(R.string.couldnt_get_album_info);
                    }
                });

            }

            //Remove Progress Dialog
            if (dialog.isShowing()) {
                dialog.dismiss();
            }
            handlerDoneLoading.sendEmptyMessage(0);
        }
    };
    t3.start();
}

From source file:com.easemob.chatuidemo.activity.LoginFragment.java

public void login(final String currentUsername, final String currentPassword, final ProgressDialog pd) {
    if (!CommonUtils.isNetWorkConnected(getActivity())) {
        Toast.makeText(getActivity(), R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;//  w  w  w.  j a  v  a 2s.c o  m
    }
    if (TextUtils.isEmpty(currentUsername)) {
        Toast.makeText(getActivity(), R.string.User_name_cannot_be_empty, Toast.LENGTH_SHORT).show();
        return;
    }
    if (TextUtils.isEmpty(currentPassword)) {
        Toast.makeText(getActivity(), R.string.Password_cannot_be_empty, Toast.LENGTH_SHORT).show();
        return;
    }

    progressShow = true;
    pd.setCanceledOnTouchOutside(false);
    pd.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            progressShow = false;
        }
    });
    pd.setMessage(getString(R.string.Is_landing));
    pd.show();

    final long start = System.currentTimeMillis();
    // sdk??
    EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() {

        @Override
        public void onSuccess() {
            if (!progressShow) {
                return;
            }
            // ?????
            HXApplication.getInstance().setUserName(currentUsername);
            HXApplication.getInstance().setPassword(currentPassword);

            try {
                // ** ?logout???
                // ** manually load all local groups and
                EMGroupManager.getInstance().loadAllGroups();
                EMChatManager.getInstance().loadAllConversations();
                // ??
                initializeContacts();
            } catch (Exception e) {
                e.printStackTrace();
                // ?????
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        HXApplication.getInstance().logout(null);
                        Toast.makeText(getActivity().getApplicationContext(), R.string.login_failure_failed, 1)
                                .show();
                    }
                });
                return;
            }
            // ?nickname ios?nick
            boolean updatenick = EMChatManager.getInstance()
                    .updateCurrentUserNick(HXApplication.currentUserNick.trim());
            if (!updatenick) {
                Log.e("LoginActivity", "update current user nick fail");
            }
            if (!getActivity().isFinishing() && pd.isShowing()) {
                pd.dismiss();
            }
            // ?
            startMainActivity();
        }

        @Override
        public void onProgress(int progress, String status) {
        }

        @Override
        public void onError(final int code, final String message) {
            if (!progressShow) {
                return;
            }
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    Toast.makeText(getActivity().getApplicationContext(),
                            getString(R.string.Login_failed) + message, Toast.LENGTH_SHORT).show();
                }
            });
        }
    });
}

From source file:me.kartikarora.transfersh.activities.TransferActivity.java

private void uploadFile(Uri uri) throws IOException {
    final ProgressDialog dialog = new ProgressDialog(TransferActivity.this);
    dialog.setMessage(getString(R.string.uploading_file));
    dialog.setCancelable(false);/*from   ww  w .  j  a  va 2 s  . c  o m*/
    dialog.show();
    Cursor cursor = getContentResolver().query(uri, null, null, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
        final String name = cursor.getString(nameIndex);
        final String mimeType = getContentResolver().getType(uri);
        Log.d(this.getClass().getSimpleName(), cursor.getString(0));
        Log.d(this.getClass().getSimpleName(), name);
        Log.d(this.getClass().getSimpleName(), mimeType);
        InputStream inputStream = getContentResolver().openInputStream(uri);
        OutputStream outputStream = openFileOutput(name, MODE_PRIVATE);
        if (inputStream != null) {
            IOUtils.copy(inputStream, outputStream);
            final File file = new File(getFilesDir(), name);
            TypedFile typedFile = new TypedFile(mimeType, file);
            TransferClient.getInterface().uploadFile(typedFile, name, new ResponseCallback() {
                @Override
                public void success(Response response) {
                    BufferedReader reader;
                    StringBuilder sb = new StringBuilder();
                    try {
                        reader = new BufferedReader(new InputStreamReader(response.getBody().in()));
                        String line;
                        try {
                            while ((line = reader.readLine()) != null) {
                                sb.append(line);
                            }
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = sb.toString();
                    Snackbar.make(mCoordinatorLayout, name + " " + getString(R.string.uploaded),
                            Snackbar.LENGTH_SHORT).show();

                    ContentValues values = new ContentValues();
                    values.put(FilesContract.FilesEntry.COLUMN_NAME, name);
                    values.put(FilesContract.FilesEntry.COLUMN_TYPE, mimeType);
                    values.put(FilesContract.FilesEntry.COLUMN_URL, result);
                    values.put(FilesContract.FilesEntry.COLUMN_SIZE, String.valueOf(file.getTotalSpace()));
                    getContentResolver().insert(FilesContract.BASE_CONTENT_URI, values);
                    getSupportLoaderManager().restartLoader(BuildConfig.VERSION_CODE, null,
                            TransferActivity.this);
                    FileUtils.deleteQuietly(file);
                    if (dialog.isShowing())
                        dialog.hide();
                }

                @Override
                public void failure(RetrofitError error) {
                    error.printStackTrace();
                    if (dialog.isShowing())
                        dialog.hide();
                    Snackbar.make(mCoordinatorLayout, R.string.something_went_wrong, Snackbar.LENGTH_INDEFINITE)
                            .setAction(R.string.report, new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    // TODO add feedback code
                                }
                            }).show();
                }
            });
        } else
            Snackbar.make(mCoordinatorLayout, R.string.unable_to_read, Snackbar.LENGTH_SHORT).show();
    }
}

From source file:de.da_sense.moses.client.AvailableFragment.java

/**
 * FIXME: The ProgressDialog doesn't show up. Handles installing APK from
 * the Server./*from  w w  w .  j  ava 2 s.c o  m*/
 * 
 * @param app
 *            the App to download and install
 */
protected void handleInstallApp(ExternalApplication app) {

    final ProgressDialog progressDialog = new ProgressDialog(WelcomeActivity.getInstance());

    Log.d(TAG, "progressDialog = " + progressDialog);

    final ApkDownloadManager downloader = new ApkDownloadManager(app,
            WelcomeActivity.getInstance().getApplicationContext(), // getActivity().getApplicationContext(),
            new ExecutableForObject() {
                @Override
                public void execute(final Object o) {
                    if (o instanceof Integer) {
                        WelcomeActivity.getInstance().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (totalSize == -1) {
                                    totalSize = (Integer) o / 1024;
                                    progressDialog.setMax(totalSize);
                                } else {
                                    progressDialog.incrementProgressBy(
                                            ((Integer) o / 1024) - progressDialog.getProgress());
                                }
                            }
                        });
                        /*
                         * They were : Runnable runnable = new Runnable() {
                         * Integer temporary = (Integer) o / 1024;
                         * 
                         * @Override public void run() { if (totalSize ==
                         * -1) { totalSize = temporary;
                         * progressDialog.setMax(totalSize); } else {
                         * progressDialog .incrementProgressBy( temporary -
                         * progressDialog.getProgress()); } } };
                         * getActivity().runOnUiThread(runnable);
                         */
                    }
                }
            });

    progressDialog.setTitle(getString(R.string.downloadingApp));
    progressDialog.setMessage(getString(R.string.pleaseWait));
    progressDialog.setMax(0);
    progressDialog.setProgress(0);
    progressDialog.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            downloader.cancel();
        }
    });

    progressDialog.setCancelable(true);
    progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (progressDialog.isShowing())
                progressDialog.cancel();
        }
    });
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

    Observer observer = new Observer() {
        @Override
        public void update(Observable observable, Object data) {
            if (downloader.getState() == ApkDownloadManager.State.ERROR) {
                // error downloading
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();
                }
                showMessageBoxErrorDownloading(downloader);
            } else if (downloader.getState() == ApkDownloadManager.State.ERROR_NO_CONNECTION) {
                // error with connection
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();
                }
                showMessageBoxErrorNoConnection(downloader);
            } else if (downloader.getState() == ApkDownloadManager.State.FINISHED) {
                // success
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();
                }
                installDownloadedApk(downloader.getDownloadedApk(), downloader.getExternalApplicationResult());
            }
        }
    };
    downloader.addObserver(observer);
    totalSize = -1;
    // progressDialog.show(); FIXME: commented out in case it throws an
    // error
    downloader.start();
}

From source file:com.piusvelte.sonet.core.SonetCreatePost.java

private void setLocation(final long accountId) {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Void, Void, String> asyncTask = new AsyncTask<Void, Void, String>() {

        int serviceId;

        @Override//from  w ww. j  av  a  2  s .c om
        protected String doInBackground(Void... none) {
            Cursor account = getContentResolver().query(Accounts.getContentUri(SonetCreatePost.this),
                    new String[] { Accounts._ID, Accounts.TOKEN, Accounts.SERVICE, Accounts.SECRET },
                    Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null);
            if (account.moveToFirst()) {
                SonetOAuth sonetOAuth;
                serviceId = account.getInt(account.getColumnIndex(Accounts.SERVICE));
                switch (serviceId) {
                case TWITTER:
                    // anonymous requests are rate limited to 150 per hour
                    // authenticated requests are rate limited to 350 per hour, so authenticate this!
                    sonetOAuth = new SonetOAuth(TWITTER_KEY, TWITTER_SECRET,
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.TOKEN))),
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.SECRET))));
                    return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(
                            new HttpGet(String.format(TWITTER_SEARCH, TWITTER_BASE_URL, mLat, mLong))));
                case FACEBOOK:
                    return SonetHttpClient.httpResponse(mHttpClient, new HttpGet(String.format(FACEBOOK_SEARCH,
                            FACEBOOK_BASE_URL, mLat, mLong, Saccess_token,
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.TOKEN))))));
                case FOURSQUARE:
                    return SonetHttpClient.httpResponse(mHttpClient, new HttpGet(String.format(
                            FOURSQUARE_SEARCH, FOURSQUARE_BASE_URL, mLat, mLong,
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.TOKEN))))));
                }
            }
            account.close();
            return null;
        }

        @Override
        protected void onPostExecute(String response) {
            if (loadingDialog.isShowing())
                loadingDialog.dismiss();
            if (response != null) {
                switch (serviceId) {
                case TWITTER:
                    try {
                        JSONArray places = new JSONObject(response).getJSONObject(Sresult)
                                .getJSONArray(Splaces);
                        final String placesNames[] = new String[places.length()];
                        final String placesIds[] = new String[places.length()];
                        for (int i = 0, i2 = places.length(); i < i2; i++) {
                            JSONObject place = places.getJSONObject(i);
                            placesNames[i] = place.getString(Sfull_name);
                            placesIds[i] = place.getString(Sid);
                        }
                        mDialog = (new AlertDialog.Builder(SonetCreatePost.this))
                                .setSingleChoiceItems(placesNames, -1, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        mAccountsLocation.put(accountId, placesIds[which]);
                                        dialog.dismiss();
                                    }
                                }).setNegativeButton(android.R.string.cancel,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.cancel();
                                            }
                                        })
                                .create();
                        mDialog.show();
                    } catch (JSONException e) {
                        Log.e(TAG, e.toString());
                    }
                    break;
                case FACEBOOK:
                    try {
                        JSONArray places = new JSONObject(response).getJSONArray(Sdata);
                        final String placesNames[] = new String[places.length()];
                        final String placesIds[] = new String[places.length()];
                        for (int i = 0, i2 = places.length(); i < i2; i++) {
                            JSONObject place = places.getJSONObject(i);
                            placesNames[i] = place.getString(Sname);
                            placesIds[i] = place.getString(Sid);
                        }
                        mDialog = (new AlertDialog.Builder(SonetCreatePost.this))
                                .setSingleChoiceItems(placesNames, -1, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        mAccountsLocation.put(accountId, placesIds[which]);
                                        dialog.dismiss();
                                    }
                                }).setNegativeButton(android.R.string.cancel,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.cancel();
                                            }
                                        })
                                .create();
                        mDialog.show();
                    } catch (JSONException e) {
                        Log.e(TAG, e.toString());
                    }
                    break;
                case FOURSQUARE:
                    try {
                        JSONArray groups = new JSONObject(response).getJSONObject(Sresponse)
                                .getJSONArray(Sgroups);
                        for (int g = 0, g2 = groups.length(); g < g2; g++) {
                            JSONObject group = groups.getJSONObject(g);
                            if (group.getString(Sname).equals(SNearby)) {
                                JSONArray places = group.getJSONArray(Sitems);
                                final String placesNames[] = new String[places.length()];
                                final String placesIds[] = new String[places.length()];
                                for (int i = 0, i2 = places.length(); i < i2; i++) {
                                    JSONObject place = places.getJSONObject(i);
                                    placesNames[i] = place.getString(Sname);
                                    placesIds[i] = place.getString(Sid);
                                }
                                mDialog = (new AlertDialog.Builder(SonetCreatePost.this))
                                        .setSingleChoiceItems(placesNames, -1,
                                                new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialog, int which) {
                                                        mAccountsLocation.put(accountId, placesIds[which]);
                                                        dialog.dismiss();
                                                    }
                                                })
                                        .setNegativeButton(android.R.string.cancel,
                                                new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialog, int which) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .create();
                                mDialog.show();
                                break;
                            }
                        }
                    } catch (JSONException e) {
                        Log.e(TAG, e.toString());
                    }
                    break;
                }
            } else {
                (Toast.makeText(SonetCreatePost.this, getString(R.string.failure), Toast.LENGTH_LONG)).show();
            }
        }

    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute();
}

From source file:com.piusvelte.sonet.SonetCreatePost.java

private void setLocation(final long accountId) {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Void, Void, String> asyncTask = new AsyncTask<Void, Void, String>() {

        int serviceId;

        @Override/*from   w ww  . j  a va  2  s . com*/
        protected String doInBackground(Void... none) {
            Cursor account = getContentResolver().query(Accounts.getContentUri(SonetCreatePost.this),
                    new String[] { Accounts._ID, Accounts.TOKEN, Accounts.SERVICE, Accounts.SECRET },
                    Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null);
            if (account.moveToFirst()) {
                SonetOAuth sonetOAuth;
                serviceId = account.getInt(account.getColumnIndex(Accounts.SERVICE));
                switch (serviceId) {
                case TWITTER:
                    // anonymous requests are rate limited to 150 per hour
                    // authenticated requests are rate limited to 350 per hour, so authenticate this!
                    sonetOAuth = new SonetOAuth(BuildConfig.TWITTER_KEY, BuildConfig.TWITTER_SECRET,
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.TOKEN))),
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.SECRET))));
                    return SonetHttpClient.httpResponse(mHttpClient, sonetOAuth.getSignedRequest(
                            new HttpGet(String.format(TWITTER_SEARCH, TWITTER_BASE_URL, mLat, mLong))));
                case FACEBOOK:
                    return SonetHttpClient.httpResponse(mHttpClient, new HttpGet(String.format(FACEBOOK_SEARCH,
                            FACEBOOK_BASE_URL, mLat, mLong, Saccess_token,
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.TOKEN))))));
                case FOURSQUARE:
                    return SonetHttpClient.httpResponse(mHttpClient, new HttpGet(String.format(
                            FOURSQUARE_SEARCH, FOURSQUARE_BASE_URL, mLat, mLong,
                            mSonetCrypto.Decrypt(account.getString(account.getColumnIndex(Accounts.TOKEN))))));
                }
            }
            account.close();
            return null;
        }

        @Override
        protected void onPostExecute(String response) {
            if (loadingDialog.isShowing())
                loadingDialog.dismiss();
            if (response != null) {
                switch (serviceId) {
                case TWITTER:
                    try {
                        JSONArray places = new JSONObject(response).getJSONObject(Sresult)
                                .getJSONArray(Splaces);
                        final String placesNames[] = new String[places.length()];
                        final String placesIds[] = new String[places.length()];
                        for (int i = 0, i2 = places.length(); i < i2; i++) {
                            JSONObject place = places.getJSONObject(i);
                            placesNames[i] = place.getString(Sfull_name);
                            placesIds[i] = place.getString(Sid);
                        }
                        mDialog = (new AlertDialog.Builder(SonetCreatePost.this))
                                .setSingleChoiceItems(placesNames, -1, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        mAccountsLocation.put(accountId, placesIds[which]);
                                        dialog.dismiss();
                                    }
                                }).setNegativeButton(android.R.string.cancel,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.cancel();
                                            }
                                        })
                                .create();
                        mDialog.show();
                    } catch (JSONException e) {
                        Log.e(TAG, e.toString());
                    }
                    break;
                case FACEBOOK:
                    try {
                        JSONArray places = new JSONObject(response).getJSONArray(Sdata);
                        final String placesNames[] = new String[places.length()];
                        final String placesIds[] = new String[places.length()];
                        for (int i = 0, i2 = places.length(); i < i2; i++) {
                            JSONObject place = places.getJSONObject(i);
                            placesNames[i] = place.getString(Sname);
                            placesIds[i] = place.getString(Sid);
                        }
                        mDialog = (new AlertDialog.Builder(SonetCreatePost.this))
                                .setSingleChoiceItems(placesNames, -1, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        mAccountsLocation.put(accountId, placesIds[which]);
                                        dialog.dismiss();
                                    }
                                }).setNegativeButton(android.R.string.cancel,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.cancel();
                                            }
                                        })
                                .create();
                        mDialog.show();
                    } catch (JSONException e) {
                        Log.e(TAG, e.toString());
                    }
                    break;
                case FOURSQUARE:
                    try {
                        JSONArray groups = new JSONObject(response).getJSONObject(Sresponse)
                                .getJSONArray(Sgroups);
                        for (int g = 0, g2 = groups.length(); g < g2; g++) {
                            JSONObject group = groups.getJSONObject(g);
                            if (group.getString(Sname).equals(SNearby)) {
                                JSONArray places = group.getJSONArray(Sitems);
                                final String placesNames[] = new String[places.length()];
                                final String placesIds[] = new String[places.length()];
                                for (int i = 0, i2 = places.length(); i < i2; i++) {
                                    JSONObject place = places.getJSONObject(i);
                                    placesNames[i] = place.getString(Sname);
                                    placesIds[i] = place.getString(Sid);
                                }
                                mDialog = (new AlertDialog.Builder(SonetCreatePost.this))
                                        .setSingleChoiceItems(placesNames, -1,
                                                new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialog, int which) {
                                                        mAccountsLocation.put(accountId, placesIds[which]);
                                                        dialog.dismiss();
                                                    }
                                                })
                                        .setNegativeButton(android.R.string.cancel,
                                                new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialog, int which) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .create();
                                mDialog.show();
                                break;
                            }
                        }
                    } catch (JSONException e) {
                        Log.e(TAG, e.toString());
                    }
                    break;
                }
            } else {
                (Toast.makeText(SonetCreatePost.this, getString(R.string.failure), Toast.LENGTH_LONG)).show();
            }
        }

    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute();
}

From source file:cm.aptoide.pt.MainActivity.java

private void dialogAddStore(final String url, final String username, final String password) {
    final ProgressDialog pd = new ProgressDialog(mContext);
    pd.setMessage(getString(R.string.please_wait));
    pd.show();//from ww  w  . j av a2 s.co m

    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                addStore(url, username, password);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        if (pd.isShowing()) {
                            pd.dismiss();
                        }
                        refreshAvailableList(true);
                    }
                });

            }

        }
    }).start();
}