use of com.afollestad.materialdialogs.MaterialDialog in project Weather by Sparker0i.
the class WeatherFragment method showNoInternet.
public void showNoInternet() {
new MaterialDialog.Builder(getContext()).title(getString(R.string.no_internet_title)).cancelable(false).content(getString(R.string.no_internet_content)).positiveText(getString(R.string.no_internet_mobile_data)).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
startActivityForResult(intent, 0);
}
}).negativeText(getString(R.string.no_internet_wifi)).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS), 0);
}
}).show();
}
use of com.afollestad.materialdialogs.MaterialDialog in project BBS-Android by bdpqchen.
the class HomeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHomeActivity = this;
mContext = this;
LogUtil.dd("token", PrefUtil.getAuthToken());
// 登录后的渐变,
if (!PrefUtil.isNoAccountUser()) {
PrefUtil.setHadLogin(true);
}
mMask.setVisibility(View.VISIBLE);
ObjectAnimator animator = ObjectAnimator.ofFloat(findViewById(R.id.mask_home), "alpha", 0f).setDuration(600);
animator.setStartDelay(400);
animator.start();
mMainFragment = MainFragment.newInstance();
mForumFragment = ForumFragment.newInstance();
mIndividualFragment = IndividualFragment.newInstance();
loadMultipleRootFragment(R.id.fl_main_container, 0, mMainFragment, mForumFragment, mIndividualFragment);
mNearBy = mBottomBar.getTabWithId(R.id.bottom_bar_tab_individual);
mBottomBar.setOnTabSelectListener(i -> {
LogUtil.dd("onTabSelected()");
if (PrefUtil.hadLogin()) {
if (i == R.id.bottom_bar_tab_main) {
mShowingFragment = Constants.FRAGMENT_MAIN;
} else if (i == R.id.bottom_bar_tab_forum) {
mShowingFragment = Constants.FRAGMENT_FORUM;
} else if (i == R.id.bottom_bar_tab_individual) {
mShowingFragment = Constants.FRAGMENT_INDIVIDUAL;
}
loadFragment();
} else if (i == R.id.bottom_bar_tab_individual && !PrefUtil.hadLogin()) {
startActivity(new Intent(this, LoginActivity.class));
}
});
// TODO: 17-5-22 解决夜间模式View的空指针问题
if (PrefUtil.hadLogin()) {
mPresenter.initIndividualInfo();
}
HandlerUtil.postDelay(() -> {
PgyUpdateManager.register(this, "9981", new UpdateManagerListener() {
@Override
public void onNoUpdateAvailable() {
LogUtil.dd("not update available");
}
@Override
public void onUpdateAvailable(final String result) {
// 将新版本信息封装到AppBean中
final AppBean appBean = getAppBeanFromString(result);
new MaterialDialog.Builder(mContext).cancelable(false).title("最新版本更新").content(appBean.getReleaseNote()).positiveText("立即下载").positiveColor(ResourceUtil.getColor(mContext, R.color.colorPrimary)).onPositive((new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
hasPermission(appBean);
}
})).negativeText("再说吧").show();
}
});
}, 1000);
}
use of com.afollestad.materialdialogs.MaterialDialog in project Tapad by berict.
the class PresetStoreAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final PresetViewHolder holder, int position) {
final Preset preset = firebaseMetadata.getPreset(position);
// set gesture
if (preset.getMusic().getGesture()) {
// preset is gesture
holder.presetGesture.setVisibility(View.VISIBLE);
holder.presetGesture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new MaterialDialog.Builder(activity).title(R.string.preset_store_gesture_help_dialog_title).content(R.string.preset_store_gesture_help_dialog_text).contentColorRes(R.color.dark_primary).positiveText(R.string.dialog_close).positiveColorRes(R.color.colorAccent).show();
}
});
} else {
holder.presetGesture.setVisibility(View.GONE);
}
// load preset image
String imageUrl = window.getStringFromId(R.string.google_firebase_link_root, activity) + "/presets%2F" + preset.getFirebaseLocation() + "%2F" + "album_art.jpg" + "?alt=media";
String presetName = preset.getAbout().getTitle();
String[] presetString = presetName.split(" - ");
// set title
holder.presetTitle.setText(presetString[1]);
// set artist name
holder.presetArtist.setText(presetString[0]);
// set preset creator
holder.presetCreator.setText(window.getStringFromId(R.string.preset_store_preset_by, activity) + " " + preset.getAbout().getPresetCreator());
// actions
if (isPresetExists(preset.getFirebaseLocation())) {
if (isPresetAvailable(preset.getFirebaseLocation())) {
// exists, select | remove action
holder.presetSelect.setVisibility(View.VISIBLE);
holder.presetSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// select and load preset
preset.setLoadPreset(activity);
}
});
// load local image
Picasso.with(activity).load("file:" + PROJECT_LOCATION_PRESETS + "/" + preset.getFirebaseLocation() + "/about/album_art.jpg").placeholder(R.drawable.ic_image_album_placeholder).error(R.drawable.ic_image_album_error).into(holder.presetImage);
onFirebasePresetUpdated(preset.getFirebaseLocation(), new Runnable() {
@Override
public void run() {
// preset updated
holder.presetUpdate.setVisibility(View.VISIBLE);
holder.presetUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// re-download the preset
preset.repairPreset(parentView, activity, new Runnable() {
@Override
public void run() {
notifyItemChanged(holder.getAdapterPosition());
}
});
}
});
// show warning
holder.presetWarningLayout.setVisibility(View.VISIBLE);
holder.presetWarning.setText(R.string.preset_store_action_update_available);
}
});
} else {
// corrupted, show repair
holder.presetSelect.setVisibility(View.VISIBLE);
holder.presetSelect.setTextColor(activity.getResources().getColor(R.color.colorAccent));
holder.presetSelect.setText(R.string.preset_store_action_repair);
// show warning
holder.presetWarningLayout.setVisibility(View.VISIBLE);
holder.presetWarning.setText(R.string.preset_store_action_repair_needed);
holder.presetSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// show repair dialog
new MaterialDialog.Builder(activity).title(R.string.preset_store_action_repair_dialog_title).content(R.string.preset_store_action_repair_dialog_text).contentColorRes(R.color.dark_primary).positiveText(R.string.preset_store_action_repair).positiveColorRes(R.color.colorAccent).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
// repair the preset
preset.repairPreset(parentView, activity, new Runnable() {
@Override
public void run() {
notifyItemChanged(holder.getAdapterPosition());
}
});
}
}).negativeText(R.string.dialog_cancel).show();
}
});
// load url image
Picasso.with(activity).load(imageUrl).placeholder(R.drawable.ic_image_album_placeholder).error(R.drawable.ic_image_album_error).into(holder.presetImage);
}
holder.presetRemove.setVisibility(View.VISIBLE);
holder.presetRemove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// remove confirm dialog
new MaterialDialog.Builder(activity).content(R.string.preset_store_remove_warning_dialog_text).contentColorRes(R.color.dark_secondary).positiveText(R.string.remove_ac).positiveColorRes(R.color.red).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
// repair the preset
preset.removePreset(new Runnable() {
@Override
public void run() {
notifyItemChanged(holder.getAdapterPosition());
}
}, activity);
}
}).negativeText(R.string.dialog_cancel).show();
}
});
holder.presetUpdate.setVisibility(View.GONE);
holder.presetDownload.setVisibility(View.GONE);
} else {
// doesn't exist, download action
holder.presetSelect.setVisibility(View.GONE);
holder.presetRemove.setVisibility(View.GONE);
holder.presetUpdate.setVisibility(View.GONE);
holder.presetDownload.setVisibility(View.VISIBLE);
holder.presetDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
preset.downloadPreset(parentView, activity, new Runnable() {
@Override
public void run() {
notifyItemChanged(holder.getAdapterPosition());
}
});
}
});
// load url image
Picasso.with(activity).load(imageUrl).placeholder(R.drawable.ic_image_album_placeholder).error(R.drawable.ic_image_album_error).into(holder.presetImage);
}
}
use of com.afollestad.materialdialogs.MaterialDialog in project Tapad by berict.
the class FileHelper method refreshPresetAdapterActions.
private void refreshPresetAdapterActions(String presetName, View parentView, final Activity activity) {
TextView presetDownload = (TextView) parentView.findViewById(R.id.layout_preset_store_action_download);
TextView presetSelect = (TextView) parentView.findViewById(R.id.layout_preset_store_action_select);
TextView presetRemove = (TextView) parentView.findViewById(R.id.layout_preset_store_action_remove);
if (isPresetExists(presetName)) {
if (isPresetAvailable(presetName)) {
// exists, select | remove action
presetSelect.setVisibility(View.VISIBLE);
presetSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// select and load preset
// TODO need to revise the loading method
}
});
} else {
// corrupted, disable select
presetSelect.setVisibility(View.VISIBLE);
presetSelect.setAlpha(0.5f);
presetSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// show repair dialog
new MaterialDialog.Builder(activity).title(R.string.preset_store_action_repair_dialog_title).content(R.string.preset_store_action_repair_dialog_text).contentColorRes(R.color.dark_primary).positiveText(R.string.preset_store_action_repair).positiveColorRes(R.color.colorAccent).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
// remove and download the preset
}
}).negativeText(R.string.dialog_cancel).show();
}
});
}
presetRemove.setVisibility(View.VISIBLE);
// presetRemove.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// // remove confirm dialog
// }
// });
presetDownload.setVisibility(View.GONE);
} else {
// doesn't exist, download action
presetSelect.setVisibility(View.GONE);
presetRemove.setVisibility(View.GONE);
presetDownload.setVisibility(View.VISIBLE);
// presetDownload.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
}
}
use of com.afollestad.materialdialogs.MaterialDialog in project AnimeTaste by daimajia.
the class ShareHelper method showUp.
public static void showUp(final Context context, final Animation animation) {
View v = LayoutInflater.from(context).inflate(R.layout.layout_share, null, false);
final MaterialDialog dialog = new MaterialDialog.Builder(context).customView(v, false).build();
dialog.show();
ShareSDK.initSDK(context);
ShareButton weibo = (ShareButton) v.findViewById(R.id.action_share_weibo);
ShareButton wechat = (ShareButton) v.findViewById(R.id.action_share_wechat);
ShareButton wechatTimeline = (ShareButton) v.findViewById(R.id.action_share_wechat_timeline);
ShareButton qq = (ShareButton) v.findViewById(R.id.action_share_qq);
ShareButton link = (ShareButton) v.findViewById(R.id.action_share_link);
ShareButton qzone = (ShareButton) v.findViewById(R.id.action_share_qzone);
TextView cancel = (TextView) v.findViewById(R.id.cancel);
final Handler showMsg = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
Toast.makeText(context, msg.obj.toString(), Toast.LENGTH_SHORT).show();
return true;
}
});
final PlatformActionListener platformActionListener = new PlatformActionListener() {
@Override
public void onComplete(Platform platform, int i, HashMap<String, Object> stringObjectHashMap) {
Message msg = Message.obtain(showMsg);
msg.obj = "(๑•̀ㅂ•́)و分享成功!Ye";
msg.sendToTarget();
}
@Override
public void onError(Platform platform, int i, Throwable throwable) {
Log.e("Error", throwable.getMessage());
Message msg = Message.obtain(showMsg);
msg.obj = "(⊙﹏⊙) 好像出了错误";
msg.sendToTarget();
}
@Override
public void onCancel(Platform platform, int i) {
Message msg = Message.obtain(showMsg);
msg.obj = "o(TヘTo) 取消了耶...";
msg.sendToTarget();
}
};
weibo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SinaWeibo.ShareParams sp = new SinaWeibo.ShareParams();
Platform pf = ShareSDK.getPlatform(context, SinaWeibo.NAME);
String toSend = "「" + animation.Name + "」 " + animation.OriginVideoUrl + " " + animation.Brief;
toSend = toSend.substring(0, 140);
sp.setText(toSend);
sp.setUrl(animation.OriginVideoUrl);
sp.setImageUrl(animation.DetailPic);
pf.setPlatformActionListener(platformActionListener);
pf.share(sp);
shareAction(context, dialog);
}
});
wechat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, Wechat.NAME);
Wechat.ShareParams sp = new Wechat.ShareParams();
sp.setTitle(animation.Name);
sp.setText(animation.Brief);
sp.setImageUrl(animation.HomePic);
sp.setUrl(animation.getShareUrl());
sp.setShareType(Platform.SHARE_WEBPAGE);
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
wechatTimeline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, WechatMoments.NAME);
WechatMoments.ShareParams sp = new WechatMoments.ShareParams();
sp.title = animation.Name;
sp.text = animation.Brief;
sp.imageUrl = animation.HomePic;
sp.url = animation.getShareUrl();
sp.shareType = Platform.SHARE_WEBPAGE;
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
qq.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, QQ.NAME);
QQ.ShareParams sp = new QQ.ShareParams();
sp.setTitle(animation.Name);
sp.setText(animation.Brief);
sp.setImageUrl(animation.HomePic);
sp.setTitleUrl(animation.getShareUrl());
sp.setShareType(QQ.SHARE_WEBPAGE);
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
qzone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Platform plat = ShareSDK.getPlatform(context, QZone.NAME);
QZone.ShareParams sp = new QZone.ShareParams();
sp.setTitle(animation.Name);
sp.setText(animation.Brief);
sp.setImageUrl(animation.HomePic);
sp.setTitleUrl(animation.getShareUrl());
sp.setShareType(QZone.SHARE_WEBPAGE);
plat.setPlatformActionListener(platformActionListener);
plat.share(sp);
shareAction(context, dialog);
}
});
link.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(animation.getShareUrl());
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("data", animation.getShareUrl());
clipboard.setPrimaryClip(clip);
}
dialog.dismiss();
Toast.makeText(context, "复制完成,快快分享给你的好朋友们!", Toast.LENGTH_LONG).show();
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
}
Aggregations