Esempio n. 1
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   if (savedInstanceState != null && AccountManager.getInstance() == null) {
     return null;
   }
   View rootView = inflater.inflate(R.layout.fragment_edit, container, false);
   mContainer = (LinearLayout) rootView.findViewById(android.R.id.list);
   View footer = inflater.inflate(R.layout.add_field, container, false);
   footer.setOnClickListener(this);
   mNameEditText = (EditText) rootView.findViewById(android.R.id.title);
   mScroll = (PbScrollView) rootView.findViewById(R.id.scroll);
   mNameEditText.addTextChangedListener(this);
   mToolbarContainer = rootView.findViewById(R.id.toolbar_container);
   if (mToolbarContainer != null) {
     mHeader = rootView.findViewById(R.id.header);
     mScroll.setPbScrollListener(this);
   }
   setupToolbar(rootView);
   mCategorySpinner = (Spinner) rootView.findViewById(R.id.category);
   if (mAccountId >= 0) {
     mDummyAccount = AccountManager.getInstance().getAccountById(mAccountId).clone();
     mName = mDummyAccount.getAccountName();
   } else {
     mDummyAccount = getEntryList();
     mName = "";
   }
   int spinnerLayout =
       android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN
           ? android.R.layout.simple_spinner_dropdown_item
           : R.layout.spinner_dropdown;
   mTypeAdapter =
       ArrayAdapter.createFromResource(
           getActivity(), R.array.field_types, android.R.layout.simple_spinner_dropdown_item);
   mTypeAdapter.setDropDownViewResource(spinnerLayout);
   mEntries = new ArrayList<>();
   mDeleteView = (ImageView) inflater.inflate(R.layout.delete_field, container, false);
   int pos = 0;
   for (Entry e : mDummyAccount.getEntryList()) {
     onAddField(e, pos++);
   }
   mContainer.addView(footer);
   mContainer.addView(mDeleteView);
   mDeleteView.setOnDragListener(mDragListener);
   ArrayAdapter<String> spinnerAdapter =
       new ArrayAdapter<>(
           getActivity(),
           android.R.layout.simple_spinner_dropdown_item,
           Application.getSortedCategoryNames());
   spinnerAdapter.setDropDownViewResource(spinnerLayout);
   mCategorySpinner.setAdapter(spinnerAdapter);
   mCategorySpinner.setOnItemSelectedListener(this);
   View top = rootView.findViewById(R.id.top_frame);
   if (top != null) {
     top.setOnClickListener(this);
   }
   return rootView;
 }
Esempio n. 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
            WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

    super.onCreate(savedInstanceState);
    if (mainmenu.height <= 480) {
      setContentView(R.layout.puzzle1small);
    } else {
      setContentView(R.layout.puzzle2);
    }
    p3lay = (RelativeLayout) findViewById(R.id.mainlay);
    p3lay.setBackgroundResource(R.drawable.p3bg);
    mp = new playaudio(getApplicationContext(), R.raw.puzzle3);
    mp.start();
    p3imgv1 = (ImageView) findViewById(R.id.ltop);
    p3imgv2 = (ImageView) findViewById(R.id.lmiddle);
    p3imgv3 = (ImageView) findViewById(R.id.lbottom);
    p3imgv4 = (ImageView) findViewById(R.id.mtop);
    p3imgv5 = (ImageView) findViewById(R.id.mmiddle);
    p3imgv6 = (ImageView) findViewById(R.id.mbottom);
    p3imgv7 = (ImageView) findViewById(R.id.rmost);
    p3imgv4.bringToFront();
    p3imgv1.setOnDragListener(new Mydraglistner());
    p3imgv2.setOnDragListener(new Mydraglistner());
    p3imgv3.setOnDragListener(new Mydraglistner());
    p3imgv4.setOnDragListener(new Mydraglistner());
    p3imgv5.setOnDragListener(new Mydraglistner());
    p3imgv6.setOnDragListener(new Mydraglistner());
    p3imgv7.setOnDragListener(new Mydraglistner());

    p3dragv = (ImageView) findViewById(R.id.pdragv);

    p3dragv.setImageResource(R.drawable.p2img7);

    p3dragv.setOnTouchListener(new Mytouchlistener());
  }
Esempio n. 3
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {

    Log.d(TAG, "onCreate()");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Setup the basket
    ImageView basketImageView = (ImageView) this.findViewById(R.id.basketImageView);
    basketImageView.setOnDragListener(this);

    // Add an onClickListener to all the children
    LinearLayout itemsLinearLayout = (LinearLayout) this.findViewById(R.id.itemsLinearLayout);
    int childCount = itemsLinearLayout.getChildCount();
    for (int i = 0; i < childCount; i++) {

      itemsLinearLayout.getChildAt(i).setOnLongClickListener(this);
      itemsLinearLayout.getChildAt(i).setOnDragListener(this);
    }
  }
Esempio n. 4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.draganddropmain);

    imageView = (ImageView) findViewById(R.id.imageView);
    mIconBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    imageView.setImageBitmap(mIconBitmap);
    imageView.setTag(IMAGEVIEW_TAG);
    imageView.setOnLongClickListener(
        new View.OnLongClickListener() {
          public boolean onLongClick(View v) {
            Toast.makeText(DragAndDropActivity.this, "ImageView is LongClicked", Toast.LENGTH_SHORT)
                .show();
            ClipData.Item item = new ClipData.Item((CharSequence) v.getTag());
            String[] mimeTypes = {ClipDescription.MIMETYPE_TEXT_PLAIN};
            ClipData dragData = new ClipData((CharSequence) v.getTag(), mimeTypes, item);
            DragShadowBuilder myShadow = new MyDragShadowBuilder(imageView);
            return v.startDrag(dragData, myShadow, null, 0);
          }
        });
    ImageView dropView = (ImageView) findViewById(R.id.dropView);
    dropView.setOnDragListener(mDragListen);
  }
Esempio n. 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bridget);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    mTitle = mDrawerTitle = getTitle();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (GridView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ImageAdapter(this, ALPHABET));

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerList.setOnDragListener(new DrawerItemDragListener());

    // views to drop onto
    block5 = (ImageView) findViewById(R.id.myanswer5);
    block6 = (ImageView) findViewById(R.id.myanswer6);
    block7 = (ImageView) findViewById(R.id.myanswer7);
    block8 = (ImageView) findViewById(R.id.myanswer8);

    // set drag listener
    block5.setOnDragListener(new ChoiceDragListener());
    block6.setOnDragListener(new ChoiceDragListener());
    block7.setOnDragListener(new ChoiceDragListener());
    block8.setOnDragListener(new ChoiceDragListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle =
        new ActionBarDrawerToggle(
            this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */) {
          public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }

          public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()

            // view to drag
            blocka = (ImageView) findViewById(R.id.myimage1);
            blockb = (ImageView) findViewById(R.id.myimage2);
            blockc = (ImageView) findViewById(R.id.myimage3);
            blockd = (ImageView) findViewById(R.id.myimage4);
            blocke = (ImageView) findViewById(R.id.myimage5);
            blockf = (ImageView) findViewById(R.id.myimage6);
            blockg = (ImageView) findViewById(R.id.myimage7);
            blockh = (ImageView) findViewById(R.id.myimage8);
            blocki = (ImageView) findViewById(R.id.myimage9);
            blockj = (ImageView) findViewById(R.id.myimage10);
            blockk = (ImageView) findViewById(R.id.myimage11);
            blockl = (ImageView) findViewById(R.id.myimage12);
            blockm = (ImageView) findViewById(R.id.myimage13);
            blockn = (ImageView) findViewById(R.id.myimage14);
            blocko = (ImageView) findViewById(R.id.myimage15);
            blockp = (ImageView) findViewById(R.id.myimage16);
            blockq = (ImageView) findViewById(R.id.myimage17);
            blockr = (ImageView) findViewById(R.id.myimage18);
            blocks = (ImageView) findViewById(R.id.myimage19);
            blockt = (ImageView) findViewById(R.id.myimage20);
            blocku = (ImageView) findViewById(R.id.myimage21);
            blockv = (ImageView) findViewById(R.id.myimage22);
            blockw = (ImageView) findViewById(R.id.myimage23);
            blockx = (ImageView) findViewById(R.id.myimage24);
            blocky = (ImageView) findViewById(R.id.myimage25);
            blockz = (ImageView) findViewById(R.id.myimage26);

            // set touch listener
            blocka.setOnTouchListener(new ChoiceTouchListener());
            blockb.setOnTouchListener(new ChoiceTouchListener());
            blockc.setOnTouchListener(new ChoiceTouchListener());
            blockd.setOnTouchListener(new ChoiceTouchListener());
            blocke.setOnTouchListener(new ChoiceTouchListener());
            blockf.setOnTouchListener(new ChoiceTouchListener());
            blockg.setOnTouchListener(new ChoiceTouchListener());
            blockh.setOnTouchListener(new ChoiceTouchListener());
            blocki.setOnTouchListener(new ChoiceTouchListener());
            blockj.setOnTouchListener(new ChoiceTouchListener());
            blockk.setOnTouchListener(new ChoiceTouchListener());
            blockl.setOnTouchListener(new ChoiceTouchListener());
            blockm.setOnTouchListener(new ChoiceTouchListener());
            blockn.setOnTouchListener(new ChoiceTouchListener());
            blocko.setOnTouchListener(new ChoiceTouchListener());
            blockp.setOnTouchListener(new ChoiceTouchListener());
            blockq.setOnTouchListener(new ChoiceTouchListener());
            blockr.setOnTouchListener(new ChoiceTouchListener());
            blocks.setOnTouchListener(new ChoiceTouchListener());
            blockt.setOnTouchListener(new ChoiceTouchListener());
            blocku.setOnTouchListener(new ChoiceTouchListener());
            blockv.setOnTouchListener(new ChoiceTouchListener());
            blockw.setOnTouchListener(new ChoiceTouchListener());
            blockx.setOnTouchListener(new ChoiceTouchListener());
            blocky.setOnTouchListener(new ChoiceTouchListener());
            blockz.setOnTouchListener(new ChoiceTouchListener());
          }
        };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
      selectItem(0);
    }
  }