Clean up graphics and animations

This commit is contained in:
d8ahazard 2016-09-12 12:03:02 -05:00
parent 204e940dcb
commit 40e92721c1
2 changed files with 83 additions and 59 deletions

View File

@ -117,6 +117,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
View.OnClickListener oCl = view -> {
Log.d("Magisk","Onlick captured, view is " + view.getId());
if (view.getId() == mHolder.updateImage.getId()) {
if (!mIsInstalled | mCanUpdate) {
@ -132,12 +133,18 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
} else {
Toast.makeText(context, repo.getId() + " is already installed.", Toast.LENGTH_SHORT).show();
}
} else if (view.getId() == mHolder.changeLog.getId()) {
} if (view.getId() == mHolder.changeLog.getId()) {
new WebWindow("Changelog",repo.getmLogUrl(),this.context);
} if (view.getId() == mHolder.authorLink.getId()) {
new WebWindow("Donate",repo.getmDonateUrl(),this.context);
} if (view.getId() == mHolder.supportLink.getId()) {
new WebWindow("Support",repo.getmSupportUrl(),this.context);
}
};
mHolder.changeLog.setOnClickListener(oCl);
mHolder.updateImage.setOnClickListener(oCl);
mHolder.authorLink.setOnClickListener(oCl);
mHolder.supportLink.setOnClickListener(oCl);
if (prefs.contains("repo-isInstalled_" + repo.getId())) {
mIsInstalled = prefs.getBoolean("repo-isInstalled_" + repo.getId(), false);
@ -174,8 +181,13 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
ImageView installedImage;
@BindView(R.id.changeLog)
ImageView changeLog;
@BindView(R.id.authorLink)
ImageView authorLink;
@BindView(R.id.supportLink)
ImageView supportLink;
private ValueAnimator mAnimator;
private AnimatorSet animSetUpRight, animSetDownLeft;
private ObjectAnimator animY2;
private ViewHolder holder;
public ViewHolder(View itemView) {
super(itemView);
@ -183,26 +195,22 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
ButterKnife.bind(this, itemView);
DisplayMetrics dimension = new DisplayMetrics();
windowmanager.getDefaultDisplay().getMetrics(dimension);
expandLayout.getViewTreeObserver().addOnPreDrawListener(
holder = this;
this.expandLayout.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
expandLayout.getViewTreeObserver().removeOnPreDrawListener(this);
expandLayout.setVisibility(View.GONE);
expandLayout.measure(widthSpec, heightSpec);
mAnimator = slideAnimator(0, expandLayout.getMeasuredHeight());
ObjectAnimator animX2 = ObjectAnimator.ofFloat(mHolder.updateImage, "x", -45);
ObjectAnimator animY2 = ObjectAnimator.ofFloat(mHolder.updateImage, "y", -134);
animSetDownLeft = new AnimatorSet();
animSetDownLeft.playTogether(animX2, animY2);
ObjectAnimator animX = ObjectAnimator.ofFloat(mHolder.updateImage, "x", 45);
ObjectAnimator animY = ObjectAnimator.ofFloat(mHolder.updateImage, "y", 134);
animSetUpRight = new AnimatorSet();
animSetUpRight.playTogether(animX, animY);
animSetUpRight.start();
holder.expandLayout.getViewTreeObserver().removeOnPreDrawListener(this);
holder.expandLayout.setVisibility(View.GONE);
holder.expandLayout.measure(widthSpec, heightSpec);
final int holderHeight = holder.expandLayout.getMeasuredHeight();
mAnimator = slideAnimator(0, holderHeight);
animY2 = ObjectAnimator.ofFloat(holder.updateImage, "translationY", holderHeight/2);
return true;
}
@ -211,9 +219,9 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
viewMain.setOnClickListener(view -> {
int position = getAdapterPosition();
if (mExpandedList.get(position)) {
collapse(expandLayout);
collapse(holder.expandLayout);
} else {
expand(expandLayout);
expand(holder.expandLayout);
}
mExpandedList.set(position, !mExpandedList.get(position));
@ -224,7 +232,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
private void expand(View view) {
view.setVisibility(View.VISIBLE);
mAnimator.start();
animSetDownLeft.start();
animY2.start();
}
@ -251,7 +259,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
}
});
mAnimator.start();
animSetUpRight.start();
animY2.reverse();
}

View File

@ -19,29 +19,28 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:padding="8dp">
<LinearLayout
android:layout_width="0dip"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:layout_weight="1"
android:orientation="vertical">
>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_width="300dip"
android:layout_height="wrap_content"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="false"/>
android:textIsSelectable="false"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp" />
<TextView
android:id="@+id/version_name"
@ -50,7 +49,23 @@
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/tertiary_text_dark"
android:textIsSelectable="false"
android:textStyle="bold|italic"/>
android:textStyle="bold|italic"
android:layout_alignParentStart="true"
android:layout_below="@id/title"
/>
<ImageView
android:id="@+id/update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="right"
android:background="@drawable/ic_file_download_black"
android:layout_marginEnd="10dp"
android:layout_gravity="right"
android:layout_alignBaseline="@id/title"
android:layout_alignParentEnd="true"
/>
<TextView
android:id="@+id/description"
@ -58,7 +73,10 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"/>
android:textIsSelectable="false"
android:layout_alignParentStart="true"
android:layout_below="@id/update"
/>
<LinearLayout
@ -66,7 +84,11 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="100dp"
android:orientation="vertical">
android:orientation="vertical"
android:layout_below="@id/description"
android:layout_alignParentStart="true"
>
<TextView
android:id="@+id/author"
@ -90,13 +112,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textIsSelectable="false"/>
android:textIsSelectable="false"
android:layout_marginBottom="20dip" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="50dip"
android:layout_gravity="center"
android:orientation="horizontal">
android:orientation="horizontal"
android:layout_marginBottom="0dip">
<ImageView
android:id="@+id/changeLog"
android:layout_width="wrap_content"
@ -105,12 +129,14 @@
android:layout_marginEnd="10dp"
android:background="@drawable/ic_changelog"/>
<ImageView
android:id="@+id/authorLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:background="@drawable/ic_author"/>
<ImageView
android:id="@+id/supportLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
@ -118,15 +144,13 @@
android:background="@drawable/ic_support"/>
<ImageView
android:id="@+id/update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="@+id/installed"
@ -134,20 +158,12 @@
android:layout_height="wrap_content"
android:focusable="false"
android:visibility="gone"
android:gravity="center_vertical"
android:gravity="right"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>