添加收藏统计
This commit is contained in:
1 parent
1a1242cc47
commit
e6e85dc8d4
5 files changed
+80
-11
No files matched your search
@@ -366,7 +366,7 @@
|
||||
<string name="homepage">首页</string>
|
||||
<string name="mode">模式</string>
|
||||
<string name="favourite">收藏</string>
|
||||
<string name="popular">好评</string>
|
||||
<string name="popular">热门</string>
|
||||
<string name="download">下载</string>
|
||||
|
||||
<string name="star_2">2 星</string>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import com.google.analytics.tracking.android.MapBuilder;
|
||||
import com.hippo.ehviewer.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class Analytics {
|
||||
|
||||
private static final String KEY_GALLERY = "gallery";
|
||||
private static final String KEY_OPEN = "open";
|
||||
private static final String KEY_READ = "read";
|
||||
private static final String KEY_DOWNLOAD = "download";
|
||||
private static final String KEY_ADD_TO_FAVORITE = "add_to_favorite";
|
||||
|
||||
private static void doGallery(Context context, GalleryInfo galleryInfo, String method) {
|
||||
if (!Config.getAllowAnalyics())
|
||||
return;
|
||||
|
||||
try {
|
||||
JSONObject js = new JSONObject();
|
||||
js.put("gid", galleryInfo.gid).put("token", galleryInfo.token);
|
||||
EasyTracker easyTracker = EasyTracker.getInstance(context);
|
||||
easyTracker.send(MapBuilder.createEvent(KEY_GALLERY, method, js.toString(), null).build());
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
public static void openGallery(Context context, GalleryInfo galleryInfo) {
|
||||
doGallery(context, galleryInfo, KEY_OPEN);
|
||||
}
|
||||
|
||||
public static void readGallery(Context context, GalleryInfo galleryInfo) {
|
||||
doGallery(context, galleryInfo, KEY_READ);
|
||||
}
|
||||
|
||||
public static void downloadGallery(Context context, GalleryInfo galleryInfo) {
|
||||
doGallery(context, galleryInfo, KEY_DOWNLOAD);
|
||||
}
|
||||
|
||||
public static void addToFavoriteGallery(Context context, GalleryInfo galleryInfo) {
|
||||
doGallery(context, galleryInfo, KEY_ADD_TO_FAVORITE);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import org.json.JSONObject;
|
||||
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import com.google.analytics.tracking.android.MapBuilder;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.data.Comment;
|
||||
@@ -118,15 +119,8 @@ public class MangaDetailActivity extends AbstractFragmentActivity
|
||||
} else {
|
||||
mGalleryInfo = intent.getParcelableExtra(KEY_G_INFO);
|
||||
}
|
||||
|
||||
if (!Config.getAllowAnalyics())
|
||||
return;
|
||||
try {
|
||||
JSONObject js = new JSONObject();
|
||||
js.put("gid", mGalleryInfo.gid).put("token", mGalleryInfo.token);
|
||||
EasyTracker easyTracker = EasyTracker.getInstance(this);
|
||||
easyTracker.send(MapBuilder.createEvent("gallery", "open", js.toString(), null).build());
|
||||
} catch (Exception e) {}
|
||||
// Analytics
|
||||
Analytics.openGallery(this, mGalleryInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,6 +224,8 @@ public class MangaDetailActivity extends AbstractFragmentActivity
|
||||
case -1:
|
||||
((AppContext)getApplication()).getData().addLocalFavourite(mGalleryInfo);
|
||||
new SuperToast(this).setMessage(R.string.toast_add_favourite).show();
|
||||
// Analytics
|
||||
Analytics.addToFavoriteGallery(MangaDetailActivity.this, mGalleryInfo);
|
||||
break;
|
||||
default:
|
||||
((AppContext)getApplication()).getEhClient().addToFavorite(mGalleryInfo.gid,
|
||||
@@ -237,6 +233,8 @@ public class MangaDetailActivity extends AbstractFragmentActivity
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
new SuperToast(MangaDetailActivity.this).setMessage(R.string.toast_add_favourite).show();
|
||||
// Analytics
|
||||
Analytics.addToFavoriteGallery(MangaDetailActivity.this, mGalleryInfo);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(String eMsg) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.ListUrls;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -504,7 +505,7 @@ public class MangaListActivity extends AbstractGalleryActivity
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1,
|
||||
int position, long arg3) {
|
||||
GalleryInfo gi;
|
||||
final GalleryInfo gi;
|
||||
switch (position) {
|
||||
case 0: // Add favourite item
|
||||
gi = getGalleryInfo(longClickItemIndex);
|
||||
@@ -512,6 +513,8 @@ public class MangaListActivity extends AbstractGalleryActivity
|
||||
switch (defaultFavorite) {
|
||||
case -2:
|
||||
Favorite.getAddToFavoriteDialog(MangaListActivity.this, gi).show();
|
||||
// Analytics
|
||||
Analytics.addToFavoriteGallery(MangaListActivity.this, gi);
|
||||
break;
|
||||
case -1:
|
||||
((AppContext)getApplication()).getData().addLocalFavourite(gi);
|
||||
@@ -523,6 +526,8 @@ public class MangaListActivity extends AbstractGalleryActivity
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
new SuperToast(MangaListActivity.this).setMessage(R.string.toast_add_favourite).show();
|
||||
// Analytics
|
||||
Analytics.addToFavoriteGallery(MangaListActivity.this, gi);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(String eMsg) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.hippo.ehviewer.util;
|
||||
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.data.GalleryInfo;
|
||||
@@ -85,6 +86,8 @@ public class Favorite {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
new SuperToast(context).setMessage(R.string.toast_add_favourite).show();
|
||||
// Analytics
|
||||
Analytics.addToFavoriteGallery(context, gi);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(String eMsg) {
|
||||
|
||||
Reference in new issue
Block a user