finished slideshow mode
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package com.mhalka.qurantranslationdisplay;
|
||||
|
||||
import com.mhalka.qurantranslationdisplay.VerticalMarqueeTextView.ScrollingStoppedListener;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.AssetManager;
|
||||
import android.os.Bundle;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
@@ -19,7 +23,11 @@ import android.widget.TextView;
|
||||
*/
|
||||
public class ShowAyah extends Activity {
|
||||
|
||||
private static int NUMBER_OF_MILISECONDS_TO_READ_ONE_LINE = 2500;
|
||||
private VerticalMarqueeTextView ayah;
|
||||
private TextView chapterName;
|
||||
int currentChapter=1;
|
||||
int currentVerse=1;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -28,32 +36,83 @@ public class ShowAyah extends Activity {
|
||||
|
||||
setContentView(R.layout.activity_show_ayah);
|
||||
ayah = (VerticalMarqueeTextView) findViewById(R.id.ayah);
|
||||
chapterName = (TextView) findViewById(R.id.chapter_name_verse_number);
|
||||
ayah.setMovementMethod(new ScrollingMovementMethod());
|
||||
ayah.pauseMarquee();
|
||||
ayah.setDuration(150);
|
||||
ayah.setPixelYOffSet(10);
|
||||
|
||||
|
||||
//
|
||||
// DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
//
|
||||
// TranslateAnimation m_ta = new TranslateAnimation(0f,0f, dm.heightPixels, -1 * (dm.heightPixels));
|
||||
//
|
||||
// m_ta.setDuration(10000);
|
||||
// m_ta.setInterpolator(new LinearInterpolator());
|
||||
// m_ta.setRepeatCount(Animation.INFINITE);
|
||||
//
|
||||
//
|
||||
// ayah.startAnimation(m_ta);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ayah.setPixelYOffSet(ayah.getMaxLines() * ayah.getLineHeight());
|
||||
|
||||
ayah.setOnScrollingStoppedListener(new ScrollingStoppedListener() {
|
||||
|
||||
@Override
|
||||
public void scrollingStopped(VerticalMarqueeTextView v) {
|
||||
nextAyah();
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
showAyah(currentChapter, currentVerse);
|
||||
|
||||
|
||||
// Example of use of QuranReader
|
||||
// AssetManager assetManager = getAssets();
|
||||
// QuranReader reader = new QuranReader(assetManager, "quran_content");
|
||||
// reader.setChapter(2);
|
||||
// String verseText = reader.getVerse(16);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void nextAyah() {
|
||||
currentVerse++;
|
||||
boolean verseExists = showAyah(currentChapter, currentVerse);
|
||||
if (!verseExists) {
|
||||
currentChapter++;
|
||||
if(currentChapter > 114)currentChapter = 1;
|
||||
currentVerse = 1;
|
||||
showAyah(currentChapter, currentVerse);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean showAyah(int chapter, int verse ) {
|
||||
|
||||
|
||||
|
||||
try {
|
||||
ayah.setText("");
|
||||
ayah.scrollTo(0, 0);
|
||||
AssetManager assetManager = getAssets();
|
||||
QuranReader reader = new QuranReader(assetManager, "quran_content");
|
||||
reader.setChapter(chapter);
|
||||
String verseText = reader.getVerse(verse);
|
||||
|
||||
if(verseText.equals("")) return false;
|
||||
// Start or restart the Marquee if paused.
|
||||
|
||||
|
||||
ayah.setText(verseText);
|
||||
chapterName.setText(reader.getChapterName() + " " + String.valueOf(chapter) + ":" + String.valueOf(verse));
|
||||
int duration = ayah.getLineCount() * NUMBER_OF_MILISECONDS_TO_READ_ONE_LINE;
|
||||
|
||||
// let them reflect a bit on one liners ! :) (also solves a bug )
|
||||
if(duration <= NUMBER_OF_MILISECONDS_TO_READ_ONE_LINE) duration = 2 * NUMBER_OF_MILISECONDS_TO_READ_ONE_LINE;
|
||||
if(ayah.getLineCount() > ayah.getMaxLines()) duration = ayah.getMaxLines() * NUMBER_OF_MILISECONDS_TO_READ_ONE_LINE;
|
||||
ayah.setDuration(duration);
|
||||
if (ayah.isPaused()) {
|
||||
ayah.resumeMarquee();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.d("SHOWAYAH",e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void onResume() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user