Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when starting activity the circle does not turn fully #25

Open
marcoazeem opened this issue May 8, 2018 · 7 comments
Open

when starting activity the circle does not turn fully #25

marcoazeem opened this issue May 8, 2018 · 7 comments

Comments

@marcoazeem
Copy link

With this the circle does not turn fully, it turns half way and open the new activity. how would I solve the issue?

circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {

                                             @Override
                                             public void onMenuSelected(int index) {
                                                 switch (index) {
                                                     case 0:
                                                         Toast.makeText(Circle.this, "Home Button Clicked", Toast.LENGTH_SHORT).show();
                                                         break;
                                                     case 1:
                                                         startActivity(new Intent(Circle.this, track.class));
                                                         break;
@amirmollaee1369
Copy link

amirmollaee1369 commented Oct 6, 2018

hi
you can use this:
private int indexitem=-1;
...
circleMenu = (CircleMenu) findViewById(R.id.circle_menu);

    circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.drawable.ic_menu_white_24dp, R.drawable.ic_close_white_24dp)
            .addSubMenu(Color.parseColor("#258CFF"), R.drawable.ic_category_white_24dp)
            .addSubMenu(Color.parseColor("#30A400"), R.drawable.search)
            .addSubMenu(Color.parseColor("#FF4B32"), R.drawable.ic_notifications_white_24dp)
            .setOnMenuSelectedListener(new OnMenuSelectedListener() {

                @Override
                public void onMenuSelected(int index) {
                    indexitem=index;


                }
            }).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {

        @Override
        public void onMenuOpened() {}

        @Override
        public void onMenuClosed() {
            switch (indexitem) {
                case 0:
                    indexitem=-1;
                    Intent intent = new Intent(context, SearchResultChannelActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.putExtra("tb_category_id", 0);
                    intent.putExtra("tb_category_title", "دسته بندی");
                    startActivity(intent);
                    break;
                case 1:
                    indexitem=-1;
                    //do something
                    break;
                case 2:
                    indexitem=-1;
                    //do something
                    break;
            }
        }

    });

@sanjum01
Copy link

is it working fine @marcoazeem ? any tips for me? how did you get it worked out??

@marcoazeem
Copy link
Author

marcoazeem commented Dec 21, 2018 via email

@sanjum01
Copy link

Thanks for your comment bro, does each icon on the circle menu leads to new activity connected to that icon? I tried to link one activity with one of the icon by using above code, but its not initiating new activity.. here is the code
package com.example.sanju.circlefinal;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.hitomi.cmlibrary.CircleMenu;
import com.hitomi.cmlibrary.OnMenuSelectedListener;
import com.hitomi.cmlibrary.OnMenuStatusChangeListener;

public class MainActivity extends AppCompatActivity {
CircleMenu circleMenu;
private int indexitem=-1;

String arrayName[]={"Facebook",
                    "Twitter",
                    "Youtube",
                    "Windows",
                    "Drive"};

@Override
protected void onCreate(Bundle savedInstanceState) {
   // private int indexitem =-1;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


     CircleMenu circleMenu = (CircleMenu) findViewById(R.id.circle_menu);
    circleMenu.setMainMenu(Color.parseColor("#CDCDCD"), R.drawable.ic_add, R.drawable.ic_remove)
            .addSubMenu(Color.parseColor("#258CFF"), R.drawable.ic_facebook)
            .addSubMenu(Color.parseColor("#6d4c41"), R.drawable.ic_twitter)
            .addSubMenu(Color.parseColor("#ff0000"), R.drawable.ic_youtube)
            .addSubMenu(Color.parseColor("#03a9f4"), R.drawable.ic_windows)
            .addSubMenu(Color.parseColor("#1a237e"), R.drawable.ic_drive)
            .setOnMenuSelectedListener(new OnMenuSelectedListener() {
                //@Override
                //   public void onMenuSelected(int index) {
                // Toast.makeText(MainActivity.this, "You selected" + arrayName[index], Toast.LENGTH_LONG).show();

                /*public void onClick(View v);
                {
                    Intent i = new Intent(this,fbActivity.class);
                    startActivity(i);
                }

            }

            @Override
            public void onBackPressed() {
                if (circleMenu.isOpened())
                    circleMenu.closeMenu();
                else
                    finish();
            }*/
                @Override

                public void onMenuSelected(int index) {



                }
            }).setOnMenuStatusChangeListener(new OnMenuStatusChangeListener() {

                @Override
                public void onMenuOpened() {
                }

                @Override
                public void onMenuClosed() {

                    switch (indexitem) {
                        case 0:
                            indexitem = -1;
                            Intent intent = new Intent(MainActivity.this, fbActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent.putExtra("tb_category_id", 0);
                            intent.putExtra("tb_category_title", "دسته بندی");
                            startActivity(intent);
                            break;
                        case 1:
                            indexitem = -1;
                          /*  //do something
                            Intent intent = new Intent(MainActivity.this, ytActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent.putExtra("tb_category_id", 0);
                            intent.putExtra("tb_category_title", "دسته بندی");
                            startActivity(intent);*/
                            break;
                        case 2:
                            indexitem = -1;
                            //do something
                            break;
                    }
                }


            });


}}

@sanjum01
Copy link

package com.example.sanju.circlefinal;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class fbActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fb);
}

}

@sanjum01
Copy link

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fbActivity">

<TextView
    android:id="@+id/tvFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="you are in fb activity now"
    tools:layout_editor_absoluteX="163dp"
    tools:layout_editor_absoluteY="122dp" />

</android.support.constraint.ConstraintLayout>

@marcoazeem
Copy link
Author

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fbActivity">

<TextView
    android:id="@+id/tvFacebook"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="you are in fb activity now"
    tools:layout_editor_absoluteX="163dp"
    tools:layout_editor_absoluteY="122dp" />

</android.support.constraint.ConstraintLayout>

`public class Circle extends AppCompatActivity {

CircleMenu circleMenu;
Handler setDelay;
Runnable startDelay;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_circle);

    //Activity Delay
    setDelay = new Handler();

    //Circle Menu Code
    circleMenu = (CircleMenu) findViewById(R.id.circle_menu);

    circleMenu.setMainMenu(Color.parseColor("#c02f34"), R.mipmap.icon_menu, R.mipmap.icon_cancel);
    circleMenu.addSubMenu(Color.parseColor("#c02f34"), R.mipmap.locationwhite)
            .addSubMenu(Color.parseColor("#c02f34"), R.mipmap.calculatorwhite)
            .addSubMenu(Color.parseColor("#c02f34"), R.mipmap.globewhite)
            .addSubMenu(Color.parseColor("#c02f34"), R.mipmap.account);

   //OnClickListener
    circleMenu.setOnMenuSelectedListener(new OnMenuSelectedListener() {

                                             @Override
                                             public void onMenuSelected(int index) {
                                                 switch (index) {
                                                     case 0:
                                                         startDelay = new Runnable() {
                                                             @Override
                                                             public void run() {
                                                                 startActivity(new Intent(Circle.this, track.class)); //this opens new activity
                                                             }
                                                         };

//this sets delay so that the circle goes around fully
setDelay.postDelayed(startDelay, 800);
break;
case 1:
startDelay = new Runnable() {
@OverRide
public void run() {
startActivity(new Intent(Circle.this, calc.class));
}
};
setDelay.postDelayed(startDelay, 800);`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants