本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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);
}
示例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());
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例13: permissionGranted
import com.darsh.multipleimageselect.helpers.Constants; //導入依賴的package包/類
@Override
protected void permissionGranted() {
sendMessage(Constants.PERMISSION_GRANTED);
}
示例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();
}
示例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);
}