Java 类com.afollestad.materialdialogs.commons.R 实例源码

项目:GitHub    文件:ColorChooserDialog.java   
@ColorInt private int getSelectedColor() {
    if (colorChooserCustomFrame != null &&
            colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
        return selectedCustomColor;
    }

    int color = 0;
    if (subIndex() > -1)
        color = mColorsSub[topIndex()][subIndex()];
    else if (topIndex() > -1)
        color = mColorsTop[topIndex()];
    if (color == 0) {
        int fallback = 0;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
        color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
    }
    return color;
}
项目:GitHub    文件:PrefUtil.java   
static void setLayoutResource(@NonNull Context context, @NonNull Preference preference, @Nullable AttributeSet attrs) {
    boolean foundLayout = false;
    if (attrs != null) {
        for (int i = 0; i < attrs.getAttributeCount(); i++) {
            final String namespace = ((XmlResourceParser) attrs).getAttributeNamespace(0);
            if (namespace.equals("http://schemas.android.com/apk/res/android") &&
                    attrs.getAttributeName(i).equals("layout")) {
                foundLayout = true;
                break;
            }
        }
    }

    boolean useStockLayout = false;
    if (attrs != null) {
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.Preference, 0, 0);
        try {
            useStockLayout = a.getBoolean(R.styleable.Preference_useStockLayout, false);
        } finally {
            a.recycle();
        }
    }

    if (!foundLayout && !useStockLayout)
        preference.setLayoutResource(R.layout.md_preference_custom);
}
项目:OpenHub    文件:ColorChooserDialog.java   
@ColorInt
private int getSelectedColor() {
  if (colorChooserCustomFrame != null
      && colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
    return selectedCustomColor;
  }

  int color = 0;
  if (subIndex() > -1) {
    color = colorsSub[topIndex()][subIndex()];
  } else if (topIndex() > -1) {
    color = colorsTop[topIndex()];
  }
  if (color == 0) {
    int fallback = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
    }
    color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
  }
  return color;
}
项目:material-dialogs    文件:MaterialEditTextPreference.java   
private void init(Context context, AttributeSet attrs) {
  PrefUtil.setLayoutResource(context, this, attrs);
  int fallback;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    fallback = DialogUtils.resolveColor(context, android.R.attr.colorAccent);
  } else {
    fallback = 0;
  }
  fallback = DialogUtils.resolveColor(context, R.attr.colorAccent, fallback);
  color = DialogUtils.resolveColor(context, R.attr.md_widget_color, fallback);

  editText = new AppCompatEditText(context, attrs);
  // Give it an ID so it can be saved/restored
  editText.setId(android.R.id.edit);
  editText.setEnabled(true);
}
项目:material-dialogs    文件:ColorChooserDialog.java   
@ColorInt
private int getSelectedColor() {
  if (colorChooserCustomFrame != null
      && colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
    return selectedCustomColor;
  }

  int color = 0;
  if (subIndex() > -1) {
    color = colorsSub[topIndex()][subIndex()];
  } else if (topIndex() > -1) {
    color = colorsTop[topIndex()];
  }
  if (color == 0) {
    int fallback = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
    }
    color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
  }
  return color;
}
项目:GitHub    文件:MaterialEditTextPreference.java   
private void init(Context context, AttributeSet attrs) {
    PrefUtil.setLayoutResource(context, this, attrs);
    int fallback;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        fallback = DialogUtils.resolveColor(context, android.R.attr.colorAccent);
    else fallback = 0;
    fallback = DialogUtils.resolveColor(context, R.attr.colorAccent, fallback);
    color = DialogUtils.resolveColor(context, R.attr.md_widget_color, fallback);

    editText = new AppCompatEditText(context, attrs);
    // Give it an ID so it can be saved/restored
    editText.setId(android.R.id.edit);
    editText.setEnabled(true);
}
项目:GitHub    文件:MaterialSimpleListAdapter.java   
SimpleListVH(View itemView, MaterialSimpleListAdapter adapter) {
    super(itemView);
    icon = (ImageView) itemView.findViewById(android.R.id.icon);
    title = (TextView) itemView.findViewById(android.R.id.title);
    this.adapter = adapter;
    itemView.setOnClickListener(this);
}
项目:GitHub    文件:ColorChooserDialog.java   
private void invalidate() {
    if (grid.getAdapter() == null) {
        grid.setAdapter(new ColorGridAdapter());
        grid.setSelector(ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
    } else ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged();
    if (getDialog() != null)
        getDialog().setTitle(getTitle());
}
项目:GitHub    文件:FileChooserDialog.java   
@SuppressWarnings("ConstantConditions")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
            ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) !=
                    PackageManager.PERMISSION_GRANTED) {
        return new MaterialDialog.Builder(getActivity())
                .title(R.string.md_error_label)
                .content(R.string.md_storage_perm_error)
                .positiveText(android.R.string.ok)
                .build();
    }

    if (getArguments() == null || !getArguments().containsKey("builder"))
        throw new IllegalStateException("You must create a FileChooserDialog using the Builder.");
    if (!getArguments().containsKey("current_path"))
        getArguments().putString("current_path", getBuilder().initialPath);
    parentFolder = new File(getArguments().getString("current_path"));
    checkIfCanGoUp();
    parentContents = listFiles(getBuilder().mimeType, getBuilder().extensions);
    return new MaterialDialog.Builder(getActivity())
            .title(parentFolder.getAbsolutePath())
            .items(getContentsArray())
            .itemsCallback(this)
            .onNegative(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    dialog.dismiss();
                }
            })
            .autoDismiss(false)
            .negativeText(getBuilder().cancelButton)
            .build();
}
项目:GitHub    文件:FileChooserDialog.java   
public <ActivityType extends AppCompatActivity & FileCallback> Builder(@NonNull ActivityType context) {
    this.context = context;
    cancelButton = android.R.string.cancel;
    initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
    mimeType = null;
    goUpLabel = "...";
}
项目:GitHub    文件:FolderChooserDialog.java   
public <ActivityType extends AppCompatActivity & FolderCallback> Builder(@NonNull ActivityType context) {
    this.context = context;
    chooseButton = R.string.md_choose_label;
    cancelButton = android.R.string.cancel;
    goUpLabel = "...";
    initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
}
项目:GitHub    文件:FolderChooserDialog.java   
@NonNull public Builder allowNewFolder(boolean allow, @StringRes int buttonLabel) {
    allowNewFolder = allow;
    if (buttonLabel == 0)
        buttonLabel = R.string.new_folder;
    newFolderButton = buttonLabel;
    return this;
}
项目:OpenHub    文件:ColorChooserDialog.java   
private void invalidate() {
  if (grid.getAdapter() == null) {
    grid.setAdapter(new ColorGridAdapter());
    grid.setSelector(
        ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
  } else {
    ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged();
  }
  if (getDialog() != null) {
    getDialog().setTitle(getTitle());
  }
}
项目:android_app_efidroidmanager    文件:RootFileChooserDialog.java   
public <ActivityType extends AppCompatActivity> Builder(@NonNull ActivityType context) {
    mContext = context;
    mCancelButton = android.R.string.cancel;
    mInitialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
    mMimeType = null;
    mProtectRoot = false;
    mHideDirectories = false;
}
项目:material-dialogs    文件:PrefUtil.java   
static void setLayoutResource(
    Context context, Preference preference, @Nullable AttributeSet attrs) {
  boolean foundLayout = false;
  if (attrs != null) {
    for (int i = 0; i < attrs.getAttributeCount(); i++) {
      final String namespace = ((XmlResourceParser) attrs).getAttributeNamespace(0);
      if (namespace.equals("http://schemas.android.com/apk/res/android")
          && attrs.getAttributeName(i).equals("layout")) {
        foundLayout = true;
        break;
      }
    }
  }

  boolean useStockLayout = false;
  if (attrs != null) {
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.Preference, 0, 0);
    try {
      useStockLayout = a.getBoolean(R.styleable.Preference_useStockLayout, false);
    } finally {
      a.recycle();
    }
  }

  if (!foundLayout && !useStockLayout) {
    preference.setLayoutResource(R.layout.md_preference_custom);
  }
}
项目:material-dialogs    文件:MaterialSimpleListAdapter.java   
@Override
public SimpleListVH onCreateViewHolder(ViewGroup parent, int viewType) {
  final View view =
      LayoutInflater.from(parent.getContext())
          .inflate(R.layout.md_simplelist_item, parent, false);
  return new SimpleListVH(view, this);
}
项目:material-dialogs    文件:MaterialSimpleListAdapter.java   
SimpleListVH(View itemView, MaterialSimpleListAdapter adapter) {
  super(itemView);
  icon = (ImageView) itemView.findViewById(android.R.id.icon);
  title = (TextView) itemView.findViewById(android.R.id.title);
  this.adapter = adapter;
  itemView.setOnClickListener(this);
}
项目:material-dialogs    文件:ColorChooserDialog.java   
private void invalidate() {
  if (grid.getAdapter() == null) {
    grid.setAdapter(new ColorGridAdapter());
    grid.setSelector(
        ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
  } else {
    ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged();
  }
  if (getDialog() != null) {
    getDialog().setTitle(getTitle());
  }
}
项目:material-dialogs    文件:FileChooserDialog.java   
@SuppressWarnings("ConstantConditions")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
      && ContextCompat.checkSelfPermission(
              getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
          != PackageManager.PERMISSION_GRANTED) {
    return new MaterialDialog.Builder(getActivity())
        .title(R.string.md_error_label)
        .content(R.string.md_storage_perm_error)
        .positiveText(android.R.string.ok)
        .build();
  }

  if (getArguments() == null || !getArguments().containsKey("builder")) {
    throw new IllegalStateException("You must create a FileChooserDialog using the Builder.");
  }
  if (!getArguments().containsKey("current_path")) {
    getArguments().putString("current_path", getBuilder().initialPath);
  }
  parentFolder = new File(getArguments().getString("current_path"));
  checkIfCanGoUp();
  parentContents = listFiles(getBuilder().mimeType, getBuilder().extensions);
  return new MaterialDialog.Builder(getActivity())
      .title(parentFolder.getAbsolutePath())
      .typeface(getBuilder().mediumFont, getBuilder().regularFont)
      .items(getContentsArray())
      .itemsCallback(this)
      .onNegative(
          new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(MaterialDialog dialog, DialogAction which) {
              dialog.dismiss();
            }
          })
      .autoDismiss(false)
      .negativeText(getBuilder().cancelButton)
      .build();
}
项目:material-dialogs    文件:FolderChooserDialog.java   
public Builder allowNewFolder(boolean allow, @StringRes int buttonLabel) {
  allowNewFolder = allow;
  if (buttonLabel == 0) {
    buttonLabel = R.string.new_folder;
  }
  newFolderButton = buttonLabel;
  return this;
}
项目:GitHub    文件:MaterialEditTextPreference.java   
@Override protected void showDialog(Bundle state) {
    Builder mBuilder = new MaterialDialog.Builder(getContext())
            .title(getDialogTitle())
            .icon(getDialogIcon())
            .positiveText(getPositiveButtonText())
            .negativeText(getNegativeButtonText())
            .dismissListener(this)
            .onAny(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    switch (which) {
                        default:
                            MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
                            break;
                        case NEUTRAL:
                            MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_NEUTRAL);
                            break;
                        case NEGATIVE:
                            MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
                            break;
                    }
                }
            })
            .dismissListener(this);

    @SuppressLint("InflateParams")
    View layout = LayoutInflater.from(getContext()).inflate(R.layout.md_stub_inputpref, null);
    onBindDialogView(layout);

    MDTintHelper.setTint(editText, color);

    TextView message = (TextView) layout.findViewById(android.R.id.message);
    if (getDialogMessage() != null && getDialogMessage().toString().length() > 0) {
        message.setVisibility(View.VISIBLE);
        message.setText(getDialogMessage());
    } else {
        message.setVisibility(View.GONE);
    }
    mBuilder.customView(layout, false);

    PrefUtil.registerOnActivityDestroyListener(this, this);

    dialog = mBuilder.build();
    if (state != null)
        dialog.onRestoreInstanceState(state);
    requestInputMethod(dialog);

    dialog.show();
}
项目:GitHub    文件:MaterialSimpleListAdapter.java   
@Override public SimpleListVH onCreateViewHolder(ViewGroup parent, int viewType) {
    final View view = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.md_simplelist_item, parent, false);
    return new SimpleListVH(view, this);
}
项目:android_app_efidroidmanager    文件:RootFileChooserDialog.java   
@SuppressWarnings("ConstantConditions")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
            ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) !=
                    PackageManager.PERMISSION_GRANTED) {
        return new MaterialDialog.Builder(getActivity())
                .title(R.string.md_error_label)
                .content(R.string.md_storage_perm_error)
                .positiveText(android.R.string.ok)
                .build();
    }

    if (getArguments() == null || !getArguments().containsKey("builder"))
        throw new IllegalStateException("You must create a FileChooserDialog using the Builder.");
    if (!getArguments().containsKey("current_path"))
        getArguments().putString("current_path", getBuilder().mInitialPath);
    mHideDirectories = getBuilder().mHideDirectories;
    parentFolder = new RootToolsEx.RootFile(getArguments().getString("current_path"));
    parentContents = listFiles(getBuilder().mMimeType);
    mProtectRoot = getBuilder().mProtectRoot;
    mInitialPath = getBuilder().mInitialPath;

    if (mProtectRoot)
        canGoUp = false;

    return new MaterialDialog.Builder(getActivity())
            .title(parentFolder.getAbsolutePath())
            .items(getContentsArray())
            .itemsCallback(this)
            .onNegative(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    dialog.dismiss();
                }
            })
            .autoDismiss(false)
            .negativeText(getBuilder().mCancelButton)
            .build();
}
项目:material-dialogs    文件:MaterialEditTextPreference.java   
@Override
protected void showDialog(Bundle state) {
  Builder mBuilder =
      new MaterialDialog.Builder(getContext())
          .title(getDialogTitle())
          .icon(getDialogIcon())
          .positiveText(getPositiveButtonText())
          .negativeText(getNegativeButtonText())
          .dismissListener(this)
          .onAny(
              new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(MaterialDialog dialog, DialogAction which) {
                  switch (which) {
                    default:
                      MaterialEditTextPreference.this.onClick(
                          dialog, DialogInterface.BUTTON_POSITIVE);
                      break;
                    case NEUTRAL:
                      MaterialEditTextPreference.this.onClick(
                          dialog, DialogInterface.BUTTON_NEUTRAL);
                      break;
                    case NEGATIVE:
                      MaterialEditTextPreference.this.onClick(
                          dialog, DialogInterface.BUTTON_NEGATIVE);
                      break;
                  }
                }
              })
          .dismissListener(this);

  @SuppressLint("InflateParams")
  View layout = LayoutInflater.from(getContext()).inflate(R.layout.md_stub_inputpref, null);
  onBindDialogView(layout);

  MDTintHelper.setTint(editText, color);

  TextView message = (TextView) layout.findViewById(android.R.id.message);
  if (getDialogMessage() != null && getDialogMessage().toString().length() > 0) {
    message.setVisibility(View.VISIBLE);
    message.setText(getDialogMessage());
  } else {
    message.setVisibility(View.GONE);
  }
  mBuilder.customView(layout, false);

  PrefUtil.registerOnActivityDestroyListener(this, this);

  dialog = mBuilder.build();
  if (state != null) {
    dialog.onRestoreInstanceState(state);
  }
  requestInputMethod(dialog);

  dialog.show();
}
项目:material-dialogs    文件:FileChooserDialog.java   
private Builder() {
  cancelButton = android.R.string.cancel;
  initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
  mimeType = null;
  goUpLabel = "...";
}
项目:material-dialogs    文件:FolderChooserDialog.java   
private Builder() {
  chooseButton = R.string.md_choose_label;
  cancelButton = android.R.string.cancel;
  goUpLabel = "...";
  initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
}