当前位置: 首页>>代码示例>>Java>>正文


Java Constants类代码示例

本文整理汇总了Java中com.darsh.multipleimageselect.helpers.Constants的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Constants类属于com.darsh.multipleimageselect.helpers包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toggleSelection

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
private void toggleSelection(int position) {
    if (!images.get(position).isSelected && countSelected >= Constants.limit) {
        Toast.makeText(
                getApplicationContext(),
                String.format(getString(R.string.limit_exceeded), Constants.limit),
                Toast.LENGTH_SHORT)
                .show();
        return;
    }

    images.get(position).isSelected = !images.get(position).isSelected;
    if (images.get(position).isSelected) {
        countSelected++;
    } else {
        countSelected--;
    }
    adapter.notifyDataSetChanged();
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:19,代码来源:ImageSelectActivity.java

示例2: showRequestPermissionRationale

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
private void showRequestPermissionRationale() {
    Snackbar snackbar = Snackbar.make(
            view,
            getString(R.string.permission_info),
            Snackbar.LENGTH_INDEFINITE)
            .setAction(getString(R.string.permission_ok), new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ActivityCompat.requestPermissions(
                            HelperActivity.this,
                            permissions,
                            Constants.PERMISSION_REQUEST_CODE);
                }
            });

    /*((TextView) snackbar.getView()
            .findViewById(android.support.design.R.id.snackbar_text)).setMaxLines(maxLines);*/
    snackbar.show();
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:20,代码来源:HelperActivity.java

示例3: showAppPermissionSettings

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
private void showAppPermissionSettings() {
    Snackbar snackbar = Snackbar.make(
            view,
            getString(R.string.permission_force),
            Snackbar.LENGTH_INDEFINITE)
            .setAction(getString(R.string.permission_settings), new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Uri uri = Uri.fromParts(
                            getString(R.string.permission_package),
                            HelperActivity.this.getPackageName(),
                            null);

                    Intent intent = new Intent();
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    intent.setData(uri);
                    startActivityForResult(intent, Constants.PERMISSION_REQUEST_CODE);
                }
            });

    /*((TextView) snackbar.getView()
            .findViewById(android.support.design.R.id.snackbar_text)).setMaxLines(maxLines);*/
    snackbar.show();
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:26,代码来源:HelperActivity.java

示例4: onCreate

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textView = (TextView) findViewById(R.id.text_view);

    Intent intent = new Intent(MainActivity.this, AlbumSelectActivity.class);
    intent.putExtra(Constants.INTENT_EXTRA_LIMIT, 3);
    startActivityForResult(intent, Constants.REQUEST_CODE);
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:12,代码来源:MainActivity.java

示例5: onActivityResult

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == Constants.REQUEST_CODE && resultCode == RESULT_OK && data != null) {
        ArrayList<Image> images = data.getParcelableArrayListExtra(Constants.INTENT_EXTRA_IMAGES);
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0, l = images.size(); i < l; i++) {
            stringBuffer.append(images.get(i).path + "\n");
        }
        textView.setText(stringBuffer.toString());
    }
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:12,代码来源:MainActivity.java

示例6: checkPermission

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
protected void checkPermission() {
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
        permissionGranted();

    } else {
        ActivityCompat.requestPermissions(this, permissions, Constants.PERMISSION_REQUEST_CODE);
    }
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:10,代码来源:HelperActivity.java

示例7: onRequestPermissionsResult

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (requestCode != Constants.PERMISSION_REQUEST_CODE
            || grantResults.length == 0
            || grantResults[0] == PackageManager.PERMISSION_DENIED) {
        permissionDenied();

    } else {
        permissionGranted();
    }
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:13,代码来源:HelperActivity.java

示例8: onActivityResult

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == Constants.REQUEST_CODE
            && resultCode == RESULT_OK
            && data != null) {
        setResult(RESULT_OK, data);
        finish();
    }
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:12,代码来源:AlbumSelectActivity.java

示例9: getPickMultipleIntent

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
/**
 *  获取图片多选的Intent
 * @param limit 最多选择图片张数的限制
 * */
public static Intent getPickMultipleIntent(TContextWrap contextWrap, int limit){
    Intent intent = new Intent(contextWrap.getActivity(), AlbumSelectActivity.class);
    intent.putExtra(Constants.INTENT_EXTRA_LIMIT, limit>0? limit:1);
    return intent;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:IntentUtils.java

示例10: getPickMultipleIntent

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
/**
 * 获取图片多选的Intent
 *
 * @param limit 最多选择图片张数的限制
 */
public static Intent getPickMultipleIntent(TContextWrap contextWrap, int limit) {
    Intent intent = new Intent(contextWrap.getActivity(), AlbumSelectActivity.class);
    intent.putExtra(Constants.INTENT_EXTRA_LIMIT, limit > 0 ? limit : 1);
    return intent;
}
 
开发者ID:duckitgo,项目名称:DigPhotoPicker,代码行数:11,代码来源:IntentUtils.java

示例11: onStart

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
protected void onStart() {
    super.onStart();

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case Constants.PERMISSION_GRANTED: {
                    loadImages();
                    break;
                }

                case Constants.FETCH_STARTED: {
                    progressBar.setVisibility(View.VISIBLE);
                    gridView.setVisibility(View.INVISIBLE);
                    break;
                }

                case Constants.FETCH_COMPLETED: {
                    /*
                    If adapter is null, this implies that the loaded images will be shown
                    for the first time, hence send FETCH_COMPLETED message.
                    However, if adapter has been initialised, this thread was run either
                    due to the activity being restarted or content being changed.
                     */
                    if (adapter == null) {
                        adapter = new CustomImageSelectAdapter(getApplicationContext(), images);
                        gridView.setAdapter(adapter);

                        progressBar.setVisibility(View.INVISIBLE);
                        gridView.setVisibility(View.VISIBLE);
                        orientationBasedUI(getResources().getConfiguration().orientation);

                    } else {
                        adapter.notifyDataSetChanged();
                        /*
                        Some selected images may have been deleted
                        hence update action mode title
                         */
                        if (actionMode != null) {
                            countSelected = msg.arg1;
                            actionMode.setTitle(countSelected + " " + getString(R.string.selected));
                        }
                    }
                    break;
                }

                case Constants.ERROR: {
                    progressBar.setVisibility(View.INVISIBLE);
                    errorDisplay.setVisibility(View.VISIBLE);
                    break;
                }

                default: {
                    super.handleMessage(msg);
                }
            }
        }
    };
    observer = new ContentObserver(handler) {
        @Override
        public void onChange(boolean selfChange) {
            loadImages();
        }
    };
    getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer);

    checkPermission();
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:71,代码来源:ImageSelectActivity.java

示例12: sendIntent

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
private void sendIntent() {
    Intent intent = new Intent();
    intent.putParcelableArrayListExtra(Constants.INTENT_EXTRA_IMAGES, getSelected());
    setResult(RESULT_OK, intent);
    finish();
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:7,代码来源:ImageSelectActivity.java

示例13: permissionGranted

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
protected void permissionGranted() {
    sendMessage(Constants.PERMISSION_GRANTED);
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:5,代码来源:ImageSelectActivity.java

示例14: onStart

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
protected void onStart() {
    super.onStart();

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case Constants.PERMISSION_GRANTED: {
                    loadAlbums();
                    break;
                }

                case Constants.FETCH_STARTED: {
                    progressBar.setVisibility(View.VISIBLE);
                    gridView.setVisibility(View.INVISIBLE);
                    break;
                }

                case Constants.FETCH_COMPLETED: {
                    if (adapter == null) {
                        adapter = new CustomAlbumSelectAdapter(getApplicationContext(), albums);
                        gridView.setAdapter(adapter);

                        progressBar.setVisibility(View.INVISIBLE);
                        gridView.setVisibility(View.VISIBLE);
                        orientationBasedUI(getResources().getConfiguration().orientation);

                    } else {
                        adapter.notifyDataSetChanged();
                    }
                    break;
                }

                case Constants.ERROR: {
                    progressBar.setVisibility(View.INVISIBLE);
                    errorDisplay.setVisibility(View.VISIBLE);
                    break;
                }

                default: {
                    super.handleMessage(msg);
                }
            }
        }
    };
    observer = new ContentObserver(handler) {
        @Override
        public void onChange(boolean selfChange, Uri uri) {
            loadAlbums();
        }
    };
    getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer);

    checkPermission();
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:57,代码来源:AlbumSelectActivity.java

示例15: run

import com.darsh.multipleimageselect.helpers.Constants; //导入依赖的package包/类
@Override
public void run() {
    android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

    if (adapter == null) {
        sendMessage(Constants.FETCH_STARTED);
    }

    Cursor cursor = getApplicationContext().getContentResolver()
            .query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection,
                    null, null, MediaStore.Images.Media.DATE_ADDED);
    if (cursor == null) {
        sendMessage(Constants.ERROR);
        return;
    }

    ArrayList<Album> temp = new ArrayList<>(cursor.getCount());
    HashSet<Long> albumSet = new HashSet<>();
    File file;
    if (cursor.moveToLast()) {
        do {
            if (Thread.interrupted()) {
                return;
            }

            long albumId = cursor.getLong(cursor.getColumnIndex(projection[0]));
            String album = cursor.getString(cursor.getColumnIndex(projection[1]));
            String image = cursor.getString(cursor.getColumnIndex(projection[2]));

            if (!albumSet.contains(albumId)) {
                /*
                It may happen that some image file paths are still present in cache,
                though image file does not exist. These last as long as media
                scanner is not run again. To avoid get such image file paths, check
                if image file exists.
                 */
                file = new File(image);
                if (file.exists()) {
                    temp.add(new Album(album, image));
                    albumSet.add(albumId);
                }
            }

        } while (cursor.moveToPrevious());
    }
    cursor.close();

    if (albums == null) {
        albums = new ArrayList<>();
    }
    albums.clear();
    albums.addAll(temp);

    sendMessage(Constants.FETCH_COMPLETED);
}
 
开发者ID:darsh2,项目名称:MultipleImageSelect,代码行数:56,代码来源:AlbumSelectActivity.java


注:本文中的com.darsh.multipleimageselect.helpers.Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。