Back to project page Musicdroid.
The source code is released under:
GNU General Public License
If you think the Android project Musicdroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Musicdroid: An on-device music generator for Android * Copyright (C) 2010-2014 The Catrobat Team * (<http://developer.catrobat.org/credits>) *//from w ww . jav a2 s. co m * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * An additional term exception under section 7 of the GNU Affero * General Public License, version 3, is available at * http://developer.catrobat.org/license_additional_term * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.catrobat.musicdroid.pocketmusic.instrument.piano; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.HorizontalScrollView; import org.catrobat.musicdroid.pocketmusic.R; import org.catrobat.musicdroid.pocketmusic.instrument.InstrumentActivity; import org.catrobat.musicdroid.pocketmusic.instrument.noteSheet.NoteSheetViewFragment; import org.catrobat.musicdroid.pocketmusic.note.MusicalInstrument; import org.catrobat.musicdroid.pocketmusic.note.MusicalKey; public class PianoActivity extends InstrumentActivity { private PianoViewFragment pianoViewFragment; private NoteSheetViewFragment noteSheetViewFragment; public PianoActivity() { super(MusicalKey.VIOLIN, MusicalInstrument.ACOUSTIC_GRAND_PIANO); } public PianoViewFragment getPianoViewFragment() { return pianoViewFragment; } public NoteSheetViewFragment getNoteSheetViewFragment() { return noteSheetViewFragment; } public String getTrackSizeString(){ return noteSheetViewFragment.getTrackSizeTextViewText(); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_piano); noteSheetViewFragment = new NoteSheetViewFragment(); pianoViewFragment = new PianoViewFragment(); if (savedInstanceState != null) { getFragmentManager().beginTransaction().replace(R.id.container, noteSheetViewFragment).commit(); getFragmentManager().beginTransaction().replace(R.id.container, pianoViewFragment).commit(); } else { getFragmentManager().beginTransaction().add(R.id.container, noteSheetViewFragment).commit(); getFragmentManager().beginTransaction().add(R.id.container, pianoViewFragment).commit(); } } @Override protected void onStart() { super.onStart(); noteSheetViewFragment.redraw(getTrack()); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.piano, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } // TODO fw add test for this?! @Override protected void redraw() { noteSheetViewFragment.redraw(getTrack()); } public void scrollNoteSheet() { if (noteSheetViewFragment.checkForScrollAndRecalculateWidth()) { HorizontalScrollView hv = (HorizontalScrollView) findViewById(R.id.scroll_note_sheet_view); hv.fullScroll(HorizontalScrollView.FOCUS_RIGHT); } } }