Search in sources :

Example 76 with ImageButton

use of android.widget.ImageButton in project SeeSik by GHHM.

the class Calendar_main method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    context = getActivity().getApplicationContext();
    // 월별 캘린더 뷰 객체 참조
    monthView = (GridView) view.findViewById(R.id.monthView);
    monthViewAdapter = new MonthAdapter(context);
    monthView.setAdapter(monthViewAdapter);
    monthText = (TextView) view.findViewById(R.id.monthText);
    setMonthText();
    // 이전 월로 넘어가는 이벤트 처리
    ImageButton monthPrevious = (ImageButton) view.findViewById(R.id.monthPrevious);
    monthPrevious.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            monthViewAdapter.setPreviousMonth();
            monthViewAdapter.notifyDataSetChanged();
            setMonthText();
        }
    });
    // 다음 월로 넘어가는 이벤트 처리
    ImageButton monthNext = (ImageButton) view.findViewById(R.id.monthNext);
    monthNext.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            monthViewAdapter.setNextMonth();
            monthViewAdapter.notifyDataSetChanged();
            setMonthText();
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) GridView(android.widget.GridView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 77 with ImageButton

use of android.widget.ImageButton in project chefly_android by chef-ly.

the class RecipeDetailActivity method setRecipeInfo.

private void setRecipeInfo() {
    final Context c = getApplicationContext();
    TextView author = (TextView) findViewById(R.id.recipeAuthor);
    // TextView description = (TextView) findViewById(R.id.recipeDescription);
    TextView serves = (TextView) findViewById(R.id.recipeServings);
    TextView time = (TextView) findViewById(R.id.recipeTime);
    String recipeName;
    Step[] directions;
    if (recipeDetail == null) {
        recipeTitle.setText(R.string.recipeNotFound);
    } else {
        recipeName = recipeDetail.getTitle();
        recipeTitle.setText(recipeName);
        author.setText(recipeDetail.getCreditText());
        int servings = recipeDetail.getServings();
        Log.d(TAG, "Serves -> " + servings);
        if (servings <= 0) {
            serves.setText(R.string.unknown);
        } else {
            serves.setText(String.valueOf(servings));
        }
        int cookTime = recipeDetail.getReadyInMinutes();
        int hour = 0;
        while (cookTime >= 60) {
            hour++;
            cookTime = cookTime - 60;
        }
        String newTime;
        if (hour < 2) {
            newTime = (hour != 0) ? hour + " hr " : "";
        } else {
            newTime = (hour != 0) ? hour + " hrs " : "";
        }
        newTime += ((cookTime > 0) ? cookTime + " min" : "");
        if (newTime.isEmpty()) {
            time.setText(R.string.unknown);
        } else {
            time.setText(newTime);
        }
        new AsyncTask<RequestMethod, Integer, Long>() {

            Bitmap image = null;

            @Override
            protected Long doInBackground(RequestMethod... params) {
                try {
                    URL url = new URL(recipeDetail.getImage());
                    image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
                } catch (IOException e) {
                    Log.d(TAG, "IOException on load image");
                    Log.d(TAG, e.getMessage());
                }
                return 1L;
            }

            @Override
            protected void onPostExecute(Long aLong) {
                if (image != null) {
                    imageView.setImageBitmap(image);
                }
            }
        }.execute();
        ingredients = recipeDetail.getExtendedIngredients();
        if (recipeDetail.getAnalyzedInstructions().length > 0) {
            directions = recipeDetail.getAnalyzedInstructions()[0].getSteps();
        } else {
            directions = new Step[] { new Step(recipeDetail.getInstructions()) };
        }
        //            checkBoxes = new CheckBox[ingredients.length];
        //            int states[][] = {{android.R.attr.state_checked}, {}};
        TableLayout table = (TableLayout) findViewById(R.id.ingredientGroup);
        TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        int leftMargin = 30;
        int topMargin = 1;
        int rightMargin = 30;
        int bottomMargin = 1;
        tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
        int color1 = getColor(c, R.color.table_color1);
        int color2 = getColor(c, R.color.table_color2);
        int count = 0;
        for (ExtendedIngredient s : ingredients) {
            final TableRow row = new TableRow(c);
            row.setLayoutParams(tableRowParams);
            row.setBackgroundColor(count % 2 == 0 ? color1 : color2);
            row.setPadding(10, 5, 10, 5);
            TextView text = new TextView(c);
            text.setText(s.getOriginalString());
            text.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.black));
            text.setTextSize((getResources().getDimension(R.dimen.text_small) / getResources().getDisplayMetrics().density));
            text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1f));
            text.setPadding(10, 5, 10, 5);
            text.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ImageView image = (ImageView) row.getChildAt(1);
                    String text = String.valueOf(((TextView) row.getChildAt(0)).getText());
                    if (row.getChildAt(1).getVisibility() == View.GONE) {
                        image.setVisibility(View.VISIBLE);
                        shoppingList.add(new ShoppingListItem(text, false));
                        Toast.makeText(c, text + " added to shopping list", Toast.LENGTH_SHORT).show();
                    } else {
                        image.setVisibility(View.GONE);
                        shoppingList.remove(new ShoppingListItem(text, false));
                        Toast.makeText(c, text + " removed from shopping list", Toast.LENGTH_SHORT).show();
                    }
                }
            });
            row.addView(text);
            ImageView check = new ImageView(c);
            check.setImageResource(R.drawable.shoppinglist);
            check.setLayoutParams(new TableRow.LayoutParams(60, 60, 0.1f));
            if (shoppingList.contains(new ShoppingListItem(s.getOriginalString(), false))) {
                check.setVisibility(View.VISIBLE);
            } else {
                check.setVisibility(View.GONE);
            }
            row.addView(check);
            table.addView(row);
            count++;
        }
        //
        final TableLayout tableDirec = (TableLayout) findViewById(R.id.directionGroup);
        tableDirec.setColumnShrinkable(0, true);
        tableDirec.setVisibility(View.GONE);
        directionsForCooking = new String[directions.length];
        count = 1;
        for (Step s : directions) {
            String step = count + ")  " + s.getStep();
            TableRow row = new TableRow(c);
            row.setLayoutParams(tableRowParams);
            row.setBackgroundColor(count % 2 == 0 ? color1 : color2);
            TextView text = new TextView(c);
            text.setText(step);
            text.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.black));
            text.setTextSize((getResources().getDimension(R.dimen.text_small) / getResources().getDisplayMetrics().density));
            text.setPadding(15, 1, 15, 1);
            text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1f));
            row.addView(text);
            tableDirec.addView(row);
            directionsForCooking[count - 1] = s.getStep();
            count++;
        }
        final ScrollView sv = (ScrollView) findViewById(R.id.scrollView);
        final ImageButton dropdown = (ImageButton) findViewById(R.id.directionsDropdown);
        final RotateAnimation rotatedown = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotatedown.setDuration(250);
        rotatedown.setFillAfter(true);
        final RotateAnimation rotateup = new RotateAnimation(180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotateup.setDuration(250);
        rotateup.setFillAfter(true);
        dropdown.setOnClickListener(new View.OnClickListener() {

            private boolean isClicked = false;

            @Override
            public void onClick(View v) {
                if (!isClicked) {
                    tableDirec.setVisibility(View.VISIBLE);
                    dropdown.startAnimation(rotatedown);
                    isClicked = true;
                    sv.post(new Runnable() {

                        @Override
                        public void run() {
                            //sv.fullScroll(ScrollView.FOCUS_DOWN);
                            sv.smoothScrollBy(0, 500);
                        }
                    });
                } else {
                    dropdown.startAnimation(rotateup);
                    tableDirec.setVisibility(View.GONE);
                    isClicked = false;
                //sv.fullScroll(ScrollView.FOCUS_DOWN);
                }
            }
        });
    }
}
Also used : RequestMethod(com.se491.chef_ly.http.RequestMethod) Step(com.se491.chef_ly.model.Step) ExtendedIngredient(com.se491.chef_ly.model.ExtendedIngredient) URL(java.net.URL) RotateAnimation(android.view.animation.RotateAnimation) Bitmap(android.graphics.Bitmap) ImageButton(android.widget.ImageButton) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TableLayout(android.widget.TableLayout) Context(android.content.Context) IOException(java.io.IOException) ShoppingListItem(com.se491.chef_ly.model.ShoppingListItem) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ScrollView(android.widget.ScrollView) TableRow(android.widget.TableRow)

Example 78 with ImageButton

use of android.widget.ImageButton in project chefly_android by chef-ly.

the class MainActivity method setupViews.

private void setupViews() {
    try {
        Button signInBtn;
        TextView continueAsGuest;
        TextView signUp;
        ImageButton webLoginButton = (ImageButton) findViewById(R.id.webLoginButton);
        webLoginButton.setOnClickListener(this);
        ImageButton googleLoginButton = (ImageButton) findViewById(R.id.googleLoginButton);
        googleLoginButton.setOnClickListener(this);
        username = (EditText) findViewById(R.id.useremail);
        password = (EditText) findViewById(R.id.password);
        signInBtn = (Button) findViewById(R.id.signInBtn);
        signInBtn.setOnClickListener(this);
        continueAsGuest = (TextView) findViewById(R.id.continueAsGuest);
        continueAsGuest.setOnClickListener(this);
        signUp = (TextView) findViewById(R.id.signUp);
        signUp.setOnClickListener(this);
    } catch (NullPointerException e) {
        Log.d(TAG, "Failed to set views");
    }
}
Also used : ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) TextView(android.widget.TextView)

Example 79 with ImageButton

use of android.widget.ImageButton in project android_frameworks_base by crdroidandroid.

the class SimplePlayer method set.

public void set(Context context, int playPausebuttonId, ImageView playPausebutton, int stopButtonId, ImageView stopButton, TextView sessionText, int stream, int session) {
    mContext = context;
    mPlayPauseButtonId = playPausebuttonId;
    mStopButtonId = stopButtonId;
    mPlayPauseButton = (ImageButton) playPausebutton;
    ImageButton stop = (ImageButton) stopButton;
    mPlayPauseButton.setOnClickListener(this);
    mPlayPauseButton.requestFocus();
    stop.setOnClickListener(this);
    mPlayImageResource = android.R.drawable.ic_media_play;
    mPauseImageResource = android.R.drawable.ic_media_pause;
    mStreamType = stream;
    mSession = session;
    mSessionText = sessionText;
}
Also used : ImageButton(android.widget.ImageButton)

Example 80 with ImageButton

use of android.widget.ImageButton in project android_frameworks_base by crdroidandroid.

the class ManualActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.manual_layout);
    onCreateCommon(mRunnable);
    mSoftwareView = (MainView) findViewById(R.id.software_view);
    mSoftwareView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    mSoftwareView.setBackgroundColor(Color.WHITE);
    mSoftwareView.addDrawCallback(mDrawCallback);
    mCompareImageView = (ImageView) findViewById(R.id.compare_image_view);
    int width = getResources().getDimensionPixelSize(R.dimen.layer_width);
    int height = getResources().getDimensionPixelSize(R.dimen.layer_height);
    mCompareBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    mErrorTextView = (TextView) findViewById(R.id.current_error);
    ((ImageButton) findViewById(R.id.next)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DisplayModifier.step();
            updateSpinners();
            redrawViews();
        }
    });
    ((ImageButton) findViewById(R.id.previous)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DisplayModifier.stepBack();
            updateSpinners();
            redrawViews();
        }
    });
    ((Button) findViewById(R.id.show_hardware_version)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mCompareImageViewState = COMPARE_VIEW_HARDWARE;
            mHandler.post(mRunnable);
        }
    });
    ((Button) findViewById(R.id.show_software_version)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mCompareImageViewState = COMPARE_VIEW_SOFTWARE;
            mHandler.post(mRunnable);
        }
    });
    ((Button) findViewById(R.id.show_error_heatmap)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mCompareImageViewState = COMPARE_VIEW_HEATMAP;
            mHandler.post(mRunnable);
        }
    });
    buildSpinnerLayout();
}
Also used : ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

ImageButton (android.widget.ImageButton)149 View (android.view.View)105 TextView (android.widget.TextView)83 ImageView (android.widget.ImageView)51 Button (android.widget.Button)26 ListView (android.widget.ListView)24 AdapterView (android.widget.AdapterView)23 OnClickListener (android.view.View.OnClickListener)21 LinearLayout (android.widget.LinearLayout)19 Intent (android.content.Intent)18 RelativeLayout (android.widget.RelativeLayout)13 DialogInterface (android.content.DialogInterface)11 Bundle (android.os.Bundle)11 LayoutInflater (android.view.LayoutInflater)11 EditText (android.widget.EditText)11 ViewGroup (android.view.ViewGroup)10 ArrayList (java.util.ArrayList)10 Builder (android.app.AlertDialog.Builder)7 MenuItem (android.view.MenuItem)7 Drawable (android.graphics.drawable.Drawable)6