Scratch image in android? - android

I want to show image only when user scratch on that, image will be overlay with colors. So when user scratch on it they can see the image. I will finished that part by using this link.
But what i need is while user scratch on that image, progress bar want to show the current progress. if user scratches all the portion of image progress bar should finish 100%.

If you use Android-WScratchView library, you can register OnScratchCallback and assign the percentage of cleared part to your progressbar
scratchView.setOnScratchCallback(new WScratchView.OnScratchCallback() {
#Override
public void onScratch(float percentage) {
yourProgressBar.setProgress(percentage);//Assign progressbar value here
}
#Override
public void onDetach(boolean fingerDetach) {
if(mPercentage > 50){
scratchView.setScratchAll(true);
updatePercentage(100);
}
}
});
You can check full sample at here

Related

FAB transparent layer does not block the parent layer

I have a problem using Clans FloatingActionButton. I need to add a transparent layer that blocks the parent layer. The effect that I need is similar to Google Inbox.
So in my example I have this sequence:
1) Click item 3
2) Click on fab
3) When I click over transparent layer, the item from ListView is clicked.
I try to block the click event transparent layer using:
final FloatingActionMenu menu1 = (FloatingActionMenu) findViewById(R.id.menu1);
menu1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
menu1.close(true);
}
});
So with this code, when I click transparent layer the fab menu is closed (this is ok), but the same click listener blocking the click event over listView.
I have tried different ways to solve this problem but the only way I found was to resize the background programmatically . This is not a good solution because the effect is not good.
In a few hours I'll upload a demo and source code to github , but even as hope someone can help me with some idea. Thank You
EDITED
Here is the LINK to my repo.
Here is the LINK to download this apk
Here is the LINK to video demo
I have download your project from Github and tried the code myself and have solved the issue.
It is working perfectly for me as demonstrated in the Inbox by Google app. You just need to change a very small portion of your code.
menu1.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
#Override
public void onMenuToggle(boolean opened) {
if (opened) {
menu1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
menu1.close(true);
menu1.setClickable(false);
}
});
} else {
Toast.makeText(getApplicationContext(), "Close", Toast.LENGTH_SHORT).show();
}
}
});
Hope I could help you.

Twitter-like splash screen animation in Android

How to achieve effect like Twitter splash screen animation (from iOS Twitter version) in Android application?
There is library https://github.com/callumboddy/CBZSplashView but it is for iOS only.
THis link may be usefull for you just download the code and as per the link suggests
You can create in code:
// create and customize the view
SplashView splashView = new SplashView(context);
// the animation will last 0.5 seconds
splashView.setDuration(500);
// transparent hole will look white before the animation
splashView.setHoleFillColor(Color.WHITE);
// this is the Twitter blue color
splashView.setIconColor(Color.rgb(23, 169, 229));
// a Twitter icon with transparent hole in it
splashView.setIconResource(R.drawable.ic_twitter);
// remove the SplashView from MainView once animation is completed
splashView.setRemoveFromParentOnEnd(true);
or in XML:
<com.yildizkabaran.twittersplash.view.SplashView
xmlns:app="http://schemas.android.com/apk/res/com.yildizkabaran.twittersplash"
android:id="#+id/splash_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:icon="#drawable/ic_twitter"
app:iconColor="#color/twitter_blue"
app:duration="500"
app:holeFillColor="#color/white"
app:removeFromParentOnEnd="true" />
then to run the animation, simply call:
--> run the animation and listen to the animation events (listener can be left as null)
splashView.splashAndDisappear(new ISplashListener(){
#Override
public void onStart(){
}
#Override
public void onUpdate(float completionFraction){
}
#Override
public void onEnd(){
}
});`
-Hope you find your answer.

Android - Star Rating Bar

I am using badoo Star Bar, and I have it all set up and working expect for when the method public void onFinalRating(int rating, boolean swipe) { is called, the number of stars that I have selected doesn't stay highlighted, it goes back to the default state. Here is the repo on git hub https://github.com/badoo/StarBar
And my set up is exactly the same, haven't changed anything but here it is anyways,
This is my layout
<com.badoo.mobile.views.starbar.StarBar
android:id="#+id/starBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
And then here I implement it
mStarBar = (StarBar)findViewById(R.id.starBar);
mStarBar.setOnRatingSliderChangeListener(new StarBar.OnRatingSliderChangeListener() {
#Override
public boolean onStartRating() {
// The user has initiated a rating by touching the StarBar. This call will
// immediately followed by a call to onPendingRating with the initial rating
// value.
Toast.makeText(DiningDetailActivity.this, "Started rating", Toast.LENGTH_SHORT).show();
return true;
}
#Override
public void onPendingRating(int rating) {
// This method will first be called when the user initiates a rating and then
// subsequently as the rating is updated (by the user swiping his finger along
// the bar).
Log.i(TAG, Integer.toString(rating) + "");
}
#Override
public void onFinalRating(int rating, boolean swipe) {
// If the rating is completed successfully onFinalRating is called with the
// final result. The swipe parameter specifies if the rating was done using
// a tap (false) or a swipe (true).
Toast.makeText(DiningDetailActivity.this, "Final rating " + rating, Toast.LENGTH_SHORT).show();
}
#Override
public void onCancelRating() {
// Called if the user cancels the rating by swiping away from the StarBar and releasing.
}
});
So my question is how when I select lets say 4 stars to get them to say highlighted, instead of going back to the gray state?
I have looked at the readME file and gone over his code and can't seem to find it.
Thanks so much for the help :)
You need to save the ratings. You only show toasts. I dont know the methods of the library but there is probably a method for changing the active stars.

Using Palatte API in ListView Adapter

Ok, first off all, I have not yet converted to using RecylerView; if for whatever reason doing that answers this question, by all means let me know.
In the meantime, I am trying to add a splash of different colors into a ListView using Palette.
Picture this: In Twitter, you have a timeline, each row has a user profile image. I am doing the equivalent of making the background of each row based on the user profile image.
I am also using Picasso to load the images.
In my Adapter, I do this:
try {
Picasso.with(context).load(url).placeholder(R.drawable.usericon).transform(new CircularTransform())
.into(holder.i1);
holder.i1.buildDrawingCache();
Bitmap b = holder.i1.getDrawingCache();
final ViewHolder finalHolder = holder;
Palette.generateAsync(b, new Palette.PaletteAsyncListener() {
#Override
public void onGenerated(Palette palette) {
Palette.Swatch vibrant = palette.getVibrantSwatch();
if (vibrant != null) {
finalHolder.r1.setBackgroundColor(
vibrant.getRgb());
finalHolder.tv3.setTextColor(
vibrant.getTitleTextColor());
finalHolder.l1.setBackgroundColor(
vibrant.getRgb());
finalHolder.tv8.setTextColor(
vibrant.getTitleTextColor());
}
}
});
} catch (Exception e) {
}
this does work; but the problem is when the list is first loaded, the rows are the default colors. I can sit there without scrolling for 5 seconds or 5 minutes and it will not change until I start scrolling. Then the rows below ARE the new color based on the Swatch. If I go back up to the top, those rows are now colored as well.
So my question: Is what I am doing too ambitious for this api? if not, is there a better way to speed things up?

How can we display progress icon in button

I need to display progress icon in button so that user can interact other GUI elements while background task is processing.
I have searched in Android developer site and found that we can use animated drawables but don't know how to use them. Please advise on the same.
The very simple way to do this without using the animated drawable is to use "PregressBar" component in the design layout xml. When u need to show it, just set it's visibility property to visible and when you need to hide it, u can set it's visibility property to GONE. But remember this is UI task so when u need to do this with non-UI thread, u need to use Handler to set the status of "ProgressBar" component at runtime.
Below id the component in the layout file.
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ProgressBar>
Below is the code written in java file
ProgressBar prg;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
prg=(ProgressBar)findViewById(R.id.ProgressBar1);
prg.setVisibility(ProgressBar.GONE);
}
public void start_background_process()
{
// starting the process
prg.setVisibility(ProgressBar.VISIBLE);
new Thread(new Runnable()
{ public void run()
{
// Do your background stuff here which takes indefinite time
mHandlerUpdateProgress.post(mUpdateUpdateProgress);
}
} ).start();
}
final Handler mHandlerUpdateProgress= new Handler();
final Runnable mUpdateUpdateProgress = new Runnable() {
public void run() {
// ending the process
prg.setVisibility(ProgressBar.GONE);
}
};
If the default progress indicator is good enough for you (i.e. the spinning wheel), then you can just use ProgressBar. To change it from a normal progress bar to a spinning wheel, use progressBar.setIndeterminate(true).

Categories

Resources