Android Open Source - BrokenDisplay Overview Fragment






From Project

Back to project page BrokenDisplay.

License

The source code is released under:

Apache License

If you think the Android project BrokenDisplay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.foolish.brokendisplay;
/*  ww w.ja  va2s  .co m*/
import com.foolish.brokendisplay.picturedialog.IOnSelectPictureDialog;
import com.foolish.brokendisplay.picturedialog.SelectPictureDialog;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ToggleButton;

public class OverviewFragment extends Fragment implements
    IOnSelectPictureDialog {
  public static int IMAGE_RESOURCE = -1;
  private Intent serviceIntent;

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    
    serviceIntent = new Intent(getActivity(),
        BrokenGlassService.class);

    // rootview
    LinearLayout rootView = new LinearLayout(getActivity());
    rootView.setOrientation(LinearLayout.VERTICAL);

    LinearLayout picture_Layout = new LinearLayout(getActivity());
    picture_Layout.setLayoutParams(new LayoutParams(
        LayoutParams.MATCH_PARENT, (int) getActivity().getResources()
            .getDimension(R.dimen.activity_layout_height)));
    picture_Layout.setOrientation(LinearLayout.HORIZONTAL);

    TextView picture_Text = new TextView(getActivity());
    picture_Text.setLayoutParams(new LinearLayout.LayoutParams(0,
        LayoutParams.WRAP_CONTENT, 0.4f));
    picture_Text.setText(R.string.picture);
    picture_Text
        .setTextSize(
            TypedValue.COMPLEX_UNIT_PX,
            getActivity().getResources().getDimensionPixelSize(
                R.dimen.header_text_size));

    Button picture_Button = new Button(getActivity());
    picture_Button.setLayoutParams(new LinearLayout.LayoutParams(0,
        LayoutParams.WRAP_CONTENT, 0.6f));
    picture_Button
        .setTextSize(
            TypedValue.COMPLEX_UNIT_PX,
            getActivity().getResources().getDimensionPixelSize(
                R.dimen.header_text_size));
    picture_Button.setText(getActivity().getResources().getText(
        R.string.picture));
    picture_Button.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        FragmentManager fm = ((FragmentActivity) getActivity())
            .getSupportFragmentManager();
        SelectPictureDialog dialog = new SelectPictureDialog();

        dialog.show(fm, null);

      }
    });
    picture_Layout.addView(picture_Text);
    picture_Layout.addView(picture_Button);
    LinearLayout control_Layout = new LinearLayout(getActivity());
    control_Layout.setLayoutParams(new LayoutParams(
        LayoutParams.MATCH_PARENT, (int) getActivity().getResources()
            .getDimension(R.dimen.activity_layout_height)));
    control_Layout.setOrientation(LinearLayout.HORIZONTAL);
    TextView control_Text = new TextView(getActivity());
    control_Text.setLayoutParams(new LinearLayout.LayoutParams(0,
        LayoutParams.WRAP_CONTENT, 0.4f));
    control_Text.setText(R.string.status);
    control_Text
        .setTextSize(
            TypedValue.COMPLEX_UNIT_PX,
            getActivity().getResources().getDimensionPixelSize(
                R.dimen.header_text_size));

    ToggleButton onToggle = new ToggleButton(getActivity());
    onToggle.setLayoutParams(new LinearLayout.LayoutParams(0,
        LayoutParams.WRAP_CONTENT, 0.6f));
    onToggle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getActivity()
        .getResources().getDimensionPixelSize(R.dimen.header_text_size));
    onToggle.setChecked(BrokenGlassService.IsRunning);

    onToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
      public void onCheckedChanged(CompoundButton buttonView,
          boolean isChecked) {
        if (isChecked) {
          

          getActivity().startService(serviceIntent);
        } else {
          getActivity().stopService(serviceIntent);
        }
      }
    });

    // Test
    Button btnTest = new Button(getActivity());
    btnTest.setText("Test");
    btnTest.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        startActivity(new Intent(getActivity(),
            OverlayEditorActivity.class));
      }
    });
    control_Layout.addView(btnTest);

    control_Layout.addView(control_Text);
    control_Layout.addView(onToggle);
    rootView.addView(picture_Layout);
    rootView.addView(control_Layout);
    return rootView;
  }

  @Override
  public void onPicture(int picture) {
    IMAGE_RESOURCE = picture;

  }

}




Java Source Code List

com.foolish.brokendisplay.BrokenDisplayActivity.java
com.foolish.brokendisplay.BrokenGlassService.java
com.foolish.brokendisplay.ItemDetailActivity.java
com.foolish.brokendisplay.ItemDetailFragment.java
com.foolish.brokendisplay.ItemListActivity.java
com.foolish.brokendisplay.ItemListFragment.java
com.foolish.brokendisplay.MyImageView.java
com.foolish.brokendisplay.OnSwipeTouchListener.java
com.foolish.brokendisplay.OverlayEditorActivity.java
com.foolish.brokendisplay.OverlayEditorFragment.java
com.foolish.brokendisplay.OverviewFragment.java
com.foolish.brokendisplay.dummy.DummyContent.java
com.foolish.brokendisplay.picturedialog.BitmapWorkerTask.java
com.foolish.brokendisplay.picturedialog.IOnSelectPictureDialog.java
com.foolish.brokendisplay.picturedialog.Picture_GridAdapter.java
com.foolish.brokendisplay.picturedialog.SelectPictureDialog.java