-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate an icon with MultiTaskView to show BatteryGure Ad
Signed-off-by: sunilpaulmathew <[email protected]>
- Loading branch information
1 parent
4727447
commit 69f5b00
Showing
3 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,26 +21,30 @@ | |
|
||
package com.smartpack.kernelmanager.views.recyclerview; | ||
|
||
import android.graphics.drawable.Drawable; | ||
import android.view.View; | ||
import android.widget.LinearLayout; | ||
|
||
import androidx.appcompat.widget.AppCompatImageButton; | ||
|
||
import com.google.android.material.progressindicator.CircularProgressIndicator; | ||
import com.google.android.material.textview.MaterialTextView; | ||
import com.smartpack.kernelmanager.R; | ||
import com.smartpack.kernelmanager.utils.Utils; | ||
|
||
/** | ||
* Created by sunilpaulmathew <[email protected]> on December 03, 2019 | ||
* | ||
* Largely based on the original implementation of StatsView by Willi Ye | ||
*/ | ||
public class MultiStatsView extends RecyclerViewItem { | ||
|
||
private AppCompatImageButton mIcon; | ||
private CharSequence mTitle, mProgressTitle, mStatOne, mStatTwo, mStatThree; | ||
private MaterialTextView mTitleView, mProgressTitleView, mStatViewOne, mStatViewTwo, mStatViewThree; | ||
private CircularProgressIndicator mProgressBar; | ||
private Drawable mDrawable; | ||
private int mMax, mProgressPercent; | ||
private LinearLayout mProgressLayout; | ||
private MaterialTextView mTitleView, mProgressTitleView, mStatViewOne, mStatViewTwo, mStatViewThree; | ||
|
||
@Override | ||
public int getLayoutRes() { | ||
|
@@ -56,6 +60,7 @@ public void onCreateView(View view) { | |
mProgressTitleView = view.findViewById(R.id.progress_title); | ||
mProgressBar = view.findViewById(R.id.progress); | ||
mProgressLayout = view.findViewById(R.id.progress_layout); | ||
mIcon = view.findViewById(R.id.icon); | ||
LinearLayout mParentLayout = view.findViewById(R.id.parent_layout); | ||
|
||
if (Utils.getScreenDPI(view.getContext()) < 390 || Utils.isTablet(view.getContext()) && | ||
|
@@ -101,6 +106,11 @@ public void setProgressTitle(CharSequence text) { | |
refresh(); | ||
} | ||
|
||
public void setIcon(Drawable icon) { | ||
mDrawable = icon; | ||
refresh(); | ||
} | ||
|
||
@Override | ||
protected void refresh() { | ||
super.refresh(); | ||
|
@@ -133,5 +143,14 @@ protected void refresh() { | |
mProgressTitleView.setText(mProgressTitle); | ||
mProgressTitleView.setVisibility(View.VISIBLE); | ||
} | ||
if (mIcon != null && mDrawable != null) { | ||
mIcon.setImageDrawable(mDrawable); | ||
mIcon.setVisibility(View.VISIBLE); | ||
mIcon.setOnClickListener(v -> { | ||
if (getOnItemClickListener() != null) { | ||
getOnItemClickListener().onClick(MultiStatsView.this); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters