|
|
@@ -25,9 +25,9 @@ import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.RequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.config.INetworkConfig;
|
|
|
import kr.co.zumo.app.lifeplus.config.NetworkConfigProvider;
|
|
|
+import kr.co.zumo.app.lifeplus.model.SuperModelInit;
|
|
|
import kr.co.zumo.app.lifeplus.network.api.LifeplusWidgetAPIService;
|
|
|
import kr.co.zumo.app.lifeplus.share.Share;
|
|
|
-import kr.co.zumo.app.lifeplus.util.AppUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.GlideApp;
|
|
|
|
|
|
/**
|
|
|
@@ -42,16 +42,6 @@ public class LifeplusWidgetProvider extends AppWidgetProvider {
|
|
|
views.setTextViewText(R.id.text_view_title, contentsBean.getTitleWithTrim());
|
|
|
views.setTextViewText(R.id.text_view_sub_title, contentsBean.getSubTitleWithTrim());
|
|
|
|
|
|
- // app link
|
|
|
- Intent mainIntent = new Intent(context, SplashActivity.class);
|
|
|
- views.setOnClickPendingIntent(R.id.image_view_bi, PendingIntent.getActivity(context, 0, mainIntent, 0));
|
|
|
-
|
|
|
- // refresh
|
|
|
- Intent refreshIntent = new Intent(context, LifeplusWidgetProvider.class);
|
|
|
- refreshIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{appWidgetId});
|
|
|
- refreshIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
|
|
- views.setOnClickPendingIntent(R.id.image_view_refresh, PendingIntent.getBroadcast(context, appWidgetId, refreshIntent, PendingIntent.FLAG_UPDATE_CURRENT));
|
|
|
-
|
|
|
// contents link
|
|
|
Intent linkIntent = new Intent(context, ContentsGateActivity.class);
|
|
|
linkIntent.setData(new Uri.Builder()
|
|
|
@@ -87,6 +77,21 @@ public class LifeplusWidgetProvider extends AppWidgetProvider {
|
|
|
appWidgetManager.updateAppWidget(appWidgetId, views);
|
|
|
}
|
|
|
|
|
|
+ private void attachEvent(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
|
|
|
+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.lifeplus_widget);
|
|
|
+ // app link
|
|
|
+ Intent mainIntent = new Intent(context, SplashActivity.class);
|
|
|
+ views.setOnClickPendingIntent(R.id.image_view_bi, PendingIntent.getActivity(context, 0, mainIntent, 0));
|
|
|
+
|
|
|
+ // refresh
|
|
|
+ Intent refreshIntent = new Intent(context, LifeplusWidgetProvider.class);
|
|
|
+ refreshIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{appWidgetId});
|
|
|
+ refreshIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
|
|
+ views.setOnClickPendingIntent(R.id.image_view_refresh, PendingIntent.getBroadcast(context, appWidgetId, refreshIntent, PendingIntent.FLAG_UPDATE_CURRENT));
|
|
|
+
|
|
|
+ appWidgetManager.updateAppWidget(appWidgetId, views);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
|
|
Log.e("APP# LifeplusWidgetProvider | onUpdate", "| " + Arrays.toString(appWidgetIds));
|
|
|
@@ -97,7 +102,11 @@ public class LifeplusWidgetProvider extends AppWidgetProvider {
|
|
|
|
|
|
@SuppressWarnings("PMD.UnusedLocalVariable")
|
|
|
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
|
|
|
- INetworkConfig networkConfig = NetworkConfigProvider.getNetworkConfig(AppUtil.isDebug());
|
|
|
+ attachEvent(context, appWidgetManager, appWidgetId);
|
|
|
+
|
|
|
+// INetworkConfig networkConfig = NetworkConfigProvider.getNetworkConfig(AppUtil.isDebug());
|
|
|
+ SuperModelInit.instant(context);
|
|
|
+ INetworkConfig networkConfig = NetworkConfigProvider.getNetworkConfig();
|
|
|
|
|
|
String API_URL = networkConfig.getHostUrl() + ":" + networkConfig.getHostPort() + "/";
|
|
|
Disposable disposable = new LifeplusWidgetAPIService(API_URL).getWidgetData(new RequestBean())
|