List of usage examples for android.os Bundle getStringArrayList
@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key)
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeFourDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(fourDollars);// w w w .j av a 2 s .c o m Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(fourDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // e.printStackTrace(); } catch (JSONException e) { // e.printStackTrace(); } catch (SendIntentException e) { // e.printStackTrace(); } } }).start(); }
From source file:de.sourcestream.movieDB.controller.TVDetails.java
/** * Fired when are restoring from backState or orientation has changed. * * @param args our bundle with saved state. *//*from w w w .j a va2 s .co m*/ private void onOrientationChange(Bundle args) { // Home page homeIconCheck = args.getInt("homeIconCheck"); if (homeIconCheck == 0) homeIconUrl = args.getString("homepage"); // Gallery galleryIconCheck = args.getInt("galleryIconCheck"); if (galleryIconCheck == 0) { galleryList = new ArrayList<>(); galleryList = args.getStringArrayList("galleryList"); if (galleryList.size() == 0) activity.hideView(galleryIcon); } // More icon moreIconCheck = args.getInt("moreIconCheck"); if (homeIconCheck == 1 && galleryIconCheck == 1) { moreIconCheck = 1; moreIcon.setVisibility(View.GONE); } else moreIconCheck = 0; mSlidingTabLayout.setOnPageChangeListener(onPageChangeSelected); activity.setTVDetailsInfoBundle(save); activity.setTVDetailsCastBundle(save); activity.setTVDetailsOverviewBundle(save); castList = save.getParcelableArrayList("castList"); if (castList != null && castList.size() == 0) { noCast = true; mSlidingTabLayout.disableTabClickListener(1); } new Handler().post(new Runnable() { @Override public void run() { tvDetailsInfo = (TVDetailsInfo) tvDetailsSlideAdapter.getRegisteredFragment(0); if (currPos == 0) { moreIcon.setVisibility(View.INVISIBLE); } else if (moreIconCheck == 0) { tvDetailsInfo.getMoreIcon().setVisibility(View.INVISIBLE); updateDownPos(); } if (moreIconCheck == 1) tvDetailsInfo.getMoreIcon().setVisibility(View.GONE); else { // set listener on backdrop and poster path click to open gallery if (galleryIconCheck == 0 && galleryList.size() > 0) { tvDetailsInfo.getBackDropPath().setOnClickListener(onGalleryIconClick); tvDetailsInfo.getPosterPath().setOnClickListener(onGalleryIconClick); } adjustIconsPos(homeIcon, galleryIcon); adjustIconsPos(tvDetailsInfo.getHomeIcon(), tvDetailsInfo.getGalleryIcon()); } // disable orientation changing, enable nav drawer sliding, show toolbar if (galleryIconCheck == 0 && galleryList.size() == 1) { activity.getWindow().getDecorView().setBackgroundColor( ContextCompat.getColor(activity, R.color.background_material_light)); if (activity.getSupportActionBar() != null) activity.getSupportActionBar().show(); activity.getMDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); if (Build.VERSION.SDK_INT >= 19) activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // Check orientation and lock to portrait if we are on phone if (getResources().getBoolean(R.bool.portrait_only)) activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } }); }
From source file:io.imoji.sdk.editor.fragment.TagImojiFragment.java
@Override public void onViewCreated(View v, @Nullable Bundle savedInstanceState) { mImojiIv = (ImageView) v.findViewById(R.id.iv_imoji); mTagEditor = v.findViewById(R.id.tag_editor); mTagEditor.setBackgroundDrawable(createTagDrawable()); mTagGrid = (GridLayout) v.findViewById(R.id.gl_tagbox); mTaggerEt = (EditText) v.findViewById(R.id.et_tag); mTaggerEt.setOnEditorActionListener(mKeyActionListener); mUploadButton = (ImageButton) v.findViewById(R.id.ib_upload); mUploadButton.setOnClickListener(mOnDoneClickListener); mProgress = (ProgressBar) v.findViewById(R.id.imoji_progress); mToolbar = (Toolbar) v.findViewById(R.id.imoji_toolbar); mToolbar.setNavigationIcon(R.drawable.create_back); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override/*from www . j a va 2 s . co m*/ public void onClick(View v) { if (isResumed()) { getFragmentManager().popBackStack(); mInputMethodManager.hideSoftInputFromWindow(mTaggerEt.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }); mClearInputBt = (ImageButton) v.findViewById(R.id.ib_cancel); mClearInputBt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mTaggerEt != null) { mTaggerEt.getText().clear(); } } }); View toolbarScrim = v.findViewById(R.id.imoji_toolbar_scrim); if (Build.VERSION.SDK_INT >= 16) { toolbarScrim.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 8, Gravity.TOP)); } else { toolbarScrim .setBackgroundDrawable(ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 8, Gravity.TOP)); } if (savedInstanceState != null) { List<String> tags = savedInstanceState.getStringArrayList(TAGS_BUNDLE_ARG_KEY); for (String tag : tags) { addTagChip(tag); } mProgress.setVisibility( savedInstanceState.getBoolean(IS_PROCESSING_BUNDLE_ARG_KEY) ? View.VISIBLE : View.GONE); } }
From source file:de.sourcestream.movieDB.controller.MovieDetails.java
/** * Fired when are restoring from backState or orientation has changed. * * @param args our bundle with saved state. *//*from w ww . j a v a2 s . c om*/ private void onOrientationChange(Bundle args) { // Home page homeIconCheck = args.getInt("homeIconCheck"); if (homeIconCheck == 0) homeIconUrl = args.getString("homepage"); // Gallery galleryIconCheck = args.getInt("galleryIconCheck"); if (galleryIconCheck == 0) { galleryList = new ArrayList<>(); galleryList = args.getStringArrayList("galleryList"); if (galleryList.size() == 0) activity.hideView(galleryIcon); } // Trailers trailerIconCheck = args.getInt("trailerIconCheck"); if (trailerIconCheck == 0) { trailerList = new ArrayList<>(); trailerList = args.getStringArrayList("trailerList"); if (trailerList.size() == 0) activity.hideView(trailerIcon); } // More icon moreIconCheck = args.getInt("moreIconCheck"); if (homeIconCheck == 1 && galleryIconCheck == 1 && trailerIconCheck == 1) { moreIconCheck = 1; moreIcon.setVisibility(View.GONE); } else moreIconCheck = 0; mSlidingTabLayout.setOnPageChangeListener(onPageChangeSelected); activity.setMovieDetailsInfoBundle(save); activity.setMovieDetailsCastBundle(save); activity.setMovieDetailsOverviewBundle(save); castList = save.getParcelableArrayList("castList"); if (castList != null && castList.size() == 0) { noCast = true; mSlidingTabLayout.disableTabClickListener(1); } new Handler().post(new Runnable() { @Override public void run() { movieDetailsInfo = (MovieDetailsInfo) movieDetailsSlideAdapter.getRegisteredFragment(0); if (currPos == 0) { moreIcon.setVisibility(View.INVISIBLE); } else if (moreIconCheck == 0) { movieDetailsInfo.getMoreIcon().setVisibility(View.INVISIBLE); updateDownPos(); } if (moreIconCheck == 1) movieDetailsInfo.getMoreIcon().setVisibility(View.GONE); else { // set listener on backdrop and poster path click to open gallery if (galleryIconCheck == 0 && galleryList.size() > 0) { movieDetailsInfo.getBackDropPath().setOnClickListener(onGalleryIconClick); movieDetailsInfo.getPosterPath().setOnClickListener(onGalleryIconClick); } adjustIconsPos(homeIcon, trailerIcon, galleryIcon); adjustIconsPos(movieDetailsInfo.getHomeIcon(), movieDetailsInfo.getTrailerIcon(), movieDetailsInfo.getGalleryIcon()); } // disable orientation changing, enable nav drawer sliding, show toolbar if (galleryIconCheck == 0 && galleryList.size() == 1) { activity.getWindow().getDecorView().setBackgroundColor( ContextCompat.getColor(activity, R.color.background_material_light)); if (activity.getSupportActionBar() != null) activity.getSupportActionBar().show(); activity.getMDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); if (Build.VERSION.SDK_INT >= 19) activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); // Check orientation and lock to portrait if we are on phone if (getResources().getBoolean(R.bool.portrait_only)) activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } }); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1001) { int responseCode = data.getIntExtra("RESPONSE_CODE", 0); final String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); new Thread(new Runnable() { public void run() { //Thread.sleep(5*1000); try { Bundle ownedItems = mservice.getPurchases(3, getPackageName(), "inapp", null); // Check response int responseCode = ownedItems.getInt("RESPONSE_CODE"); if (responseCode != 0) { throw new Exception("Error"); }/*ww w . j a va 2 s .c om*/ // Get the list of purchased items ArrayList<String> purchaseDataList = ownedItems .getStringArrayList("INAPP_PURCHASE_DATA_LIST"); for (String purchaseData : purchaseDataList) { JSONObject o = new JSONObject(purchaseData); String purchaseToken = o.optString("token", o.optString("purchaseToken")); // Consume purchaseToken, handling any errors mservice.consumePurchase(3, getPackageName(), purchaseToken); } } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); if (resultCode == RESULT_OK) { try { JSONObject jo = new JSONObject(purchaseData); String sku = jo.getString("productId"); new Thread(new Runnable() { public void run() { try { Bundle ownedItems = mservice.getPurchases(3, getPackageName(), "inapp", null); // Check response int responseCode = ownedItems.getInt("RESPONSE_CODE"); if (responseCode != 0) { throw new Exception("Error"); } // Get the list of purchased items ArrayList<String> purchaseDataList = ownedItems .getStringArrayList("INAPP_PURCHASE_DATA_LIST"); for (String purchaseData : purchaseDataList) { JSONObject o = new JSONObject(purchaseData); String purchaseToken = o.optString("token", o.optString("purchaseToken")); // Consume purchaseToken, handling any errors mservice.consumePurchase(3, getPackageName(), purchaseToken); } } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); } catch (JSONException e) { e.printStackTrace(); } } } }
From source file:co.zzyzx.showtimes.android.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); app = ShowtimesApplication.getInstance(); mTabPagerAdapter = new TabPagerAdapter(getFragmentManager()); final ActionBar ab = getSupportActionBar(); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ab.setDisplayShowHomeEnabled(false); // hides action bar icon ab.setDisplayShowTitleEnabled(false); // hides action bar title // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mTabPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* w ww. ja v a 2s .c o m*/ public void onPageSelected(int position) { ab.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mTabPagerAdapter.getCount(); i++) { ab.addTab(ab.newTab().setIcon(mTabPagerAdapter.getIcon(i)).setTabListener(this)); } // Set up the account manager mAccountManager = DbxAccountManager.getInstance(getApplicationContext(), app.appKey, app.appSecret); // Set up the app.datastore manager if (mAccountManager.hasLinkedAccount()) { try { // Use Dropbox datastores this.app.datastoreManager = DbxDatastoreManager.forAccount(mAccountManager.getLinkedAccount()); //Log.i(LOG_TAG, "Account was linked"); } catch (DbxException.Unauthorized e) { //Log.i(LOG_TAG, "Account was unlinked remotely"); } } else { //Log.i(LOG_TAG, "Account was local"); this.app.datastoreManager = DbxDatastoreManager.localManager(mAccountManager); } if (!app.isDirty && savedInstanceState != null) { savedFavList = savedInstanceState.getStringArrayList("favList"); app.isDirty = false; } }
From source file:com.facebook.android.friendsmash.HomeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home);/*w w w.j a v a 2 s . com*/ FragmentManager fm = getSupportFragmentManager(); fragments[FB_LOGGED_OUT_HOME] = fm.findFragmentById(R.id.fbLoggedOutHomeFragment); fragments[HOME] = fm.findFragmentById(R.id.homeFragment); FragmentTransaction transaction = fm.beginTransaction(); for (int i = 0; i < fragments.length; i++) { transaction.hide(fragments[i]); } transaction.commit(); // Restore the logged-in user's information if it has been saved and the existing data in the application // has been destroyed (i.e. the app hasn't been used for a while and memory on the device is low) // - only do this if the session is open for the social version only if (FriendSmashApplication.IS_SOCIAL) { // loggedIn if (savedInstanceState != null) { boolean loggedInState = savedInstanceState.getBoolean(FriendSmashApplication.getLoggedInKey(), false); ((FriendSmashApplication) getApplication()).setLoggedIn(loggedInState); if (((FriendSmashApplication) getApplication()).isLoggedIn() && (((FriendSmashApplication) getApplication()).getFriends() == null || ((FriendSmashApplication) getApplication()).getCurrentFBUser() == null)) { try { // currentFBUser String currentFBUserJSONString = savedInstanceState .getString(FriendSmashApplication.getCurrentFbUserKey()); if (currentFBUserJSONString != null) { GraphUser currentFBUser = GraphObject.Factory .create(new JSONObject(currentFBUserJSONString), GraphUser.class); ((FriendSmashApplication) getApplication()).setCurrentFBUser(currentFBUser); } // friends ArrayList<String> friendsJSONStringArrayList = savedInstanceState .getStringArrayList(FriendSmashApplication.getFriendsKey()); if (friendsJSONStringArrayList != null) { ArrayList<GraphUser> friends = new ArrayList<GraphUser>(); Iterator<String> friendsJSONStringArrayListIterator = friendsJSONStringArrayList .iterator(); while (friendsJSONStringArrayListIterator.hasNext()) { friends.add(GraphObject.Factory.create( new JSONObject(friendsJSONStringArrayListIterator.next()), GraphUser.class)); } ((FriendSmashApplication) getApplication()).setFriends(friends); } } catch (JSONException e) { Log.e(FriendSmashApplication.TAG, e.toString()); } } } } }
From source file:org.ale.scanner.zotero.MainActivity.java
@Override public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main);//from w ww . j a v a 2s . co m Bundle extras = getIntent().getExtras(); mUIThreadHandler = new Handler(); // Get the account we're logged in as mAccount = (Account) extras.getParcelable(INTENT_EXTRA_ACCOUNT); // Load preferences SharedPreferences prefs = getSharedPreferences(mAccount.getUid(), MODE_PRIVATE); // The group we'll upload to (default to user's personal library) mSelectedGroup = prefs.getInt(PREF_GROUP, Group.GROUP_LIBRARY); mISBNService = prefs.getInt(PREF_SERVICE, SERVICE_GOOGLE); // Initialize Clients mGoogleBooksAPI = new GoogleBooksAPIClient(); mWorldCatAPI = new WorldCatAPIClient(); mZAPI = new ZoteroAPIClient(); mZAPI.setAccount(mAccount); // BibItem list ExpandableListView bibItemList = (ExpandableListView) findViewById(R.id.bib_items); // Pending item list View pendingListHolder = getLayoutInflater().inflate(R.layout.pending_item_list, bibItemList, false); bibItemList.addHeaderView(pendingListHolder); mPendingList = (ListView) pendingListHolder.findViewById(R.id.pending_item_list); int[] checked; if (state == null) { // Fresh activity mAccountAccess = null; // will check for permissions in onResume mPendingItems = new ArrayList<String>(2); // RC_PEND mPendingStatus = new ArrayList<Integer>(2); // RC_PEND_STAT checked = new int[0]; mUploadState = UPLOAD_STATE_WAIT; mGroups = new SparseArray<PString>(); } else { // Recreating activity // Rebuild pending list mAccountAccess = state.getParcelable(RC_ACCESS); mPendingItems = state.getStringArrayList(RC_PEND); mPendingStatus = state.getIntegerArrayList(RC_PEND_STAT); // Set checked items checked = state.getIntArray(RC_CHECKED); mUploadState = state.getInt(RC_UPLOADING); mGroups = state.getSparseParcelableArray(RC_GROUPS); } // Initialize list adapters mItemAdapter = new BibItemListAdapter(MainActivity.this); mItemAdapter.setChecked(checked); bibItemList.setAdapter(mItemAdapter); registerForContextMenu(bibItemList); mPendingAdapter = new PendingListAdapter(MainActivity.this, R.layout.pending_item, R.id.pending_item_id, mPendingItems, mPendingStatus); mPendingList.setAdapter(mPendingAdapter); registerForContextMenu(mPendingList); // Listeners findViewById(R.id.scan_isbn).setOnClickListener(scanIsbn); findViewById(R.id.upload).setOnClickListener(uploadSelected); // Load animations mAnimations = new Animation[] { AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_in_next), AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_out_next), AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_in_previous), AnimationUtils.loadAnimation(MainActivity.this, R.anim.slide_out_previous) }; // Upload Bar findViewById(R.id.upload_progress).setOnClickListener(dismissUploadStatus); }
From source file:com.rothconsulting.android.billing.util.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;// w w w. j a v a 2 s . c o m do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); Utils.log(mDebugTag, "++ --- ownedItems from Service = " + ownedItems); Utils.log(mDebugTag, "++ --- ownedItems itemType = " + itemType); Utils.log(mDebugTag, "++ --- ownedItems keySet = " + ownedItems.keySet()); Utils.log(mDebugTag, "++ --- ownedItems isEmpty = " + ownedItems.isEmpty()); Utils.log(mDebugTag, "++ --- ownedItems INAPP_PURCHASE_ITEM_LIST = " + ownedItems.get("INAPP_PURCHASE_ITEM_LIST")); Utils.log(mDebugTag, "++ --- ownedItems INAPP_PURCHASE_DATA_LIST = " + ownedItems.get("INAPP_PURCHASE_DATA_LIST")); Utils.log(mDebugTag, "++ --- ownedItems INAPP_DATA_SIGNATURE_LIST = " + ownedItems.get("INAPP_DATA_SIGNATURE_LIST")); Utils.log(mDebugTag, "++ --- ownedItems RESPONSE_CODE = " + ownedItems.get("RESPONSE_CODE")); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:com.yanzhenjie.album.fragment.AlbumFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Bundle argument = getArguments(); mToolBarColor = argument.getInt(AlbumWrapper.KEY_INPUT_TOOLBAR_COLOR, ContextCompat.getColor(getContext(), R.color.albumColorPrimary)); String title = argument.getString(AlbumWrapper.KEY_INPUT_TITLE); if (TextUtils.isEmpty(title)) title = getString(R.string.album_title); mNavigationColor = argument.getInt(AlbumWrapper.KEY_INPUT_NAVIGATION_COLOR, ContextCompat.getColor(getContext(), R.color.albumColorPrimaryBlack)); int columnCount = argument.getInt(AlbumWrapper.KEY_INPUT_COLUMN_COUNT, 2); mAllowSelectCount = argument.getInt(AlbumWrapper.KEY_INPUT_LIMIT_COUNT, Integer.MAX_VALUE); mHasCamera = argument.getBoolean(AlbumWrapper.KEY_INPUT_ALLOW_CAMERA, true); // noinspection ConstantConditions getToolbar().setBackgroundColor(mToolBarColor); setTitle(title);/*from w w w.j a v a 2 s . co m*/ mLayoutManager = new GridLayoutManager(getContext(), columnCount); mRvContentList.setLayoutManager(mLayoutManager); Drawable decoration = ContextCompat.getDrawable(getContext(), R.drawable.album_decoration_white); mRvContentList.addItemDecoration(new AlbumVerticalGirdDecoration(decoration)); int itemSize = (DisplayUtils.screenWidth - decoration.getIntrinsicWidth() * (columnCount + 1)) / columnCount; mAlbumContentAdapter = new AlbumImageAdapter(getContext(), mHasCamera, itemSize, ContextCompat.getColor(getContext(), R.color.albumWhiteGray), mToolBarColor); mAlbumContentAdapter.setAddPhotoClickListener(mAddPhotoListener); mAlbumContentAdapter.setOnCheckListener(mItemCheckListener); mAlbumContentAdapter.setItemClickListener(new OnCompatItemClickListener() { @Override public void onItemClick(View view, int position) { List<AlbumImage> albumImages = mAlbumFolders.get(mCurrentFolderPosition).getImages(); AlbumPreviewFragment previewFragment = NoFragment.instantiate(getContext(), AlbumPreviewFragment.class, argument); previewFragment.bindAlbumImages(albumImages, mCheckedImages, position); startFragmentForResquest(previewFragment, REQUEST_CODE_FRAGMENT_PREVIEW); } }); mRvContentList.setAdapter(mAlbumContentAdapter); ScanTask scanTask = new ScanTask(getContext(), mScanCallback, mCheckedImages); List<String> checkedPathList = argument.getStringArrayList(UIWrapper.KEY_INPUT_CHECKED_LIST); //noinspection unchecked scanTask.execute(checkedPathList); }