Skip to content

Commit

Permalink
Fixed bugs in demo 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielemariotti committed Nov 8, 2014
1 parent 61ffadb commit 7e2a6b2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion demo/stock/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
</activity>
<activity
android:name=".ui.NativeMenuActivity"
android:label="@string/navdrawer_item_native_cardslib"
android:theme="@style/Theme.Carddemo.Main">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
return inflater.inflate(R.layout.demo_fragment_native_misc_card, container, false);
}

float mElevationCircle;
int mSizeCircle;

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

mScrollView = (ScrollView) getActivity().findViewById(R.id.card_scrollview);
mElevationCircle = getResources().getDimension(R.dimen.circle_elevation);
mSizeCircle = getResources().getDimensionPixelSize(R.dimen.circle_size);

initCard();
}
Expand Down Expand Up @@ -165,15 +170,14 @@ public boolean applyBitmap(final View imageView, Bitmap bitmap) {
imageView.setBackgroundDrawable(circle);


ViewCompat.setElevation(imageView, getResources().getDimension(R.dimen.circle_elevation));
ViewCompat.setElevation(imageView, mElevationCircle);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
final int size = getResources().getDimensionPixelSize(R.dimen.circle_size);
imageView.setOutlineProvider(
new ViewOutlineProvider(){
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, size, size);
outline.setOval(0, 0, mSizeCircle, mSizeCircle);
}
});
imageView.setClipToOutline(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ class LoaderAsyncTask extends AsyncTask<Void, Void, ArrayList<Card>> {
protected ArrayList<Card> doInBackground(Void... params) {
//elaborate images
SystemClock.sleep(1000); //delay to simulate download, don't use it in a real app
ArrayList<Card> cards = initCard();
return cards;
if (isAdded()) {
ArrayList<Card> cards = initCard();
return cards;
}else
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.carddemo_activity_native);

if (getSupportActionBar() != null)
getSupportActionBar().setTitle(R.string.navdrawer_item_native_cardslib);

if (null == savedInstanceState) {
getFragmentManager().beginTransaction()
.replace(R.id.container, NativeDashFragment.newInstance())
Expand Down
2 changes: 1 addition & 1 deletion demo/stock/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<resources>

<!--App name -->
<string name="app_name">CardsLibDemo</string>
<string name="app_name">CardsLib Demo</string>

<!--Authority -->
<string name="config_authority">it.gmariotti.cardslib.demo.provider</string>
Expand Down

0 comments on commit 7e2a6b2

Please sign in to comment.