Search in sources :

Example 1 with DateFormat

use of android.text.format.DateFormat in project Awful.apk by Awful.

the class ImgurInserter method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    FragmentActivity activity = getActivity();
    dateFormat = DateFormat.getDateFormat(activity);
    timeFormat = DateFormat.getTimeFormat(activity);
    View layout = activity.getLayoutInflater().inflate(R.layout.insert_imgur_dialog, null);
    bind(this, layout);
    AlertDialog dialog = new AlertDialog.Builder(activity).setTitle(R.string.imgur_uploader_dialog_title).setView(layout).setPositiveButton(R.string.imgur_uploader_ok_button, null).setNegativeButton(R.string.cancel, (dialogInterface, i) -> dismiss()).show();
    // get the dialog's 'upload' positive button so we can enable and disable it
    // setting the click listener directly prevents the dialog from dismissing, so the upload can run
    uploadButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
    uploadButton.setOnClickListener(view -> startUpload());
    // TODO: 05/06/2017 is that method guaranteed to be fired when the system creates the spinner and sets the first item?
    updateUploadType();
    updateRemainingUploads();
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) Uri(android.net.Uri) ImageView(android.widget.ImageView) DialogFragment(android.support.v4.app.DialogFragment) StringUtils(org.apache.commons.lang3.StringUtils) OnClick(butterknife.OnClick) TextInputLayout(android.support.design.widget.TextInputLayout) BindView(butterknife.BindView) JSONException(org.json.JSONException) Patterns(android.util.Patterns) JSONObject(org.json.JSONObject) CheckBox(android.widget.CheckBox) ContentResolver(android.content.ContentResolver) ButterKnife.bind(butterknife.ButterKnife.bind) View(android.view.View) Button(android.widget.Button) VISIBLE(android.view.View.VISIBLE) Log(android.util.Log) Fragment(android.support.v4.app.Fragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImgurUploadRequest(com.ferg.awfulapp.task.ImgurUploadRequest) ViewGroup(android.view.ViewGroup) FileNotFoundException(java.io.FileNotFoundException) DateFormat(android.text.format.DateFormat) TextView(android.widget.TextView) GONE(android.view.View.GONE) FragmentActivity(android.support.v4.app.FragmentActivity) Nullable(android.support.annotation.Nullable) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Pair(android.util.Pair) Dialog(android.app.Dialog) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) NonNull(android.support.annotation.NonNull) OnTextChanged(butterknife.OnTextChanged) NetworkUtils(com.ferg.awfulapp.network.NetworkUtils) R(com.ferg.awfulapp.R) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) Formatter(android.text.format.Formatter) VolleyError(com.android.volley.VolleyError) OpenableColumns(android.provider.OpenableColumns) Spinner(android.widget.Spinner) Request(com.android.volley.Request) AlertDialog(android.support.v7.app.AlertDialog) Bitmap(android.graphics.Bitmap) OnItemSelected(butterknife.OnItemSelected) Activity(android.app.Activity) EditText(android.widget.EditText) InputStream(java.io.InputStream) FragmentActivity(android.support.v4.app.FragmentActivity) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) NonNull(android.support.annotation.NonNull)

Example 2 with DateFormat

use of android.text.format.DateFormat in project UltimateAndroid by cymcsg.

the class PublishedActivity method takePhoto.

//    public void photo() {
//        Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//        File file = new File(Environment.getExternalStorageDirectory()
//                + "/myimage/", String.valueOf(System.currentTimeMillis())
//                + ".jpg");
//        path = file.getPath();
//        Uri imageUri = Uri.fromFile(file);
//        openCameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
//        startActivityForResult(openCameraIntent, TAKE_PICTURE);
//    }
/**
     * 调用系统相机
     */
public void takePhoto() {
    // 调用系统相机
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    new DateFormat();
    String name = DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg";
    Uri imageUri = Uri.fromFile(new File(PATH, name));
    path = PATH + "/" + name;
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    startActivityForResult(intent, TAKE_PICTURE);
}
Also used : DateFormat(android.text.format.DateFormat) Intent(android.content.Intent) Uri(android.net.Uri) File(java.io.File)

Aggregations

Intent (android.content.Intent)2 Uri (android.net.Uri)2 DateFormat (android.text.format.DateFormat)2 Activity (android.app.Activity)1 Dialog (android.app.Dialog)1 ContentResolver (android.content.ContentResolver)1 DialogInterface (android.content.DialogInterface)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Bundle (android.os.Bundle)1 OpenableColumns (android.provider.OpenableColumns)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 TextInputLayout (android.support.design.widget.TextInputLayout)1 DialogFragment (android.support.v4.app.DialogFragment)1 Fragment (android.support.v4.app.Fragment)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 AlertDialog (android.support.v7.app.AlertDialog)1