use of android.app.Dialog in project androidquery by androidquery.
the class Common method showProgress.
public static void showProgress(Object p, String url, boolean show) {
if (p != null) {
if (p instanceof View) {
View pv = (View) p;
ProgressBar pbar = null;
if (p instanceof ProgressBar) {
pbar = (ProgressBar) p;
}
if (show) {
pv.setTag(AQuery.TAG_URL, url);
pv.setVisibility(View.VISIBLE);
if (pbar != null) {
pbar.setProgress(0);
pbar.setMax(100);
}
} else {
Object tag = pv.getTag(AQuery.TAG_URL);
if (tag == null || tag.equals(url)) {
pv.setTag(AQuery.TAG_URL, null);
if (pbar == null || pbar.isIndeterminate()) {
pv.setVisibility(View.GONE);
}
}
}
} else if (p instanceof Dialog) {
Dialog pd = (Dialog) p;
AQuery aq = new AQuery(pd.getContext());
if (show) {
aq.show(pd);
} else {
aq.dismiss(pd);
}
} else if (p instanceof Activity) {
Activity act = (Activity) p;
;
act.setProgressBarIndeterminateVisibility(show);
act.setProgressBarVisibility(show);
if (show) {
act.setProgress(0);
}
}
}
}
use of android.app.Dialog in project androidquery by androidquery.
the class Progress method showProgress.
private void showProgress(Object p, String url, boolean show) {
if (p != null) {
if (p instanceof View) {
View pv = (View) p;
ProgressBar pbar = null;
if (p instanceof ProgressBar) {
pbar = (ProgressBar) p;
}
if (show) {
pv.setTag(AQuery.TAG_URL, url);
pv.setVisibility(View.VISIBLE);
if (pbar != null) {
pbar.setProgress(0);
pbar.setMax(100);
}
} else {
Object tag = pv.getTag(AQuery.TAG_URL);
if (tag == null || tag.equals(url)) {
pv.setTag(AQuery.TAG_URL, null);
if (pbar != null && pbar.isIndeterminate()) {
pv.setVisibility(View.GONE);
}
}
}
} else if (p instanceof Dialog) {
Dialog pd = (Dialog) p;
AQuery aq = new AQuery(pd.getContext());
if (show) {
aq.show(pd);
} else {
aq.dismiss(pd);
}
} else if (p instanceof Activity) {
Activity act = (Activity) p;
;
act.setProgressBarIndeterminateVisibility(show);
act.setProgressBarVisibility(show);
if (show) {
act.setProgress(0);
}
}
}
}
use of android.app.Dialog in project platform_frameworks_base by android.
the class UserController method showUserSwitchDialog.
void showUserSwitchDialog(Pair<UserInfo, UserInfo> fromToUserPair) {
// The dialog will show and then initiate the user switch by calling startUserInForeground
Dialog d = new UserSwitchingDialog(mService, mService.mContext, fromToUserPair.first, fromToUserPair.second, true);
d.show();
}
use of android.app.Dialog in project AndroidPicker by gzu-liyujiang.
the class BasicPopup method initDialog.
private void initDialog() {
contentLayout = new FrameLayout(activity);
contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
contentLayout.setFocusable(true);
contentLayout.setFocusableInTouchMode(true);
//contentLayout.setFitsSystemWindows(true);
dialog = new Dialog(activity);
//触摸屏幕取消窗体
dialog.setCanceledOnTouchOutside(true);
//按返回键取消窗体
dialog.setCancelable(true);
dialog.setOnKeyListener(this);
dialog.setOnDismissListener(this);
Window window = dialog.getWindow();
if (window != null) {
window.setGravity(Gravity.BOTTOM);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//AndroidRuntimeException: requestFeature() must be called before adding content
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setContentView(contentLayout);
}
setSize(screenWidthPixels, WRAP_CONTENT);
}
use of android.app.Dialog in project ListenerMusicPlayer by hefuyicoder.
the class ListenerUtil method showAddPlaylistDialog.
public static void showAddPlaylistDialog(final Context context, final long[] songIds) {
PlaylistLoader.getPlaylists(context, true).map(new Func1<List<Playlist>, Dialog>() {
@Override
public Dialog call(final List<Playlist> playlists) {
final CharSequence[] chars = new CharSequence[playlists.size() + 1];
chars[0] = context.getResources().getString(R.string.create_new_playlist);
for (int i = 0; i < playlists.size(); i++) {
chars[i + 1] = playlists.get(i).name;
}
return new MaterialDialog.Builder(context).title(R.string.add_to_playlist).items(chars).itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
if (which == 0) {
CreatePlaylistDialog.newInstance(songIds).show(((AppCompatActivity) context).getSupportFragmentManager(), context.getString(R.string.create_new_playlist));
return;
} else if (which == 1) {
//我喜欢
int num = FavoriteSong.getInstance(context).addFavoriteSong(songIds);
Toast.makeText(getContext(), R.string.add_favorite_success, Toast.LENGTH_SHORT).show();
RxBus.getInstance().post(new FavourateSongEvent());
dialog.dismiss();
return;
}
MusicPlayer.addToPlaylist(context, songIds, playlists.get(which - 1).id);
RxBus.getInstance().post(new PlaylistUpdateEvent());
dialog.dismiss();
}
}).build();
}
}).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Dialog>() {
@Override
public void call(Dialog dialog) {
dialog.show();
}
});
}
Aggregations