|
@ -1,5 +1,7 @@ |
|
|
package gr.thmmy.mthmmy.activities; |
|
|
package gr.thmmy.mthmmy.activities; |
|
|
|
|
|
|
|
|
|
|
|
import android.animation.Animator; |
|
|
|
|
|
import android.animation.AnimatorListenerAdapter; |
|
|
import android.annotation.TargetApi; |
|
|
import android.annotation.TargetApi; |
|
|
import android.content.Context; |
|
|
import android.content.Context; |
|
|
import android.content.Intent; |
|
|
import android.content.Intent; |
|
@ -130,6 +132,12 @@ public class TopicActivity extends BaseActivity { |
|
|
// Increment once for a click
|
|
|
// Increment once for a click
|
|
|
increment.setOnClickListener(new View.OnClickListener() { |
|
|
increment.setOnClickListener(new View.OnClickListener() { |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
|
|
|
|
if(!autoIncrement && step == LARGE_STEP){ //If just clicked go to last page
|
|
|
|
|
|
changePage(numberOfPages - 1); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
//Clicked and holden
|
|
|
|
|
|
autoIncrement = false; //Stop incrementing
|
|
|
increment(step); |
|
|
increment(step); |
|
|
changePage(pageValue - 1); |
|
|
changePage(pageValue - 1); |
|
|
} |
|
|
} |
|
@ -140,17 +148,16 @@ public class TopicActivity extends BaseActivity { |
|
|
new View.OnLongClickListener(){ |
|
|
new View.OnLongClickListener(){ |
|
|
public boolean onLongClick(View arg0) { |
|
|
public boolean onLongClick(View arg0) { |
|
|
autoIncrement = true; |
|
|
autoIncrement = true; |
|
|
repeatUpdateHandler.postDelayed(new RepetetiveUpdater(step), INITIAL_DELAY); |
|
|
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// When the button is released, if we're auto incrementing, stop
|
|
|
// When the button is released
|
|
|
increment.setOnTouchListener( new View.OnTouchListener() { |
|
|
increment.setOnTouchListener( new View.OnTouchListener() { |
|
|
public boolean onTouch(View v, MotionEvent event) { |
|
|
public boolean onTouch(View v, MotionEvent event) { |
|
|
if( event.getAction() == MotionEvent.ACTION_UP && autoIncrement ){ |
|
|
if( event.getAction() == MotionEvent.ACTION_UP && autoIncrement ){ |
|
|
autoIncrement = false; |
|
|
|
|
|
changePage(pageValue - 1); |
|
|
changePage(pageValue - 1); |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
@ -162,6 +169,12 @@ public class TopicActivity extends BaseActivity { |
|
|
// Decrement once for a click
|
|
|
// Decrement once for a click
|
|
|
decrement.setOnClickListener(new View.OnClickListener() { |
|
|
decrement.setOnClickListener(new View.OnClickListener() { |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
|
|
|
|
if(!autoDecrement && step == LARGE_STEP){ //If just clicked go to first page
|
|
|
|
|
|
changePage(0); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
//Clicked and holden
|
|
|
|
|
|
autoDecrement = false; //Stop incrementing
|
|
|
decrement(step); |
|
|
decrement(step); |
|
|
changePage(pageValue - 1); |
|
|
changePage(pageValue - 1); |
|
|
} |
|
|
} |
|
@ -173,28 +186,29 @@ public class TopicActivity extends BaseActivity { |
|
|
new View.OnLongClickListener(){ |
|
|
new View.OnLongClickListener(){ |
|
|
public boolean onLongClick(View arg0) { |
|
|
public boolean onLongClick(View arg0) { |
|
|
autoDecrement = true; |
|
|
autoDecrement = true; |
|
|
repeatUpdateHandler.postDelayed( new RepetetiveUpdater(step), INITIAL_DELAY); |
|
|
repeatUpdateHandler.postDelayed( new RepetitiveUpdater(step), INITIAL_DELAY); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// When the button is released, if we're auto decrementing, stop
|
|
|
// When the button is released
|
|
|
decrement.setOnTouchListener( new View.OnTouchListener() { |
|
|
decrement.setOnTouchListener( new View.OnTouchListener() { |
|
|
public boolean onTouch(View v, MotionEvent event) { |
|
|
public boolean onTouch(View v, MotionEvent event) { |
|
|
if( event.getAction() == MotionEvent.ACTION_UP && autoDecrement ){ |
|
|
if( event.getAction() == MotionEvent.ACTION_UP && autoDecrement ){ |
|
|
autoDecrement = false; |
|
|
|
|
|
changePage(pageValue - 1); |
|
|
changePage(pageValue - 1); |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void increment(int step){ |
|
|
private void increment(int step){ |
|
|
if( pageValue < numberOfPages - step - 1){ |
|
|
if( pageValue < numberOfPages - step){ |
|
|
pageValue = pageValue + step; |
|
|
pageValue = pageValue + step; |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
pageValue = numberOfPages; |
|
|
pageIndicator.setText(pageValue + "/" + String.valueOf(numberOfPages)); |
|
|
pageIndicator.setText(pageValue + "/" + String.valueOf(numberOfPages)); |
|
|
if(pageValue >= 1000) |
|
|
if(pageValue >= 1000) |
|
|
pageIndicator.setTextSize(16); |
|
|
pageIndicator.setTextSize(16); |
|
@ -203,9 +217,10 @@ public class TopicActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void decrement(int step){ |
|
|
private void decrement(int step){ |
|
|
if( pageValue > step + 1 ){ |
|
|
if( pageValue > step) |
|
|
pageValue = pageValue - step; |
|
|
pageValue = pageValue - step; |
|
|
} |
|
|
else |
|
|
|
|
|
pageValue = 1; |
|
|
pageIndicator.setText(pageValue + "/" + String.valueOf(numberOfPages)); |
|
|
pageIndicator.setText(pageValue + "/" + String.valueOf(numberOfPages)); |
|
|
if(numberOfPages >= 1000) |
|
|
if(numberOfPages >= 1000) |
|
|
pageIndicator.setTextSize(16); |
|
|
pageIndicator.setTextSize(16); |
|
@ -214,7 +229,7 @@ public class TopicActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void changePage(int pageRequested){ |
|
|
private void changePage(int pageRequested){ |
|
|
if(pageRequested != thisPage - 1) { |
|
|
if(pageRequested != thisPage - 1){ |
|
|
//Restart activity with new page
|
|
|
//Restart activity with new page
|
|
|
Intent intent = getIntent(); |
|
|
Intent intent = getIntent(); |
|
|
intent.putExtra("TOPIC_URL", pagesUrls.get(pageRequested)); |
|
|
intent.putExtra("TOPIC_URL", pagesUrls.get(pageRequested)); |
|
@ -244,7 +259,10 @@ public class TopicActivity extends BaseActivity { |
|
|
{ |
|
|
{ |
|
|
if(pageUrl.contains("msg")){ |
|
|
if(pageUrl.contains("msg")){ |
|
|
String tmp = pageUrl.substring(pageUrl.indexOf("msg") + 3); |
|
|
String tmp = pageUrl.substring(pageUrl.indexOf("msg") + 3); |
|
|
postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf(";"))); |
|
|
if(tmp.contains(";")) |
|
|
|
|
|
postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf(";"))); |
|
|
|
|
|
else |
|
|
|
|
|
postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf("#"))); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -416,7 +434,7 @@ public class TopicActivity extends BaseActivity { |
|
|
CircularNetworkImageView thumbnail = (CircularNetworkImageView) convertView.findViewById(R.id.thumbnail); |
|
|
CircularNetworkImageView thumbnail = (CircularNetworkImageView) convertView.findViewById(R.id.thumbnail); |
|
|
TextView username = (TextView) convertView.findViewById(R.id.username); |
|
|
TextView username = (TextView) convertView.findViewById(R.id.username); |
|
|
TextView subject = (TextView) convertView.findViewById(R.id.subject); |
|
|
TextView subject = (TextView) convertView.findViewById(R.id.subject); |
|
|
WebView post = (WebView) convertView.findViewById(R.id.post); |
|
|
final WebView post = (WebView) convertView.findViewById(R.id.post); |
|
|
CardView cardView = (CardView) convertView.findViewById(R.id.card_view); |
|
|
CardView cardView = (CardView) convertView.findViewById(R.id.card_view); |
|
|
|
|
|
|
|
|
//Post's WebView parameters set
|
|
|
//Post's WebView parameters set
|
|
@ -457,10 +475,7 @@ public class TopicActivity extends BaseActivity { |
|
|
cardView.setOnClickListener(new View.OnClickListener() { |
|
|
cardView.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
|
if (cardExpandable.getVisibility() == View.GONE) |
|
|
visibilityChangeAnimate(cardExpandable); |
|
|
cardExpandable.setVisibility(View.VISIBLE); |
|
|
|
|
|
else |
|
|
|
|
|
cardExpandable.setVisibility(View.GONE); |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -488,10 +503,15 @@ public class TopicActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
case MotionEvent.ACTION_UP: |
|
|
case MotionEvent.ACTION_UP: |
|
|
fingerState = FINGER_RELEASED; |
|
|
fingerState = FINGER_RELEASED; |
|
|
if (cardExpandable.getVisibility() == View.GONE) |
|
|
|
|
|
cardExpandable.setVisibility(View.VISIBLE); |
|
|
//If this was a link don't expand the card
|
|
|
else |
|
|
WebView.HitTestResult htResult = post.getHitTestResult(); |
|
|
cardExpandable.setVisibility(View.GONE); |
|
|
if (htResult.getExtra() != null |
|
|
|
|
|
&& htResult.getExtra() != null) |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
//Expand/Collapse card
|
|
|
|
|
|
visibilityChangeAnimate(cardExpandable); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case MotionEvent.ACTION_MOVE: |
|
|
case MotionEvent.ACTION_MOVE: |
|
@ -522,6 +542,49 @@ public class TopicActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
//--------------------------------------POPULATE UI METHOD END--------------------------------------
|
|
|
//--------------------------------------POPULATE UI METHOD END--------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------VISIBILITY CHANGE ANIMATE METHOD---------------------------------
|
|
|
|
|
|
//Method that animates views visibility changes
|
|
|
|
|
|
private void visibilityChangeAnimate(final View mCard){ |
|
|
|
|
|
//If the view is gone fade it in
|
|
|
|
|
|
if (mCard.getVisibility() == View.GONE) { |
|
|
|
|
|
mCard.clearAnimation(); |
|
|
|
|
|
// Prepare the View for the animation
|
|
|
|
|
|
mCard.setVisibility(View.VISIBLE); |
|
|
|
|
|
mCard.setAlpha(0.0f); |
|
|
|
|
|
|
|
|
|
|
|
// Start the animation
|
|
|
|
|
|
mCard.animate() |
|
|
|
|
|
.translationY(0) |
|
|
|
|
|
.alpha(1.0f) |
|
|
|
|
|
.setDuration(300) |
|
|
|
|
|
.setListener(new AnimatorListenerAdapter() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
|
|
super.onAnimationEnd(animation); |
|
|
|
|
|
mCard.setVisibility(View.VISIBLE); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
//If the view is visible fade it out
|
|
|
|
|
|
else { |
|
|
|
|
|
mCard.clearAnimation(); |
|
|
|
|
|
|
|
|
|
|
|
// Start the animation
|
|
|
|
|
|
mCard.animate() |
|
|
|
|
|
.translationY(mCard.getHeight()) |
|
|
|
|
|
.alpha(0.0f) |
|
|
|
|
|
.setDuration(300) |
|
|
|
|
|
.setListener(new AnimatorListenerAdapter() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
|
|
super.onAnimationEnd(animation); |
|
|
|
|
|
mCard.setVisibility(View.GONE); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//-------------------------------VISIBILITY CHANGE ANIMATE METHOD END-------------------------------
|
|
|
|
|
|
|
|
|
//--------------------------------------CUSTOM WEBVIEW CLIENT---------------------------------------
|
|
|
//--------------------------------------CUSTOM WEBVIEW CLIENT---------------------------------------
|
|
|
private class LinkLauncher extends WebViewClient { |
|
|
private class LinkLauncher extends WebViewClient { |
|
|
//Older versions
|
|
|
//Older versions
|
|
@ -550,13 +613,22 @@ public class TopicActivity extends BaseActivity { |
|
|
//host's application activity or load it in a browser.
|
|
|
//host's application activity or load it in a browser.
|
|
|
if (Objects.equals(host, "www.thmmy.gr")) { |
|
|
if (Objects.equals(host, "www.thmmy.gr")) { |
|
|
//This is my web site, so figure out what Activity should launch
|
|
|
//This is my web site, so figure out what Activity should launch
|
|
|
if (uri.toString().contains("topic=")) { |
|
|
if (uri.toString().contains("topic=")) { //This url points to a topic
|
|
|
//Restart activity with new topic
|
|
|
//Is the link pointing to current topic?
|
|
|
Intent intent = getIntent(); |
|
|
if(Objects.equals( |
|
|
intent.putExtra("TOPIC_URL", uri.toString()); |
|
|
uri.toString().substring(0, uri.toString().lastIndexOf(".")), base_url)){ |
|
|
intent.putExtra("TOPIC_TITLE", ""); |
|
|
//Don't restart Activity
|
|
|
finish(); |
|
|
//Just change post focus
|
|
|
startActivity(intent); |
|
|
//TODO
|
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
//Restart activity with new data
|
|
|
|
|
|
Intent intent = getIntent(); |
|
|
|
|
|
intent.putExtra("TOPIC_URL", uri.toString()); |
|
|
|
|
|
intent.putExtra("TOPIC_TITLE", ""); |
|
|
|
|
|
finish(); |
|
|
|
|
|
startActivity(intent); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -569,18 +641,18 @@ public class TopicActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
//------------------------------------CUSTOM WEBVIEW CLIENT END-------------------------------------
|
|
|
//------------------------------------CUSTOM WEBVIEW CLIENT END-------------------------------------
|
|
|
|
|
|
|
|
|
class RepetetiveUpdater implements Runnable { |
|
|
class RepetitiveUpdater implements Runnable { |
|
|
private final int step; |
|
|
private final int step; |
|
|
|
|
|
|
|
|
RepetetiveUpdater(int step){this.step = step;} |
|
|
RepetitiveUpdater(int step){this.step = step;} |
|
|
public void run() { |
|
|
public void run() { |
|
|
long REPEAT_DELAY = 250; |
|
|
long REPEAT_DELAY = 250; |
|
|
if( autoIncrement ){ |
|
|
if( autoIncrement ){ |
|
|
increment(step); |
|
|
increment(step); |
|
|
repeatUpdateHandler.postDelayed( new RepetetiveUpdater(step), REPEAT_DELAY); |
|
|
repeatUpdateHandler.postDelayed( new RepetitiveUpdater(step), REPEAT_DELAY); |
|
|
} else if( autoDecrement ){ |
|
|
} else if( autoDecrement ){ |
|
|
decrement(step); |
|
|
decrement(step); |
|
|
repeatUpdateHandler.postDelayed( new RepetetiveUpdater(step), REPEAT_DELAY); |
|
|
repeatUpdateHandler.postDelayed( new RepetitiveUpdater(step), REPEAT_DELAY); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|