本文整理汇总了Java中com.gc.materialdesign.widgets.SnackBar.show方法的典型用法代码示例。如果您正苦于以下问题:Java SnackBar.show方法的具体用法?Java SnackBar.show怎么用?Java SnackBar.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gc.materialdesign.widgets.SnackBar
的用法示例。
在下文中一共展示了SnackBar.show方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPostExecute
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Void result) {
// Only perform these actions if this is a regular DNS record update (not one called within addRecord)
if (clickedDNSRecord != null) {
// Hide loading circle
findViewById(R.id.loading_circle).setVisibility(View.INVISIBLE);
// Snackbar success status
if (!success) {
SnackBar snackBar = new SnackBar(AddEditDNSRecordActivity.this, "There was an error updating the DNS record.", null, null);
snackBar.show();
return;
}
// Go back to the DNS records fragment
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.putExtra("returnToFragment", "DNS Records");
intent.putExtra("dnsRecordSuccess", true);
startActivity(intent);
}
}
示例2: deleteAccount
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
/**
* Deletes the selected user account.
*/
public void deleteAccount() {
// Delete the account
String deleteAPIKey = clickedCloudFlareAccount.getApiKey();
AccountConfig.deleteAccount(getApplicationContext(), deleteAPIKey);
// Snackbar a confirmation
SnackBar snackBar = new SnackBar(AccountManagerActivity.this, "Account successfully deleted!", null, null);
snackBar.show();
// Refresh list of accounts
populateAccountsList();
// If deleting this account deletes the current account, set the new current account to the first account in the list
AccountConfig.setCurrentAccount(getApplicationContext(), accounts.get(0).getApiKey(), accounts.get(0).getEmail());
}
示例3: onPostExecute
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(HashMap<String, Boolean> zoneNames) {
// Dismiss loading circle
findViewById(R.id.loading_circle).setVisibility(View.INVISIBLE);
// Error if the account has no domains (why??)
if (zoneNames.size() == 0) {
SnackBar snackBar = new SnackBar(WelcomeActivity.this, getResources().getString(R.string.no_domains_error), null, null);
snackBar.show();
newAccount = null;
}
else {
// Store API key and email address
AccountConfig.addAccount(getApplicationContext(), newAccount.getApiKey(), newAccount.getEmail());
AccountConfig.setCurrentAccount(getApplicationContext(), newAccount.getApiKey(), null);
Log.d("Account data", AccountConfig.getAllAccounts(getApplicationContext()).toString());
// Safe to use AccountConfig.getCurrentAccountAPIKey since it is set in the Login asynctask.
AccountConfig.addDomains(getApplicationContext(), AccountConfig.getCurrentAccountAPIKey(getApplicationContext()), zoneNames);
domainSelectDialog();
}
}
示例4: onActivityResult
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// cancel handling if the request failed
if (resultCode != Activity.RESULT_OK) {
return;
}
switch (requestCode) {
case Constants.REQUEST_IMAGE_CAPTURE:
finishWithResult(Uri.fromFile(mFileTemp));
break;
case Constants.REQUEST_IMAGE_CHOOSE:
String filePath = null;
try {
filePath = FileUtils.getPath(this, data.getData());
} catch (NullPointerException e) {
// no file selected, ignore exception
}
if (filePath == null) {
SnackBar snackBar = new SnackBar(this, getString(R.string.error_remote_file));
snackBar.show();
// Toast.makeText(this, getString(R.string.error_remote_file), Toast.LENGTH_SHORT).show();
} else {
finishWithResult(Uri.parse(filePath));
}
break;
}
}
示例5: onPostExecute
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Void result) {
// Dismiss loading circle
swipeLayout.setRefreshing(false);
// Populate ListView with domains
if (error) {
SnackBar snackBar = new SnackBar(getActivity(), "There was an error logging in. Ensure that you have network connectivity and that your API key and email are correct.", null, null);
snackBar.show();
}
else if (getView() != null) {
ArrayAdapter<DNSRecord> adapter = new listAdapter();
list = (ListView) getView().findViewById(R.id.dns_records_list);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
/**
* Set on item click listener for each list view item. Assigns a DNSRecord object to the
* clickedDNSRecord instance variable, for use later.
*/
@Override
public void onItemClick(AdapterView<?> parent, View viewClicked, int position, long id) {
clickedDNSRecord = dnsRecordsList.get(position);
actionDialog();
}
});
}
}
示例6: onPostExecute
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(HashMap<String, Boolean> zoneNames) {
if (error) {
SnackBar snackBar = new SnackBar(MainActivity.this, "There was an error logging in. Ensure that you have network connectivity and that your API key and email are correct.", null, null);
snackBar.show();
}
else {
// Update the user's domains
AccountConfig.addDomains(getApplicationContext(), AccountConfig.getCurrentAccountAPIKey(getApplicationContext()), zoneNames);
// Update the domains in the navigation drawer
initDomainSpinner();
}
}
示例7: showSnackBar
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
public static void showSnackBar(Activity activity, String message, SnackBar.OnHideListener onHideListener) {
SnackBar snackBar = new SnackBar(activity, message);
snackBar.show();
if (onHideListener != null) {
snackBar.setOnhideListener(onHideListener);
}
}
示例8: wrongCredentials
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
public void wrongCredentials(int returned) {
if (MailMainActivity.this.getActivity() == null)
return;
Resources res = MailMainActivity.this.getActivity().getResources();
if (password != null && login_button != null) {
if (MailMainActivity.this.getActivity() != null)
Toast.makeText(MailMainActivity.this.getActivity(),
getResources().getString(R.string.facebook_login_incorrect_or_offline), Toast.LENGTH_SHORT)
.show();
password.setText("");
login_button.getBackground().setColorFilter(null);
login_button.setEnabled(true);
} else {
if (MailMainActivity.this.getActivity() != null) {
final SnackBar snackbar = new SnackBar(MailMainActivity.this.getActivity(), res
.getString(R.string.snackbar_cannot_load_mails), res.getString(R.string.snackbar_retry),
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (MailMainActivity.this.getActivity() instanceof MainActivity) {
MainActivity ac = (MainActivity) MailMainActivity.this.getActivity();
ac.emailLogin(1);
}
}
});
snackbar.show();
}
}
if (returned == 0) {
prefs.edit().clear().apply();
if (MailMainActivity.this.getActivity() != null) {
((MainActivity) getActivity()).redrawMailFragment();
((MainActivity) getActivity()).drawMailFragment();
}
}
}
示例9: createItem
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@OnClick(R.id.button_create)
public void createItem(View view) {
if (textType.getText().toString().equals(getString(R.string.type_error))
|| TextUtils.isEmpty(textType.getText())) {
// there was an error, show it
SnackBar snackBar = new SnackBar(getActivity(),
"Please select another category or image.");
snackBar.show();
} else {
// save the item
FridgeItem fridgeItem = new FridgeItem();
String name = autoCompleteTextView.getText().toString().trim();
String type = textType.getText().toString().trim();
fridgeItem.setName(name.length() > 0 ? name : type);
fridgeItem.setType(type.equals(getString(R.string.type_camera)) ?
mFileTemp.getAbsolutePath() : String.valueOf(ItemType.valueOf(type).ordinal()));
fridgeItem.setItemId(fridgeItem.hashCode());
fridgeItem.setEditTimestamp(Calendar.getInstance().getTimeInMillis());
fridgeItem.save();
// remove instance to saved file
mFileTemp = null;
// add the saved item to history
HistoryItem historyItem = new HistoryItem(fridgeItem,
Calendar.getInstance().getTimeInMillis() / 1000, ChangeType.ADD);
historyItem.save();
// hide the keyboard if shown
KeyboardUtils.hideSoftKeyboard(autoCompleteTextView);
// clear the text
autoCompleteTextView.setText("");
autoCompleteTextView.clearFocus();
// restart the loader on DB change
((MainActivity) getActivity()).setDatabaseChanged(true);
// set the screenshot
takeScreenShot();
((MainActivity) getActivity()).setScreenshotable(this);
Rect rect = new Rect();
buttonCreate.getLocalVisibleRect(rect);
Point buttonCenter = new Point((int) buttonCreate.getX() + buttonCreate.getWidth() / 2,
(int) buttonCreate.getY() + buttonCreate.getHeight() / 2);
mListener.onFragmentInteraction(false, buttonCenter,
FridgeFragment.class.getCanonicalName());
}
}
示例10: createItem
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@OnClick(R.id.button_create)
public void createItem(View view) {
if (textType.getText().toString().equals(getString(R.string.type_error))
|| TextUtils.isEmpty(textType.getText())) {
// there was an error, show it
SnackBar snackBar = new SnackBar(getActivity(),
"Please select another category or image.");
snackBar.show();
} else {
// save the item
FridgeItem fridgeItem = new FridgeItem();
String name = autoCompleteTextView.getText().toString().trim();
String type = textType.getText().toString().trim();
fridgeItem.setName(name.length() > 0 ? name : type);
fridgeItem.setType(type.equals(getString(R.string.type_camera)) ?
filePath : String.valueOf(ItemType.valueOf(type).ordinal()));
fridgeItem.setItemId(fridgeItem.hashCode());
fridgeItem.setEditTimestamp(Calendar.getInstance().getTimeInMillis());
fridgeItem.save();
// remove instance to saved file
filePath = null;
// add the saved item to history
HistoryItem historyItem = new HistoryItem(fridgeItem,
Calendar.getInstance().getTimeInMillis() / 1000, ChangeType.ADD);
historyItem.save();
// hide the keyboard if shown
KeyboardUtils.hideSoftKeyboard(autoCompleteTextView);
// clear the text
autoCompleteTextView.setText("");
autoCompleteTextView.clearFocus();
// restart the loader on DB change
((MainActivity) getActivity()).setDatabaseChanged(true);
// set the screenshot
takeScreenShot();
((MainActivity) getActivity()).setScreenshotable(this);
Rect rect = new Rect();
buttonCreate.getLocalVisibleRect(rect);
Point buttonCenter = new Point((int) buttonCreate.getX() + buttonCreate.getWidth() / 2,
(int) buttonCreate.getY() + buttonCreate.getHeight() / 2);
mListener.onFragmentInteraction(false, buttonCenter,
FridgeFragment.class.getCanonicalName());
}
}
示例11: onCreate
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Debug logging
Log.d("Shared preferences data", AccountConfig.getAllPreferenceData(getApplicationContext()).toString());
// First determine if the user has an account logged in. If so, continue; otherwise, redirect the user to WelcomeActivity.class
if (!AccountConfig.hasCurrentAccount(getApplicationContext())) {
startActivity(new Intent(this, WelcomeActivity.class));
return;
}
// Initialize all the views
initViews();
if (toolbar != null) {
// Sets the title of the action bar
toolbar.setTitle(R.string.app_name);
setSupportActionBar(toolbar);
}
// Initialize the navigation drawer
initDrawer();
// Snackbar from DNS update activity
boolean success = getIntent().getBooleanExtra("dnsRecordSuccess", false);
if (success) {
SnackBar snackBar = new SnackBar(MainActivity.this, "DNS record created or updated successfully!", null, null);
snackBar.show();
}
// Set default page
// Different depending on intent
// First get the string representing the fragment to return to; if null, default to Analytics
Fragment fragment = null;
String returnToFragment = getIntent().getStringExtra("returnToFragment");
if (returnToFragment == null)
returnToFragment = "Analytics";
// Initialize the fragment accordingly
if (returnToFragment.equals("Analytics"))
fragment = new AnalyticsFragment();
if (returnToFragment.equals("Performance Settings"))
fragment = new PerformanceSettingsFragment();
if (returnToFragment.equals("Security Settings"))
fragment = new SecuritySettingsFragment();
if (returnToFragment.equals("DNS Records"))
fragment = new DNSRecordsFragment();
// Show the fragment
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
// Select the appropriate index in the navigation drawer
leftDrawerList.setItemChecked(java.util.Arrays.asList(drawerSections).indexOf(returnToFragment) + 1, true);
// Notify adapter of selected index, for background highlighting behavior
adapter.setSelection(java.util.Arrays.asList(drawerSections).indexOf(returnToFragment) + 1);
toolbar.setTitle(drawerSections[java.util.Arrays.asList(drawerSections).indexOf(returnToFragment)]);
// Refresh the user's domains
new findDomains().execute(AccountConfig.getCurrentAccountAPIKey(getApplicationContext()), AccountConfig.getCurrentAccountEmail(getApplicationContext()));
}
示例12: onPostExecute
import com.gc.materialdesign.widgets.SnackBar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Void result) {
// Dismiss loading circle
swipeLayout.setRefreshing(false);
if (error) {
SnackBar snackBar = new SnackBar(getActivity(), "There was an error logging in. Ensure that you have network connectivity and that your API key and email are correct.", null, null);
snackBar.show();
}
else if (getView() != null) {
// Update UI elements
if (developmentMode.equals("0"))
((Switch) getView().findViewById(R.id.development_mode_switch)).setChecked(false);
else
((Switch) getView().findViewById(R.id.development_mode_switch)).setChecked(true);
if (alwaysOnline.equals("0"))
((Switch) getView().findViewById(R.id.always_online_switch)).setChecked(false);
else
((Switch) getView().findViewById(R.id.always_online_switch)).setChecked(true);
try {
if (spdy.equals("0") || spdy.equals(null))
((Switch) getView().findViewById(R.id.spdy_switch)).setChecked(false);
else
((Switch) getView().findViewById(R.id.spdy_switch)).setChecked(true);
} catch (Exception e) {
//lazy programmer
}
if (ipv6.equals("0"))
((Switch) getView().findViewById(R.id.ipv6_switch)).setChecked(false);
else
((Switch) getView().findViewById(R.id.ipv6_switch)).setChecked(true);
if (cacheLevel.equals("agg"))
((Spinner) getView().findViewById(R.id.cache_level_spinner)).setSelection(0);
if (cacheLevel.equals("iqs"))
((Spinner) getView().findViewById(R.id.cache_level_spinner)).setSelection(1);
if (cacheLevel.equals("basic"))
((Spinner) getView().findViewById(R.id.cache_level_spinner)).setSelection(2);
if (rocketLoader.equals("0"))
((Spinner) getView().findViewById(R.id.rocket_loader_spinner)).setSelection(0);
if (rocketLoader.equals("a"))
((Spinner) getView().findViewById(R.id.rocket_loader_spinner)).setSelection(1);
if (rocketLoader.equals("m"))
((Spinner) getView().findViewById(R.id.rocket_loader_spinner)).setSelection(2);
((Spinner) getView().findViewById(R.id.minification_spinner)).setSelection(Integer.parseInt(minify));
((TextView) getView().findViewById(R.id.challenge_ttl)).setText("Challenge TTL: " + challengeTTL + " seconds");
((TextView) getView().findViewById(R.id.expire_ttl)).setText("Expire TTL: " + expirationTTL + " seconds");
((TextView) getView().findViewById(R.id.cache_ttl)).setText("Cache TTL: " + cacheTTL + " seconds");
// Disable Pro-only features, as necessary
if (!AccountConfig.isCurrentDomainPro(getActivity())) {
getView().findViewById(R.id.spdy_switch).setEnabled(false);
}
// Disable features that are not modifiable by the API
getView().findViewById(R.id.always_online_switch).setEnabled(false);
}
}