#include "ui_resource_image.h"
#include "common/image_cache_manager.h"
-#define DIAL_DIR "user/res/dials"
+#define DIAL_DIR "user/res/dials"
// 表盘名称||表盘缩约图||表盘路径
DialInfo_1 dialInfo_1[MAX_DIALNUM_1];
{
DIR *dirp = opendir(DIAL_DIR);
// 遍历文件
- dial_num=0;
- if (dirp != NULL)
+ dial_num = 0;
+ if (dirp != NULL)
{
- while (dirent * ret=readdir(dirp))
+ while (dirent *ret = readdir(dirp))
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"file_name %s \r\n",ret->d_name);
- if(dialInfo_1[dial_num].dialPath)
+ //WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "file_name %s \r\n", ret->d_name);
+ if (dialInfo_1[dial_num].dialPath)
{
- free((void*)dialInfo_1[dial_num].dialPath);
- dialInfo_1[dial_num].dialPath=NULL;
+ free((void *)dialInfo_1[dial_num].dialPath);
+ dialInfo_1[dial_num].dialPath = NULL;
}
- char path[124]={0};
+ char path[124] = {0};
- sprintf(path,"user/res/dials/%s",ret->d_name);
- char * str_1=(char*) malloc(sizeof(path));
- strcpy(str_1,path);
- dialInfo_1[dial_num].dialPath=str_1;
+ sprintf(path, "user/res/dials/%s", ret->d_name);
+ char *str_1 = (char *)malloc(sizeof(path));
+ strcpy(str_1, path);
+ dialInfo_1[dial_num].dialPath = str_1;
- if(dialInfo_1[dial_num].thumbnailPath)
+ if (dialInfo_1[dial_num].thumbnailPath)
{
- free((void*)dialInfo_1[dial_num].thumbnailPath);
- dialInfo_1[dial_num].thumbnailPath=NULL;
+ free((void *)dialInfo_1[dial_num].thumbnailPath);
+ dialInfo_1[dial_num].thumbnailPath = NULL;
}
- char path_1[124]={0};
- sprintf(path_1,"user/res/dialupdate/%s",ret->d_name);
- str_1=(char*) malloc(sizeof(path_1));
- strcpy(str_1,path_1);
- dialInfo_1[dial_num].thumbnailPath=str_1;
+ char path_1[124] = {0};
+ sprintf(path_1, "user/res/dialupdate/%s", ret->d_name);
+ str_1 = (char *)malloc(sizeof(path_1));
+ strcpy(str_1, path_1);
+ dialInfo_1[dial_num].thumbnailPath = str_1;
- if(dialInfo_1[dial_num].title)
+ if (dialInfo_1[dial_num].title)
{
- free((void*)dialInfo_1[dial_num].title);
- dialInfo_1[dial_num].title=NULL;
+ free((void *)dialInfo_1[dial_num].title);
+ dialInfo_1[dial_num].title = NULL;
}
- FILE * fp = fopen(path, "rb");
- if (fp == nullptr)
+ FILE *fp = fopen(path, "rb");
+ if (fp == nullptr)
{
return;
}
- OHOS::DialHeader* data = static_cast<OHOS::DialHeader*>
- (OHOS::DialBinParser::GetInstance()->MallocAndReadBuf(fp, sizeof(OHOS::DialHeader)));
-
- char * str_2=(char*) malloc(sizeof(data->dialName));
- strcpy(str_2,data->dialName);
- dialInfo_1->imageOffset=data->imageOffset;
- dialInfo_1[dial_num++].title=str_2;
+ OHOS::DialHeader *data = static_cast<OHOS::DialHeader *>(OHOS::DialBinParser::GetInstance()->MallocAndReadBuf(fp, sizeof(OHOS::DialHeader)));
+ char *str_2 = (char *)malloc(sizeof(data->dialName));
+ strcpy(str_2, data->dialName);
+ dialInfo_1->imageOffset = data->imageOffset;
+ dialInfo_1[dial_num++].title = str_2;
-
-
-
-
fclose(fp);
UIFree(data);
}
}
-
+
// 关闭目录
closedir(dirp);
}
void printf_dial(void)
{
- for(int i=0;i<dial_num;i++)
+ for (int i = 0; i < dial_num; i++)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"file_name %s \r\n", dialInfo_1[i].dialPath);
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"file_title %s \r\n", dialInfo_1[i].title);
-
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "file_name %s \r\n", dialInfo_1[i].dialPath);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "file_title %s \r\n", dialInfo_1[i].title);
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"num %d \r\n",dial_num );
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "num %d \r\n", dial_num);
}
- //{"默认表盘", "user/res/dialupdate/defult_dial.bin", "user/res/dials/defult_dial.bin"}
+//{"默认表盘", "user/res/dialupdate/defult_dial.bin", "user/res/dials/defult_dial.bin"}
namespace OHOS
{
DialUpdateModel::DialUpdateModel() {}
uint8_t DialUpdateModel::GetDialConfigPath()
{
read_dial();
- printf_dial();
+ // printf_dial();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetDialConfigPath:%d", Current_dial);
return Current_dial;
}
delete container_;
container_ = nullptr;
}
-
- for(int i=0;i<dial_num;i++)
+
+ for (int i = 0; i < dial_num; i++)
{
- if(Button[i]!=NULL)
+ if (Button[i] != NULL)
{
delete Button[i];
- Button[i]=NULL;
+ Button[i] = NULL;
}
}
g_pDialUpdateView = nullptr;
// button2_->SetVisible(true);
}
-
void DialUpdateView::init_button()
{
// read_dial();
- printf_dial(); // dial_num
+ // printf_dial(); // dial_num
uint8_t fileid = DialUpdateModel::GetInstance()->GetDialConfigPath();
for (int i = fileid; i < dial_num + fileid; i++)
{
if (!MainViewSample::GetInstance()->IsMainClockPage()) // 当前页面为主表盘的其他页面时,切换回主表盘页面
{
MainViewSample::GetInstance()->SwitchToClockPage();
- RootView::GetInstance()->Invalidate(); // 刷新界面
}
else
{
VerticalViewInit();
VertViewLoad();
mainSwipeGroup->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- mainSwipeGroup->SetAnimatorTime(50); // 50: animator drag time(ms);
+ mainSwipeGroup->SetAnimatorTime(10); // 50: animator drag time(ms);
mainSwipeGroup->SetLoopState(true);
mainSwipeGroup->EnableScreenCap(true); // 屏幕截图展示,取消使用实时绘制
mainSwipeGroup->RegisterSwipeCallback(callback);
messageView->SetViewId("messageView");
messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
messageView->PreLoad();
messageView->SetDraggable(false);
messageView->SetIntercept(true);
+ messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
#endif
/* -------------------------------------------------------------------------- */
#if 0
}
#endif
// DialUpdateModel::GetInstance()->LoadDialConfigFromJson();
- //read_dial();
+ // read_dial();
uint8_t fileid = DialUpdateModel::GetInstance()->GetDialConfigPath();
std::string filePath = dialInfo_1[fileid].dialPath;
mainClockView->SetDial(filePath);
UIView::OnLongPressListener *buttonLongPress = static_cast<UIView::OnLongPressListener *>(MainPresenterSample::GetInstance());
mainClockView->SetOnLongPressListener(buttonLongPress);
// Add to rootView
- //mainClockView->Add(changebut);
- //changebut->SetVisible(true);
+ // mainClockView->Add(changebut);
+ // changebut->SetVisible(true);
#endif
return mainClockView;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageView->SetupViewPage() == false!");
return false;
}
+ messageview->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
Add(messageview);
messageview->GetList()->RefreshList(); // 刷新列表
return true;
bool MessagePresenter::OnDrag(UIView &view, const DragEvent &event)
{
-
+#if 0
if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
(event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
{
NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
}
+#endif
return true;
}
UNUSED(event);
MessageItemView *messageItemView = static_cast<MessageItemView *>(&view);
int index = messageItemView->GetMessageListIndex();
- printf("%d\n",index);//测试点击是否有效
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index:%d", index);
if (index >= p_MessageModel->GetMessageListNum())
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnClick is no index");
namespace OHOS
{
-
+ static constexpr uint8_t NUM_2 = 2;
static MessageView *g_pMessageView{nullptr};
MessageView::MessageView()
{
- UIViewGroup::SetPosition(43, 120, 466, 466);
+ UIViewGroup::SetPosition(42, 120, 380, 960);
g_pMessageView = this;
}
{
scrollView = new UIScrollView();
}
- scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
- scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
- scrollView->SetScrollBlankSize(20);
+ scrollView->SetPosition(0, 0, 380, 466);
+ // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ scrollView->SetScrollBlankSize(35);
scrollView->SetReboundSize(50);
scrollView->SetTouchable(true);
scrollView->SetDraggable(true);
+ scrollView->SetDirection(1);
draglistener = static_cast<UIView::OnDragListener *>(MessagePresenter::GetInstance());
scrollView->SetOnDragListener(draglistener);
/* -------------------------------------------------------------------------- */
- if (title == nullptr)
- {
- title = new UILabel();
- }
- title->SetPosition(173, 52, 120, 35);
- title->Resize(120, 35);
- title->SetStyle(STYLE_TEXT_FONT, 30);
- title->SetStyle(STYLE_LINE_HEIGHT, 36);
- title->SetText("信息通知");
- title->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
- title->SetStyle(STYLE_TEXT_COLOR, Color::White().full);
- title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
- /* -------------------------------------------------------------------------- */
// UIList 的适配器
p_MessageListAdapter = new MessageListAdapter();
p_MessageListAdapter->SetItemClickListener(presenter_);
MessageList = new UIList();
}
MessageList->SetPosition(43, 120, 380, 600);
- MessageList->SetStyle(STYLE_BACKGROUND_COLOR, 0x00000000);
+ MessageList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
}
void MessageView::DeInitView()
void MessageView::OnSetUpView()
{
View<MessagePresenter>::OnSetUpView();
- scrollView->Add(title);
+ // scrollView->Add(title);
scrollView->Add(MessageList);
- scrollView->SetBackgroundBlur(10000);
+ scrollView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
RootView::GetInstance()->Add(scrollView);
MessageList->SetAdapter(p_MessageListAdapter);
- MessageList->RefreshList(); // 刷新列表
+ // MessageList->RefreshList(); // 刷新列表
Draw();
}
{
MessageList = new UIList();
}
- MessageList->SetPosition(0, 0, 380, 600);
- MessageList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
- MessageList->SetScrollBlankSize(10);
- MessageList->EnableAutoAlign(true);
- MessageList->RefreshList(); // 刷新列表
+ MessageList->SetPosition(0, 0);
+ MessageList->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
MessageList->SetDraggable(true);
- MessageList->SetThrowDrag(false);
- MessageList->SetLoopState(true);
-
- // MessageList->SetYScrollBarVisible(true);
+ MessageList->SetThrowDrag(true);
+ MessageList->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
+ //MessageList->SetOpaScale(100);
+
+ MessageList->SetScrollBlankSize(100);
+ MessageList->SetReboundSize(50);
+ MessageList->SetSelectPosition(HORIZONTAL_RESOLUTION / 2); // middle position
+ MessageList->SetDirection(1);
+ UIView::OnClickListener *list1Click = static_cast<UIView::OnClickListener *>(MessagePresenter::GetInstance());
+ MessageList->SetOnClickListener(list1Click);
+ UIView::OnDragListener *list1Drag = static_cast<UIView::OnDragListener *>(MessagePresenter::GetInstance());
+ MessageList->SetOnDragListener(list1Drag);
Add(MessageList);
MessageList->SetAdapter(p_MessageListAdapter);
MessageList->SetVisible(true);