Browse Source

[곻통][Common] 위젯 구현 중

Hasemi 6 years ago
parent
commit
78bd7db167

+ 25 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/widget/LifeplusWidget.java

@@ -5,8 +5,13 @@ import android.appwidget.AppWidgetManager;
 import android.appwidget.AppWidgetProvider;
 import android.content.Context;
 import android.content.Intent;
+import android.util.Log;
 import android.widget.RemoteViews;
 
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.request.RequestOptions;
+import com.bumptech.glide.request.target.AppWidgetTarget;
+
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.activity.MainActivity;
 
@@ -15,12 +20,28 @@ import kr.co.zumo.app.lifeplus.activity.MainActivity;
  */
 public class LifeplusWidget extends AppWidgetProvider {
 
+  private static String REFRESH_CLICK = "refresh_click";
+
+
   static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                               int appWidgetId) {
     // Construct the RemoteViews object
     RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.lifeplus_widget);
-    Intent main = new Intent(context, MainActivity.class);
-    views.setOnClickPendingIntent(R.id.image_view_bi, PendingIntent.getActivity(context, 0, main, 0));
+
+    Intent mainIntent = new Intent(context, MainActivity.class);
+    views.setOnClickPendingIntent(R.id.image_view_bi, PendingIntent.getActivity(context, 0, mainIntent, 0));
+
+    views.setTextViewText(R.id.text_view_title, "test Title");
+    views.setTextViewText(R.id.text_view_sub_title, "test Sub Title");
+
+
+    AppWidgetTarget backgroundImage = new AppWidgetTarget(context, R.id.image_view_background, views, appWidgetId);
+
+    Glide.with(context)
+      .asBitmap()
+      .apply(new RequestOptions().centerCrop())
+      .load("http://210.216.157.64:38080/resources/contents/bucket/bg/img_bestbucket_1.jpg")
+      .into(backgroundImage);
 
     appWidgetManager.updateAppWidget(appWidgetId, views);
 
@@ -30,6 +51,8 @@ public class LifeplusWidget extends AppWidgetProvider {
   public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
     // There may be multiple widgets active, so update all of them
 
+    Log.e("APP#  LifeplusWidget | onUpdate", "|" + appWidgetIds.length);
+
     for (int appWidgetId : appWidgetIds) {
       updateAppWidget(context, appWidgetManager, appWidgetId);
     }

+ 4 - 1
app/src/main/res/drawable/widget_radius.xml

@@ -3,5 +3,8 @@
        android:shape="rectangle">
   <solid android:color="@color/CE6FFFFFF"/>
   <corners
-    android:radius="8dp"/>
+    android:bottomLeftRadius="8dp"
+    android:bottomRightRadius="8dp"
+    android:topLeftRadius="0dp"
+    android:topRightRadius="0dp"/>
 </shape>

+ 7 - 5
app/src/main/res/layout/lifeplus_widget.xml

@@ -3,6 +3,8 @@
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
+  android:layout_margin="@dimen/widget_margin"
+  tools:background="@color/C000000"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
 
@@ -10,8 +12,8 @@
     android:id="@+id/image_view_background"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@drawable/banner_bg_1"
     android:scaleType="centerCrop"
+    tools:background="@drawable/banner_bg_1"
     />
 
   <ImageView
@@ -28,7 +30,7 @@
     android:layout_width="match_parent"
     android:layout_height="53dp"
     android:layout_gravity="bottom"
-    android:background="@drawable/widget_radius"
+    android:background="@drawable/rectangle_ce6ffffff_bottom_raduis_8"
     >
 
     <TextView
@@ -40,9 +42,9 @@
       android:layout_marginStart="14dp"
       android:layout_marginTop="11dp"
       android:lineSpacingExtra="4sp"
-      android:text="무장해제 핑크홀릭 봄맞이 핑크카페 6"
       android:textColor="@color/C000000"
       android:textSize="12sp"
+      tools:text="무장해제 핑크홀릭 봄맞이 핑크카페 6"
       />
 
     <TextView
@@ -54,9 +56,9 @@
       android:layout_marginStart="14dp"
       android:layout_marginTop="2dp"
       android:lineSpacingExtra="4sp"
-      android:text="봄 기운 만끽할 준비된 핑덕들 웰컴!"
       android:textColor="@color/C666666"
-      android:textSize="11dp"
+      android:textSize="11sp"
+      tools:text="봄 기운 만끽할 준비된 핑덕들 웰컴!"
       />
 
     <ImageView

+ 1 - 1
app/src/main/res/values-v14/dimens.xml

@@ -5,6 +5,6 @@
 Refer to App Widget Documentation for margin information
 http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
     -->
-  <dimen name="widget_margin">0dp</dimen>
+  <dimen name="widget_margin">15dp</dimen>
 
 </resources>

+ 1 - 1
app/src/main/res/values/dimens.xml

@@ -23,5 +23,5 @@
 Refer to App Widget Documentation for margin information
 http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
     -->
-  <dimen name="widget_margin">8dp</dimen>
+  <dimen name="widget_margin">15dp</dimen>
 </resources>

+ 1 - 2
app/src/main/res/xml/lifeplus_widget_info.xml

@@ -4,8 +4,7 @@
                     android:initialLayout="@layout/lifeplus_widget"
                     android:minWidth="250dp"
                     android:minHeight="100dp"
-                    android:previewImage="@drawable/bi_splash"
-                    android:resizeMode="horizontal|vertical"
+                    android:resizeMode="none"
                     android:updatePeriodMillis="86400000"
                     android:widgetCategory="home_screen">
 </appwidget-provider>