[and] Fancy animations.
This commit is contained in:
parent
3505a50180
commit
3500bcc37f
5 changed files with 91 additions and 31 deletions
|
@ -8,7 +8,7 @@
|
|||
android:minSdkVersion="9"
|
||||
android:targetSdkVersion="18" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -17,6 +17,7 @@
|
|||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.example.travelguide.ArticleInfoListActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="adjustResize" >
|
||||
<intent-filter>
|
||||
|
@ -27,6 +28,7 @@
|
|||
</activity>
|
||||
<activity
|
||||
android:name="com.example.travelguide.ArticleInfoDetailActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/title_articleinfo_detail"
|
||||
android:parentActivityName=".ArticleInfoListActivity" >
|
||||
<meta-data
|
||||
|
@ -35,4 +37,4 @@
|
|||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
|
@ -30,32 +30,38 @@
|
|||
android:src="@drawable/ic_articleselection" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.example.travelguide.webkit.TgWebView
|
||||
android:id="@+id/webView"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone" >
|
||||
<com.example.travelguide.webkit.TgWebView
|
||||
android:id="@+id/webView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
android:id="@+id/progressContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="4dip"
|
||||
android:singleLine="true"
|
||||
android:text="@string/loading"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
</LinearLayout>
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="4dip"
|
||||
android:singleLine="true"
|
||||
android:text="@string/loading"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,7 +1,5 @@
|
|||
package com.example.travelguide;
|
||||
|
||||
import static com.example.travelguide.util.Utils.hideView;
|
||||
import static com.example.travelguide.util.Utils.showView;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
|
@ -105,18 +103,18 @@ public class ArticleInfoDetailFragment extends Fragment implements OnClickListen
|
|||
public void onPageFinished(WebView view, String url)
|
||||
{
|
||||
super.onPageFinished(view, url);
|
||||
showView(mWebView);
|
||||
hideView(mProgressContainer);
|
||||
Utils.fadeOut(getActivity(), mProgressContainer);
|
||||
Utils.fadeIn(getActivity(), mWebView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon)
|
||||
{
|
||||
super.onPageStarted(view, url, favicon);
|
||||
showView(mProgressContainer);
|
||||
hideView(mWebView);
|
||||
Utils.fadeOut(getActivity(), mWebView);
|
||||
Utils.fadeIn(getActivity() ,mProgressContainer);
|
||||
|
||||
if (!Utils.isExternalUrl(url))
|
||||
if (!Utils.isExternalUrl(url) && url.endsWith(".html"))
|
||||
{
|
||||
final String strippedUrl = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
|
||||
final String title = Storage.getTitleByUrl(strippedUrl);
|
||||
|
|
|
@ -96,6 +96,7 @@ public class ArticleInfoListActivity extends FragmentActivity implements Article
|
|||
else
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
|
||||
.show(mArtInfoListFragment)
|
||||
.commit();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,11 @@ package com.example.travelguide.util;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.Animation.AnimationListener;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
public class Utils
|
||||
{
|
||||
|
@ -37,4 +41,53 @@ public class Utils
|
|||
{
|
||||
return path.startsWith("http") || path.startsWith("www.");
|
||||
}
|
||||
|
||||
public static void fadeIn(Context context, final View target)
|
||||
{
|
||||
final Animation anim = AnimationUtils.loadAnimation(context, android.R.anim.fade_in);
|
||||
final AnimationListener listener = new AnimationListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation)
|
||||
{
|
||||
showView(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation)
|
||||
{}
|
||||
};
|
||||
anim.setAnimationListener(listener);
|
||||
target.startAnimation(anim);
|
||||
}
|
||||
|
||||
public static void fadeOut(Context context, final View target)
|
||||
{
|
||||
final Animation anim = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
|
||||
final AnimationListener listener = new AnimationListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation)
|
||||
{}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation)
|
||||
{
|
||||
hideView(target);
|
||||
}
|
||||
};
|
||||
anim.setAnimationListener(listener);
|
||||
target.startAnimation(anim);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue